From b6deda1111fd654086f6faf7d3dc6a0227e55b39 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Mon, 18 Feb 2019 12:28:18 +0100 Subject: [PATCH 01/93] FIX credit note used on list --- .../fourn/class/fournisseur.facture.class.php | 21 +++++++++++++++++++ htdocs/fourn/facture/list.php | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 086f154184d..4ad0b221c36 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2574,6 +2574,27 @@ class FactureFournisseur extends CommonInvoice return ($this->statut == self::STATUS_VALIDATED) && ($this->date_echeance < ($now - $conf->facture->fournisseur->warning_delay)); } + + /** + * Is credit note used + * + * @return bool + */ + public function isCreditNoteUsed() + { + global $db; + + $isUsed = false; + + $sql = "SELECT fk_invoice_supplier FROM ".MAIN_DB_PREFIX."societe_remise_except WHERE fk_invoice_supplier_source=".$this->id; + $resql = $db->query($sql); + if(!empty($resql)){ + $obj = $db->fetch_object($resql); + if(!empty($obj->fk_invoice_supplier))$isUsed=true; + } + + return $isUsed; + } } diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 98a6956a809..b53a07104c7 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -833,6 +833,7 @@ if ($resql) $facturestatic->date_echeance = $db->jdate($obj->datelimite); $facturestatic->statut = $obj->fk_statut; + $thirdparty->id=$obj->socid; $thirdparty->name=$obj->name; $thirdparty->client=$obj->client; @@ -850,6 +851,11 @@ if ($resql) $totalpay = $paiement + $totalcreditnotes + $totaldeposits; $remaintopay = $obj->total_ttc - $totalpay; + //If invoice has been converted and the conversion has been used, we dont have remain to pay on invoice + if($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE && $facturestatic->statut == FactureFournisseur::STATUS_CLOSED) { + if($facturestatic->isCreditNoteUsed())$remaintopay=0; + } + print ''; if (! empty($arrayfields['f.ref']['checked'])) { From 785092544115056183e718a831e3ac419c4b797e Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 22 Feb 2019 15:10:41 +0100 Subject: [PATCH 02/93] FIX amount opened on thirdparty card dont care of credit note not converted --- htdocs/societe/class/societe.class.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 412bf46b082..b894504bb10 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3727,7 +3727,7 @@ class Societe extends CommonObject $alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT'); $remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT'); */ - if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; + if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, type, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f"; $sql .= " WHERE fk_soc = ". $this->id; if ($mode == 'supplier') { @@ -3754,7 +3754,13 @@ class Societe extends CommonObject $tmpobject=new Facture($this->db); } while($obj=$this->db->fetch_object($resql)) { - $tmpobject->id=$obj->rowid; + $tmpobject->id=$obj->rowid; + + $paiement = $tmpobject->getSommePaiement(); + $creditnotes = $tmpobject->getSumCreditNotesUsed(); + $deposits = $tmpobject->getSumDepositsUsed(); + + if ($obj->fk_statut != 0 // Not a draft && ! ($obj->fk_statut == 3 && $obj->close_code == 'replaced') // Not a replaced invoice ) @@ -3768,11 +3774,14 @@ class Societe extends CommonObject && $obj->fk_statut != 2) // Not classified as paid //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason { - $paiement = $tmpobject->getSommePaiement(); - $creditnotes = $tmpobject->getSumCreditNotesUsed(); - $deposits = $tmpobject->getSumDepositsUsed(); + $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; } + + if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $obj->fk_statut == FactureFournisseur::STATUS_CLOSED && !$tmpobject->isCreditNoteUsed()) { //if credit note is converted but not used + + $outstandingOpened+=$obj->total_ttc-$paiement; + } } return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } From dc7a2fbb30e34b04a5cc88af5ac6234c8be56911 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Mon, 25 Feb 2019 10:01:26 +0100 Subject: [PATCH 03/93] FIX placement function --- htdocs/societe/class/societe.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index b894504bb10..7d54e7ad01e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3756,9 +3756,7 @@ class Societe extends CommonObject while($obj=$this->db->fetch_object($resql)) { $tmpobject->id=$obj->rowid; - $paiement = $tmpobject->getSommePaiement(); - $creditnotes = $tmpobject->getSumCreditNotesUsed(); - $deposits = $tmpobject->getSumDepositsUsed(); + if ($obj->fk_statut != 0 // Not a draft @@ -3774,12 +3772,15 @@ class Societe extends CommonObject && $obj->fk_statut != 2) // Not classified as paid //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason { + $paiement = $tmpobject->getSommePaiement(); + $creditnotes = $tmpobject->getSumCreditNotesUsed(); + $deposits = $tmpobject->getSumDepositsUsed(); $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; } if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $obj->fk_statut == FactureFournisseur::STATUS_CLOSED && !$tmpobject->isCreditNoteUsed()) { //if credit note is converted but not used - + if(empty($paiement)) $paiement = $tmpobject->getSommePaiement(); $outstandingOpened+=$obj->total_ttc-$paiement; } } From 6deba39c6a9d67826297d7422f8130bb95133b35 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 12 Apr 2019 10:16:13 +0200 Subject: [PATCH 04/93] FIX credit note can be split --- htdocs/core/class/commoninvoice.class.php | 23 ++++++++++++ htdocs/core/class/discount.class.php | 43 +++++++++++++++++++++++ htdocs/fourn/facture/list.php | 7 ++-- htdocs/societe/class/societe.class.php | 8 ++--- 4 files changed, 75 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 3aa8eb4e1ab..35ec6ad283e 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -195,6 +195,29 @@ abstract class CommonInvoice extends CommonObject } } + /** + * Return amount (with tax) of all converted amount for this credit note + * + * @param int $multicurrency Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + */ + function getSumFromThisCreditNotesNotUsed($multicurrency=0) + { + require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; + + $discountstatic=new DiscountAbsolute($this->db); + $result=$discountstatic->getSumFromThisCreditNotesNotUsed($this, $multicurrency); + if ($result >= 0) + { + return $result; + } + else + { + $this->error=$discountstatic->error; + return -1; + } + } + /** * Renvoie tableau des ids de facture avoir issus de la facture * diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index cfe7ac24dea..2e99a83ec42 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -568,6 +568,49 @@ class DiscountAbsolute return -1; } } + /** + * Return amount (with tax) of all converted amount for this credit note + * + * @param CommonInvoice $invoice Object invoice + * @param int $multicurrency Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and deposits amount otherwise + */ + function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency=0) + { + dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); + + if ($invoice->element == 'facture' || $invoice->element == 'invoice') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; + $sql.= ' WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = '.$invoice->id; + } + else if ($invoice->element == 'invoice_supplier') + { + $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; + $sql.= ' WHERE rc.fk_invoice_supplier IS NULL AND rc.fk_invoice_supplier_source = '.$invoice->id; + } + else + { + $this->error=get_class($this)."::getSumCreditNotesUsed was called with a bad object as a first parameter"; + dol_print_error($this->error); + return -1; + } + + $resql=$this->db->query($sql); + if ($resql) + { + $obj = $this->db->fetch_object($resql); + if ($multicurrency) return $obj->multicurrency_amount; + else return $obj->amount; + } + else + { + $this->error = $this->db->lasterror(); + return -1; + } + } /** * Return clickable ref of object (with picto or not) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 3e1827d6818..d8e18257d23 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -852,8 +852,11 @@ if ($resql) $remaintopay = $obj->total_ttc - $totalpay; //If invoice has been converted and the conversion has been used, we dont have remain to pay on invoice - if($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE && $facturestatic->statut == FactureFournisseur::STATUS_CLOSED) { - if($facturestatic->isCreditNoteUsed())$remaintopay=0; + if($facturestatic->type == FactureFournisseur::TYPE_CREDIT_NOTE) { + + if($facturestatic->isCreditNoteUsed()){ + $remaintopay=-$facturestatic->getSumFromThisCreditNotesNotUsed(); + } } print ''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 7d54e7ad01e..87c4956e48e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3778,11 +3778,11 @@ class Societe extends CommonObject $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; } + + //if credit note is converted but not used + if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $tmpobject->isCreditNoteUsed())$outstandingOpened-=$tmpobject->getSumFromThisCreditNotesNotUsed(); + - if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $obj->fk_statut == FactureFournisseur::STATUS_CLOSED && !$tmpobject->isCreditNoteUsed()) { //if credit note is converted but not used - if(empty($paiement)) $paiement = $tmpobject->getSommePaiement(); - $outstandingOpened+=$obj->total_ttc-$paiement; - } } return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } From 9c47cb6f916ed057d17ed9242139b9bd4e9e2336 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Mon, 8 Jul 2019 23:16:32 +0200 Subject: [PATCH 05/93] NEW : can choose lines while creating order from origin --- htdocs/commande/card.php | 7 +++++-- htdocs/core/class/commonobject.class.php | 11 +++++++---- htdocs/core/tpl/originproductline.tpl.php | 4 ++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 7362f30e5a8..f9fd3a716f5 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -232,6 +232,7 @@ if (empty($reshook)) { $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + $selectedLines = GETPOST('toselect'); if ($datecommande == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors'); @@ -338,6 +339,8 @@ if (empty($reshook)) for($i = 0; $i < $num; $i ++) { + if(!in_array($lines[$i]->id, $selectedLines)) continue; // Skip unselected lines + $label = (! empty($lines[$i]->label) ? $lines[$i]->label : ''); $desc = (! empty($lines[$i]->desc) ? $lines[$i]->desc : ''); $product_type = (! empty($lines[$i]->product_type) ? $lines[$i]->product_type : 0); @@ -1870,8 +1873,6 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; print ''; - print ''; - // Show origin lines if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) { $title = $langs->trans('ProductsAndServices'); @@ -1883,6 +1884,8 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } + + print ''; } else { // Mode view $now = dol_now(); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0a300476fb5..f3832ff2782 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4145,7 +4145,7 @@ abstract class CommonObject */ public function printOriginLinesList($restrictlist = '') { - global $langs, $hookmanager, $conf; + global $langs, $hookmanager, $conf, $form; print ''; print ''.$langs->trans('Ref').''; @@ -4158,8 +4158,9 @@ abstract class CommonObject { print ''.$langs->trans('Unit').''; } - print ''.$langs->trans('ReductionShort').''; - + print ''.$langs->trans('ReductionShort').''; + print ''.$form->showCheckAddButtons('checkforselect', 1).''; + print ''; $var = true; $i = 0; @@ -4200,7 +4201,7 @@ abstract class CommonObject */ public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir = '/core/tpl') { - global $langs, $conf; + global $langs, $conf, $selectedLines; //var_dump($line); if (!empty($line->date_start)) @@ -4222,6 +4223,8 @@ abstract class CommonObject if ($line->date_fin_reel) $date_end=$line->date_fin_reel; } + $this->tpl['id'] = $line->id; + $this->tpl['label'] = ''; if (! empty($line->fk_parent_line)) $this->tpl['label'].= img_picto('', 'rightarrow'); diff --git a/htdocs/core/tpl/originproductline.tpl.php b/htdocs/core/tpl/originproductline.tpl.php index 2f0accd6306..e29ea678282 100644 --- a/htdocs/core/tpl/originproductline.tpl.php +++ b/htdocs/core/tpl/originproductline.tpl.php @@ -40,6 +40,10 @@ if($conf->global->PRODUCT_USE_UNITS) print ''.$langs->trans($this->tpl['unit']).''; print ''.$this->tpl['remise_percent'].''; + +$selected=1; +if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) $selected=0; +print ''; print ''."\n"; ?> From 18eb2a83fe7c2d01bdb34cceec389a6f9541e1f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 16 Aug 2019 16:41:53 +0200 Subject: [PATCH 06/93] FIX #11671 CVE-2019-15062 --- htdocs/core/actions_linkedfiles.inc.php | 8 +++----- htdocs/core/class/html.formfile.class.php | 4 ++-- htdocs/user/card.php | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 297f7821599..16ba1669337 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -118,8 +118,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') { require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; $link = new Link($db); - $link->id = $linkid; - $link->fetch(); + $link->fetch($linkid); $res = $link->delete($user); $langs->load('link'); @@ -153,8 +152,7 @@ elseif ($action == 'confirm_updateline' && GETPOST('save','alpha') && GETPOST('l require_once DOL_DOCUMENT_ROOT . '/core/class/link.class.php'; $langs->load('link'); $link = new Link($db); - $link->id = GETPOST('linkid', 'int'); - $f = $link->fetch(); + $f = $link->fetch(GETPOST('linkid', 'int')); if ($f) { $link->url = GETPOST('link', 'alpha'); @@ -162,7 +160,7 @@ elseif ($action == 'confirm_updateline' && GETPOST('save','alpha') && GETPOST('l { $link->url = 'http://' . $link->url; } - $link->label = GETPOST('label', 'alpha'); + $link->label = GETPOST('label', 'alphanohtml'); $res = $link->update($user); if (!$res) { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 2b02ada6b47..a198fba4f98 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1757,7 +1757,7 @@ class FormFile print $langs->trans('Link') . ': '; print ''; print ''; - print $langs->trans('Label') . ': '; + print $langs->trans('Label') . ': '; print ''; print '' . dol_print_date(dol_now(), "dayhour", "tzuser") . ''; print ''; @@ -1771,7 +1771,7 @@ class FormFile print ''; print img_picto('', 'object_globe').' '; print ''; - print $link->label; + print dol_escape_htmltag($link->label); print ''; print ''."\n"; print ''; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index adcf094e7a4..460e345131c 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -309,12 +309,12 @@ if (empty($reshook)) { { $error = 0; - if (!$_POST["lastname"]) { + if (! GETPOST("lastname", 'alpha')) { setEventMessages($langs->trans("NameNotDefined"), null, 'errors'); $action = "edit"; // Go back to create page $error ++; } - if (!$_POST["login"]) { + if (! GETPOST("login", 'alpha')) { setEventMessages($langs->trans("LoginNotDefined"), null, 'errors'); $action = "edit"; // Go back to create page $error ++; From e15d91640bd8ca40e88e7498233353190c08a6cb Mon Sep 17 00:00:00 2001 From: Frans Bosman Date: Thu, 22 Aug 2019 09:43:04 +0200 Subject: [PATCH 07/93] Update card.php --- htdocs/commande/card.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index a44054cdfd0..c603eba168c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1758,7 +1758,14 @@ if ($action == 'create' && $usercancreate) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); + // copy from thirdparty + $tpExtrafields = new Extrafields($db); + $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element); + if ($soc->fetch_optionals() > 0) { + $object->array_options = array_merge($object->array_options, $soc->array_options); + } + print $object->showOptionals($extrafields, 'edit'); + } // Template to use by default From 5bab233252f907a20496a164c2652e67106b2901 Mon Sep 17 00:00:00 2001 From: schhub <36532274+schhub@users.noreply.github.com> Date: Thu, 22 Aug 2019 13:19:45 +0200 Subject: [PATCH 08/93] Delete action correction for documents backup. correction of delete action always trying to delete files in document/admin/backup directory. Documents backups are stored in documents/admin/documents directory. If preg_match is too "heavy" it can be replaced by strpos. --- htdocs/admin/tools/dolibarr_export.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index c06314daa9a..f445c7eb791 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -50,11 +50,21 @@ if (! $user->admin) if ($action == 'delete') { - $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); - $ret=dol_delete_file($file, 1); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - $action=''; + if (preg_match('#backup/#', GETPOST('urlfile', 'alpha'))) + { + $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); + $ret=dol_delete_file($file, 1); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + } + else + { + $file=$conf->admin->dir_output.'/documents/'.basename(GETPOST('urlfile', 'alpha')); + $ret=dol_delete_file($file, 1); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + } + $action=''; } From 0be59646a848760b52d6761748187fa454617b21 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 22 Aug 2019 22:00:53 +0200 Subject: [PATCH 09/93] Update stripelive_oauthcallback.php --- htdocs/core/modules/oauth/stripelive_oauthcallback.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/oauth/stripelive_oauthcallback.php b/htdocs/core/modules/oauth/stripelive_oauthcallback.php index cf2c2418092..bbea53f9049 100644 --- a/htdocs/core/modules/oauth/stripelive_oauthcallback.php +++ b/htdocs/core/modules/oauth/stripelive_oauthcallback.php @@ -65,7 +65,7 @@ $storage = new DoliStorage($db, $conf); // Setup the credentials for the requests $credentials = new Credentials( - $conf->global->OAUTH_STRIPE_TEST_ID, + $conf->global->OAUTH_STRIPE_LIVE_ID, $conf->global->STRIPE_LIVE_SECRET_KEY, $currentUri->getAbsoluteUri() ); From cef4bdab7b388302168fe7d778222751f032b32a Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 22 Aug 2019 22:20:50 +0200 Subject: [PATCH 10/93] NEW update / delete stripe account for supplier --- htdocs/societe/paymentmodes.php | 48 ++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 9310ede87c5..cd8571fa869 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -600,6 +600,52 @@ if (empty($reshook)) $db->rollback(); } } + + if ($action == 'setkey_account_supplier') + { + $error = 0; + + $newsup = GETPOST('key_account_supplier', 'alpha'); + + $db->begin(); + + if (empty($newsup)) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = ".$servicestatus." AND entity = ".$conf->entity; + } else { + try { + $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); + + $tokenstring['stripe_user_id'] = $stripesup->id; + $tokenstring['type'] = $stripesup->type; + $sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token"; + $sql.= " SET tokenstring = '".dol_json_encode($tokenstring)."'"; + $sql.= " WHERE fk_soc = ".$object->id." AND service = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + } + catch(Exception $e) + { + $error++; + setEventMessages($e->getMessage(), null, 'errors'); + } + } + + $resql = $db->query($sql); + $num = $db->num_rows($resql); + if (empty($num) && !empty($newsup)) + { + //TODO CREATE ACCOUNT + } + + if (! $error) + { + $stripesupplieracc = $newsup; + $db->commit(); + } + else + { + $db->rollback(); + } + } + if ($action == 'setlocalassourcedefault') // Set as default when payment mode defined locally (and may be also remotely) { try { @@ -845,7 +891,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' print $form->editfieldkey("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', 0, 2, 'socid'); print ''; print $form->editfieldval("StripeConnectAccount", 'key_account_supplier', $stripesupplieracc, $object, $permissiontowrite, 'string', '', null, null, '', 2, '', 'socid'); - if (! empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account') + if (! empty($conf->stripe->enabled) && $stripesupplieracc && $action != 'editkey_account_supplier') { $connect=''; From 4536b8618e9eeea91c0585868e907e7f2bf40b62 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 22 Aug 2019 22:48:37 +0200 Subject: [PATCH 11/93] Update paymentmodes.php --- htdocs/societe/paymentmodes.php | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index cd8571fa869..374eff99766 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -612,27 +612,38 @@ if (empty($reshook)) if (empty($newsup)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = ".$servicestatus." AND entity = ".$conf->entity; } else { - try { + try { $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); - $tokenstring['stripe_user_id'] = $stripesup->id; - $tokenstring['type'] = $stripesup->type; + $tokenstring['type'] = $stripesup->type; $sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token"; $sql.= " SET tokenstring = '".dol_json_encode($tokenstring)."'"; $sql.= " WHERE fk_soc = ".$object->id." AND service = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! - } - catch(Exception $e) - { - $error++; - setEventMessages($e->getMessage(), null, 'errors'); - } - } + } + catch(Exception $e) + { + $error++; + setEventMessages($e->getMessage(), null, 'errors'); + } + } $resql = $db->query($sql); $num = $db->num_rows($resql); if (empty($num) && !empty($newsup)) { - //TODO CREATE ACCOUNT + try { + $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); + $tokenstring['stripe_user_id'] = $stripesup->id; + $tokenstring['type'] = $stripesup->type; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_token (service, fk_soc, entity, tokenstring)"; + $sql .= " VALUES ('".$service."', ".$object->id.", ".$conf->entity.", '".dol_json_encode($tokenstring)."')"; + } + catch(Exception $e) + { + $error++; + setEventMessages($e->getMessage(), null, 'errors'); + } + $resql = $db->query($sql); } if (! $error) From 06fdd5ddbc116a3f9894f7c25df7cfbe5265ab76 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 22 Aug 2019 22:50:41 +0200 Subject: [PATCH 12/93] Update stripelive_oauthcallback.php --- htdocs/core/modules/oauth/stripelive_oauthcallback.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/oauth/stripelive_oauthcallback.php b/htdocs/core/modules/oauth/stripelive_oauthcallback.php index bbea53f9049..a32223105b9 100644 --- a/htdocs/core/modules/oauth/stripelive_oauthcallback.php +++ b/htdocs/core/modules/oauth/stripelive_oauthcallback.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/core/modules/oauth/stripe_oauthcallback.php + * \file htdocs/core/modules/oauth/stripelive_oauthcallback.php * \ingroup oauth * \brief Page to get oauth callback */ @@ -45,7 +45,7 @@ $backtourl = GETPOST('backtourl', 'alpha'); $uriFactory = new \OAuth\Common\Http\Uri\UriFactory(); //$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER); //$currentUri->setQuery(''); -$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/stripe_oauthcallback.php'); +$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/stripelive_oauthcallback.php'); /** From 2d59f6bb3d1c17ceefa6be3e32f04e117e45f6da Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 23 Aug 2019 07:59:36 +0200 Subject: [PATCH 13/93] FIX avoid sql error if fk_project is empty during update --- .../compta/sociales/class/chargesociales.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index c3995a2202d..b08f1bda27f 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -291,17 +291,17 @@ class ChargeSociales extends CommonObject $sql.= ", date_ech='".$this->db->idate($this->date_ech)."'"; $sql.= ", periode='".$this->db->idate($this->periode)."'"; $sql.= ", amount='".price2num($this->amount,'MT')."'"; - $sql.= ", fk_projet='".$this->db->escape($this->fk_project)."'"; + $sql.= ", fk_projet=".($this->fk_project>0?$this->db->escape($this->fk_project):"NULL"); $sql.= ", fk_user_modif=".$user->id; $sql.= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql=$this->db->query($sql); - + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - + if (! $error) { if (! $notrigger) @@ -312,7 +312,7 @@ class ChargeSociales extends CommonObject // End call triggers } } - + // Commit or rollback if ($error) { @@ -329,8 +329,8 @@ class ChargeSociales extends CommonObject $this->db->commit(); return 1; } - - + + } /** From 9d3b4eb6994a6963c56fba85c7e32be861e5aa30 Mon Sep 17 00:00:00 2001 From: schhub <36532274+schhub@users.noreply.github.com> Date: Fri, 23 Aug 2019 08:05:44 +0200 Subject: [PATCH 14/93] Update dolibarr_export.php --- htdocs/admin/tools/dolibarr_export.php | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index f445c7eb791..d3996d44a31 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -50,21 +50,21 @@ if (! $user->admin) if ($action == 'delete') { - if (preg_match('#backup/#', GETPOST('urlfile', 'alpha'))) - { - $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); - $ret=dol_delete_file($file, 1); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - } - else - { - $file=$conf->admin->dir_output.'/documents/'.basename(GETPOST('urlfile', 'alpha')); - $ret=dol_delete_file($file, 1); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - } - $action=''; + if (preg_match('#backup/#', GETPOST('urlfile', 'alpha'))) + { + $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); + $ret=dol_delete_file($file, 1); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + } + else + { + $file=$conf->admin->dir_output.'/documents/'.basename(GETPOST('urlfile', 'alpha')); + $ret=dol_delete_file($file, 1); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + } + $action=''; } From 264763f6b7f5813293268d3d6487607737426681 Mon Sep 17 00:00:00 2001 From: schhub <36532274+schhub@users.noreply.github.com> Date: Fri, 23 Aug 2019 08:31:50 +0200 Subject: [PATCH 15/93] Update dolibarr_export.php --- htdocs/admin/tools/dolibarr_export.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index d3996d44a31..82554aaf490 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -67,7 +67,6 @@ if ($action == 'delete') $action=''; } - /* * View */ From 3c706ae28ac98e3377da27e2de7af51b027df5ff Mon Sep 17 00:00:00 2001 From: schhub <36532274+schhub@users.noreply.github.com> Date: Fri, 23 Aug 2019 08:53:43 +0200 Subject: [PATCH 16/93] Update dolibarr_export.php --- htdocs/admin/tools/dolibarr_export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 82554aaf490..65a2c40d363 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -50,7 +50,7 @@ if (! $user->admin) if ($action == 'delete') { - if (preg_match('#backup/#', GETPOST('urlfile', 'alpha'))) + if (preg_match('#backup/#', GETPOST('urlfile', 'alpha'))) { $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); $ret=dol_delete_file($file, 1); From 839ba76ae4da2ee11f544e9f6e2acb733ef691b5 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 23 Aug 2019 08:58:08 +0200 Subject: [PATCH 17/93] Update stripetest_oauthcallback.php --- htdocs/core/modules/oauth/stripetest_oauthcallback.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/oauth/stripetest_oauthcallback.php b/htdocs/core/modules/oauth/stripetest_oauthcallback.php index eb7463749ae..55b532f231c 100644 --- a/htdocs/core/modules/oauth/stripetest_oauthcallback.php +++ b/htdocs/core/modules/oauth/stripetest_oauthcallback.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/core/modules/oauth/stripe_oauthcallback.php + * \file htdocs/core/modules/oauth/stripetest_oauthcallback.php * \ingroup oauth * \brief Page to get oauth callback */ @@ -45,7 +45,7 @@ $backtourl = GETPOST('backtourl', 'alpha'); $uriFactory = new \OAuth\Common\Http\Uri\UriFactory(); //$currentUri = $uriFactory->createFromSuperGlobalArray($_SERVER); //$currentUri->setQuery(''); -$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/stripe_oauthcallback.php'); +$currentUri = $uriFactory->createFromAbsolute($urlwithroot.'/core/modules/oauth/stripetest_oauthcallback.php'); /** From 55d70004b1c1ff0ca75d1d01f3a22284437281ef Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 23 Aug 2019 09:00:11 +0200 Subject: [PATCH 18/93] Update paymentmodes.php --- htdocs/societe/paymentmodes.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 374eff99766..958ba4810b7 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -612,10 +612,10 @@ if (empty($reshook)) if (empty($newsup)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = ".$servicestatus." AND entity = ".$conf->entity; } else { - try { + try { $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); $tokenstring['stripe_user_id'] = $stripesup->id; - $tokenstring['type'] = $stripesup->type; + $tokenstring['type'] = $stripesup->type; $sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token"; $sql.= " SET tokenstring = '".dol_json_encode($tokenstring)."'"; $sql.= " WHERE fk_soc = ".$object->id." AND service = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! @@ -631,8 +631,8 @@ if (empty($reshook)) $num = $db->num_rows($resql); if (empty($num) && !empty($newsup)) { - try { - $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); + try { + $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); $tokenstring['stripe_user_id'] = $stripesup->id; $tokenstring['type'] = $stripesup->type; $sql = "INSERT INTO ".MAIN_DB_PREFIX."oauth_token (service, fk_soc, entity, tokenstring)"; From c6bcf19a88075e12d457a9c5674e0b8719134346 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 23 Aug 2019 09:01:05 +0200 Subject: [PATCH 19/93] Fix phpcs --- htdocs/stripe/class/stripe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 5dda24a763e..cf683671c5d 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -92,7 +92,7 @@ class Stripe extends CommonObject if ($fk_soc > 0) { $sql.= " AND fk_soc = ".$fk_soc; } - else { + else { $sql.= " AND fk_soc IS NULL"; } $sql.= " AND fk_user IS NULL AND fk_adherent IS NULL"; From 0afc55ab51e16c3cb9021999cb208295325813be Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 23 Aug 2019 09:08:39 +0200 Subject: [PATCH 20/93] Update paymentmodes.php --- htdocs/societe/paymentmodes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 958ba4810b7..4d49fc3792a 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -610,7 +610,7 @@ if (empty($reshook)) $db->begin(); if (empty($newsup)) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = ".$servicestatus." AND entity = ".$conf->entity; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."oauth_token WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; } else { try { $stripesup = \Stripe\Account::retrieve($db->escape(GETPOST('key_account_supplier', 'alpha'))); @@ -618,7 +618,7 @@ if (empty($reshook)) $tokenstring['type'] = $stripesup->type; $sql = "UPDATE ".MAIN_DB_PREFIX."oauth_token"; $sql.= " SET tokenstring = '".dol_json_encode($tokenstring)."'"; - $sql.= " WHERE fk_soc = ".$object->id." AND service = ".$servicestatus." AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! + $sql.= " WHERE fk_soc = ".$object->id." AND service = '".$service."' AND entity = ".$conf->entity; // Keep = here for entity. Only 1 record must be modified ! } catch(Exception $e) { From f14f1c9190914fbeaeef1190558b76cd10f8b67d Mon Sep 17 00:00:00 2001 From: atm-ph Date: Fri, 23 Aug 2019 09:15:15 +0200 Subject: [PATCH 21/93] Fix wrong placement to print title and missing hook to print value --- htdocs/compta/paiement.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 2da6052c63f..631cc10389a 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -593,6 +593,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''.$alreadypayedlabel.''; print ''.$remaindertopay.''; print ''.$langs->trans('PaymentAmount').''; + + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $facture, $action); // Note that $action and $object may have been modified by hook + print ' '; print "\n"; @@ -737,7 +741,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ""; $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $objp, $action); // Note that $action and $object may have been modified by hook // Warning print ''; From 22c661be9f43d68614e88eec7ab6b293776d5f77 Mon Sep 17 00:00:00 2001 From: schhub <36532274+schhub@users.noreply.github.com> Date: Fri, 23 Aug 2019 10:26:07 +0200 Subject: [PATCH 22/93] Update stripe.class.php removed space in line 95 --- htdocs/stripe/class/stripe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 5dda24a763e..cf683671c5d 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -92,7 +92,7 @@ class Stripe extends CommonObject if ($fk_soc > 0) { $sql.= " AND fk_soc = ".$fk_soc; } - else { + else { $sql.= " AND fk_soc IS NULL"; } $sql.= " AND fk_user IS NULL AND fk_adherent IS NULL"; From 73bcf3110dbf629a0030726a659aa6abd58512b3 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 23 Aug 2019 13:56:04 +0200 Subject: [PATCH 23/93] NEW birthday boxe for member use new function for displays the X next birthday by date ASC --- htdocs/core/boxes/box_birthdays_members.php | 163 ++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 htdocs/core/boxes/box_birthdays_members.php diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php new file mode 100644 index 00000000000..09863046cdf --- /dev/null +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -0,0 +1,163 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2015 Frederic France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_adherent_birthdays.php + * \ingroup member + * \brief Box for member birthdays + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show user birthdays + */ +class box_birthdays_members extends ModeleBoxes +{ + public $boxcode="birthdays_members"; + public $boximg="object_user"; + public $boxlabel="BoxBirthdaysMembers"; + public $depends = array("adherent"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param = '') + { + global $conf, $user; + + $this->db = $db; + + $this->hidden = ! ($user->rights->adherent->lire && empty($user->socid)); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 20) + { + global $user, $langs, $db, $conf; + $langs->load("boxes"); + + $this->max=$max; + + include_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $memberstatic=new Adherent($db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleMemberNextBirthdays")); + + if ($user->rights->adherent->lire) + { + $sql = "SELECT u.rowid, u.firstname, u.lastname"; + $sql.= ", u.birth"; + $sql.= " FROM ".MAIN_DB_PREFIX."adherent as u"; + $sql.= " WHERE u.entity IN (".getEntity('adherent').")"; + $sql.= " AND u.statut = 1"; + $sql.= " AND date_format(u.birth, '%m-%d') >= date_format(curdate(), '%m-%d')"; + $sql.= " ORDER BY date_format(u.birth, '%m-%d') ASC"; + $sql.= $db->plimit($max, 0); + + dol_syslog(get_class($this)."::loadBox", LOG_DEBUG); + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + + $line = 0; + while ($line < $num) + { + $objp = $db->fetch_object($result); + $memberstatic->id = $objp->rowid; + $memberstatic->firstname = $objp->firstname; + $memberstatic->lastname = $objp->lastname; + $memberstatic->email = $objp->email; + $dateb=$db->jdate($objp->birth); + $age = date('Y', dol_now()) - date('Y', $dateb); + + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $memberstatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right"', + 'text' => dol_print_date($dateb, "day") . ' - ' . $age . ' ' . $langs->trans('DurationYears') + ); + + /*$this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $memberstatic->LibStatut($objp->status, 3) + );*/ + + $line++; + } + + if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedUsers")); + + $db->free($result); + } + else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($db->error().' sql='.$sql) + ); + } + } + else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} From 30b929c62111a55ee3ddffd25ee51d896c8595d4 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 23 Aug 2019 13:57:22 +0200 Subject: [PATCH 24/93] Update modAdherent.class.php --- htdocs/core/modules/modAdherent.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 827928af6b6..300f071de1e 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -181,7 +181,10 @@ class modAdherent extends DolibarrModules // Boxes //------- - $this->boxes = array(0=>array('file'=>'box_members.php','enabledbydefaulton'=>'Home')); + $this->boxes = array( + 0=>array('file'=>'box_members.php','enabledbydefaulton'=>'Home'), + 2=>array('file'=>'box_birthdays_members.php','enabledbydefaulton'=>'Home') + ); // Permissions //------------ From b7e7ca46b577917416ccbf545e22024b1808df42 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 Aug 2019 14:01:13 +0200 Subject: [PATCH 25/93] Fix responsive --- htdocs/fourn/facture/list.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 7d51f3783c1..fa05108b05c 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2019 Laurent Destailleur * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2013-2019 Philippe Grand * Copyright (C) 2013 Florian Henry @@ -588,14 +588,14 @@ if ($resql) if (! empty($arrayfields['f.ref']['checked'])) { print ''; - print ''; + print ''; print ''; } // Ref supplier if (! empty($arrayfields['f.ref_supplier']['checked'])) { print ''; - print ''; + print ''; print ''; } // Type @@ -622,7 +622,7 @@ if ($resql) if (! empty($arrayfields['f.label']['checked'])) { print ''; - print ''; + print ''; print ''; } // Date invoice @@ -647,17 +647,17 @@ if ($resql) // Project if (! empty($arrayfields['p.ref']['checked'])) { - print ''; + print ''; } // Thirpdarty if (! empty($arrayfields['s.nom']['checked'])) { - print ''; + print ''; } // Town - if (! empty($arrayfields['s.town']['checked'])) print ''; + if (! empty($arrayfields['s.town']['checked'])) print ''; // Zip - if (! empty($arrayfields['s.zip']['checked'])) print ''; + if (! empty($arrayfields['s.zip']['checked'])) print ''; // State if (! empty($arrayfields['state.nom']['checked'])) { @@ -688,35 +688,35 @@ if ($resql) } if (! empty($arrayfields['f.total_ht']['checked'])) { - // Amount + // Amount without tax print ''; print ''; print ''; } if (! empty($arrayfields['f.total_vat']['checked'])) { - // Amount + // Amount vat print ''; print ''; print ''; } if (! empty($arrayfields['f.total_localtax1']['checked'])) { - // Amount + // Amount tax 1 print ''; print ''; print ''; } if (! empty($arrayfields['f.total_localtax2']['checked'])) { - // Amount + // Amount tax 2 print ''; print ''; print ''; } if (! empty($arrayfields['f.total_ttc']['checked'])) { - // Amount + // Amount inc tac print ''; print ''; print ''; @@ -776,7 +776,7 @@ if ($resql) if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER['PHP_SELF'], "p.ref", '', $param, '', $sortfield, $sortorder); if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER['PHP_SELF'], 's.nom', '', $param, '', $sortfield, $sortorder); if (! empty($arrayfields['s.town']['checked'])) print_liste_field_titre($arrayfields['s.town']['label'], $_SERVER["PHP_SELF"], 's.town', '', $param, '', $sortfield, $sortorder); - if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['s.zip']['checked'])) print_liste_field_titre($arrayfields['s.zip']['label'], $_SERVER["PHP_SELF"], 's.zip', '', $param, '', $sortfield, $sortorder, 'center '); if (! empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder); if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center '); if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center '); @@ -944,7 +944,7 @@ if ($resql) // Zip if (! empty($arrayfields['s.zip']['checked'])) { - print ''; + print ''; print $obj->zip; print ''; if (! $i) $totalarray['nbfield']++; From c8cf06ed2fb2caaf2bacee766304ffed2a0ab9d4 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 23 Aug 2019 14:59:12 +0200 Subject: [PATCH 26/93] Update box_birthdays_members.php --- htdocs/core/boxes/box_birthdays_members.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_birthdays_members.php b/htdocs/core/boxes/box_birthdays_members.php index 09863046cdf..6a36bc01ae4 100644 --- a/htdocs/core/boxes/box_birthdays_members.php +++ b/htdocs/core/boxes/box_birthdays_members.php @@ -88,7 +88,7 @@ class box_birthdays_members extends ModeleBoxes $sql.= " FROM ".MAIN_DB_PREFIX."adherent as u"; $sql.= " WHERE u.entity IN (".getEntity('adherent').")"; $sql.= " AND u.statut = 1"; - $sql.= " AND date_format(u.birth, '%m-%d') >= date_format(curdate(), '%m-%d')"; + $sql.= " AND date_format(u.birth, '%m-%d') >= date_format(curdate(), '%m-%d')"; $sql.= " ORDER BY date_format(u.birth, '%m-%d') ASC"; $sql.= $db->plimit($max, 0); From 064ab389ed0030e19514fcea944f6d64af212e03 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 24 Aug 2019 12:44:23 +0200 Subject: [PATCH 27/93] FIX wrong parameters (same error in branch 9, 10, develop) --- htdocs/compta/paiement.php | 2 +- htdocs/projet/index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 4888b758cc1..aa344c3df2e 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -530,7 +530,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $sql = 'SELECT f.rowid as facid, f.facnumber, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ttc, f.type,'; $sql.= ' f.datef as df, f.fk_soc as socid'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture as f'; - $sql.= ' WHERE f.entity IN ('.getEntity('facture', $conf->entity).')'; + $sql.= ' WHERE f.entity IN ('.getEntity('facture').')'; $sql.= ' AND (f.fk_soc = '.$facture->socid; // Can pay invoices of all child of parent company if(!empty($conf->global->FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS) && !empty($facture->thirdparty->parent)) { diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 906cb3783f1..4c4ae4c71cf 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -258,7 +258,7 @@ $sql = "SELECT COUNT(p.rowid) as nb, SUM(p.opp_amount)"; $sql.= ", s.nom as name, s.rowid as socid"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; -$sql.= " WHERE p.entity IN (".getEntity('project', $conf->entity).")"; +$sql.= " WHERE p.entity IN (".getEntity('project').")"; $sql.= " AND p.fk_statut = 1"; if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")"; // If we have this test true, it also means projectset is not 2 if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; From 73a6b45e23ac22c070ab69c4d37e5ade23bf6c51 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 13:26:01 +0200 Subject: [PATCH 28/93] Fix load langs in takepos --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index ed3e5def318..68c7cf0ef55 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -29,7 +29,7 @@ require '../main.inc.php'; // Load $user and permissions require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -$langs->loadLangs(array("bills", "cashdesk")); +$langs->loadLangs(array("companies","commercial","bills", "cashdesk")); $id = GETPOST('id','int'); $action = GETPOST('action','alpha'); From 686d43a12230b9673fe23b378e212999c94b533b Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 13:44:21 +0200 Subject: [PATCH 29/93] NEW display membership in takepos if member link to thirdparty For some business or cases (ie: fundation), we need to know if customer is a member and membership is up to date. --- htdocs/takepos/invoice.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 17805a6b060..08822d46c6d 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -692,6 +692,29 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep print '

'; print $langs->trans("Customer").': '.$soc->name; print '

'; + + // Module Adherent + if (! empty($conf->adherent->enabled)) + { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $langs->load("members"); + print '

'; + print $langs->trans("Member").': '; + $adh=new Adherent($db); + $result=$adh->fetch('', '', $invoice->socid); + if ($result > 0) + { + $adh->ref=$adh->getFullName($langs); + print $adh->getFullName($langs); + print '
'.$langs->trans("Type").': '.$adh->type; + print '
'.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day'); + } + else + { + print ''.$langs->trans("ThirdpartyNotLinkedToMember").''; + } + print '

'; + } } if ($action == "search") From cc1de15438d646e83c73facef96afaeaee0a61d1 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 13:52:40 +0200 Subject: [PATCH 30/93] Update invoice.php --- htdocs/takepos/invoice.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 08822d46c6d..c628daa44ad 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -707,7 +707,18 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep $adh->ref=$adh->getFullName($langs); print $adh->getFullName($langs); print '
'.$langs->trans("Type").': '.$adh->type; - print '
'.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day'); + if ($adh->datefin) + { + print dol_print_date($adh->datefin, 'day'); + if ($adh->hasDelay()) { + print " ".img_warning($langs->trans("Late")); + } + } + else + { + print $langs->trans("SubscriptionNotReceived"); + if ($adh->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated + } } else { From bb763ecb59bfafde02b8095ef4a8721dba358b86 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 14:02:25 +0200 Subject: [PATCH 31/93] Fix lang in takepos --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index e09c31664cd..4737ecbde27 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -367,7 +367,7 @@ if ($action=="valid" || $action=="history") } else { - if ($invoice->paye) $sectionwithinvoicelink.=''.$langs->trans("Payed").''; + if ($invoice->paye) $sectionwithinvoicelink.=''.$langs->trans("Paid").''; else $sectionwithinvoicelink.=$langs->trans('BillShortStatusValidated'); } $sectionwithinvoicelink.=''; From 361bb724486c81e090b704f08134fd00b5074157 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 14:17:58 +0200 Subject: [PATCH 32/93] Update invoice.php --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index c628daa44ad..663c7d4d006 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -725,7 +725,7 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep print ''.$langs->trans("ThirdpartyNotLinkedToMember").''; } print '

'; - } + } } if ($action == "search") From d2ff37ae723fc37295b6066f0927d1fe57a285fd Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 15:00:49 +0200 Subject: [PATCH 33/93] NEW email template for Takepos (sending invoice) --- htdocs/takepos/admin/setup.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 6d33b8a19c2..23e6eb05c48 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -80,6 +80,7 @@ if (GETPOST('action', 'alpha') == 'set') $res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "TAKEPOS_DIRECT_PAYMENT", GETPOST('TAKEPOS_DIRECT_PAYMENT', 'int'), 'int', 0, '', $conf->entity); + $res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity); if ($conf->global->TAKEPOS_ORDER_NOTES==1) { @@ -231,6 +232,30 @@ print ''; print $form->selectyesno("TAKEPOS_DIRECT_PAYMENT", $conf->global->TAKEPOS_DIRECT_PAYMENT, 1); print "\n"; +// Email template for send invoice +print ''; +print $langs->trans('EmailTemplate'); +print ''; +include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; +$formmail = new FormMail($db); +$nboftemplates = $formmail->fetchAllEMailTemplate('facture_send', $user, null, -1); // We set lang=null to get in priority record with no lang +//$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, ''); +$arrayofmessagename=array(); +if (is_array($formmail->lines_model)) +{ + foreach($formmail->lines_model as $modelmail) + { + //var_dump($modelmail); + $moreonlabel=''; + if (! empty($arrayofmessagename[$modelmail->label])) $moreonlabel=' ('.$langs->trans("SeveralLangugeVariatFound").')'; + $arrayofmessagename[$modelmail->label]=$langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)).$moreonlabel; + } +} +//var_dump($arraydefaultmessage); +//var_dump($arrayofmessagename); +print $form->selectarray('TAKEPOS_EMAIL_TEMPLATE_INVOICE', $arrayofmessagename, $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE, 'None', 1, 0, '', 0, 0, 0, '', '', 1); +print "\n"; + $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; From c4b18890d952a2e1611d08b419ebf295c1db6c4c Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 15:12:56 +0200 Subject: [PATCH 34/93] Update invoice.php --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 4737ecbde27..1e11161e8a1 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -511,7 +511,7 @@ print '
'.$sectionwithinvoicelink; print ''; print '' . $langs->trans('ReductionShort') . ''; print '' . $langs->trans('Qty') . ''; -print '' . $langs->trans('TotalHTShort') . ''; +print '' . $langs->trans('Total') . ''; print "\n"; if ($placeid > 0) From 2be125e647daa8680559a7900cacac959b8a89c1 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 15:47:17 +0200 Subject: [PATCH 35/93] Fix display context for takepos in invoice list fix for thirdparty name and create button --- htdocs/compta/facture/list.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 284b747465d..f0c10598f82 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -605,7 +605,7 @@ if ($resql) $massactionbutton=$form->selectMassAction('', $arrayofmassactions); $newcardbutton=''; - if($user->rights->facture->creer) + if($user->rights->facture->creer && $contextpage != 'poslist') { $newcardbutton.= dolGetButtonTitle($langs->trans('NewBill'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/facture/card.php?action=create'); } @@ -1068,7 +1068,14 @@ if ($resql) if (! empty($arrayfields['s.nom']['checked'])) { print ''; - print $thirdpartystatic->getNomUrl(1, 'customer'); + if ($contextpage == 'poslist') + { + print $thirdpartystatic->name; + } + else + { + print $thirdpartystatic->getNomUrl(1, 'customer'); + } print ''; if (! $i) $totalarray['nbfield']++; } From 7112fcee9a6031a93294f235f132f55a3ac65906 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 15:54:14 +0200 Subject: [PATCH 36/93] Update list.php --- htdocs/compta/facture/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index f0c10598f82..653f1182d78 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -687,7 +687,7 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); + if ($massactionbutton && $contextpage != 'poslist') $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); print '
'; print ''."\n"; @@ -1237,7 +1237,7 @@ if ($resql) // Action column print ''; } +if (! empty($arrayfields['p.jabberid']['checked'])) +{ + print ''; +} if (! empty($arrayfields['p.twitter']['checked'])) { print ''; print ''; print ''; -print ''; +print ''; print "\n"; if ($placeid > 0) From 6771af4565eda5ad2c7d1722c93222ef32fd1990 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Aug 2019 16:33:22 +0200 Subject: [PATCH 56/93] Update dolibarr_export.php --- htdocs/admin/tools/dolibarr_export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 65a2c40d363..50a590d636b 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -50,7 +50,7 @@ if (! $user->admin) if ($action == 'delete') { - if (preg_match('#backup/#', GETPOST('urlfile', 'alpha'))) + if (preg_match('/backup\//', GETPOST('urlfile', 'alpha'))) { $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); $ret=dol_delete_file($file, 1); From 5c13f5d397d13f4a5e299027d1007d6613b33250 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Aug 2019 16:33:38 +0200 Subject: [PATCH 57/93] Update dolibarr_export.php --- htdocs/admin/tools/dolibarr_export.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 50a590d636b..e07e7999414 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -50,7 +50,7 @@ if (! $user->admin) if ($action == 'delete') { - if (preg_match('/backup\//', GETPOST('urlfile', 'alpha'))) + if (preg_match('/^backup\//', GETPOST('urlfile', 'alpha'))) { $file=$conf->admin->dir_output.'/backup/'.basename(GETPOST('urlfile', 'alpha')); $ret=dol_delete_file($file, 1); From 7d8f86c6146f2aa80bea912a014aa4d9c3de22f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Traull=C3=A9?= <613615+jtraulle@users.noreply.github.com> Date: Mon, 26 Aug 2019 17:51:13 +0200 Subject: [PATCH 58/93] Create .stickler.yml --- .stickler.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .stickler.yml diff --git a/.stickler.yml b/.stickler.yml new file mode 100644 index 00000000000..af0cb290035 --- /dev/null +++ b/.stickler.yml @@ -0,0 +1,7 @@ +--- +linters: + phpcs: + standard: 'dev/setup/codesniffer/ruleset.xml' + extensions: 'php' + tab_width: 4 + fixer: true From ad38478fc6596ef43eb1fc813de4adb2f6338735 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 26 Aug 2019 20:01:05 +0200 Subject: [PATCH 59/93] Fix lang for "nature" in contact --- htdocs/core/tpl/contacts.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 14534b3472e..1f7d403b575 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -149,7 +149,7 @@ if ($permission) { ?> -
trans("Nature"); ?>
+
trans("NatureOfContact"); ?>
trans("ThirdParty"); ?>
trans("Users").'/'.$langs->trans("Contacts"); ?>
trans("ContactType"); ?>
From c08c3b5c9c101a6aadc4f836ef3ce8c915415117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Traull=C3=A9?= <613615+jtraulle@users.noreply.github.com> Date: Mon, 26 Aug 2019 21:33:46 +0200 Subject: [PATCH 60/93] Enable fixer to auto-fix code style issues --- .stickler.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.stickler.yml b/.stickler.yml index af0cb290035..b68804448b2 100644 --- a/.stickler.yml +++ b/.stickler.yml @@ -5,3 +5,6 @@ linters: extensions: 'php' tab_width: 4 fixer: true + +fixers: + enable: true From 76bd9a09a69eb37d4e4f292de0a507c56c6df65c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Aug 2019 22:34:41 +0200 Subject: [PATCH 61/93] FIX #11570 --- htdocs/core/class/html.form.class.php | 34 +++--- test/phpunit/FormTest.php | 149 ++++++++++++++++++++++++++ 2 files changed, 168 insertions(+), 15 deletions(-) create mode 100644 test/phpunit/FormTest.php diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index d2130e24291..ad81f7d7a2b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1862,10 +1862,10 @@ class Form * @param int $forcecombo Force to use combo box * @param string $morecss Add more css on select * @param int $hidepriceinlabel 1=Hide prices in label - * @param string $warehouseStatus warehouse status filter, following comma separated filter options can be used - * 'warehouseopen' = select products from open warehouses, - * 'warehouseclosed' = select products from closed warehouses, - * 'warehouseinternal' = select products from warehouses for internal correct/transfer only + * @param string $warehouseStatus Warehouse status filter to count the quantity in stock. Following comma separated filter options can be used + * 'warehouseopen' = count products from open warehouses, + * 'warehouseclosed' = count products from closed warehouses, + * 'warehouseinternal' = count products from warehouses for internal correct/transfer only * @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) * @return void */ @@ -1877,7 +1877,7 @@ class Form // check parameters $price_level = (! empty($price_level) ? $price_level : 0); if (is_null($ajaxoptions)) $ajaxoptions=array(); - + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PRODUIT_USE_SEARCH_TO_SELECT)) { $placeholder=''; @@ -2007,10 +2007,10 @@ class Form * @param int $forcecombo Force to use combo box * @param string $morecss Add more css on select * @param int $hidepriceinlabel 1=Hide prices in label - * @param string $warehouseStatus warehouse status filter, following comma separated filter options can be used - * 'warehouseopen' = select products from open warehouses, - * 'warehouseclosed' = select products from closed warehouses, - * 'warehouseinternal' = select products from warehouses for internal correct/transfer only + * @param string $warehouseStatus Warehouse status filter to group/count stock. Following comma separated filter options can be used. + * 'warehouseopen' = count products from open warehouses, + * 'warehouseclosed' = count products from closed warehouses, + * 'warehouseinternal' = count products from warehouses for internal correct/transfer only * @return array Array of keys for json */ function select_produits_list($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$filterkey='',$status=1,$finished=2,$outputmode=0,$socid=0,$showempty='1',$forcecombo=0,$morecss='',$hidepriceinlabel=0, $warehouseStatus='') @@ -2040,7 +2040,14 @@ class Form } $selectFields = " p.rowid, p.label, p.ref, p.description, p.barcode, p.fk_product_type, p.price, p.price_ttc, p.price_base_type, p.tva_tx, p.duration, p.fk_price_expression"; - (count($warehouseStatusArray)) ? $selectFieldsGrouped = ", sum(ps.reel) as stock" : $selectFieldsGrouped = ", p.stock"; + if (count($warehouseStatusArray)) + { + $selectFieldsGrouped = ", sum(".$db->ifsql("e.statut IS NULL", "0", "ps.reel").") as stock"; // e.statut is null if there is no record in stock + } + else + { + $selectFieldsGrouped = ", p.stock"; + } $sql = "SELECT "; $sql.= $selectFields . $selectFieldsGrouped; @@ -2076,6 +2083,7 @@ class Form { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_product = p.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on ps.fk_entrepot = e.rowid"; + $sql.= ' AND e.statut IN ('.$this->db->escape(implode(',',$warehouseStatusArray)).')'; // Return line if product is inside the selected stock. If not, an empty line will be returned so we will count 0. } // include search in supplier ref @@ -2099,10 +2107,6 @@ class Form } $sql.= ' WHERE p.entity IN ('.getEntity('product').')'; - if (count($warehouseStatusArray)) - { - $sql.= ' AND (p.fk_product_type = 1 OR e.statut IN ('.$this->db->escape(implode(',',$warehouseStatusArray)).'))'; - } if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { $sql .= " AND pac.rowid IS NULL"; @@ -2273,7 +2277,7 @@ class Form /** * constructProductListOption * - * @param resultset $objp Resultset of fetch + * @param resource $objp Resultset of fetch * @param string $opt Option (var used for returned value in string option format) * @param string $optJson Option (var used for returned value in json format) * @param int $price_level Price level diff --git a/test/phpunit/FormTest.php b/test/phpunit/FormTest.php new file mode 100644 index 00000000000..b3025b4c345 --- /dev/null +++ b/test/phpunit/FormTest.php @@ -0,0 +1,149 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see http://www.gnu.org/ + */ + +/** + * \file test/phpunit/FormTest.php + * \ingroup test + * \brief PHPUnit test + * \remarks To run this script as CLI: phpunit filename.php + */ + +global $conf,$user,$langs,$db; +//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver +//require_once 'PHPUnit/Autoload.php'; +require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; +require_once dirname(__FILE__).'/../../htdocs/core/class/html.form.class.php'; + +if (empty($user->id)) +{ + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); +} +$conf->global->MAIN_DISABLE_ALL_MAILS=1; + + +/** + * Class for PHPUnit tests + * + * @backupGlobals disabled + * @backupStaticAttributes enabled + * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. + */ +class FormTest extends PHPUnit\Framework\TestCase +{ + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; + + /** + * Constructor + * We save global variables into local variables + * + * @return FactureTest + */ + function __construct() + { + parent::__construct(); + + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + print __METHOD__."\n"; + } + + // tear down after class + public static function tearDownAfterClass() + { + global $conf,$user,$langs,$db; + $db->rollback(); + + print __METHOD__."\n"; + } + + /** + * Init phpunit tests + * + * @return void + */ + protected function setUp() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + print __METHOD__."\n"; + } + + /** + * End phpunit tests + * + * @return void + */ + protected function tearDown() + { + print __METHOD__."\n"; + } + + /** + * testSelectProduitsList + * + * @return int + */ + public function testSelectProduitsList() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new Form($this->savdb); + $result=$localobject->select_produits_list('', 'productid', '', 5, 0, '', 1, 2, 1); + + $this->assertEquals(count($result), 5); + print __METHOD__." result=".$result."\n"; + + $conf->global->ENTREPOT_EXTRA_STATUS = 1; + + // Exclude stock in warehouseinternal + $result=$localobject->select_produits_list('', 'productid', '', 5, 0, '', 1, 2, 1, 0, '1', 0, '', 0, 'warehouseclosed,warehouseopen'); + $this->assertEquals(count($result), 5); + print __METHOD__." result=".$result."\n"; + + return $result; + } +} From b6db04a727402b66973fcd69a17ba8d73310db6d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Aug 2019 22:42:04 +0200 Subject: [PATCH 62/93] Fix add missing filter on entity on stock listing for product combo --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ad81f7d7a2b..1666901d04a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2082,7 +2082,7 @@ class Form if (count($warehouseStatusArray)) { $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.fk_product = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on ps.fk_entrepot = e.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on ps.fk_entrepot = e.rowid AND e.entity IN (".getEntity('stock').")"; $sql.= ' AND e.statut IN ('.$this->db->escape(implode(',',$warehouseStatusArray)).')'; // Return line if product is inside the selected stock. If not, an empty line will be returned so we will count 0. } From 669301669d3d8c6032de1b4031eebf8ed7ae173e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Aug 2019 22:48:45 +0200 Subject: [PATCH 63/93] Add phpunit for FormTest --- test/phpunit/AllTests.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index ee7ec9375d6..db3dc95e434 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -239,6 +239,8 @@ class AllTests require_once dirname(__FILE__).'/FormAdminTest.php'; $suite->addTestSuite('FormAdminTest'); + require_once dirname(__FILE__).'/FormTest.php'; + $suite->addTestSuite('FormTest'); require_once dirname(__FILE__).'/ModulesTest.php'; // At end because it's the longer $suite->addTestSuite('ModulesTest'); From 9e04eccf547a8b229d0d009b418c31efc55b6421 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Aug 2019 23:28:06 +0200 Subject: [PATCH 64/93] Fix syntax error --- htdocs/commande/card.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index dea2d0c0ed8..5b6a47fa998 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1758,15 +1758,16 @@ if ($action == 'create' && $usercancreate) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); print $hookmanager->resPrint; if (empty($reshook)) { - if (! empty($conf->global->THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER)) - // copy from thirdparty - $tpExtrafields = new Extrafields($db); - $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element); - if ($soc->fetch_optionals() > 0) { - $object->array_options = array_merge($object->array_options, $soc->array_options); - } + if (! empty($conf->global->THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER)) { + // copy from thirdparty + $tpExtrafields = new Extrafields($db); + $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element); + if ($soc->fetch_optionals() > 0) { + $object->array_options = array_merge($object->array_options, $soc->array_options); + } }; - print $object->showOptionals($extrafields, 'edit'); + + print $object->showOptionals($extrafields, 'edit'); } // Template to use by default From db6b1b6ffb37b159eb0273d695fc25f63a3a48ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Aug 2019 23:44:20 +0200 Subject: [PATCH 65/93] NEW Add status of warehouse in tooltip of a warehouse. --- htdocs/product/stock/class/entrepot.class.php | 2 ++ htdocs/product/stock/product.php | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index e857166e392..ad475436932 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -686,6 +686,8 @@ class Entrepot extends CommonObject $label.= '
' . $langs->trans('Ref') . ': ' . (empty($this->ref)?(empty($this->label)?$this->libelle:$this->label):$this->ref); if (! empty($this->lieu)) $label.= '
' . $langs->trans('LocationSummary').': '.$this->lieu; + if (isset($this->statut)) + $label.= '
' . $langs->trans("Status").": ".$this->getLibStatut(2); $url = DOL_URL_ROOT.'/product/stock/card.php?id='.$this->id; diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 2c0515d309c..9dd46428ffb 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -827,7 +827,7 @@ if (! $variants) { print ''; } - $sql = "SELECT e.rowid, e.ref as label, e.lieu, ps.reel, ps.rowid as product_stock_id, p.pmp"; + $sql = "SELECT e.rowid, e.ref as label, e.lieu, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp"; $sql .= " FROM " . MAIN_DB_PREFIX . "entrepot as e,"; $sql .= " " . MAIN_DB_PREFIX . "product_stock as ps"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = ps.fk_product"; @@ -851,9 +851,12 @@ if (! $variants) { $var = false; while ($i < $num) { $obj = $db->fetch_object($resql); + $entrepotstatic->id = $obj->rowid; $entrepotstatic->libelle = $obj->label; $entrepotstatic->lieu = $obj->lieu; + $entrepotstatic->statut = $obj->statut; + $stock_real = price2num($obj->reel, 'MS'); print '
'; print ''; From e8bb84e803ce3cd15201a44967c1df0204da3d1f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Aug 2019 23:54:15 +0200 Subject: [PATCH 66/93] NEW Add status of warehouse in tooltip of a warehouse. --- htdocs/product/stock/class/entrepot.class.php | 2 +- htdocs/product/stock/list.php | 17 ++++++++++++++--- htdocs/product/stock/movement_list.php | 8 ++++++-- htdocs/product/stock/product.php | 7 +++++-- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index ad475436932..18d17f9acf0 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -687,7 +687,7 @@ class Entrepot extends CommonObject if (! empty($this->lieu)) $label.= '
' . $langs->trans('LocationSummary').': '.$this->lieu; if (isset($this->statut)) - $label.= '
' . $langs->trans("Status").": ".$this->getLibStatut(2); + $label.= '
' . $langs->trans("Status").": ".$this->getLibStatut(5); $url = DOL_URL_ROOT.'/product/stock/card.php?id='.$this->id; diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 8e19242d1c1..9426d2041b0 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -104,13 +104,19 @@ $form=new Form($db); $warehouse=new Entrepot($db); $sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent,"; -$sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; +$sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty,"; // Add fields from extrafields -foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); +if (! empty($extrafields->attributes[$object->table_element]['label'])) + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql.=($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); +// Add fields from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/, $/', '', $sql); $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot_extrafields as ef on (e.rowid = ef.fk_object)"; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (e.rowid = ef.fk_object)"; $sql.= " WHERE e.entity IN (".getEntity('stock').")"; if ($search_ref) $sql.= natural_search("e.ref", $search_ref); // ref if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label @@ -118,6 +124,10 @@ if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$sear if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; $sql.= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent"; $totalnboflines=0; $result=$db->query($sql); @@ -241,6 +251,7 @@ if ($result) $warehouse->label = $obj->ref; $warehouse->lieu = $obj->lieu; $warehouse->fk_parent = $obj->fk_parent; + $warehouse->statut = $obj->statut; print '
'; print ''; diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index f62b732cf7e..149804ee966 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -420,7 +420,7 @@ $formproduct=new FormProduct($db); if (!empty($conf->projet->enabled)) $formproject=new FormProjets($db); $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,"; -$sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,"; +$sql.= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu, e.fk_parent, e.statut,"; $sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; $sql.= " m.batch, m.price,"; $sql.= " m.type_mouvement,"; @@ -988,8 +988,12 @@ if ($resql) $productlot->sellby= $objp->sellby; $warehousestatic->id=$objp->entrepot_id; - $warehousestatic->libelle=$objp->stock; + $warehousestatic->ref=$objp->warehouse_ref; + $warehousestatic->libelle=$objp->warehouse_ref; + $warehousestatic->label=$objp->warehouse_ref; $warehousestatic->lieu=$objp->lieu; + $warehousestatic->fk_parent = $objp->fk_parent; + $warehousestatic->statut = $objp->statut; $arrayofuniqueproduct[$objp->rowid]=$objp->produit; if(!empty($objp->fk_origin)) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 9dd46428ffb..41c9b151865 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -827,7 +827,7 @@ if (! $variants) { print ''; } - $sql = "SELECT e.rowid, e.ref as label, e.lieu, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp"; + $sql = "SELECT e.rowid, e.ref, e.lieu, e.fk_parent, e.statut, ps.reel, ps.rowid as product_stock_id, p.pmp"; $sql .= " FROM " . MAIN_DB_PREFIX . "entrepot as e,"; $sql .= " " . MAIN_DB_PREFIX . "product_stock as ps"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = ps.fk_product"; @@ -853,8 +853,11 @@ if (! $variants) { $obj = $db->fetch_object($resql); $entrepotstatic->id = $obj->rowid; - $entrepotstatic->libelle = $obj->label; + $entrepotstatic->ref = $obj->ref; + $entrepotstatic->libelle = $obj->ref; + $entrepotstatic->label = $obj->ref; $entrepotstatic->lieu = $obj->lieu; + $entrepotstatic->fk_parent = $obj->fk_parent; $entrepotstatic->statut = $obj->statut; $stock_real = price2num($obj->reel, 'MS'); From c7f06fe50e88804fdc0fdadb0b4d5ba617dfc6e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Aug 2019 23:56:17 +0200 Subject: [PATCH 67/93] Fix phpcs --- htdocs/societe/class/societe.class.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index c45e6871420..6bbbf987fcf 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3853,11 +3853,9 @@ class Societe extends CommonObject $outstandingOpened+=$obj->total_ttc - $paiement - $creditnotes - $deposits; } - + //if credit note is converted but not used if($mode == 'supplier' && $obj->type == FactureFournisseur::TYPE_CREDIT_NOTE && $tmpobject->isCreditNoteUsed())$outstandingOpened-=$tmpobject->getSumFromThisCreditNotesNotUsed(); - - } return array('opened'=>$outstandingOpened, 'total_ht'=>$outstandingTotal, 'total_ttc'=>$outstandingTotalIncTax); // 'opened' is 'incl taxes' } From 4fb36ce84debdad4f5ddd5fd5bd2d3c1d7e8ffb6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 03:22:58 +0200 Subject: [PATCH 68/93] Fix phpcs --- htdocs/core/class/commoninvoice.class.php | 2 +- htdocs/core/class/discount.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 86ef739d63e..2121330a751 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -201,7 +201,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ - function getSumFromThisCreditNotesNotUsed($multicurrency=0) + public function getSumFromThisCreditNotesNotUsed($multicurrency=0) { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index cb2ad44b90c..5ed79b7c2d5 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -636,7 +636,7 @@ class DiscountAbsolute * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ - function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency=0) + public function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency=0) { dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); From 784f5ec0972e3256cce2b885df46111703cd4a8a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 03:23:25 +0200 Subject: [PATCH 69/93] Fix bad name of hidden constant --- htdocs/admin/system/perf.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index fbf6fa3bb14..e17756391f1 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -522,9 +522,9 @@ if ($resql) $nb=$obj->nb; if ($nb > $limitforoptim) { - if (empty($conf->global->THIRDPARTY_DONOTSEARCH_ANYWHERE)) + if (empty($conf->global->COMPANY_DONOTSEARCH_ANYWHERE)) { - print img_picto('', 'warning.png').' '.$langs->trans("YouHaveXObjectUseSearchOptim", $nb, $langs->transnoentitiesnoconv("ThirdParties"), 'THIRDPARTY_DONOTSEARCH_ANYWHERE'); + print img_picto('', 'warning.png').' '.$langs->trans("YouHaveXObjectUseSearchOptim", $nb, $langs->transnoentitiesnoconv("ThirdParties"), 'COMPANY_DONOTSEARCH_ANYWHERE'); } else { From 0ae7be8fe681a6ae57360bad988f68495dbcffd5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 03:34:43 +0200 Subject: [PATCH 70/93] Test sponsor github --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 81813c2bebe..6b651234788 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -2,3 +2,4 @@ open_collective: dolibarr custom: https://wiki.dolibarr.org/index.php/Subscribe +github: [eldy] \ No newline at end of file From 01e2a181b83b64236c0ece0633288f9403304540 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 03:36:47 +0200 Subject: [PATCH 71/93] Fix user not yet enrolled --- .github/FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 6b651234788..186b20a051d 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -2,4 +2,4 @@ open_collective: dolibarr custom: https://wiki.dolibarr.org/index.php/Subscribe -github: [eldy] \ No newline at end of file +# github: [eldy] \ No newline at end of file From 855ebc298f671e92848807af2311718f0c343bbf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 03:39:27 +0200 Subject: [PATCH 72/93] Removed hound (not used) --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 5d4de0af909..f4ccc78e9dc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # DOLIBARR ERP & CRM ![Downloads per day](https://img.shields.io/sourceforge/dw/dolibarr.svg) -[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com) |7|8|9|10|develop| |----------|----------|----------|----------|----------| From 63dcef710eb44f7afc0c6ec3ea2ef07939daa984 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 03:41:02 +0200 Subject: [PATCH 73/93] Fix phpcs --- htdocs/core/class/commoninvoice.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 2121330a751..259014cf691 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -201,7 +201,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ - public function getSumFromThisCreditNotesNotUsed($multicurrency=0) + public function getSumFromThisCreditNotesNotUsed($multicurrency = 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; From 505a06ca3e68110f6e92d533f63567aa29809991 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 03:42:34 +0200 Subject: [PATCH 74/93] Fix phpunit --- test/phpunit/FormAdminTest.php | 2 +- test/phpunit/FormTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/phpunit/FormAdminTest.php b/test/phpunit/FormAdminTest.php index 8532d6ac283..844be2e4f32 100644 --- a/test/phpunit/FormAdminTest.php +++ b/test/phpunit/FormAdminTest.php @@ -119,7 +119,7 @@ class FormAdminTest extends PHPUnit_Framework_TestCase } /** - * testFactureCreate + * testSelectPaperFormat * * @return int */ diff --git a/test/phpunit/FormTest.php b/test/phpunit/FormTest.php index b3025b4c345..69594325b20 100644 --- a/test/phpunit/FormTest.php +++ b/test/phpunit/FormTest.php @@ -58,7 +58,7 @@ class FormTest extends PHPUnit\Framework\TestCase * * @return FactureTest */ - function __construct() + public function __construct() { parent::__construct(); From 0702ef4e0ffc71e74066374b62708355a4b8e3e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Traull=C3=A9?= Date: Tue, 27 Aug 2019 08:43:58 +0200 Subject: [PATCH 75/93] Fix CI (code style) --- htdocs/core/class/commoninvoice.class.php | 2 +- htdocs/core/class/discount.class.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 86ef739d63e..259014cf691 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -201,7 +201,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ - function getSumFromThisCreditNotesNotUsed($multicurrency=0) + public function getSumFromThisCreditNotesNotUsed($multicurrency = 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index cb2ad44b90c..5cf7e8cdb7a 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -636,7 +636,7 @@ class DiscountAbsolute * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ - function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency=0) + public function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency = 0) { dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); @@ -646,7 +646,7 @@ class DiscountAbsolute $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; $sql.= ' WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = '.$invoice->id; } - else if ($invoice->element == 'invoice_supplier') + elseif ($invoice->element == 'invoice_supplier') { $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; From 9ca85b8e19cc23fa5c92d871309f91b9fbb01b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Traull=C3=A9?= <613615+jtraulle@users.noreply.github.com> Date: Tue, 27 Aug 2019 09:30:42 +0200 Subject: [PATCH 76/93] Disabling coding style checks for Pull Requests Because coding style would have been checked by SticklerCI, we can safely skip this in Travis-CI when in Pull Request context. It will increase build speed by about 50%. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1521035578b..7c1552bb2a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -293,12 +293,12 @@ script: echo - | - echo "Checking coding style" + echo "Checking coding style (excluding Pull Requests builds)" # Ensure we catch errors set -e # Exclusions are defined in the ruleset.xml file #phpcs -s -n -p -d memory_limit=-1 --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 . - phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true . + if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi set +e echo From 9fb06b1e7e3071887ce67a55d58657b9263ba0a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 11:42:18 +0200 Subject: [PATCH 77/93] Fix phpcs --- htdocs/core/class/discount.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 5ed79b7c2d5..0f508507491 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -636,7 +636,7 @@ class DiscountAbsolute * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ - public function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency=0) + public function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency = 0) { dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); From c2c9e1d042b8eea785afdfa055d88a65e46ca2f8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 12:15:29 +0200 Subject: [PATCH 78/93] Fix warning --- htdocs/install/inc.php | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index eab86b07136..54a718ef1fc 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -253,27 +253,6 @@ foreach ($handlers as $handler) if (empty($conf->loghandlers[$handler])) $conf->loghandlers[$handler]=$loghandlerinstance; } -// Removed magic_quotes -if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* removed in PHP 5.4 -{ - if (get_magic_quotes_gpc()) - { - // Forcing parameter setting magic_quotes_gpc and cleaning parameters - // (Otherwise he would have for each position, condition - // Reading stripslashes variable according to state get_magic_quotes_gpc). - // Off mode (recommended, you just do $db->escape when an insert / update. - function stripslashes_deep($value) - { - return (is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value)); - } - $_GET = array_map('stripslashes_deep', $_GET); - $_POST = array_map('stripslashes_deep', $_POST); - $_COOKIE = array_map('stripslashes_deep', $_COOKIE); - $_REQUEST = array_map('stripslashes_deep', $_REQUEST); - @set_magic_quotes_runtime(0); - } -} - // Defini objet langs $langs = new Translate('..', $conf); if (GETPOST('lang', 'aZ09')) $langs->setDefaultLang(GETPOST('lang', 'aZ09')); From 36c936357cb15127e1e6e419f2e8f1c95d246d9e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 12:25:24 +0200 Subject: [PATCH 79/93] Add phpunit testDolStringIsGoodIso --- htdocs/core/lib/functions.lib.php | 2 +- test/phpunit/FunctionsLibTest.php | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 625cbbee4b7..30267a57ad5 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5635,7 +5635,7 @@ function dol_string_is_good_iso($s) $ok=1; for($scursor=0;$scursor<$len;$scursor++) { - $ordchar=ord($s{$scursor}); + $ordchar=ord($s[$scursor]); //print $scursor.'-'.$ordchar.'
'; if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) { $ok=0; break; } if ($ordchar > 126 && $ordchar < 160) { $ok=0; break; } diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 5b2b65c9e50..2a7734716eb 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -1260,4 +1260,25 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase return true; } + + /** + * testDolStringIsGoodIso + * + * @return boolean + */ + public function testDolStringIsGoodIso() + { + global $conf, $langs; + + $chaine='This is an ISO string'; + $result = dol_string_is_good_iso($chaine); + $this->assertEquals($result, 1); + + $chaine='This is a not ISO string '.chr(0); + $result = dol_string_is_good_iso($chaine); + $this->assertEquals($result, 0); + + return true; + } + } From 22719b90b6524561424728d2e98df2f0cbd93e1f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 12:31:15 +0200 Subject: [PATCH 80/93] Fix remove warning --- htdocs/core/lib/json.lib.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index 4a8f61915b5..423607fb819 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -119,7 +119,7 @@ function _val($val) */ for ($c = 0; $c < $strlen_var; ++$c) { - $ord_var_c = ord($val{$c}); + $ord_var_c = ord($val[$c]); switch (true) { case $ord_var_c == 0x08: @@ -142,18 +142,18 @@ function _val($val) case $ord_var_c == 0x2F: case $ord_var_c == 0x5C: // double quote, slash, slosh - $ascii .= '\\'.$val{$c}; + $ascii .= '\\'.$val[$c]; break; case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): // characters U-00000000 - U-0000007F (same as ASCII) - $ascii .= $val{$c}; + $ascii .= $val[$c]; break; case (($ord_var_c & 0xE0) == 0xC0): // characters U-00000080 - U-000007FF, mask 110XXXXX // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, ord($val{$c + 1})); + $char = pack('C*', $ord_var_c, ord($val[$c + 1])); $c += 1; $utf16 = utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); @@ -162,7 +162,7 @@ function _val($val) case (($ord_var_c & 0xF0) == 0xE0): // characters U-00000800 - U-0000FFFF, mask 1110XXXX // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2})); + $char = pack('C*', $ord_var_c, ord($val[$c + 1]), ord($val[$c + 2])); $c += 2; $utf16 = utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); @@ -171,7 +171,7 @@ function _val($val) case (($ord_var_c & 0xF8) == 0xF0): // characters U-00010000 - U-001FFFFF, mask 11110XXX // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2}), ord($val{$c + 3})); + $char = pack('C*', $ord_var_c, ord($val[$c + 1]), ord($val[$c + 2]), ord($val[$c + 3])); $c += 3; $utf16 = utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); @@ -180,7 +180,7 @@ function _val($val) case (($ord_var_c & 0xFC) == 0xF8): // characters U-00200000 - U-03FFFFFF, mask 111110XX // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2}), ord($val{$c + 3}), ord($val{$c + 4})); + $char = pack('C*', $ord_var_c, ord($val[$c + 1]), ord($val[$c + 2]), ord($val[$c + 3]), ord($val[$c + 4])); $c += 4; $utf16 = utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); @@ -189,7 +189,7 @@ function _val($val) case (($ord_var_c & 0xFE) == 0xFC): // characters U-04000000 - U-7FFFFFFF, mask 1111110X // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, ord($val{$c + 1}), ord($val{$c + 2}), ord($val{$c + 3}), ord($val{$c + 4}), ord($val{$c + 5})); + $char = pack('C*', $ord_var_c, ord($val[$c + 1]), ord($val[$c + 2]), ord($val[$c + 3]), ord($val[$c + 4]), ord($val[$c + 5])); $c += 5; $utf16 = utf82utf16($char); $ascii .= sprintf('\u%04s', bin2hex($utf16)); From 31e99414b5cbca836b9422992bce416425542e3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 12:34:46 +0200 Subject: [PATCH 81/93] Prepare for php 8 --- test/phpunit/AllTests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index db3dc95e434..37abbc9a2bd 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -75,7 +75,7 @@ class AllTests public static function suite() { - $suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework'); + $suite = new PHPUnit\Framework\TestSuite('PHPUnit Framework'); //require_once dirname(__FILE__).'/CoreTest.php'; //$suite->addTestSuite('CoreTest'); From 9ac1add42589d3c537c4132433493b9f28ddb1db Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 27 Aug 2019 12:46:28 +0200 Subject: [PATCH 82/93] FIX amount or stripe account with currency --- htdocs/societe/paymentmodes.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 4d49fc3792a..e20b76b1349 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -1316,7 +1316,10 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { foreach ($balance->available as $cpt) { - print '
'; + $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); + if (! in_array($cpt->currency, $arrayzerounitcurrency)) $amount = $cpt->amount / 100; + else $amount = $cpt->amount; + print ''; } } @@ -1324,7 +1327,10 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard' { foreach ($balance->pending as $cpt) { - print ''; + $arrayzerounitcurrency=array('BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'); + if (! in_array($cpt->currency, $arrayzerounitcurrency)) $amount = $cpt->amount / 100; + else $amount = $cpt->amount; + print ''; } } print '
'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + if (($massactionbutton || $massaction) && $contextpage != 'poslist') // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { $selected=0; if (in_array($obj->id, $arrayofselected)) $selected=1; From 7b5c9818f7b25b623a68b472f7f79a3083d1898d Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 15:58:33 +0200 Subject: [PATCH 37/93] Fix context display with takepos societe/list.php --- htdocs/societe/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index daff9aec557..8f352a21b28 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -670,7 +670,7 @@ if ($moreforfilter) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -if ($massactionbutton) $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +if ($massactionbutton && $contextpage != 'poslist') $selectedfields.=$form->showCheckAddButtons('checkforselect', 1); if (empty($arrayfields['customerorsupplier']['checked'])) print ''; @@ -1287,7 +1287,7 @@ while ($i < min($num, $limit)) // Action column print ''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + if (($massactionbutton || $massaction) && $contextpage != 'poslist') // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { $selected=0; if (in_array($obj->rowid, $arrayofselected)) $selected=1; From dbcead47e1eaf8c972b0850704eafe7409341cd1 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sat, 24 Aug 2019 16:05:21 +0200 Subject: [PATCH 38/93] Update list.php --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index daff9aec557..ebf03cb2d3d 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -199,7 +199,7 @@ $arrayfields=array( 's.idprof5'=>array('label'=>"ProfId5Short", 'checked'=>$checkedprofid5), 's.idprof6'=>array('label'=>"ProfId6Short", 'checked'=>$checkedprofid6), 's.tva_intra'=>array('label'=>"VATIntraShort", 'checked'=>0), - 'customerorsupplier'=>array('label'=>'Nature', 'checked'=>1), + 'customerorsupplier'=>array('label'=>'Type', 'checked'=>1), 's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'checked'=>$checkprospectlevel), 's.fk_stcomm'=>array('label'=>"StatusProsp", 'checked'=>$checkstcomm), 's2.nom'=>array('label'=>'ParentCompany', 'checked'=>0), From 5d0dbea920d8f794df01f92cf8976498d77bb9a9 Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sat, 24 Aug 2019 16:44:06 +0200 Subject: [PATCH 39/93] Control errors before validate invoice in TakePOS --- htdocs/langs/en_US/cashdesk.lang | 2 ++ htdocs/takepos/invoice.php | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 628de17efcc..856cf1de0d2 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -72,3 +72,5 @@ BasicPhoneLayout=Use basic layout for phones SetupOfTerminalNotComplete=Setup of terminal %s is not complete DirectPayment=Direct payment DirectPaymentButton=Direct cash payment button +InvoiceIsAlreadyValidated=Invoice is already validated +NoLinesToBill=No lines to bill diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 17805a6b060..0176330db0a 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -161,7 +161,17 @@ if ($action == 'valid' && $user->rights->facture->creer) $invoice->update($user); } - if (! empty($conf->stock->enabled) && $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]} != "1") + if ($invoice->statut != Facture::STATUS_DRAFT) + { + dol_syslog("Sale already validated"); + dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); + } + else if (count($invoice->lines)==0) + { + dol_syslog("Sale without lines"); + dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1); + } + else if (! empty($conf->stock->enabled) && $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]} != "1") { $invoice->validate($user, '', $conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]}); } From 07244f002b7c8e37f690fb20201b67106ffda0df Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Sat, 24 Aug 2019 18:11:47 +0200 Subject: [PATCH 40/93] else if to elseif --- htdocs/takepos/invoice.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 0176330db0a..c03ec826d6d 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -166,12 +166,12 @@ if ($action == 'valid' && $user->rights->facture->creer) dol_syslog("Sale already validated"); dol_htmloutput_errors($langs->trans("InvoiceIsAlreadyValidated", "TakePos"), null, 1); } - else if (count($invoice->lines)==0) + elseif (count($invoice->lines)==0) { dol_syslog("Sale without lines"); dol_htmloutput_errors($langs->trans("NoLinesToBill", "TakePos"), null, 1); } - else if (! empty($conf->stock->enabled) && $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]} != "1") + elseif (! empty($conf->stock->enabled) && $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]} != "1") { $invoice->validate($user, '', $conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]}); } From 60c3cefc53040eaaf3f311a73b4bc5db03cf7aaa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Aug 2019 16:41:59 +0200 Subject: [PATCH 41/93] FIX Api of documents work with value 'thirdparty' --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 1012b825254..c6a5cb14426 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2445,7 +2445,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } // Wrapping for third parties - elseif (($modulepart == 'company' || $modulepart == 'societe') && !empty($conf->societe->dir_output)) + elseif (($modulepart == 'company' || $modulepart == 'societe' || $modulepart == 'thirdparty') && !empty($conf->societe->dir_output)) { if (empty($entity) || empty($conf->societe->multidir_output[$entity])) return array('accessallowed'=>0, 'error'=>'Value entity must be provided'); if ($fuser->rights->societe->{$lire} || preg_match('/^specimen/i', $original_file)) From a822a34a51e0de54a168f3b30e21ebef7f8ecbda Mon Sep 17 00:00:00 2001 From: Frans Bosman Date: Sun, 25 Aug 2019 19:54:42 +0200 Subject: [PATCH 42/93] Update card.php --- htdocs/commande/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index c603eba168c..3f5449d4f18 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1765,7 +1765,6 @@ if ($action == 'create' && $usercancreate) $object->array_options = array_merge($object->array_options, $soc->array_options); } print $object->showOptionals($extrafields, 'edit'); - } // Template to use by default From 23311abd6a1471f74397877db991c4a726d82adc Mon Sep 17 00:00:00 2001 From: Frans Bosman Date: Sun, 25 Aug 2019 19:57:49 +0200 Subject: [PATCH 43/93] Update card.php --- htdocs/commande/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 3f5449d4f18..dea2d0c0ed8 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1758,12 +1758,14 @@ if ($action == 'create' && $usercancreate) $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); print $hookmanager->resPrint; if (empty($reshook)) { + if (! empty($conf->global->THIRDPARTY_PROPAGATE_EXTRAFIELDS_TO_ORDER)) // copy from thirdparty $tpExtrafields = new Extrafields($db); $tpExtrafieldLabels = $tpExtrafields->fetch_name_optionals_label($soc->table_element); if ($soc->fetch_optionals() > 0) { $object->array_options = array_merge($object->array_options, $soc->array_options); } + }; print $object->showOptionals($extrafields, 'edit'); } From b00020c4ea2bc948feff82b8e491637337798779 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 26 Aug 2019 12:10:19 +0200 Subject: [PATCH 44/93] FIX #11746 Unable to modify amount of insurance of a loan --- htdocs/loan/card.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index e826e86ea57..c1a4d022fda 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -179,11 +179,12 @@ if (empty($reshook)) } else { - $object->datestart = $datestart; - $object->dateend = $dateend; - $object->capital = $capital; - $object->nbterm = GETPOST("nbterm", 'int'); - $object->rate = price2num(GETPOST("rate", 'alpha')); + $object->datestart = $datestart; + $object->dateend = $dateend; + $object->capital = $capital; + $object->nbterm = GETPOST("nbterm", 'int'); + $object->rate = price2num(GETPOST("rate", 'alpha')); + $object->insurance_amount = price2num(GETPOST('insurance_amount', 'int')); $accountancy_account_capital = GETPOST('accountancy_account_capital'); $accountancy_account_insurance = GETPOST('accountancy_account_insurance'); From 20e2180de41fe3fe97292c39a5e089e62d084d9e Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 26 Aug 2019 13:54:46 +0200 Subject: [PATCH 45/93] Fix travis --- htdocs/stripe/class/stripe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 5dda24a763e..cf683671c5d 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -92,7 +92,7 @@ class Stripe extends CommonObject if ($fk_soc > 0) { $sql.= " AND fk_soc = ".$fk_soc; } - else { + else { $sql.= " AND fk_soc IS NULL"; } $sql.= " AND fk_user IS NULL AND fk_adherent IS NULL"; From e5f2b0c623cb6b2e806c8315ae9f03106be1253d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Traull=C3=A9?= <613615+jtraulle@users.noreply.github.com> Date: Mon, 26 Aug 2019 14:10:28 +0200 Subject: [PATCH 46/93] Add project funding links --- .github/FUNDING.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000000..81813c2bebe --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,4 @@ +# These are supported funding model platforms + +open_collective: dolibarr +custom: https://wiki.dolibarr.org/index.php/Subscribe From af23f344ce2f3ad9fa37abde6949831e370cc22e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Traull=C3=A9?= <613615+jtraulle@users.noreply.github.com> Date: Mon, 26 Aug 2019 14:23:14 +0200 Subject: [PATCH 47/93] Use distinct Github issue templates for Bugs and Feature requests This allow to have distinct placeholder texts and auto-assign labels (Bug or Feature request). --- .github/ISSUE_TEMPLATE/bug_report.md | 35 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 27 +++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000000..432f30f2332 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,35 @@ +--- +name: Bug report +about: Create a report to help us fix something that is broken +title: '' +labels: Bug +assignees: '' + +--- + +# Instructions +*This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.* +*Please:* +- *replace the bracket enclosed texts with meaningful information* +- *remove any unused sub-section* + + +# Bug +[*Short description*] + +## Environment +- **Version**: [*Affected Dolibarr version(s)*] +- **OS**: [*Server OS type and version*] +- **Web server**: [*Webserver type and version*] +- **PHP**: [*PHP version*] +- **Database**: [*Database type and version*] +- **URL(s)**: [*Affected URL(s)*] + +## Expected and actual behavior +[*Verbose description*] + +## Steps to reproduce the behavior +[*Verbose description*] + +## [Attached files](https://help.github.com/articles/issue-attachments) (Screenshots, screencasts, dolibarr.log, debugging informations…) +[*Files*] diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000000..32e2deff2c1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,27 @@ +--- +name: Feature request +about: Suggest a new idea for this project +title: '' +labels: Feature request +assignees: '' + +--- + +# Instructions +*This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.* +*Please:* +- *replace the bracket enclosed texts with meaningful information* +- *remove any unused sub-section* + + +# Feature Request +[*Short description*] + +## Use case +[*Verbose description*] + +## Suggested implementation +[*Verbose description*] + +## Suggested steps +[*List of tasks to achieve goal*] From 92ea663266ef46863ee88fc219a7cdaa183e423e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Traull=C3=A9?= <613615+jtraulle@users.noreply.github.com> Date: Mon, 26 Aug 2019 14:27:43 +0200 Subject: [PATCH 48/93] Delete old issue template --- .github/ISSUE_TEMPLATE.md | 41 --------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md deleted file mode 100644 index a105eed20ea..00000000000 --- a/.github/ISSUE_TEMPLATE.md +++ /dev/null @@ -1,41 +0,0 @@ -# Instructions -*This is a template to help you report good issues. You may use [Github Markdown](https://help.github.com/articles/getting-started-with-writing-and-formatting-on-github/) syntax to format your issue report.* -*Please:* -- *only keep the "Bug" or "Feature Request" section* -- *replace the bracket enclosed texts with meaningful informations* -- *remove any unused sub-section* - - -# Bug -[*Short description*] - -## Environment -- **Version**: [*Affected Dolibarr version(s)*] -- **OS**: [*Server OS type and version*] -- **Web server**: [*Webserver type and version*] -- **PHP**: [*PHP version*] -- **Database**: [*Database type and version*] -- **URL(s)**: [*Affected URL(s)*] - -## Expected and actual behavior -[*Verbose description*] - -## Steps to reproduce the behavior -[*Verbose description*] - -## [Attached files](https://help.github.com/articles/issue-attachments) (Screenshots, screencasts, dolibarr.log, debugging informations…) -[*Files*] - - - -# Feature Request -[*Short description*] - -## Use case -[*Verbose description*] - -## Suggested implementation -[*Verbose description*] - -## Suggested steps -[*List of tasks to achieve goal*] From bc7250dc92e0a00a562dfba2ffe29ac780d4fac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Traull=C3=A9?= <613615+jtraulle@users.noreply.github.com> Date: Mon, 26 Aug 2019 15:17:19 +0200 Subject: [PATCH 49/93] Fix CI --- htdocs/stripe/class/stripe.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index c6df1206d0f..cf683671c5d 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -78,9 +78,10 @@ class Stripe extends CommonObject * Return main company OAuth Connect stripe account * * @param string $mode 'StripeTest' or 'StripeLive' + * @param int $fk_soc Id of thirdparty * @return string Stripe account 'acc_....' or '' if no OAuth token found */ - public function getStripeAccount($mode = 'StripeTest') + public function getStripeAccount($mode = 'StripeTest', $fk_soc = 0) { global $conf; @@ -88,6 +89,13 @@ class Stripe extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."oauth_token"; $sql.= " WHERE entity = ".$conf->entity; $sql.= " AND service = '".$mode."'"; + if ($fk_soc > 0) { + $sql.= " AND fk_soc = ".$fk_soc; + } + else { + $sql.= " AND fk_soc IS NULL"; + } + $sql.= " AND fk_user IS NULL AND fk_adherent IS NULL"; dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $result = $this->db->query($sql); From bc14f3979d63fe156661bbabc51b06ce9bf0378d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Traull=C3=A9?= <613615+jtraulle@users.noreply.github.com> Date: Mon, 26 Aug 2019 15:19:51 +0200 Subject: [PATCH 50/93] Fix CI --- htdocs/stripe/class/stripe.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index c6df1206d0f..cf683671c5d 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -78,9 +78,10 @@ class Stripe extends CommonObject * Return main company OAuth Connect stripe account * * @param string $mode 'StripeTest' or 'StripeLive' + * @param int $fk_soc Id of thirdparty * @return string Stripe account 'acc_....' or '' if no OAuth token found */ - public function getStripeAccount($mode = 'StripeTest') + public function getStripeAccount($mode = 'StripeTest', $fk_soc = 0) { global $conf; @@ -88,6 +89,13 @@ class Stripe extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."oauth_token"; $sql.= " WHERE entity = ".$conf->entity; $sql.= " AND service = '".$mode."'"; + if ($fk_soc > 0) { + $sql.= " AND fk_soc = ".$fk_soc; + } + else { + $sql.= " AND fk_soc IS NULL"; + } + $sql.= " AND fk_user IS NULL AND fk_adherent IS NULL"; dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $result = $this->db->query($sql); From 76691925a4796474dc8d60b36b143c01e9eb8f6c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 26 Aug 2019 15:35:20 +0200 Subject: [PATCH 51/93] FIX Missing div for buttons in tax, loan, various payment modules --- htdocs/compta/bank/various_payment/card.php | 6 +++--- htdocs/compta/salaries/card.php | 6 +++--- htdocs/compta/sociales/card.php | 12 ++++++------ htdocs/compta/tva/card.php | 6 +++--- htdocs/loan/card.php | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 67f1e2909fc..aac8f603054 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -544,16 +544,16 @@ if ($id) { if (! empty($user->rights->banque->modifier)) { - print ''.$langs->trans("Delete").''; + print ''; } else { - print ''.$langs->trans("Delete").''; + print ''; } } else { - print ''.$langs->trans("Delete").''; + print ''; } print ""; diff --git a/htdocs/compta/salaries/card.php b/htdocs/compta/salaries/card.php index c19b18bc0f0..392b90b7bb6 100644 --- a/htdocs/compta/salaries/card.php +++ b/htdocs/compta/salaries/card.php @@ -473,16 +473,16 @@ if ($id) { if (! empty($user->rights->salaries->delete)) { - print ''.$langs->trans("Delete").''; + print ''; } else { - print ''.$langs->trans("Delete").''; + print ''; } } else { - print ''.$langs->trans("Delete").''; + print ''; } print ""; } diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 0318efb7e1a..9e68e6e79a3 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -710,37 +710,37 @@ if ($id > 0) // Reopen if ($object->paye && $user->rights->tax->charges->creer) { - print "id&action=reopen\">".$langs->trans("ReOpen").""; + print ""; } // Edit if ($object->paye == 0 && $user->rights->tax->charges->creer) { - print "id&action=edit\">".$langs->trans("Modify").""; + print ""; } // Emit payment if ($object->paye == 0 && ((price2num($object->amount) < 0 && price2num($resteapayer, 'MT') < 0) || (price2num($object->amount) > 0 && price2num($resteapayer, 'MT') > 0)) && $user->rights->tax->charges->creer) { - print "id&action=create\">".$langs->trans("DoPayment").""; + print ""; } // Classify 'paid' if ($object->paye == 0 && round($resteapayer) <=0 && $user->rights->tax->charges->creer) { - print "id&action=paid\">".$langs->trans("ClassifyPaid").""; + print ""; } // Clone if ($user->rights->tax->charges->creer) { - print "id&action=clone\">".$langs->trans("ToClone").""; + print ""; } // Delete if ($user->rights->tax->charges->supprimer) { - print "id&action=delete\">".$langs->trans("Delete").""; + print ""; } print ""; diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index be738b374cf..759ed75df5e 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -385,16 +385,16 @@ if ($id) { if (! empty($user->rights->tax->charges->supprimer)) { - print ''.$langs->trans("Delete").''; + print ''; } else { - print ''.$langs->trans("Delete").''; + print ''; } } else { - print ''.$langs->trans("Delete").''; + print ''; } print ""; } diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index e826e86ea57..f4c624e0e96 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -793,25 +793,25 @@ if ($id > 0) { // print ''.$langs->trans('CreateCalcSchedule').''; - print ''.$langs->trans("Modify").''; + print ''; } // Emit payment if ($object->paid == 0 && ((price2num($object->capital) > 0 && round($staytopay) < 0) || (price2num($object->capital) > 0 && round($staytopay) > 0)) && $user->rights->loan->write) { - print ''.$langs->trans("DoPayment").''; + print ''; } // Classify 'paid' if ($object->paid == 0 && round($staytopay) <=0 && $user->rights->loan->write) { - print ''.$langs->trans("ClassifyPaid").''; + print ''; } // Delete if ($object->paid == 0 && $user->rights->loan->delete) { - print ''.$langs->trans("Delete").''; + print ''; } print ""; From 7ebd79a45f796068c3e37e8ab0d1b9b33ea21964 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Aug 2019 16:02:24 +0200 Subject: [PATCH 52/93] Update list.php --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index ebf03cb2d3d..a7cdc68f34a 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -199,7 +199,7 @@ $arrayfields=array( 's.idprof5'=>array('label'=>"ProfId5Short", 'checked'=>$checkedprofid5), 's.idprof6'=>array('label'=>"ProfId6Short", 'checked'=>$checkedprofid6), 's.tva_intra'=>array('label'=>"VATIntraShort", 'checked'=>0), - 'customerorsupplier'=>array('label'=>'Type', 'checked'=>1), + 'customerorsupplier'=>array('label'=>'NatureOfThirdParty', 'checked'=>1), 's.fk_prospectlevel'=>array('label'=>"ProspectLevelShort", 'checked'=>$checkprospectlevel), 's.fk_stcomm'=>array('label'=>"StatusProsp", 'checked'=>$checkstcomm), 's2.nom'=>array('label'=>'ParentCompany', 'checked'=>0), From 0c8640bfd9c52e2fc1a22641f9327504a1cf3d12 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Aug 2019 16:09:20 +0200 Subject: [PATCH 53/93] FIX #11752 --- htdocs/core/tpl/contacts.tpl.php | 2 +- htdocs/langs/en_US/companies.lang | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 3830e2bc31a..14534b3472e 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -69,7 +69,7 @@ $userstatic=new User($db); if ($permission) { ?>
-
trans("Nature"); ?>
+
trans("NatureOfContact"); ?>
trans("ThirdParty"); ?>
trans("Users").'/'.$langs->trans("Contacts"); ?>
trans("ContactType"); ?>
diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 616b565496a..dccd53c597a 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -54,6 +54,7 @@ Firstname=First name PostOrFunction=Job position UserTitle=Title NatureOfThirdParty=Nature of Third party +NatureOfContact=Nature of Contact Address=Address State=State/Province StateShort=State From d08ed9fbcf2f2c50b3d59269bf6745ded98f6cfd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Aug 2019 16:19:39 +0200 Subject: [PATCH 54/93] FIX column jabberid missing --- htdocs/contact/list.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index fa26c5ed30b..b0db8b0affb 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -165,8 +165,8 @@ $arrayfields=array( 'p.fax'=>array('label'=>"Fax", 'checked'=>0), 'p.email'=>array('label'=>"EMail", 'checked'=>1), 'p.no_email'=>array('label'=>"No_Email", 'checked'=>0, 'enabled'=>(! empty($conf->mailing->enabled))), - 'p.jabberid'=>array('label'=>"Jabber", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.skype'=>array('label'=>"Skype", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), + 'p.jabberid'=>array('label'=>"Jabber", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.twitter'=>array('label'=>"Twitter", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.facebook'=>array('label'=>"Facebook", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), 'p.linkedin'=>array('label'=>"LinkedIn", 'checked'=>1, 'enabled'=>(! empty($conf->socialnetworks->enabled))), @@ -427,7 +427,7 @@ if ($search_societe != '') $param.='&search_societe='.urlencode($search_soci if ($search_zip != '') $param.='&search_zip='.urlencode($search_zip); if ($search_town != '') $param.='&search_town='.urlencode($search_town); if ($search_country != '') $param.= "&search_country=".urlencode($search_country); -if ($search_job != '') $param.='&search_job='.urlencode($search_job); +if ($search_poste != '') $param.='&search_poste='.urlencode($search_poste); if ($search_phone_pro != '') $param.='&search_phone_pro='.urlencode($search_phone_pro); if ($search_phone_perso != '') $param.='&search_phone_perso='.urlencode($search_phone_perso); if ($search_phone_mobile != '') $param.='&search_phone_mobile='.urlencode($search_phone_mobile); @@ -629,6 +629,12 @@ if (! empty($arrayfields['p.skype']['checked'])) print ''; print '
'; + print ''; + print ''; @@ -720,6 +726,7 @@ if (! empty($arrayfields['p.fax']['checked'])) print_liste_field if (! empty($arrayfields['p.email']['checked'])) print_liste_field_titre($arrayfields['p.email']['label'], $_SERVER["PHP_SELF"], "p.email", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.no_email']['checked'])) print_liste_field_titre($arrayfields['p.no_email']['label'], $_SERVER["PHP_SELF"], "p.no_email", $begin, $param, '', $sortfield, $sortorder, 'center '); if (! empty($arrayfields['p.skype']['checked'])) print_liste_field_titre($arrayfields['p.skype']['label'], $_SERVER["PHP_SELF"], "p.skype", $begin, $param, '', $sortfield, $sortorder); +if (! empty($arrayfields['p.jabberid']['checked'])) print_liste_field_titre($arrayfields['p.jabberid']['label'], $_SERVER["PHP_SELF"], "p.jabberid", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.twitter']['checked'])) print_liste_field_titre($arrayfields['p.twitter']['label'], $_SERVER["PHP_SELF"], "p.twitter", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.facebook']['checked'])) print_liste_field_titre($arrayfields['p.facebook']['label'], $_SERVER["PHP_SELF"], "p.facebook", $begin, $param, '', $sortfield, $sortorder); if (! empty($arrayfields['p.linkedin']['checked'])) print_liste_field_titre($arrayfields['p.linkedin']['label'], $_SERVER["PHP_SELF"], "p.linkedin", $begin, $param, '', $sortfield, $sortorder); From 6771a2e1f9e5ec38b65088cbb95ff78ad1dde99f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Aug 2019 16:27:00 +0200 Subject: [PATCH 55/93] Update invoice.php --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 1e11161e8a1..a6ff3be5b06 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -511,7 +511,7 @@ print '
'.$sectionwithinvoicelink; print '
' . $langs->trans('ReductionShort') . '' . $langs->trans('Qty') . '' . $langs->trans('Total') . '' . $langs->trans('TotalTTCShort') . '
' . $entrepotstatic->getNomUrl(1) . '
' . $warehouse->getNomUrl(1) . '
'.$langs->trans("Available").''.price($cpt->amount, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).' '.$langs->trans("Currency".strtoupper($cpt->currency)).'
'.$langs->trans("Available").''.price(amount, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).' '.$langs->trans("Currency".strtoupper($cpt->currency)).'
'.$langs->trans("Pending").''.price($cpt->amount, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).' '.$langs->trans("Currency".strtoupper($cpt->currency)).'
'.$langs->trans("Pending").''.price($amount, 0, '', 1, - 1, - 1, strtoupper($cpt->currency)).' '.$langs->trans("Currency".strtoupper($cpt->currency)).'
'; From 69507118d149d95eade7f5366fee63f64b1ff512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Traull=C3=A9?= <613615+jtraulle@users.noreply.github.com> Date: Tue, 27 Aug 2019 12:58:28 +0200 Subject: [PATCH 83/93] Fix Minimum PHP vers. requirement in Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f4ccc78e9dc..8100cabddbe 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Multi-company by adding of an external module. - Very user friendly and easy to use. - Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one) -- Works with PHP 5.3+ and MariaDB 5.0.3+, MySQL 5.0.3+ or PostgreSQL 8.1.4+ (See requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequisite)) +- Works with PHP 5.5+ and MariaDB 5.0.3+, MySQL 5.0.3+ or PostgreSQL 8.1.4+ (See requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequisite)) - Compatible with all Cloud solutions that match MySQL, PHP or PostgreSQL prerequisites. - APIs. - An easy to understand, maintain and develop code (PHP with no heavy framework; trigger and hook architecture) From b0905c90cbca648a225f83d10e89aa5238d10d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Traull=C3=A9?= <613615+jtraulle@users.noreply.github.com> Date: Tue, 27 Aug 2019 12:58:28 +0200 Subject: [PATCH 84/93] Fix Minimum PHP vers. requirement in Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a59e3e8d8f3..cc18e1c0d12 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Multi-company by adding of an external module. - Very user friendly and easy to use. - Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one) -- Works with PHP 5.3+ and MariaDB 5.0.3+, MySQL 5.0.3+ or PostgreSQL 8.1.4+ (See requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequisite)) +- Works with PHP 5.5+ and MariaDB 5.0.3+, MySQL 5.0.3+ or PostgreSQL 8.1.4+ (See requirements on the [Wiki](https://wiki.dolibarr.org/index.php/Prerequisite)) - Compatible with all Cloud solutions that match MySQL, PHP or PostgreSQL prerequisites. - APIs. - An easy to understand, maintain and develop code (PHP with no heavy framework; trigger and hook architecture) From 1b64c89c2a195b687a2ac3bd7c016cef994ba6bc Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 27 Aug 2019 13:32:55 +0200 Subject: [PATCH 85/93] Fix tab and lang --- htdocs/takepos/invoice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 60f942caccf..7a8aa91afda 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -719,7 +719,7 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep print '
'.$langs->trans("Type").': '.$adh->type; if ($adh->datefin) { - print dol_print_date($adh->datefin, 'day'); + print '
'.$langs->trans("SubscriptionEndDate").': '.dol_print_date($adh->datefin, 'day'); if ($adh->hasDelay()) { print " ".img_warning($langs->trans("Late")); } From 3eb32360cea4f967ea74ed25c7674a6acccc6985 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 14:10:23 +0200 Subject: [PATCH 86/93] Fix escape --- htdocs/commande/class/commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index de93ff778c4..02ea14142fc 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -365,7 +365,7 @@ class Commande extends CommonOrder // Validate $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; - $sql.= " SET ref = '".$num."',"; + $sql.= " SET ref = '".$this->db->escape($num)."',"; $sql.= " fk_statut = ".self::STATUS_VALIDATED.","; $sql.= " date_valid='".$this->db->idate($now)."',"; $sql.= " fk_user_valid = ".$user->id; From 4bd806ea65b24ddda8cf8bee9a2a571e014cc567 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 27 Jul 2019 18:13:44 +0200 Subject: [PATCH 87/93] Move $selectedlines to parameter --- htdocs/commande/card.php | 2 +- htdocs/core/class/commonobject.class.php | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index f398fe49713..28dbb52a965 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1880,7 +1880,7 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; - $objectsrc->printOriginLinesList(); + $objectsrc->printOriginLinesList('', $selectedLines); print '
'; } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 43ba2499680..8881cffe659 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4142,9 +4142,10 @@ abstract class CommonObject * But for the moment we don't know if it's possible, so we keep the method available on overloaded objects. * * @param string $restrictlist ''=All lines, 'services'=Restrict to services only + * @param array $selectedLines Array of lines id for selected lines * @return void */ - public function printOriginLinesList($restrictlist = '') + public function printOriginLinesList($restrictlist = '', $selectedLines = array()) { global $langs, $hookmanager, $conf, $form; @@ -4180,7 +4181,7 @@ abstract class CommonObject } else { - $this->printOriginLine($line, $var, $restrictlist); + $this->printOriginLine($line, $var, $restrictlist, '/core/tpl', $selectedLines); } $i++; @@ -4198,11 +4199,12 @@ abstract class CommonObject * @param string $var Var * @param string $restrictlist ''=All lines, 'services'=Restrict to services only (strike line if not) * @param string $defaulttpldir Directory where to find the template + * @param array $selectedLines Array of lines id for selected lines * @return void */ - public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir = '/core/tpl') + public function printOriginLine($line, $var, $restrictlist = '', $defaulttpldir = '/core/tpl', $selectedLines = array()) { - global $langs, $conf, $selectedLines; + global $langs, $conf; //var_dump($line); if (!empty($line->date_start)) @@ -5030,7 +5032,7 @@ abstract class CommonObject //dol_syslog("attributeLabel=".$attributeLabel, LOG_DEBUG); //dol_syslog("attributeType=".$attributeType, LOG_DEBUG); - + if (!empty($attrfieldcomputed)) { if (!empty($conf->global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) From f9094cfc446cff82beac3b5bfdb03af4f321ddf3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 15:00:41 +0200 Subject: [PATCH 88/93] Update card.php --- htdocs/commande/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 18d851fb628..031d2c95235 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -240,7 +240,7 @@ if (empty($reshook)) { $datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); $datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - $selectedLines = GETPOST('toselect'); + $selectedLines = GETPOST('toselect', 'array'); if ($datecommande == '') { setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), null, 'errors'); From 478b1fea2546694f8ba106201dcb148401413be0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 15:06:50 +0200 Subject: [PATCH 89/93] FIX #11711 --- htdocs/adherents/class/adherent_type.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 3a39632d783..0d3980318a4 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -121,10 +121,12 @@ class AdherentType extends CommonObject $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type ("; - $sql.= "libelle"; + $sql.= " morphy"; + $sql.= ", libelle"; $sql.= ", entity"; $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->label)."'"; + $sql.= "'".$this->db->escape($this->morphy)."'"; + $sql.= ", '".$this->db->escape($this->label)."'"; $sql.= ", ".$conf->entity; $sql.= ")"; From 7165389f6c091aa1a4d57a8a592ccd3117241561 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 15:39:35 +0200 Subject: [PATCH 90/93] Add log Add protection to avoid change on a non draft invoice. --- htdocs/takepos/invoice.php | 11 ++++++++--- htdocs/takepos/takepos.php | 7 ++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index a44771da63a..a1b51e6b50b 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -138,7 +138,9 @@ if ($action == 'valid' && $user->rights->facture->creer) if (! empty($conf->stock->enabled) && $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]} != "1") { - $invoice->validate($user, '', $conf->global->{'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]}); + $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; + dol_syslog("Validate invoice with stock change into warehouse id ".$constantforkey); + $invoice->validate($user, '', $conf->global->$cosntantforkey); } else { @@ -259,10 +261,13 @@ if ($action == "deleteline") { } if ($action == "delete") { - if ($placeid > 0) { //If invoice exists + // $placeid is the invoice id (it differs from place) and is defined if the place is set and the ref of invoice is '(PROV-POS'.$_SESSION["takeposterminal"].'-'.$place.')', so the fetch at begining of page works. + if ($placeid > 0) { $result = $invoice->fetch($placeid); - if ($result > 0) + + if ($result > 0 && $invoice->statut == Facture::STATUS_DRAFT) { + // We delete the lines $sql = "DELETE FROM " . MAIN_DB_PREFIX . "facturedet where fk_facture='".$placeid."'"; $resql = $db->query($sql); diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index dba42a105ae..b7061c0e135 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -391,8 +391,9 @@ function Refresh() { } function New() { - console.log("New"); - var r = confirm('trans("ConfirmDeletionOfThisPOSSale"); ?>'); + // If we go here,it means $conf->global->TAKEPOS_BAR_RESTAURANT is not defined + console.log("New with place = , js place="+place); + var r = confirm(' 0 ? $langs->trans("ConfirmDeletionOfThisPOSSale") : $langs->trans("ConfirmDiscardOfThisPOSSale")); ?>'); if (r == true) { $("#poslines").load("invoice.php?action=delete&place="+place, function() { //$('#poslines').scrollTop($('#poslines')[0].scrollHeight); @@ -651,7 +652,7 @@ if (empty($conf->global->TAKEPOS_BAR_RESTAURANT)) else { // BAR RESTAURANT specific menu - $menus[$r++]=array('title'=>'
'.$langs->trans("Floors").'
', 'action'=>'Floors();'); + $menus[$r++]=array('title'=>'
'.$langs->trans("Place").'
', 'action'=>'Floors();'); } $menus[$r++]=array('title'=>'
'.$langs->trans("Customer").'
', 'action'=>'Customer();'); From a2b1d96d427016496605137aef116c3b9c3670e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 15:42:35 +0200 Subject: [PATCH 91/93] Fix protection in cleaning invoice with transaction. Delete also extrafield lines. --- htdocs/takepos/invoice.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index a1b51e6b50b..9616085f6fb 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -267,9 +267,22 @@ if ($action == "delete") { if ($result > 0 && $invoice->statut == Facture::STATUS_DRAFT) { + $db->begin(); + // We delete the lines - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "facturedet where fk_facture='".$placeid."'"; - $resql = $db->query($sql); + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "facturedet_extrafields where fk_object = ".$placeid; + $resql1 = $db->query($sql); + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "facturedet where fk_facture = ".$placeid; + $resql2 = $db->query($sql); + + if ($resql1 && $resql2) + { + $db->commit(); + } + else + { + $db->rollback(); + } $invoice->fetch($placeid); } From d4d3e28437d05a8fab8c7df46211aad57b2885fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 15:53:03 +0200 Subject: [PATCH 92/93] It is diffcult to understand how stock decrease is done so we show the ref of stock. --- htdocs/takepos/invoice.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 9616085f6fb..1682db54468 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -136,11 +136,12 @@ if ($action == 'valid' && $user->rights->facture->creer) $invoice->update($user); } - if (! empty($conf->stock->enabled) && $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]} != "1") + $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; + if (! empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") { $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; dol_syslog("Validate invoice with stock change into warehouse id ".$constantforkey); - $invoice->validate($user, '', $conf->global->$cosntantforkey); + $invoice->validate($user, '', $conf->global->$constantforkey); } else { @@ -593,8 +594,17 @@ if ($invoice->socid != $conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takep $soc = new Societe($db); if ($invoice->socid > 0) $soc->fetch($invoice->socid); else $soc->fetch($conf->global->{'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]}); - print '

'; + print '

'; print $langs->trans("Customer").': '.$soc->name; + + $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; + if (! empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") + { + $constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"]; + $warehouse = new Entrepot($db); + $warehouse->fetch($conf->global->$constantforkey); + print '
'.$langs->trans("Warehouse").': '.$warehouse->ref; + } print '

'; } From 1ac9affd82083db74ce54ef50f828e3a4bd4ae1b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 27 Aug 2019 15:54:44 +0200 Subject: [PATCH 93/93] Trans --- htdocs/langs/en_US/cashdesk.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 749c749293c..d65046d3277 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -62,6 +62,7 @@ TicketVatGrouped=Group VAT by rate in tickets AutoPrintTickets=Automatically print tickets EnableBarOrRestaurantFeatures=Enable features for Bar or Restaurant ConfirmDeletionOfThisPOSSale=Do your confirm the deletion of this current sale ? +ConfirmDiscardOfThisPOSSale=Do you want to discard this current sale ? History=History ValidateAndClose=Validate and close Terminal=Terminal