From c77d1206d33d1141e5998c166a36b547c9d4850c Mon Sep 17 00:00:00 2001 From: Giovanni Vella Date: Fri, 22 Oct 2021 14:45:28 +0200 Subject: [PATCH 001/174] NEW: receipt beep alternative and current date/time I have added the alternative command for the beep (when that does not work) and the possibility to print the current date and time on the receipt. --- htdocs/core/class/dolreceiptprinter.class.php | 10 ++++++++++ htdocs/langs/en_US/receiptprinter.lang | 2 ++ htdocs/langs/it_IT/receiptprinter.lang | 2 ++ 3 files changed, 14 insertions(+) diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 2062f1b351c..cb49f53e0c5 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -42,6 +42,7 @@ * {dol_cut_paper_partial} Cut ticket partially * {dol_open_drawer} Open cash drawer * {dol_beep} Activate buzzer + * {dol_beep_alternative} Activate buzzer (alternative mode) * {dol_print_barcode} Print barcode * {dol_print_logo} Print logo stored on printer. Example : 32|32 * {dol_print_logo_old} Print logo stored on printer. Must be followed by logo code. For old printers. @@ -52,6 +53,7 @@ * {dol_print_order_lines} Print order lines for Printer * {dol_print_object_lines_with_notes} Print object lines with notes * {dol_print_payment} Print payment method + * {dol_print_curr_date} Print the current date/time. Must be followed by format string. * * Code which can be placed everywhere * Replaced by date AAAA-MM-DD @@ -177,6 +179,7 @@ class dolReceiptPrinter extends Printer 'dol_cut_paper_partial' => 'DOL_CUT_PAPER_PARTIAL', 'dol_open_drawer' => 'DOL_OPEN_DRAWER', 'dol_beep' => 'DOL_BEEP', + 'dol_beep_alternative' => 'DOL_BEEP_ALTERNATIVE', 'dol_print_text' => 'DOL_PRINT_TEXT', 'dol_print_barcode' => 'DOL_PRINT_BARCODE', 'dol_value_date' => 'DateInvoice', @@ -187,6 +190,7 @@ class dolReceiptPrinter extends Printer 'dol_value_day' => 'DOL_VALUE_DAY', 'dol_value_day_letters' => 'DOL_VALUE_DAY', 'dol_print_payment' => 'DOL_PRINT_PAYMENT', + 'dol_print_curr_date' => 'DOL_PRINT_CURR_DATE', 'dol_print_logo' => 'DOL_PRINT_LOGO', 'dol_print_logo_old' => 'DOL_PRINT_LOGO_OLD', 'dol_value_object_id' => 'InvoiceID', @@ -707,6 +711,9 @@ class dolReceiptPrinter extends Printer $spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0); $this->printer->text($title.$spaces.str_pad(price($object->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); break; + case 'DOL_PRINT_CURR_DATE': + $this->printer->text(date($vals[$tplline]['value'])."\n"); + break; case 'DOL_LINE_FEED': $this->printer->feed(); break; @@ -789,6 +796,9 @@ class dolReceiptPrinter extends Printer case 'DOL_BEEP': $this->printer->getPrintConnector() -> write("\x1e"); break; + case 'DOL_BEEP_ALTERNATIVE': //if DOL_BEEP not works + $this->printer->getPrintConnector() -> write(Printer::ESC . "B" . chr(4) . chr(1)); + break; case 'DOL_PRINT_ORDER_LINES': foreach ($object->lines as $line) { if ($line->special_code == $this->orderprinter) { diff --git a/htdocs/langs/en_US/receiptprinter.lang b/htdocs/langs/en_US/receiptprinter.lang index 284c4fa61fa..b505ee63cf5 100644 --- a/htdocs/langs/en_US/receiptprinter.lang +++ b/htdocs/langs/en_US/receiptprinter.lang @@ -55,6 +55,8 @@ DOL_DEFAULT_HEIGHT_WIDTH=Default height and width size DOL_UNDERLINE=Enable underline DOL_UNDERLINE_DISABLED=Disable underline DOL_BEEP=Beep sound +DOL_BEEP_ALTERNATIVE=Beep sound (alternative mode) +DOL_PRINT_CURR_DATE=Print current date/time DOL_PRINT_TEXT=Print text DateInvoiceWithTime=Invoice date and time YearInvoice=Invoice year diff --git a/htdocs/langs/it_IT/receiptprinter.lang b/htdocs/langs/it_IT/receiptprinter.lang index 49621049ddf..566f762bbbd 100644 --- a/htdocs/langs/it_IT/receiptprinter.lang +++ b/htdocs/langs/it_IT/receiptprinter.lang @@ -55,6 +55,8 @@ DOL_DEFAULT_HEIGHT_WIDTH=Altezza e larghezza predefinite DOL_UNDERLINE=Abilita sottolineatura DOL_UNDERLINE_DISABLED=Disabilita la sottolineatura DOL_BEEP=Suono di Beep +DOL_BEEP_ALTERNATIVE=Suono di Beep (modalità alternativa) +DOL_PRINT_CURR_DATE=Stampa la data/ora corrente DOL_PRINT_TEXT=Stampa il testo DateInvoiceWithTime=Data e ora della fattura YearInvoice=Anno della fattura From a855ef132951b99675d7e181b3482a1ccca118b1 Mon Sep 17 00:00:00 2001 From: Giovanni Vella Date: Sun, 24 Oct 2021 12:07:23 +0200 Subject: [PATCH 002/174] current date default format string Added a default format for date/time tag DOL_PRINT_CURR_DATE --- htdocs/core/class/dolreceiptprinter.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index cb49f53e0c5..116624c428b 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -712,7 +712,8 @@ class dolReceiptPrinter extends Printer $this->printer->text($title.$spaces.str_pad(price($object->total_ttc), 10, ' ', STR_PAD_LEFT)."\n"); break; case 'DOL_PRINT_CURR_DATE': - $this->printer->text(date($vals[$tplline]['value'])."\n"); + if (strlen($vals[$tplline]['value'])<2) $this->printer->text(date('d/m/Y H:i:s')."\n"); + else $this->printer->text(date($vals[$tplline]['value'])."\n"); break; case 'DOL_LINE_FEED': $this->printer->feed(); From 5c862435a89cebcd46119b26be09bacfc2224fa9 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 7 Feb 2022 16:06:25 +0100 Subject: [PATCH 003/174] Ajout ligne BOM enfant dans mo_card action "create" --- htdocs/mrp/tpl/originproductline.tpl.php | 98 +++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/htdocs/mrp/tpl/originproductline.tpl.php b/htdocs/mrp/tpl/originproductline.tpl.php index ba1d7fccd86..97847427fcd 100644 --- a/htdocs/mrp/tpl/originproductline.tpl.php +++ b/htdocs/mrp/tpl/originproductline.tpl.php @@ -32,12 +32,30 @@ $qtytoconsumeforline = $this->tpl['qty'] / ( ! empty($this->tpl['efficiency']) ? }*/ $qtytoconsumeforline = price2num($qtytoconsumeforline, 'MS'); +$tmpproduct = new Product($this->db); +$tmpproduct->fetch($line->fk_product); +$tmpbom = new BOM($this->db); +$res = $tmpbom->fetch($line->fk_bom_child); + ?> tpl['strike']) ? '' : ' strikefordisabled').'">'; -print ''.$this->tpl['label'].''; +print ''; +if($res){ + print $tmpproduct->getNomUrl(1); + print ' '.$langs->trans("or").' '; + print $tmpbom->getNomUrl(1); + print ' '; + print (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? img_picto('', 'folder') : img_picto('', 'folder-open')); + print ''; + +} else{ + print $this->tpl['label']; +} +print ''; +//print ''.$this->tpl['label'].''; print ''.$this->tpl['qty'].(($this->tpl['efficiency'] > 0 && $this->tpl['efficiency'] < 1) ? ' / '.$form->textwithpicto($this->tpl['efficiency'], $langs->trans("ValueOfMeansLoss")).' = '.$qtytoconsumeforline : '').''; print ''.(empty($this->tpl['stock']) ? 0 : price2num($this->tpl['stock'], 'MS')); if ($this->tpl['seuil_stock_alerte'] != '' && ($this->tpl['stock'] < $this->tpl['seuil_stock_alerte'])) { @@ -61,5 +79,83 @@ print ''; //print ''; print ''; print ''."\n"; + +// Select of all the sub-BOM lines +$sql = 'SELECT rowid, fk_bom_child, fk_product, qty FROM '.MAIN_DB_PREFIX.'bom_bomline AS bl'; +$sql.= ' WHERE fk_bom ='. (int) $tmpbom->id; +$resql = $this->db->query($sql); + +if ($resql) { + // Loop on all the sub-BOM lines if they exist + while ($obj = $this->db->fetch_object($resql)) { + $sub_bom_product = new Product($this->db); + $sub_bom_product->fetch($obj->fk_product); + $sub_bom_product->load_stock(); + + $sub_bom = new BOM($this->db); + $sub_bom->fetch($obj->fk_bom_child); + + $sub_bom_line = new BOMLine($this->db); + $sub_bom_line->fetch($obj->rowid); + + //If hidden conf is set, we show directly all the sub-BOM lines + if (!empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT)) { + print ''; + } else { + print ''; + } + + // Product OR BOM + print ''; + if (!empty($obj->fk_bom_child)) { + print $sub_bom_product->getNomUrl(1); + print ' '.$langs->trans('or').' '; + print $sub_bom->getNomUrl(1); + } else { + print $sub_bom_product->getNomUrl(1); + print ''; + } + + // Qty + if ($sub_bom_line->qty_frozen > 0) { + print ''.price($sub_bom_line->qty, 0, '', 0, 0).''; + } else { + print ''.price($sub_bom_line->qty * $line->qty, 0, '', 0, 0).''; + } + + // Stock réel + if ($sub_bom_product->stock_reel > 0) { + print ''.$sub_bom_product->stock_reel.''; + } else { + print ' '; + } + + // Stock virtuel + if ($sub_bom_product->stock_theorique > 0) { + print ''.$sub_bom_product->stock_theorique.''; + } else { + print ' '; + } + + // Frozen qty + if ($sub_bom_line->qty_frozen > 0) { + print ''.$langs->trans('Yes').''; + } else { + print ' '; + } + + // Disable stock change + if ($sub_bom_line->disable_stock_change > 0) { + print ''.yn($sub_bom_line->disable_stock_change).''; + } else { + print ' '; + } + + print ''; + print ''; + print ''; + } +} + ?> From f921c10e3ac4204ff5bf5a313fe69ede88100a58 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 7 Feb 2022 16:28:58 +0100 Subject: [PATCH 004/174] =?UTF-8?q?Gestion=20js=20:=20d=C3=A9roulement=20d?= =?UTF-8?q?es=20sous=20bom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/mrp/class/mo.class.php | 7 ++++ htdocs/mrp/mo_card.php | 41 +++++++++++++++++++++++- htdocs/mrp/tpl/originproductline.tpl.php | 2 +- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 29db4bcb669..7a2b738b81e 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1312,6 +1312,13 @@ class Mo extends CommonObject $text_stock_options .= (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE) ? '- '.$langs->trans("StockOnReception").'
' : ''); print ''; + // Product or sub-bom + print ''.$langs->trans('Description'); + if (!empty($conf->global->BOM_SUB_BOM)) { + print '   '.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").'  '; + print ''.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").' '; + } + print ''; print ''.$langs->trans('Ref').''; print ''.$langs->trans('Qty'); if ($this->bom->bomtype == 0) { diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 48e36831592..4ba3fe8f250 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -243,7 +243,46 @@ if ($action == 'create') { ?> - - + + + + array('enabled'=>$conf->propal->enabled, 'perms'=>1, 'label'=>'LinkToProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."propal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('propal').')'), 'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>1, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".$this->db->prefix()."societe as s, ".$this->db->prefix()."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$this->db->sanitize($listofidcompanytoscan).') AND t.entity IN ('.getEntity('commande').')'), @@ -8571,7 +8569,6 @@ class Form $sql = $possiblelink['sql']; $resqllist = $this->db->query($sql); - if ($resqllist) { $num = $this->db->num_rows($resqllist); $i = 0; diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index a686e2892f6..f3df78af869 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -675,7 +675,6 @@ class Mo extends CommonObject } $resultline = $moline->create($user, false); // Never use triggers here - if ($resultline <= 0) { $error++; $this->error = $moline->error; @@ -1206,7 +1205,7 @@ class Mo extends CommonObject /** * Create an array of lines - * + * @param string $rolefilter * @return array|int array of lines if OK, <0 if KO */ public function getLinesArray($rolefilter = '') @@ -1694,9 +1693,7 @@ class MoLine extends CommonObjectLine $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); - $i = 0; - while ($i < ($limit ? min($limit, $num) : $num)) { $obj = $this->db->fetch_object($resql); diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index fc6ae99ad55..2b6e7f5dbe4 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php'; require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp_mo.lib.php'; require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php'; + // Load translation files required by the page $langs->loadLangs(array("mrp", "other")); @@ -112,7 +114,6 @@ if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } - if (empty($reshook)) { $error = 0; @@ -130,14 +131,11 @@ if (empty($reshook)) { if ($cancel && !empty($backtopageforcancel)) { $backtopage = $backtopageforcancel; } - - - $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen - if ($action == 'add' && empty($id)) { + if ($action == 'add' && empty($id) && !empty($TBomLineId)) { $noback = ""; include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; @@ -281,48 +279,11 @@ if ($action == 'create') { print dol_get_fiche_end(); + print mrpCollapseBomManagement(); + ?> Date: Tue, 15 Feb 2022 16:24:39 +0100 Subject: [PATCH 018/174] Clean Code --- htdocs/langs/en_US/mrp.lang | 1 + htdocs/mrp/class/mo.class.php | 2 +- htdocs/mrp/mo_card.php | 14 +++++--------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 97b2634d40d..e3167bb7109 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -108,3 +108,4 @@ BOM=Bill Of Materials CollapseBOMHelp=You can define the default display of the details of the nomenclature in the configuration of the BOM module MOAndLines=Manufacturing Orders and lines MoChildGenerate=Generate Child Mo +ParentMo=MO Parent diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index f3df78af869..0eb01e09cb5 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1205,7 +1205,7 @@ class Mo extends CommonObject /** * Create an array of lines - * @param string $rolefilter + * @param string $rolefilter string lines role filter * @return array|int array of lines if OK, <0 if KO */ public function getLinesArray($rolefilter = '') diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 2b6e7f5dbe4..a104a9a5d31 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -133,10 +133,9 @@ if (empty($reshook)) { } $triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record - // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen - + //Create MO with Childs if ($action == 'add' && empty($id) && !empty($TBomLineId)) { - $noback = ""; + $noback = 0; include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; $mo_parent = $object; @@ -163,16 +162,13 @@ if (empty($reshook)) { $res = $object->add_object_linked('mo', $mo_parent->id); } - $noback = 0; - - header("Location: ".$urltogo); + header("Location: ".dol_buildpath('/mrp/mo_list.php', 1)); exit; } + // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; - - // Actions when linking object each other include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; @@ -531,7 +527,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $mo_parent = $object->getMoParent(); if (is_object($mo_parent)) { print ''; - print '' . $langs->trans('MOParent') . ''; + print '' . $langs->trans('ParentMo') . ''; print '' .$mo_parent->getNomUrl(1).''; print ''; } From c2bc3b20bbfd8c40c0e41326f3e8ea9f62417ec6 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 17 Feb 2022 11:05:03 +0100 Subject: [PATCH 019/174] Don't display collapse if no bom on bomline --- htdocs/mrp/tpl/originproductline.tpl.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/mrp/tpl/originproductline.tpl.php b/htdocs/mrp/tpl/originproductline.tpl.php index d261764f1c8..78d58062d4c 100644 --- a/htdocs/mrp/tpl/originproductline.tpl.php +++ b/htdocs/mrp/tpl/originproductline.tpl.php @@ -45,10 +45,12 @@ print 'getNomUrl(1); - print ' '; - print (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? img_picto('', 'folder') : img_picto('', 'folder-open')); + if($tmpbom->id) { + print ' ' . $langs->trans("or") . ' '; + print $tmpbom->getNomUrl(1); + print ' '; + print (empty($conf->global->BOM_SHOW_ALL_BOM_BY_DEFAULT) ? img_picto('', 'folder') : img_picto('', 'folder-open')); + } print ''; } else { print $this->tpl['label']; @@ -92,6 +94,7 @@ $resql = $this->db->query($sql); if ($resql) { // Loop on all the sub-BOM lines if they exist while ($obj = $this->db->fetch_object($resql)) { + $sub_bom_product = new Product($this->db); $sub_bom_product->fetch($obj->fk_product); $sub_bom_product->load_stock(); From 7e6a5d5792ed06a41e6ad35a43e1f9bcc2c83854 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 17 Feb 2022 10:13:30 +0000 Subject: [PATCH 020/174] Fixing style errors. --- htdocs/mrp/tpl/originproductline.tpl.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/mrp/tpl/originproductline.tpl.php b/htdocs/mrp/tpl/originproductline.tpl.php index 78d58062d4c..17ee9305726 100644 --- a/htdocs/mrp/tpl/originproductline.tpl.php +++ b/htdocs/mrp/tpl/originproductline.tpl.php @@ -45,7 +45,7 @@ print 'getNomUrl(1); print ' '; @@ -94,7 +94,6 @@ $resql = $this->db->query($sql); if ($resql) { // Loop on all the sub-BOM lines if they exist while ($obj = $this->db->fetch_object($resql)) { - $sub_bom_product = new Product($this->db); $sub_bom_product->fetch($obj->fk_product); $sub_bom_product->load_stock(); From c4a8bffa4822276a67ba15a5b39025c3ee0369c3 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 21 Feb 2022 10:05:18 +0100 Subject: [PATCH 021/174] FIX Travis : global $db --- htdocs/mrp/tpl/originproductline.tpl.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/mrp/tpl/originproductline.tpl.php b/htdocs/mrp/tpl/originproductline.tpl.php index 78d58062d4c..f4dbf74ea7d 100644 --- a/htdocs/mrp/tpl/originproductline.tpl.php +++ b/htdocs/mrp/tpl/originproductline.tpl.php @@ -22,19 +22,22 @@ if (empty($conf) || !is_object($conf)) { exit; } +global $db; + if (!is_object($form)) { $form = new Form($db); } + $qtytoconsumeforline = $this->tpl['qty'] / ( ! empty($this->tpl['efficiency']) ? $this->tpl['efficiency'] : 1 ); /*if ((empty($this->tpl['qty_frozen']) && $this->tpl['qty_bom'] > 1)) { $qtytoconsumeforline = $qtytoconsumeforline / $this->tpl['qty_bom']; }*/ $qtytoconsumeforline = price2num($qtytoconsumeforline, 'MS'); -$tmpproduct = new Product($this->db); +$tmpproduct = new Product($db); $tmpproduct->fetch($line->fk_product); -$tmpbom = new BOM($this->db); +$tmpbom = new BOM($db); $res = $tmpbom->fetch($line->fk_bom_child); ?> @@ -89,20 +92,20 @@ print ''."\n"; // Select of all the sub-BOM lines $sql = 'SELECT rowid, fk_bom_child, fk_product, qty FROM '.MAIN_DB_PREFIX.'bom_bomline AS bl'; $sql.= ' WHERE fk_bom ='. (int) $tmpbom->id; -$resql = $this->db->query($sql); +$resql = $db->query($sql); if ($resql) { // Loop on all the sub-BOM lines if they exist - while ($obj = $this->db->fetch_object($resql)) { + while ($obj = $db->fetch_object($resql)) { - $sub_bom_product = new Product($this->db); + $sub_bom_product = new Product($db); $sub_bom_product->fetch($obj->fk_product); $sub_bom_product->load_stock(); - $sub_bom = new BOM($this->db); + $sub_bom = new BOM($db); $sub_bom->fetch($obj->fk_bom_child); - $sub_bom_line = new BOMLine($this->db); + $sub_bom_line = new BOMLine($db); $sub_bom_line->fetch($obj->rowid); //If hidden conf is set, we show directly all the sub-BOM lines From e02b82e3464abe8bf46de196737fc0044c6b3502 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 21 Feb 2022 09:09:39 +0000 Subject: [PATCH 022/174] Fixing style errors. --- htdocs/mrp/tpl/originproductline.tpl.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/mrp/tpl/originproductline.tpl.php b/htdocs/mrp/tpl/originproductline.tpl.php index 035cb3a2184..22e53ae721e 100644 --- a/htdocs/mrp/tpl/originproductline.tpl.php +++ b/htdocs/mrp/tpl/originproductline.tpl.php @@ -96,7 +96,6 @@ $resql = $db->query($sql); if ($resql) { // Loop on all the sub-BOM lines if they exist while ($obj = $db->fetch_object($resql)) { - $sub_bom_product = new Product($db); $sub_bom_product->fetch($obj->fk_product); $sub_bom_product->load_stock(); From f177973efe21dba3e6984d549ecac06249e64419 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Mon, 21 Feb 2022 10:13:25 +0100 Subject: [PATCH 023/174] Don't create Mo Child if it's only a product line on BOM --- htdocs/mrp/tpl/originproductline.tpl.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/mrp/tpl/originproductline.tpl.php b/htdocs/mrp/tpl/originproductline.tpl.php index 035cb3a2184..d8a7eb99ed8 100644 --- a/htdocs/mrp/tpl/originproductline.tpl.php +++ b/htdocs/mrp/tpl/originproductline.tpl.php @@ -82,9 +82,13 @@ print ''; //print ''; print ''; -print ''; -print ''; -print ''; +if($tmpbom->id) { + print ''; + print ''; + print ''; +} else { + print ' '; +} print ''."\n"; From cf2f2c283b4928b4f9e9bfc4180511f5ef261f9e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 21 Feb 2022 09:17:20 +0000 Subject: [PATCH 024/174] Fixing style errors. --- htdocs/mrp/tpl/originproductline.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/tpl/originproductline.tpl.php b/htdocs/mrp/tpl/originproductline.tpl.php index 096ae6109fd..d65f625048b 100644 --- a/htdocs/mrp/tpl/originproductline.tpl.php +++ b/htdocs/mrp/tpl/originproductline.tpl.php @@ -82,7 +82,7 @@ print ''; //print ''; print ''; -if($tmpbom->id) { +if ($tmpbom->id) { print ''; print ''; print ''; From 45fe83289f77614d5315c1745b5f1db45b51c598 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 22 Feb 2022 11:32:33 +0100 Subject: [PATCH 025/174] MoChild category --- htdocs/core/class/html.form.class.php | 4 ++-- htdocs/langs/en_US/mrp.lang | 1 + htdocs/mrp/mo_card.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b8e1850feaf..6ee9bf79049 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8339,7 +8339,7 @@ class Form * @param array $compatibleImportElementsList Array of compatibles elements object for "import from" action * @return int <0 if KO, >=0 if OK */ - public function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleImportElementsList = false) + public function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleImportElementsList = false, $title='RelatedObjects') { global $conf, $langs, $hookmanager; global $bc, $action; @@ -8358,7 +8358,7 @@ class Form $nbofdifferenttypes = count($object->linkedObjects); print ''; - print load_fiche_titre($langs->trans('RelatedObjects'), $morehtmlright, '', 0, 0, 'showlinkedobjectblock'); + print load_fiche_titre($langs->trans($title), $morehtmlright, '', 0, 0, 'showlinkedobjectblock'); print '
'; diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index e3167bb7109..cef9054f727 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -109,3 +109,4 @@ CollapseBOMHelp=You can define the default display of the details of the nomencl MOAndLines=Manufacturing Orders and lines MoChildGenerate=Generate Child Mo ParentMo=MO Parent +MOChild=MO Child diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index a104a9a5d31..34ed92a2164 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -731,7 +731,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('mo')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, false, 'MOChild'); print '
'; From e5ba5b208e5f4732dcdf2f285340df552d83c55d Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 22 Feb 2022 11:36:41 +0100 Subject: [PATCH 026/174] Correct Stickler --- 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 6ee9bf79049..48b7b27cc14 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -8339,7 +8339,7 @@ class Form * @param array $compatibleImportElementsList Array of compatibles elements object for "import from" action * @return int <0 if KO, >=0 if OK */ - public function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleImportElementsList = false, $title='RelatedObjects') + public function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleImportElementsList = false, $title = 'RelatedObjects') { global $conf, $langs, $hookmanager; global $bc, $action; From 5e644ed0a4afca0ed5e804a1d942e357d6b545f0 Mon Sep 17 00:00:00 2001 From: ATM john Date: Tue, 15 Mar 2022 18:24:49 +0100 Subject: [PATCH 027/174] Fix search degradation --- htdocs/compta/facture/list.php | 1 - htdocs/core/class/extrafields.class.php | 80 +++++++++++++------ .../tpl/extrafields_list_search_sql.tpl.php | 9 ++- 3 files changed, 61 insertions(+), 29 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index ccf3c2f3f0c..c97e1a6d10f 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -139,7 +139,6 @@ $search_btn = GETPOST('button_search', 'alpha'); $search_remove_btn = GETPOST('button_removefilter', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha'); - $option = GETPOST('search_option'); if ($option == 'late') { $search_status = '1'; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index f8e5726d344..770956a7581 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1173,35 +1173,56 @@ class ExtraFields $out = ' '; } elseif ($type == 'select') { $out = ''; - if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_EXTRAFIELDS_DISABLE_SELECT2)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $out .= ajax_combobox($keyprefix.$key.$keysuffix, array(), 0); - } + if ($mode) { + $options = array(); + foreach ($param['options'] as $okey => $val) { + if ((string) $okey == '') { + continue; + } - $out .= ''; + $out .= ''; + foreach ($param['options'] as $key => $val) { + if ((string) $key == '') { + continue; + } + $valarray = explode('|', $val); + $val = $valarray[0]; + $parent = ''; + if (!empty($valarray[1])) { + $parent = $valarray[1]; + } + $out .= ''; + } + $out .= ''; } - $out .= ''; } elseif ($type == 'sellist') { $out = ''; if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_EXTRAFIELDS_DISABLE_SELECT2)) { @@ -2208,6 +2229,17 @@ class ExtraFields } else { continue; // Value was not provided, we should not set it. } + } elseif ($key_type == 'select') { + // to detect if we are in search context + $value_arr_test = GETPOST($keysuffix."options_".$key.$keyprefix, 'none'); + if (is_array($value_arr_test)) { + $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix, 'array:aZ09'); + // Make sure we get an array even if there's only one selected + $value_arr = (array) $value_arr; + $value_key = implode(',', $value_arr); + } else { + $value_key = GETPOST($keysuffix."options_".$key.$keyprefix); + } } elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) { if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) { continue; // Value was not provided, we should not set it. diff --git a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php index 8b7ff9ac62c..a4b0a8591b4 100644 --- a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php @@ -48,7 +48,7 @@ if (!empty($extrafieldsobjectkey) && !empty($search_array_options) && is_array($ } $sql .= ")"; } - } elseif ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0') && (!in_array($typ, array('link')) || $crit != '-1')) { + } elseif ($crit != '' && (!in_array($typ, array('select', 'sellist', 'select')) || $crit != '0') && (!in_array($typ, array('link')) || $crit != '-1')) { $mode_search = 0; if (in_array($typ, array('int', 'double', 'real', 'price'))) { $mode_search = 1; // Search on a numeric @@ -59,13 +59,14 @@ if (!empty($extrafieldsobjectkey) && !empty($search_array_options) && is_array($ if (in_array($typ, array('sellist')) && !is_numeric($crit)) { $mode_search = 0;// Search on a foreign key string } - if (in_array($typ, array('chkbxlst', 'checkbox'))) { + if (in_array($typ, array('chkbxlst', 'checkbox', 'select'))) { $mode_search = 4; // Search on a multiselect field with sql type = text } if (is_array($crit)) { $crit = implode(' ', $crit); // natural_search() expects a string - } elseif ($typ === 'select' and is_string($crit) and strpos($crit, ' ') === false) { - $sql .= " AND (".$extrafieldsobjectprefix.$tmpkey." = '".$db->escape($crit)."')"; + } elseif ($typ === 'select' and is_string($crit) and strpos($crit, ',') === false) { + $critSelect = implode("','", array_map(array($db, 'escape'), explode(',', $crit))); + $sql .= " AND (".$extrafieldsobjectprefix.$tmpkey." IN ('".$critSelect."') )"; continue; } $sql .= natural_search($extrafieldsobjectprefix.$tmpkey, $crit, $mode_search); From 16968b08f9f5f2971af0153923a618bff4c3bb1b Mon Sep 17 00:00:00 2001 From: ATM john Date: Wed, 30 Mar 2022 11:49:48 +0200 Subject: [PATCH 028/174] Add GETPOSTISARRAY --- htdocs/core/class/extrafields.class.php | 3 +-- htdocs/core/lib/functions.lib.php | 26 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index a840dbd02b9..6e92714293b 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2131,8 +2131,7 @@ class ExtraFields } } elseif ($key_type == 'select') { // to detect if we are in search context - $value_arr_test = GETPOST($keysuffix."options_".$key.$keyprefix, 'none'); - if (is_array($value_arr_test)) { + if (GETPOSTISARRAY($keysuffix."options_".$key.$keyprefix)) { $value_arr = GETPOST($keysuffix."options_".$key.$keyprefix, 'array:aZ09'); // Make sure we get an array even if there's only one selected $value_arr = (array) $value_arr; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f9672f776e5..9c268d31980 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -370,6 +370,32 @@ function GETPOSTISSET($paramname) return $isset; } +/** + * Return true if the parameter $paramname is submit from a POST OR GET as an array. + * Can be used before GETPOST to know if the $check param of GETPOST need to check an array or a string + * + * @param string $paramname Name or parameter to test + * @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get) + * @return bool True if we have just submit a POST or GET request with the parameter provided (even if param is empty) + */ +function GETPOSTISARRAY($paramname, $method = 0) +{ + // for $method test need return the same $val as GETPOST + if (empty($method)) { + $val = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : ''); + } elseif ($method == 1) { + $val = isset($_GET[$paramname]) ? $_GET[$paramname] : ''; + } elseif ($method == 2) { + $val = isset($_POST[$paramname]) ? $_POST[$paramname] : ''; + } elseif ($method == 3) { + $val = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : ''); + } else { + $val = 'BadFirstParameterForGETPOST'; + } + + return is_array($val); +} + /** * Return value of a param into GET or POST supervariable. * Use the property $user->default_values[path]['createform'] and/or $user->default_values[path]['filters'] and/or $user->default_values[path]['sortorder'] From c1d9ea95dcb1d362c951317d1cc8216412cc2c26 Mon Sep 17 00:00:00 2001 From: ATM john Date: Wed, 30 Mar 2022 12:16:17 +0200 Subject: [PATCH 029/174] fix function name --- htdocs/api/class/api.class.php | 4 ++-- htdocs/categories/class/categorie.class.php | 2 +- .../comm/propal/class/api_proposals.class.php | 8 +++---- htdocs/commande/class/api_orders.class.php | 8 +++---- .../bank/class/api_bankaccounts.class.php | 22 +++++++++---------- .../facture/class/api_invoices.class.php | 8 +++---- htdocs/contrat/class/api_contracts.class.php | 8 +++---- htdocs/core/lib/functions.lib.php | 22 ++++++++++++++++--- .../expedition/class/api_shipments.class.php | 8 +++---- .../class/api_expensereports.class.php | 8 +++---- htdocs/exports/class/export.class.php | 2 +- .../class/api_supplier_invoices.class.php | 8 +++---- .../class/api_knowledgemanagement.class.php | 4 ++-- .../template/class/api_mymodule.class.php | 4 ++-- htdocs/product/class/api_products.class.php | 6 ++--- htdocs/projet/class/api_projects.class.php | 4 ++-- htdocs/projet/class/api_tasks.class.php | 4 ++-- .../class/api_recruitment.class.php | 8 +++---- 18 files changed, 77 insertions(+), 61 deletions(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index fa21c37649f..32d691400d6 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -88,9 +88,9 @@ class DolibarrApi // phpcs:enable // TODO Use type detected in $object->fields if (in_array($field, array('note', 'note_private', 'note_public', 'desc', 'description'))) { - return checkVal($value, 'restricthtml'); + return sanitizeVal($value, 'restricthtml'); } else { - return checkVal($value, 'alphanohtml'); + return sanitizeVal($value, 'alphanohtml'); } } diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index a3d2dc3e57f..fca780cadef 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -913,7 +913,7 @@ class Categorie extends CommonObject $categories = array(); - $type = checkVal($type, 'aZ09'); + $type = sanitizeVal($type, 'aZ09'); $sub_type = $type; $subcol_name = "fk_".$type; diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 59a03f78bb2..882189c86b3 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -343,8 +343,8 @@ class Proposals extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); $updateRes = $this->propal->addline( $request_data->desc, @@ -488,8 +488,8 @@ class Proposals extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); $propalline = new PropaleLigne($this->db); $result = $propalline->fetch($lineid); diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index fb912139d5f..e73fee8941f 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -335,8 +335,8 @@ class Orders extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); $updateRes = $this->commande->addline( $request_data->desc, @@ -403,8 +403,8 @@ class Orders extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); $updateRes = $this->commande->updateline( $lineid, diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 23d4c2eefbb..8e38d1ffe78 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -250,7 +250,7 @@ class BankAccounts extends DolibarrApi } // Clean data - $description = checkVal($description, 'alphanohtml'); + $description = sanitizeVal($description, 'alphanohtml'); /** @@ -498,13 +498,13 @@ class BankAccounts extends DolibarrApi throw new RestException(404, 'account not found'); } - $type = checkVal($type); - $label = checkVal($label); - $cheque_number = checkVal($cheque_number); - $cheque_writer = checkVal($cheque_writer); - $cheque_bank = checkVal($cheque_bank); - $accountancycode = checkVal($accountancycode); - $num_releve = checkVal($num_releve); + $type = sanitizeVal($type); + $label = sanitizeVal($label); + $cheque_number = sanitizeVal($cheque_number); + $cheque_writer = sanitizeVal($cheque_writer); + $cheque_bank = sanitizeVal($cheque_bank); + $accountancycode = sanitizeVal($accountancycode); + $num_releve = sanitizeVal($num_releve); $result = $account->addline( $date, @@ -557,9 +557,9 @@ class BankAccounts extends DolibarrApi throw new RestException(404, 'account line not found'); } - $url = checkVal($url); - $label = checkVal($label); - $type = checkVal($type); + $url = sanitizeVal($url); + $label = sanitizeVal($label); + $type = sanitizeVal($type); $result = $account->add_url_line($line_id, $url_id, $url, $label, $type); if ($result < 0) { diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 551edb05731..19fda9ee253 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -423,8 +423,8 @@ class Invoices extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); $updateRes = $this->invoice->updateline( $lineid, @@ -712,8 +712,8 @@ class Invoices extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); // Reset fk_parent_line for no child products and special product if (($request_data->product_type != 9 && empty($request_data->fk_parent_line)) || $request_data->product_type == 9) { diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 5e534f3e43c..ea228550cae 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -278,8 +278,8 @@ class Contracts extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->price_base_type = checkVal($request_data->price_base_type); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->price_base_type = sanitizeVal($request_data->price_base_type); $updateRes = $this->contract->addline( $request_data->desc, @@ -336,8 +336,8 @@ class Contracts extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->price_base_type = checkVal($request_data->price_base_type); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->price_base_type = sanitizeVal($request_data->price_base_type); $updateRes = $this->contract->updateline( $lineid, diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9c268d31980..9d5a9eae857 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -683,11 +683,11 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null $tmpcheck = 'alphanohtml'; } foreach ($out as $outkey => $outval) { - $out[$outkey] = checkVal($outval, $tmpcheck, $filter, $options); + $out[$outkey] = sanitizeVal($outval, $tmpcheck, $filter, $options); } } } else { - $out = checkVal($out, $check, $filter, $options); + $out = sanitizeVal($out, $check, $filter, $options); } // Sanitizing for special parameters. @@ -736,9 +736,11 @@ function GETPOSTINT($paramname, $method = 0) return (int) GETPOST($paramname, 'int', $method, null, null, 0); } + /** - * Return a value after checking on a rule. A sanitization may also have been done. + * Return a sanitized or empty value after checking value against a rule. * + * @deprecated * @param string|array $out Value to check/clear. * @param string $check Type of check/sanitizing * @param int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails) @@ -746,6 +748,20 @@ function GETPOSTINT($paramname, $method = 0) * @return string|array Value sanitized (string or array). It may be '' if format check fails. */ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options = null) +{ + return sanitizeVal($out, $check, $filter, $options); +} + +/** + * Return a sanitized or empty value after checking value against a rule. + * + * @param string|array $out Value to check/clear. + * @param string $check Type of check/sanitizing + * @param int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails) + * @param mixed $options Options to pass to filter_var when $check is set to 'custom' + * @return string|array Value sanitized (string or array). It may be '' if format check fails. + */ +function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options = null) { global $conf; diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 402fbdc04d1..357683ef35a 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -279,8 +279,8 @@ class Shipments extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); $updateRes = $this->shipment->addline( $request_data->desc, @@ -347,8 +347,8 @@ class Shipments extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); $updateRes = $this->shipment->updateline( $lineid, diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 37319a3ec71..876b08f18f0 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -251,8 +251,8 @@ class ExpenseReports extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); $updateRes = $this->expensereport->addline( $request_data->desc, @@ -319,8 +319,8 @@ class ExpenseReports extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); - $request_data->label = checkVal($request_data->label); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); + $request_data->label = sanitizeVal($request_data->label); $updateRes = $this->expensereport->updateline( $lineid, diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index c87f03f3110..a836be7d9d4 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -302,7 +302,7 @@ class Export public function build_filterQuery($TypeField, $NameField, $ValueField) { // phpcs:enable - $NameField = checkVal($NameField, 'aZ09'); + $NameField = sanitizeVal($NameField, 'aZ09'); $szFilterQuery = ''; //print $TypeField." ".$NameField." ".$ValueField; diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 35e783729ff..d08409a279b 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -558,8 +558,8 @@ class SupplierInvoices extends DolibarrApi $request_data = (object) $request_data; - $request_data->description = checkVal($request_data->description, 'restricthtml'); - $request_data->ref_supplier = checkVal($request_data->ref_supplier); + $request_data->description = sanitizeVal($request_data->description, 'restricthtml'); + $request_data->ref_supplier = sanitizeVal($request_data->ref_supplier); $updateRes = $this->invoice->addline( $request_data->description, @@ -625,8 +625,8 @@ class SupplierInvoices extends DolibarrApi $request_data = (object) $request_data; - $request_data->description = checkVal($request_data->description, 'restricthtml'); - $request_data->ref_supplier = checkVal($request_data->ref_supplier); + $request_data->description = sanitizeVal($request_data->description, 'restricthtml'); + $request_data->ref_supplier = sanitizeVal($request_data->ref_supplier); $updateRes = $this->invoice->updateline( $lineid, diff --git a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php index 5d26fa90137..e52c677318e 100644 --- a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php +++ b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php @@ -218,7 +218,7 @@ class KnowledgeManagement extends DolibarrApi } // Clean data - // $this->knowledgerecord->abc = checkVal($this->knowledgerecord->abc, 'alphanohtml'); + // $this->knowledgerecord->abc = sanitizeVal($this->knowledgerecord->abc, 'alphanohtml'); if ($this->knowledgerecord->create(DolibarrApiAccess::$user)<0) { throw new RestException(500, "Error creating KnowledgeRecord", array_merge(array($this->knowledgerecord->error), $this->knowledgerecord->errors)); @@ -260,7 +260,7 @@ class KnowledgeManagement extends DolibarrApi } // Clean data - // $this->knowledgerecord->abc = checkVal($this->knowledgerecord->abc, 'alphanohtml'); + // $this->knowledgerecord->abc = sanitizeVal($this->knowledgerecord->abc, 'alphanohtml'); if ($this->knowledgerecord->update(DolibarrApiAccess::$user, false) > 0) { return $this->get($id); diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 4cb50c8de2f..5299ff04caa 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -218,7 +218,7 @@ class MyModuleApi extends DolibarrApi } // Clean data - // $this->myobject->abc = checkVal($this->myobject->abc, 'alphanohtml'); + // $this->myobject->abc = sanitizeVal($this->myobject->abc, 'alphanohtml'); if ($this->myobject->create(DolibarrApiAccess::$user)<0) { throw new RestException(500, "Error creating MyObject", array_merge(array($this->myobject->error), $this->myobject->errors)); @@ -260,7 +260,7 @@ class MyModuleApi extends DolibarrApi } // Clean data - // $this->myobject->abc = checkVal($this->myobject->abc, 'alphanohtml'); + // $this->myobject->abc = sanitizeVal($this->myobject->abc, 'alphanohtml'); if ($this->myobject->update(DolibarrApiAccess::$user, false) > 0) { return $this->get($id); diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index e44aef221f6..4c5f0810edd 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -779,9 +779,9 @@ class Products extends DolibarrApi } // Clean data - $ref_fourn = checkVal($ref_fourn, 'alphanohtml'); - $desc_fourn = checkVal($desc_fourn, 'restricthtml'); - $barcode = checkVal($barcode, 'alphanohtml'); + $ref_fourn = sanitizeVal($ref_fourn, 'alphanohtml'); + $desc_fourn = sanitizeVal($desc_fourn, 'restricthtml'); + $barcode = sanitizeVal($barcode, 'alphanohtml'); $result = $this->productsupplier->update_buyprice($qty, $buyprice, DolibarrApiAccess::$user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges, $remise_percent, $remise, $newnpr, $delivery_time_days, $supplier_reputation, $localtaxes_array, $newdefaultvatcode, $multicurrency_buyprice, $multicurrency_price_base_type, $multicurrency_tx, $multicurrency_code, $desc_fourn, $barcode, $fk_barcode_type); diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 59576b961d4..6a522346210 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -333,7 +333,7 @@ class Projects extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); $updateRes = $this->project->addline( $request_data->desc, @@ -400,7 +400,7 @@ class Projects extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); $updateRes = $this->project->updateline( $lineid, diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index cafb60f2865..0eaf8654421 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -333,7 +333,7 @@ class Tasks extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); $updateRes = $this->project->addline( $request_data->desc, @@ -400,7 +400,7 @@ class Tasks extends DolibarrApi $request_data = (object) $request_data; - $request_data->desc = checkVal($request_data->desc, 'restricthtml'); + $request_data->desc = sanitizeVal($request_data->desc, 'restricthtml'); $updateRes = $this->project->updateline( $lineid, diff --git a/htdocs/recruitment/class/api_recruitment.class.php b/htdocs/recruitment/class/api_recruitment.class.php index e0c2cb5da11..26e6c58fa4a 100644 --- a/htdocs/recruitment/class/api_recruitment.class.php +++ b/htdocs/recruitment/class/api_recruitment.class.php @@ -359,7 +359,7 @@ class Recruitment extends DolibarrApi } // Clean data - // $this->jobposition->abc = checkVal($this->jobposition->abc, 'alphanohtml'); + // $this->jobposition->abc = sanitizeVal($this->jobposition->abc, 'alphanohtml'); if ($this->jobposition->create(DolibarrApiAccess::$user)<0) { throw new RestException(500, "Error creating jobposition", array_merge(array($this->jobposition->error), $this->jobposition->errors)); @@ -391,7 +391,7 @@ class Recruitment extends DolibarrApi } // Clean data - // $this->jobposition->abc = checkVal($this->jobposition->abc, 'alphanohtml'); + // $this->jobposition->abc = sanitizeVal($this->jobposition->abc, 'alphanohtml'); if ($this->candidature->create(DolibarrApiAccess::$user)<0) { throw new RestException(500, "Error creating candidature", array_merge(array($this->candidature->error), $this->candidature->errors)); @@ -433,7 +433,7 @@ class Recruitment extends DolibarrApi } // Clean data - // $this->jobposition->abc = checkVal($this->jobposition->abc, 'alphanohtml'); + // $this->jobposition->abc = sanitizeVal($this->jobposition->abc, 'alphanohtml'); if ($this->jobposition->update(DolibarrApiAccess::$user, false) > 0) { return $this->get($id); @@ -476,7 +476,7 @@ class Recruitment extends DolibarrApi } // Clean data - // $this->jobposition->abc = checkVal($this->jobposition->abc, 'alphanohtml'); + // $this->jobposition->abc = sanitizeVal($this->jobposition->abc, 'alphanohtml'); if ($this->candidature->update(DolibarrApiAccess::$user, false) > 0) { return $this->get($id); From d50e0457f340aa790049d94f15a310a563f77642 Mon Sep 17 00:00:00 2001 From: ATM john Date: Wed, 30 Mar 2022 12:33:17 +0200 Subject: [PATCH 030/174] add todo comment --- htdocs/core/lib/functions.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 9d5a9eae857..3515cacd874 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -765,6 +765,7 @@ function sanitizeVal($out = '', $check = 'alphanohtml', $filter = null, $options { global $conf; + // TODO : use class "Validate" to perform tests (and add missing tests) if needed for factorize // Check is done after replacement switch ($check) { case 'none': From 08a3ef5bbf5e1aa7b38a9340d183880f1e14ffa1 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 10 May 2022 12:25:38 +0200 Subject: [PATCH 031/174] NEW : method avoid being blocked when entry already exists for import in llx_categorie_product (use update keys) --- htdocs/core/modules/import/import_csv.modules.php | 14 +++++++++++++- .../core/modules/import/import_xlsx.modules.php | 15 ++++++++++++++- htdocs/core/modules/modCategorie.class.php | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 78c8f5e104f..8a99dfe90d2 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -776,11 +776,18 @@ class ImportCsv extends ModeleImports $updatedone = false; $insertdone = false; + $is_table_category_link = false; + $fname = 'rowid'; + if(strpos($tablename, '_categorie_') !== false) { + $is_table_category_link = true; + $fname='*'; + } + if (!empty($updatekeys)) { // We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields) if (empty($lastinsertid)) { // No insert done yet for a parent table - $sqlSelect = 'SELECT rowid FROM '.$tablename; + $sqlSelect = 'SELECT '.$fname.' FROM '.$tablename; $data = array_combine($listfields, $listvalues); $where = array(); @@ -798,6 +805,7 @@ class ImportCsv extends ModeleImports $res = $this->db->fetch_object($resql); if ($resql->num_rows == 1) { $lastinsertid = $res->rowid; + if($is_table_category_link) $lastinsertid = 'linktable'; // used to apply update on tables like llx_categorie_product and avoid being blocked for all file content if at least one entry already exists $last_insert_id_array[$tablename] = $lastinsertid; } elseif ($resql->num_rows > 1) { $this->errors[$error]['lib'] = $langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); @@ -859,6 +867,10 @@ class ImportCsv extends ModeleImports } $sqlend = ' WHERE '.$keyfield.' = '.((int) $lastinsertid); + if($is_table_category_link) { + $sqlend = ' WHERE ' . implode(' AND ', $where); + } + $sql = $sqlstart.$sqlend; // Run update request diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 38c9cd8c56a..c972dcbcb28 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -816,11 +816,19 @@ class ImportXlsx extends ModeleImports if (!empty($listfields)) { $updatedone = false; $insertdone = false; + + $is_table_category_link = false; + $fname = 'rowid'; + if(strpos($tablename, '_categorie_') !== false) { + $is_table_category_link = true; + $fname='*'; + } + if (!empty($updatekeys)) { // We do SELECT to get the rowid, if we already have the rowid, it's to be used below for related tables (extrafields) if (empty($lastinsertid)) { // No insert done yet for a parent table - $sqlSelect = 'SELECT rowid FROM ' . $tablename; + $sqlSelect = 'SELECT '.$fname.' FROM ' . $tablename; $data = array_combine($listfields, $listvalues); $where = array(); @@ -838,6 +846,7 @@ class ImportXlsx extends ModeleImports $res = $this->db->fetch_object($resql); if ($resql->num_rows == 1) { $lastinsertid = $res->rowid; + if($is_table_category_link) $lastinsertid = 'linktable'; // used to apply update on tables like llx_categorie_product and avoid being blocked for all file content if at least one entry already exists $last_insert_id_array[$tablename] = $lastinsertid; } elseif ($resql->num_rows > 1) { $this->errors[$error]['lib'] = $langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); @@ -899,6 +908,10 @@ class ImportXlsx extends ModeleImports } $sqlend = ' WHERE ' . $keyfield . ' = '.((int) $lastinsertid); + if($is_table_category_link) { + $sqlend = ' WHERE ' . implode(' AND ', $where); + } + $sql = $sqlstart . $sqlend; // Run update request diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 776c5c76681..ab48a702250 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -481,6 +481,7 @@ class modCategorie extends DolibarrModules 'cp.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product') ); $this->import_examplevalues_array[$r] = array('cp.fk_categorie'=>"rowid or label", 'cp.fk_product'=>"rowid or ref"); + $this->import_updatekeys_array[$r] = array('cp.fk_categorie' => 'Category', 'cp.fk_product' => 'ProductRef'); } // 1 Suppliers From 98f5edbfba15678d1b59d41a7c8f798f358ca400 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 10 May 2022 10:47:18 +0000 Subject: [PATCH 032/174] Fixing style errors. --- htdocs/core/modules/import/import_csv.modules.php | 6 +++--- htdocs/core/modules/import/import_xlsx.modules.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 58ff558b54b..2032730112e 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -787,7 +787,7 @@ class ImportCsv extends ModeleImports $is_table_category_link = false; $fname = 'rowid'; - if(strpos($tablename, '_categorie_') !== false) { + if (strpos($tablename, '_categorie_') !== false) { $is_table_category_link = true; $fname='*'; } @@ -814,7 +814,7 @@ class ImportCsv extends ModeleImports $res = $this->db->fetch_object($resql); if ($resql->num_rows == 1) { $lastinsertid = $res->rowid; - if($is_table_category_link) $lastinsertid = 'linktable'; // used to apply update on tables like llx_categorie_product and avoid being blocked for all file content if at least one entry already exists + if ($is_table_category_link) $lastinsertid = 'linktable'; // used to apply update on tables like llx_categorie_product and avoid being blocked for all file content if at least one entry already exists $last_insert_id_array[$tablename] = $lastinsertid; } elseif ($resql->num_rows > 1) { $this->errors[$error]['lib'] = $langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); @@ -876,7 +876,7 @@ class ImportCsv extends ModeleImports } $sqlend = " WHERE ".$keyfield." = ".((int) $lastinsertid); - if($is_table_category_link) { + if ($is_table_category_link) { $sqlend = " WHERE " . implode(' AND ', $where); } diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 564156e8cc1..9433d864d50 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -828,7 +828,7 @@ class ImportXlsx extends ModeleImports $is_table_category_link = false; $fname = 'rowid'; - if(strpos($tablename, '_categorie_') !== false) { + if (strpos($tablename, '_categorie_') !== false) { $is_table_category_link = true; $fname='*'; } @@ -855,7 +855,7 @@ class ImportXlsx extends ModeleImports $res = $this->db->fetch_object($resql); if ($resql->num_rows == 1) { $lastinsertid = $res->rowid; - if($is_table_category_link) $lastinsertid = 'linktable'; // used to apply update on tables like llx_categorie_product and avoid being blocked for all file content if at least one entry already exists + if ($is_table_category_link) $lastinsertid = 'linktable'; // used to apply update on tables like llx_categorie_product and avoid being blocked for all file content if at least one entry already exists $last_insert_id_array[$tablename] = $lastinsertid; } elseif ($resql->num_rows > 1) { $this->errors[$error]['lib'] = $langs->trans('MultipleRecordFoundWithTheseFilters', implode(', ', $filters)); @@ -917,7 +917,7 @@ class ImportXlsx extends ModeleImports } $sqlend = " WHERE " . $keyfield . " = ".((int) $lastinsertid); - if($is_table_category_link) { + if ($is_table_category_link) { $sqlend = " WHERE " . implode(' AND ', $where); } From 0bf588962b89f91021d1cff771156c91368a45ef Mon Sep 17 00:00:00 2001 From: atm-florian Date: Thu, 19 May 2022 09:45:37 +0200 Subject: [PATCH 033/174] FIX 15.0: modules cannot declare more than 1 cron job using the same method with different parameters --- htdocs/core/modules/DolibarrModules.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index dcb59df7ebb..83c79da87f4 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -1430,6 +1430,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it if ($command) { $sql .= " AND command = '".$this->db->escape($command)."'"; } + if ($parameters) { + $sql .= " AND params = '".$this->db->escape($parameters)."'"; + } $sql .= " AND entity = ".((int) $entity); // Must be exact entity $now = dol_now(); From 25196fa7092b561ab14cd3f0c670aed31a2de2cc Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Thu, 19 May 2022 10:20:31 +0200 Subject: [PATCH 034/174] FIX: new member subscription: bank account and payment mode might be hidden --- htdocs/adherents/subscription.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 799f043c4df..c069f0d12e2 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -960,12 +960,12 @@ if ($rowid > 0) { // Bank account print ''.$langs->trans("FinancialAccount").''; - $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2); + $form->select_comptes(GETPOST('accountid'), 'accountid', 0, '', 2, '', 0, 'minwidth200'); print "\n"; // Payment mode print ''.$langs->trans("PaymentMode").''; - $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2); + $form->select_types_paiements(GETPOST('operation'), 'operation', '', 2, 1, 0, 0, 1, 'minwidth200'); print "\n"; // Date of payment From e44e9d812aa0d5e72d3e07b5ea6beac8820afbe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 19 May 2022 12:28:50 +0200 Subject: [PATCH 035/174] Update card.php --- htdocs/commande/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b6e16a22a9e..18efae9dc5c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1632,7 +1632,7 @@ if ($action == 'create' && $usercancreate) { if ($socid > 0) { // Contacts (ask contact only if thirdparty already defined). print "".$langs->trans("DefaultContact").''; - print img_picto('', 'contact'); + print img_picto('', 'contact', 'class="pictofixedwidth"'); print $form->selectcontacts($soc->id, $contactid, 'contactid', 1, $srccontactslist, '', 1); print ''; @@ -1670,7 +1670,7 @@ if ($action == 'create' && $usercancreate) { // Terms of the settlement print ''.$langs->trans('PaymentConditionsShort').''; - print img_picto('', 'paiment'); + print img_picto('', 'payment', 'class="pictofixedwidth"'); $form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', - 1, 1); print ''; From 2114e51b0e0bfd8e31878fc210cfdf5f24c72af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 19 May 2022 12:34:54 +0200 Subject: [PATCH 036/174] 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 18efae9dc5c..a321b347ad4 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1690,7 +1690,7 @@ if ($action == 'create' && $usercancreate) { // Shipping Method if (!empty($conf->expedition->enabled)) { print ''.$langs->trans('SendingMethod').''; - print img_picto('', 'object_dollyrevert', 'class="pictofixedwidth"'); + print img_picto('', 'object_dolly', 'class="pictofixedwidth"'); print $form->selectShippingMethod($shipping_method_id, 'shipping_method_id', '', 1, '', 0, 'maxwidth200 widthcentpercentminusx'); print ''; } From ad3276b57972a00492725a536cd041307d78c0fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 19 May 2022 12:42:15 +0200 Subject: [PATCH 037/174] 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 a321b347ad4..a52d4c8339c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1671,7 +1671,7 @@ if ($action == 'create' && $usercancreate) { // Terms of the settlement print ''.$langs->trans('PaymentConditionsShort').''; print img_picto('', 'payment', 'class="pictofixedwidth"'); - $form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', - 1, 1); + $form->select_conditions_paiements($cond_reglement_id, 'cond_reglement_id', - 1, 1, 0, 'maxwidth200 widthcentpercentminusx'); print ''; // Payment mode From 243dfacb1571703261ab10be0941781ab500685b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 19 May 2022 12:46:15 +0200 Subject: [PATCH 038/174] 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 a52d4c8339c..4eca459300a 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -1633,7 +1633,7 @@ if ($action == 'create' && $usercancreate) { // Contacts (ask contact only if thirdparty already defined). print "".$langs->trans("DefaultContact").''; print img_picto('', 'contact', 'class="pictofixedwidth"'); - print $form->selectcontacts($soc->id, $contactid, 'contactid', 1, $srccontactslist, '', 1); + print $form->selectcontacts($soc->id, $contactid, 'contactid', 1, $srccontactslist, '', 1, 'maxwidth200 widthcentpercentminusx'); print ''; // Ligne info remises tiers From a2fe72225f61054db1f58342d5f1f00177f70595 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Fri, 20 May 2022 10:06:28 +0200 Subject: [PATCH 039/174] NEW : hook for dol_format_address --- htdocs/core/lib/functions.lib.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e891904e39e..19fa4cd5c63 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2154,7 +2154,7 @@ function dol_bc($var, $moreclass = '') */ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs = '', $mode = 0, $extralangcode = '') { - global $conf, $langs; + global $conf, $langs, $hookmanager; $ret = ''; $countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS @@ -2220,6 +2220,14 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs $langs->load("dict"); $ret .= (empty($object->country_code) ? '' : ($ret ? $sep : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code))); } + if ($hookmanager) { + $parameters = array('withcountry' => $withcountry, 'sep' => $sep, 'outputlangs' => $outputlangs,'mode' => $mode, 'extralangcode' => $extralangcode); + $reshook = $hookmanager->executeHooks('formatAddress', $parameters, $object); + if ($reshook > 0) { + $ret = ''; + } + $ret .= $hookmanager->resPrint; + } return $ret; } From 1452e74431ae7eb87fbace7c19a914414bcbff74 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Fri, 20 May 2022 19:01:25 +0200 Subject: [PATCH 040/174] Fix sanitize --- htdocs/core/tpl/extrafields_list_search_sql.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php index 418ecd85522..0c3d98f03a6 100644 --- a/htdocs/core/tpl/extrafields_list_search_sql.tpl.php +++ b/htdocs/core/tpl/extrafields_list_search_sql.tpl.php @@ -65,8 +65,8 @@ if (!empty($extrafieldsobjectkey) && !empty($search_array_options) && is_array($ if (is_array($crit)) { $crit = implode(' ', $crit); // natural_search() expects a string } elseif ($typ === 'select' and is_string($crit) and strpos($crit, ',') === false) { - $critSelect = implode("','", array_map(array($db, 'escape'), explode(',', $crit))); - $sql .= " AND (".$extrafieldsobjectprefix.$tmpkey." IN ('".$critSelect."') )"; + $critSelect = "'".implode("','", array_map(array($db, 'escape'), explode(',', $crit)))."'"; + $sql .= " AND (".$extrafieldsobjectprefix.$tmpkey." IN (".$db->sanitize($critSelect, 1).") )"; continue; } $sql .= natural_search($extrafieldsobjectprefix.$tmpkey, $crit, $mode_search); From bba6a917cb5469216a47be1de36bde8520b969ad Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 20 May 2022 23:21:08 +0200 Subject: [PATCH 041/174] Fix missing const in recruitment module --- htdocs/core/modules/modRecruitment.class.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/htdocs/core/modules/modRecruitment.class.php b/htdocs/core/modules/modRecruitment.class.php index 6da69ed888d..a1a2f7774aa 100644 --- a/htdocs/core/modules/modRecruitment.class.php +++ b/htdocs/core/modules/modRecruitment.class.php @@ -134,9 +134,20 @@ class modRecruitment extends DolibarrModules // Example: $this->const=array(1 => array('RECRUITMENT_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1), // 2 => array('RECRUITMENT_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1) // ); - $this->const = array( - // 1 => array('RECRUITMENT_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) - ); + $r = 0; + $this->const[$r][0] = "RECRUITMENT_RECRUITMENTJOBPOSITION_ADDON"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "mod_recruitmentjobposition_standard"; + $this->const[$r][3] = 'Name of manager to generate recruitment job position ref number'; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "RECRUITMENT_RECRUITMENTCANDIDATURE_ADDON"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "mod_recruitmentcandidature_standard"; + $this->const[$r][3] = 'Name of manager to generate recruitment candidature ref number'; + $this->const[$r][4] = 0; + $r++; // Some keys to add into the overwriting translation tables /*$this->overwrite_translation = array( From 8231a9ea0fab852d3c9268c29a97833d7f3f49f2 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 20 May 2022 23:29:35 +0200 Subject: [PATCH 042/174] Fix wrong right test to show button --- htdocs/expensereport/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 07d3e018390..acd6a60f0f9 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -2648,7 +2648,7 @@ if ($action != 'create' && $action != 'edit') } // If bank module is not used - if (($user->rights->expensereport->to_paid || empty($conf->banque->enabled)) && $object->status == ExpenseReport::STATUS_APPROVED) + if (($user->rights->expensereport->to_paid && empty($conf->banque->enabled)) && $object->status == ExpenseReport::STATUS_APPROVED) { //if ((round($remaintopay) == 0 || empty($conf->banque->enabled)) && $object->paid == 0) if ($object->paid == 0) From 755bce9fe1186070e13913feb7d25cdac513f0f2 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 21 May 2022 00:22:47 +0200 Subject: [PATCH 043/174] Fix : date_creation must have visible=-2 --- htdocs/commande/class/commande.class.php | 2 +- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- htdocs/mrp/class/mo.class.php | 2 +- htdocs/recruitment/class/recruitmentjobposition.class.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f51c8026672..728e0f62ede 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -347,7 +347,7 @@ class Commande extends CommonOrder 'pos_source' =>array('type'=>'varchar(32)', 'label'=>'POSTerminal', 'enabled'=>1, 'visible'=>-1, 'position'=>280), 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-1, 'position'=>300), 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>302), - 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>304), + 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>304), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>306), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>400), 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Status', 'enabled'=>1, 'visible'=>-1, 'position'=>500), diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index a20075295d9..ce1fffba01e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -195,7 +195,7 @@ class CommandeFournisseur extends CommonOrder 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>35), 'ref_supplier' =>array('type'=>'varchar(255)', 'label'=>'RefSupplier', 'enabled'=>1, 'visible'=>-1, 'position'=>40), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>45), - 'date_creation' =>array('type'=>'datetime', 'label'=>'Date creation', 'enabled'=>1, 'visible'=>-1, 'position'=>50), + 'date_creation' =>array('type'=>'datetime', 'label'=>'Date creation', 'enabled'=>1, 'visible'=>-2, 'position'=>50), 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>55), 'date_approve' =>array('type'=>'datetime', 'label'=>'Date approve', 'enabled'=>1, 'visible'=>-1, 'position'=>60), 'date_approve2' =>array('type'=>'datetime', 'label'=>'Date approve2', 'enabled'=>1, 'visible'=>-1, 'position'=>65), diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 6f7dfd2260b..92cb819aab3 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -1435,7 +1435,7 @@ class MoLine extends CommonObjectLine 'role' =>array('type'=>'varchar(10)', 'label'=>'Role', 'enabled'=>1, 'visible'=>-1, 'position'=>145), 'fk_mrp_production' =>array('type'=>'integer', 'label'=>'Fk mrp production', 'enabled'=>1, 'visible'=>-1, 'position'=>150), 'fk_stock_movement' =>array('type'=>'integer', 'label'=>'StockMovement', 'enabled'=>1, 'visible'=>-1, 'position'=>155), - 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>160), + 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>160), 'tms' =>array('type'=>'timestamp', 'label'=>'Tms', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>165), 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserCreation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>170), 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModification', 'enabled'=>1, 'visible'=>-1, 'position'=>175), diff --git a/htdocs/recruitment/class/recruitmentjobposition.class.php b/htdocs/recruitment/class/recruitmentjobposition.class.php index 3b52e5b4fa6..2edd752786b 100644 --- a/htdocs/recruitment/class/recruitmentjobposition.class.php +++ b/htdocs/recruitment/class/recruitmentjobposition.class.php @@ -115,7 +115,7 @@ class RecruitmentJobPosition extends CommonObject 'description' => array('type'=>'html', 'label'=>'Description', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>3,), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>101, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>102, 'notnull'=>0, 'visible'=>0,), - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-4,), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,), 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',), 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), From 0d7386ab896e51778a5396ad6e04e566e57dbffd Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 21 May 2022 01:23:39 +0200 Subject: [PATCH 044/174] Fix select projet on event creation --- htdocs/comm/action/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index aa513e07794..02f52de7388 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1237,7 +1237,7 @@ if ($action == 'create') { print ''.$langs->trans("Project").''; print img_picto('', 'project', 'class="pictofixedwidth"'); - print $formproject->select_projects((empty($societe->id) ? '' : $societe->id), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); + print $formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx'); print ' '; print ''; From c12ae28ad725c974cfeba9f3f305520d58622c15 Mon Sep 17 00:00:00 2001 From: IC-Ilies Date: Sat, 21 May 2022 09:31:33 +0200 Subject: [PATCH 045/174] FIX#20448 missing preg_replace for vat rate when adding a free line --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 54e64c73f99..b40092abfaa 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -838,7 +838,7 @@ if (empty($reshook)) { $prod_entry_mode = GETPOST('prod_entry_mode'); if ($prod_entry_mode == 'free') { $idprod = 0; - $tva_tx = (GETPOST('tva_tx') ? price2num(GETPOST('tva_tx')) : 0); + $tva_tx = (GETPOST('tva_tx') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx'))) : 0); } else { $idprod = GETPOST('idprod', 'int'); $tva_tx = ''; From 11da45646ed6ea5281da55f73680c3c3101efd80 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sat, 21 May 2022 15:30:52 +0200 Subject: [PATCH 046/174] FIX signature online with proposal with n page. --- htdocs/core/ajax/onlineSign.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php index ce9ae57864d..994ba5c42f3 100644 --- a/htdocs/core/ajax/onlineSign.php +++ b/htdocs/core/ajax/onlineSign.php @@ -129,8 +129,12 @@ if ($action == "importSignature") { $pdf->AddPage(); $pagecount = $pdf->setSourceFile($upload_dir.$ref.".pdf"); // original PDF - $tppl = $pdf->importPage(1); - $pdf->useTemplate($tppl); + for ($i=1;$i<($pagecount+1);$i++) { + if ($i>1) $pdf->AddPage(); + $tppl=$pdf->importPage($i); + $pdf->useTemplate($tppl); + } + $pdf->Image($upload_dir.$filename, 129, 239.6, 60, 15); // FIXME Position will be wrong with non A4 format. Use a value from width and height of page minus relative offset. $pdf->Close(); $pdf->Output($newpdffilename, "F"); From 4c10ef8f4c913cca2c16b3be2cfda25c5687ea22 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 21 May 2022 15:36:04 +0200 Subject: [PATCH 047/174] Fix labels in tickets widgets --- htdocs/core/boxes/box_graph_nb_tickets_type.php | 2 +- htdocs/core/boxes/box_graph_ticket_by_severity.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_graph_nb_tickets_type.php b/htdocs/core/boxes/box_graph_nb_tickets_type.php index 2da54d84e7a..f4efce23797 100644 --- a/htdocs/core/boxes/box_graph_nb_tickets_type.php +++ b/htdocs/core/boxes/box_graph_nb_tickets_type.php @@ -131,7 +131,7 @@ class box_graph_nb_tickets_type extends ModeleBoxes } foreach ($listofoppcode as $rowid => $code) { $dataseries[] = array( - 'label' => $langs->getLabelFromKey($this->db, 'TicketTypeShort' . $code, 'c_ticket_category', 'code', 'label', $code), + 'label' => $langs->getLabelFromKey($this->db, 'TicketTypeShort' . $code, 'c_ticket_type', 'code', 'label', $code), 'data' => (empty($data[$code]) ? 0 : $data[$code]) ); } diff --git a/htdocs/core/boxes/box_graph_ticket_by_severity.php b/htdocs/core/boxes/box_graph_ticket_by_severity.php index 13cd0c40c86..a7fa571b6c7 100644 --- a/htdocs/core/boxes/box_graph_ticket_by_severity.php +++ b/htdocs/core/boxes/box_graph_ticket_by_severity.php @@ -152,7 +152,7 @@ class box_graph_ticket_by_severity extends ModeleBoxes } foreach ($listofoppcode as $rowid => $code) { $dataseries[] = array( - 'label' => $langs->getLabelFromKey($this->db, 'TicketSeverityShort' . $code, 'c_ticket_category', 'code', 'label', $code), + 'label' => $langs->getLabelFromKey($this->db, 'TicketSeverityShort' . $code, 'c_ticket_severity', 'code', 'label', $code), 'data' => (empty($data[$code]) ? 0 : $data[$code]) ); } From 4932f86a2d2f5cc04d065417cc5eccdff7eb4899 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 21 May 2022 15:41:34 +0200 Subject: [PATCH 048/174] Fix default value for boolean extrafield --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 02421ea9157..14c91ccd19a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7518,7 +7518,7 @@ abstract class CommonObject } // HTML, text, select, integer and varchar: take into account default value in database if in create mode - if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('html', 'text', 'varchar', 'select', 'int'))) { + if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('html', 'text', 'varchar', 'select', 'int', 'boolean'))) { if ($action == 'create') { $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) || $value) ? $value : $extrafields->attributes[$this->table_element]['default'][$key]; } From 9b2a54317090025c0dc5151b0f12c25a1abd46ef Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 21 May 2022 15:49:27 +0200 Subject: [PATCH 049/174] Fix phpcs too long line --- htdocs/core/class/commonobject.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 14c91ccd19a..a706583c7cc 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7503,14 +7503,16 @@ abstract class CommonObject if (!is_numeric($this->array_options['options_'.$key])) { // For backward compatibility $datenotinstring = $this->db->jdate($datenotinstring); } - $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) ? dol_mktime(12, 0, 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring; + $datekey = $keyprefix.'options_'.$key.$keysuffix; + $value = (GETPOSTISSET($datekey)) ? dol_mktime(12, 0, 0, GETPOST($datekey.'month', 'int', 3), GETPOST($datekey.'day', 'int', 3), GETPOST($datekey.'year', 'int', 3)) : $datenotinstring; } if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('datetime'))) { $datenotinstring = $this->array_options['options_'.$key]; if (!is_numeric($this->array_options['options_'.$key])) { // For backward compatibility $datenotinstring = $this->db->jdate($datenotinstring); } - $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) ? dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."sec", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3), 'tzuserrel') : $datenotinstring; + $timekey = $keyprefix.'options_'.$key.$keysuffix; + $value = (GETPOSTISSET($timekey)) ? dol_mktime(GETPOST($timekey.'hour', 'int', 3), GETPOST($timekey.'min', 'int', 3), GETPOST($timekey.'sec', 'int', 3), GETPOST($timekey.'month', 'int', 3), GETPOST($timekey.'day', 'int', 3), GETPOST($timekey.'year', 'int', 3), 'tzuserrel') : $datenotinstring; } // Convert float submited string into real php numeric (value in memory must be a php numeric) if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('price', 'double'))) { From 1b6e0a9fc0f05d5f6711a014218c9da039bb3584 Mon Sep 17 00:00:00 2001 From: IC-Ilies Date: Sat, 21 May 2022 16:25:47 +0200 Subject: [PATCH 050/174] FIX#20886 : manage durations in list_print_total.tpl.php --- htdocs/core/tpl/list_print_total.tpl.php | 9 ++++++++- htdocs/fichinter/list.php | 7 ++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php index 929ea2df50f..c103970a26d 100644 --- a/htdocs/core/tpl/list_print_total.tpl.php +++ b/htdocs/core/tpl/list_print_total.tpl.php @@ -13,7 +13,14 @@ if (isset($totalarray['pos'])) { while ($i < $totalarray['nbfield']) { $i++; if (!empty($totalarray['pos'][$i])) { - print ''.price(!empty($totalarray['val'][$totalarray['pos'][$i]])?$totalarray['val'][$totalarray['pos'][$i]]:0).''; + if(!empty($totalarray['type'][$i])){ + if($totalarray['type'][$i] == 'duration'){ + print ''.(!empty($totalarray['val'][$totalarray['pos'][$i]])? convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]]): '00:00').''; + } + } + else { + print '' . price(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : 0) . ''; + } } else { if ($i == 1) { if (is_null($limit) || $num < $limit) { diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index d710d7cd6cc..08c35e2b002 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -132,7 +132,7 @@ $arrayfields = array( 'f.fk_statut'=>array('label'=>'Status', 'checked'=>1, 'position'=>1000), 'fd.description'=>array('label'=>"DescriptionOfLine", 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0), 'fd.date'=>array('label'=>'DateOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0), - 'fd.duree'=>array('label'=>'DurationOfLine', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0), + 'fd.duree'=>array('label'=>'DurationOfLine', 'type'=> 'duration', 'checked'=>1, 'enabled'=>empty($conf->global->FICHINTER_DISABLE_DETAILS) ? 1 : 0), //type duration is here because in database, column 'duree' is double ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -737,9 +737,8 @@ if ($resql) { print ''.convertSecondToTime($obj->duree, 'allhourmin').''; if (!$i) { $totalarray['nbfield']++; - } - if (!$i) { $totalarray['pos'][$totalarray['nbfield']] = 'fd.duree'; + $totalarray['type'][$totalarray['nbfield']] = $arrayfields['fd.duree']['type']; //pass the type for the list_print_total.tpl.php to manage durations } $totalarray['val']['fd.duree'] += $obj->duree; } @@ -763,6 +762,8 @@ if ($resql) { $i++; } + + // Show total line include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; From 3fc8adf13e8ea19aa3e7463ce87675a856b772dc Mon Sep 17 00:00:00 2001 From: Sylvain Legrand Date: Sat, 21 May 2022 16:42:27 +0200 Subject: [PATCH 051/174] missing MULTI CURRENCY on recurrent invoices #20664 --- htdocs/compta/facture/class/facture-rec.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 047a66a78b9..17facd188e3 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1310,6 +1310,11 @@ class FactureRec extends CommonInvoice $facture->status = self::STATUS_DRAFT; $facture->date = (empty($facturerec->date_when) ? $now : $facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. $facture->socid = $facturerec->socid; + if (!empty($facturerec->fk_multicurrency)){ + $facture->fk_multicurrency = $facturerec->fk_multicurrency; + $facture->multicurrency_code = $facturerec->multicurrency_code; + $facture->multicurrency_tx = $facturerec->multicurrency_tx; + } $invoiceidgenerated = $facture->create($user); if ($invoiceidgenerated <= 0) { From bd42680e2ca5c3c4e3fd9778801f83959680c75e Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 21 May 2022 14:43:30 +0000 Subject: [PATCH 052/174] Fixing style errors. --- htdocs/compta/facture/class/facture-rec.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 17facd188e3..63c2a1c687b 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1310,7 +1310,7 @@ class FactureRec extends CommonInvoice $facture->status = self::STATUS_DRAFT; $facture->date = (empty($facturerec->date_when) ? $now : $facturerec->date_when); // We could also use dol_now here but we prefer date_when so invoice has real date when we would like even if we generate later. $facture->socid = $facturerec->socid; - if (!empty($facturerec->fk_multicurrency)){ + if (!empty($facturerec->fk_multicurrency)) { $facture->fk_multicurrency = $facturerec->fk_multicurrency; $facture->multicurrency_code = $facturerec->multicurrency_code; $facture->multicurrency_tx = $facturerec->multicurrency_tx; From d8a68d280ee197729dfc700acf05d9d1f301e0a5 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Sat, 21 May 2022 17:06:36 +0200 Subject: [PATCH 053/174] FIX missing morecss for multiselectarray --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 02421ea9157..bbca87fe125 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6760,7 +6760,7 @@ abstract class CommonObject $out .= ''; } elseif ($type == 'checkbox') { $value_arr = explode(',', $value); - $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, '', 0, '100%'); + $out = $form->multiselectarray($keyprefix.$key.$keysuffix, (empty($param['options']) ?null:$param['options']), $value_arr, '', 0, $morecss, 0, '100%'); } elseif ($type == 'radio') { $out = ''; foreach ($param['options'] as $keyopt => $val) { From 9ea12664f72e9bed6b5ebf614ea99fa1cf2c2f16 Mon Sep 17 00:00:00 2001 From: IC-Ilies Date: Sat, 21 May 2022 17:14:26 +0200 Subject: [PATCH 054/174] FIX #20487 missing letter D in constant THIRDPARTIES_DISABLE_RELATED_OBJECT_TAB --- htdocs/core/lib/company.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index e98a25ddbee..6b3ced3e621 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -188,7 +188,7 @@ function societe_prepare_head(Societe $object) // Related items if ((!empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->facture->enabled) || !empty($conf->ficheinter->enabled) || (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) - && empty($conf->global->THIRPARTIES_DISABLE_RELATED_OBJECT_TAB)) { + && empty($conf->global->THIRDPARTIES_DISABLE_RELATED_OBJECT_TAB)) { $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; $head[$h][1] = $langs->trans("Referers"); $head[$h][2] = 'consumption'; From f9ff16c6f3723bff44c3da61417a62cf02a9be4a Mon Sep 17 00:00:00 2001 From: IC-Ilies Date: Sat, 21 May 2022 17:33:03 +0200 Subject: [PATCH 055/174] fix psr2 --- htdocs/core/tpl/list_print_total.tpl.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php index c103970a26d..09768f71ae4 100644 --- a/htdocs/core/tpl/list_print_total.tpl.php +++ b/htdocs/core/tpl/list_print_total.tpl.php @@ -13,12 +13,11 @@ if (isset($totalarray['pos'])) { while ($i < $totalarray['nbfield']) { $i++; if (!empty($totalarray['pos'][$i])) { - if(!empty($totalarray['type'][$i])){ - if($totalarray['type'][$i] == 'duration'){ + if (!empty($totalarray['type'][$i])) { + if ($totalarray['type'][$i] == 'duration') { print ''.(!empty($totalarray['val'][$totalarray['pos'][$i]])? convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]]): '00:00').''; } - } - else { + } else { print '' . price(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : 0) . ''; } } else { From bc77a2697602921440b4efe90b56166ca1ec5e94 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Sat, 21 May 2022 23:24:03 +0200 Subject: [PATCH 056/174] New : dol_move_dir --- htdocs/core/lib/files.lib.php | 63 +++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 4e972b0be4e..b310eafd308 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -964,6 +964,69 @@ function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $te return $result; } +/** + * Move a directory into another name. + * + * @param string $srcdir Source directory + * @param string $destdir Destination directory + * @param int $overwriteifexists Overwrite directory if exists (1 by default) + * @param int $indexdatabase Index new file into database. + * @param int $renamedircontent Rename contents inside srcdir. + * + * @return boolean True if OK, false if KO +*/ +function dol_move_dir($srcdir, $destdir, $overwriteifexists = 1, $indexdatabase = 1, $renamedircontent = 1) +{ + + global $user, $db, $conf; + $result = false; + + dol_syslog("files.lib.php::dol_dir_move srcdir=".$srcdir." destdir=".$destdir." overwritifexists=".$overwriteifexists); + $srcexists = dol_is_dir($srcdir); + $srcbasename = basename($srcdir); + $destexists = dol_is_dir($destdir); + + if (!$srcexists) { + dol_syslog("files.lib.php::dol_dir_move srcdir does not exists. we ignore the move request."); + return false; + } + + if ($overwriteifexists || !$destexists) { + $newpathofsrcdir = dol_osencode($srcdir); + $newpathofdestdir = dol_osencode($destdir); + + $result = @rename($newpathofsrcdir, $newpathofdestdir); + + if ($result && $renamedircontent) { + if (file_exists($newpathofdestdir)) { + $destbasename = basename($newpathofdestdir); + $files = dol_dir_list($newpathofdestdir); + if (!empty($files) && is_array($files)) { + foreach ($files as $key => $file) { + if (!file_exists($file["fullname"])) continue; + $oldpath = $file["fullname"]; + + $newpath = str_replace($srcbasename, $destbasename, $oldpath); + if (!empty($newpath)) { + if (dol_is_dir($oldpath)) { + $res = dol_move_dir($oldpath, $newpath, $overwriteifexists, $indexdatabase, $renamedircontent); + } else { + $res = dol_move($oldpath, $newpath); + } + if (!$res) { + return $result; + } + } + } + $result = true; + } + } + } + } + + return $result; +} + /** * Unescape a file submitted by upload. * PHP escape char " (%22) or char ' (%27) into $FILES. From dbf66988a6ab79198f5109191eb79d8da215caa9 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Sat, 21 May 2022 23:24:18 +0200 Subject: [PATCH 057/174] fix style errors --- 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 b310eafd308..7b0aa332ccb 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -972,7 +972,7 @@ function dol_move($srcfile, $destfile, $newmask = 0, $overwriteifexists = 1, $te * @param int $overwriteifexists Overwrite directory if exists (1 by default) * @param int $indexdatabase Index new file into database. * @param int $renamedircontent Rename contents inside srcdir. - * + * * @return boolean True if OK, false if KO */ function dol_move_dir($srcdir, $destdir, $overwriteifexists = 1, $indexdatabase = 1, $renamedircontent = 1) From bf39a259baf5ee0a40f47ae4c6bbcd6eca1b3737 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 22 May 2022 00:05:03 +0200 Subject: [PATCH 058/174] Fix PDF watermark over PDF text --- htdocs/core/lib/pdf.lib.php | 11 +++++++++-- .../commande/doc/pdf_einstein.modules.php | 13 +++++++------ .../commande/doc/pdf_eratosthene.modules.php | 13 +++++++------ .../expedition/doc/pdf_espadon.modules.php | 14 ++++++++------ .../expedition/doc/pdf_rouget.modules.php | 14 ++++++++------ .../modules/facture/doc/pdf_crabe.modules.php | 13 +++++++------ .../modules/facture/doc/pdf_sponge.modules.php | 13 +++++++------ .../modules/fichinter/doc/pdf_soleil.modules.php | 13 +++++++------ .../modules/propale/doc/pdf_azur.modules.php | 13 +++++++------ .../modules/propale/doc/pdf_cyan.modules.php | 13 +++++++------ .../reception/doc/pdf_squille.modules.php | 16 +++++++++------- .../supplier_proposal/doc/pdf_aurore.modules.php | 15 ++++++++------- 12 files changed, 91 insertions(+), 70 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index ea8c6c2ce23..eff818fe01d 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -973,13 +973,15 @@ function pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber = 0, * @param Societe $fromcompany Object company * @param int $marge_basse Margin bottom we use for the autobreak * @param int $marge_gauche Margin left (no more used) - * @param int $page_hauteur Page height (no more used) + * @param int $page_hauteur Page height * @param Object $object Object shown in PDF * @param int $showdetails Show company adress details into footer (0=Nothing, 1=Show address, 2=Show managers, 3=Both) * @param int $hidefreetext 1=Hide free text, 0=Show free text + * @param int $page_largeur Page width + * @param int $watermark Watermark text to print on page * @return int Return height of bottom margin including footer text */ -function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails = 0, $hidefreetext = 0) +function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails = 0, $hidefreetext = 0, $page_largeur = 0, $watermark = '') { global $conf, $user, $mysoc, $hookmanager; @@ -1232,6 +1234,11 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $pdf->MultiCell(15, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); } + // Show Draft Watermark + if (!empty($watermark)) { + pdf_watermark($pdf, $outputlangs, $page_hauteur, $page_largeur, 'mm', $watermark); + } + return $marginwithfooter; } diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index db961962ba6..27d4fc9870e 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -164,6 +164,7 @@ class pdf_einstein extends ModelePDFCommandes $this->option_credit_note = 0; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->watermark = ''; // Get source company $this->emetteur = $mysoc; @@ -236,6 +237,11 @@ class pdf_einstein extends ModelePDFCommandes // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); + // Show Draft Watermark + if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { + $this->watermark = $conf->global->COMMANDE_DRAFT_WATERMARK; + } + global $outputlangsbis; $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { @@ -1282,11 +1288,6 @@ class pdf_einstein extends ModelePDFCommandes pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); - // Show Draft Watermark - if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK); - } - $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -1531,6 +1532,6 @@ class pdf_einstein extends ModelePDFCommandes // phpcs:enable global $conf; $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + return pdf_pagefoot($pdf, $outputlangs, 'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); } } diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 560344a9eeb..161c3c60345 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -169,6 +169,7 @@ class pdf_eratosthene extends ModelePDFCommandes $this->option_credit_note = 0; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->watermark = ''; // Get source company $this->emetteur = $mysoc; @@ -220,6 +221,11 @@ class pdf_eratosthene extends ModelePDFCommandes // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); + // Show Draft Watermark + if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { + $this->watermark = $conf->global->COMMANDE_DRAFT_WATERMARK; + } + global $outputlangsbis; $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { @@ -1449,11 +1455,6 @@ class pdf_eratosthene extends ModelePDFCommandes pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); - // Show Draft Watermark - if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK); - } - $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -1716,7 +1717,7 @@ class pdf_eratosthene extends ModelePDFCommandes // phpcs:enable global $conf; $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + return pdf_pagefoot($pdf, $outputlangs, 'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); } diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index efc061b9e67..00fa6bbbdc5 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -140,6 +140,8 @@ class pdf_espadon extends ModelePdfExpedition $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; $this->option_logo = 1; // Display logo + $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->watermark = ''; // Get source company $this->emetteur = $mysoc; @@ -180,6 +182,11 @@ class pdf_espadon extends ModelePdfExpedition // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "orders", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); + // Show Draft Watermark + if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) { + $this->watermark = $conf->global->SHIPPING_DRAFT_WATERMARK; + } + global $outputlangsbis; $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { @@ -947,11 +954,6 @@ class pdf_espadon extends ModelePdfExpedition pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); - // Show Draft Watermark - if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK); - } - //Prepare next $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -1186,7 +1188,7 @@ class pdf_espadon extends ModelePdfExpedition { global $conf; $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); } /** diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 211231b9812..6b5d2e6fc3d 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -141,6 +141,8 @@ class pdf_rouget extends ModelePdfExpedition $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; $this->option_logo = 1; // Display logo + $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->watermark = ''; // Get source company $this->emetteur = $mysoc; @@ -214,6 +216,11 @@ class pdf_rouget extends ModelePdfExpedition // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); + // Show Draft Watermark + if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) { + $this->watermark = $conf->global->SHIPPING_DRAFT_WATERMARK; + } + $nblines = count($object->lines); // Loop on each lines to detect if there is at least one image to show @@ -892,11 +899,6 @@ class pdf_rouget extends ModelePdfExpedition pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); - // Show Draft Watermark - if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK); - } - //Prepare la suite $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -1131,6 +1133,6 @@ class pdf_rouget extends ModelePdfExpedition { global $conf; $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); } } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 8046347e881..4e5c0431170 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -170,6 +170,7 @@ class pdf_crabe extends ModelePDFFactures $this->option_credit_note = 1; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->watermark = ''; // Get source company $this->emetteur = $mysoc; @@ -249,6 +250,11 @@ class pdf_crabe extends ModelePDFFactures // Load translation files required by the page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies")); + // Show Draft Watermark + if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) { + $this->watermark = $conf->global->FACTURE_DRAFT_WATERMARK; + } + global $outputlangsbis; $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { @@ -1718,11 +1724,6 @@ class pdf_crabe extends ModelePDFFactures pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); - // Show Draft Watermark - if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK); - } - $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -2048,6 +2049,6 @@ class pdf_crabe extends ModelePDFFactures { global $conf; $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); } } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index ed11f61b74b..228b73d825a 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -171,6 +171,7 @@ class pdf_sponge extends ModelePDFFactures $this->option_credit_note = 1; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->watermark = ''; // Get source company $this->emetteur = $mysoc; @@ -234,6 +235,11 @@ class pdf_sponge extends ModelePDFFactures $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies")); } + // Show Draft Watermark + if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) { + $this->watermark = $conf->global->FACTURE_DRAFT_WATERMARK; + } + $nblines = count($object->lines); $hidetop = 0; @@ -1944,11 +1950,6 @@ class pdf_sponge extends ModelePDFFactures pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); - // Show Draft Watermark - if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK); - } - $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -2274,7 +2275,7 @@ class pdf_sponge extends ModelePDFFactures { global $conf; $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); } /** diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 719fb670672..bc2b75e219e 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -149,6 +149,7 @@ class pdf_soleil extends ModelePDFFicheinter $this->option_codeproduitservice = 0; // Display product-service code $this->option_multilang = 1; // Available in several languages $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->watermark = ''; // Get source company $this->emetteur = $mysoc; @@ -188,6 +189,11 @@ class pdf_soleil extends ModelePDFFicheinter // Load traductions files required by page $outputlangs->loadLangs(array("main", "interventions", "dict", "companies")); + // Show Draft Watermark + if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->FICHINTER_DRAFT_WATERMARK))) { + $this->watermark = $conf->global->FICHINTER_DRAFT_WATERMARK; + } + if ($conf->ficheinter->dir_output) { $object->fetch_thirdparty(); @@ -561,11 +567,6 @@ class pdf_soleil extends ModelePDFFicheinter pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); - //Affiche le filigrane brouillon - Print Draft Watermark - if ($object->statut == 0 && (!empty($conf->global->FICHINTER_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FICHINTER_DRAFT_WATERMARK); - } - //Prepare next $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -732,6 +733,6 @@ class pdf_soleil extends ModelePDFFicheinter { global $conf; $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'FICHINTER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + return pdf_pagefoot($pdf, $outputlangs, 'FICHINTER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); } } diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 0e30ec96e44..6e89c17cb2c 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -160,6 +160,7 @@ class pdf_azur extends ModelePDFPropales $this->option_credit_note = 0; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->watermark = ''; // Get source company $this->emetteur = $mysoc; @@ -242,6 +243,11 @@ class pdf_azur extends ModelePDFPropales $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal")); } + // Show Draft Watermark + if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->PROPALE_DRAFT_WATERMARK))) { + $this->watermark = $conf->global->PROPALE_DRAFT_WATERMARK; + } + $nblines = count($object->lines); // Loop on each lines to detect if there is at least one image to show @@ -1466,11 +1472,6 @@ class pdf_azur extends ModelePDFPropales pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); - // Show Draft Watermark - if ($object->statut == 0 && (!empty($conf->global->PROPALE_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK); - } - $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -1715,7 +1716,7 @@ class pdf_azur extends ModelePDFPropales { global $conf; $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 7f78f86ba07..50061cacd0a 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -163,6 +163,7 @@ class pdf_cyan extends ModelePDFPropales $this->option_credit_note = 0; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->watermark = ''; // Get source company $this->emetteur = $mysoc; @@ -216,6 +217,11 @@ class pdf_cyan extends ModelePDFPropales // Load translation files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal")); + // Show Draft Watermark + if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->PROPALE_DRAFT_WATERMARK))) { + $this->watermark = $conf->global->PROPALE_DRAFT_WATERMARK; + } + global $outputlangsbis; $outputlangsbis = null; if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { @@ -1538,11 +1544,6 @@ class pdf_cyan extends ModelePDFPropales pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); - // Show Draft Watermark - if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->PROPALE_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK); - } - $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -1804,7 +1805,7 @@ class pdf_cyan extends ModelePDFPropales { global $conf; $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); } /** diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 44ca37eb070..c51209fa6c8 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -63,6 +63,8 @@ class pdf_squille extends ModelePdfReception $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; $this->option_logo = 1; // Display logo + $this->option_draft_watermark = 1; // Support add of a watermark on drafts + $this->watermark = ''; // Get source company $this->emetteur = $mysoc; @@ -105,7 +107,7 @@ class pdf_squille extends ModelePdfReception /** * Function to build pdf onto disk * - * @param Object $object Object reception to generate (or id if old method) + * @param Reception $object Object reception to generate (or id if old method) * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details @@ -130,6 +132,11 @@ class pdf_squille extends ModelePdfReception $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal", "deliveries", "receptions", "productbatch", "sendings")); + // Show Draft Watermark + if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->RECEPTION_DRAFT_WATERMARK))) { + $this->watermark = $conf->global->RECEPTION_DRAFT_WATERMARK; + } + $nblines = count($object->lines); // Loop on each lines to detect if there is at least one image to show @@ -817,11 +824,6 @@ class pdf_squille extends ModelePdfReception pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); - // Show Draft Watermark - if ($object->statut == 0 && (!empty($conf->global->RECEPTION_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->RECEPTION_DRAFT_WATERMARK); - } - //Prepare la suite $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -1055,6 +1057,6 @@ class pdf_squille extends ModelePdfReception { global $conf; $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'RECEPTION_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + return pdf_pagefoot($pdf, $outputlangs, 'RECEPTION_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); } } diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 60b3e6b4922..362d831f3af 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -155,6 +155,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->option_credit_note = 1; // Support credit notes $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; //Support add of a watermark on drafts + $this->watermark = ''; // Get source company $this->emetteur = $mysoc; @@ -205,7 +206,7 @@ class pdf_aurore extends ModelePDFSupplierProposal /** * Function to build pdf onto disk * - * @param Object $object Object to generate + * @param SupplierProposal $object Object to generate * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details @@ -229,6 +230,11 @@ class pdf_aurore extends ModelePDFSupplierProposal // Load traductions files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "supplier_proposal")); + // Show Draft Watermark + if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK))) { + $this->watermark = $conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK; + } + $nblines = count($object->lines); // Loop on each lines to detect if there is at least one image to show @@ -1284,11 +1290,6 @@ class pdf_aurore extends ModelePDFSupplierProposal pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); - // Show Draft Watermark - if ($object->statut == 0 && (!empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK); - } - $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -1496,6 +1497,6 @@ class pdf_aurore extends ModelePDFSupplierProposal { global $conf; $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark); } } From e5c38572d196bb38ae0f3bedbba784f55ed2ce94 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 22 May 2022 00:23:16 +0200 Subject: [PATCH 059/174] Fix no document available on job candidature --- htdocs/core/modules/modRecruitment.class.php | 12 +++++------- .../recruitment/modules_recruitmentcandidature.php | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/core/modules/modRecruitment.class.php b/htdocs/core/modules/modRecruitment.class.php index 3d4e88872ef..41679c19a1c 100644 --- a/htdocs/core/modules/modRecruitment.class.php +++ b/htdocs/core/modules/modRecruitment.class.php @@ -423,7 +423,7 @@ class modRecruitment extends DolibarrModules $sql = array(); // Document template - $moduledir = 'mymodule'; + $moduledir = 'recruitment'; $myTmpObjects = array(); $myTmpObjects['RecruitmentJobPosition'] = array('includerefgeneration'=>1, 'includedocgeneration'=>1); @@ -431,10 +431,10 @@ class modRecruitment extends DolibarrModules if ($myTmpObjectKey == 'MyObject') { continue; } - if ($myTmpObjectArray['includerefgeneration']) { - $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt'; - $dirodt = DOL_DATA_ROOT.'/doctemplates/mymodule'; - $dest = $dirodt.'/template_myobjects.odt'; + if ($myTmpObjectArray['includedocgeneration']) { + $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/'.$moduledir.'/template_recruitmentjobposition.odt'; + $dirodt = DOL_DATA_ROOT.'/doctemplates/'.$moduledir; + $dest = $dirodt.'/template_recruitmentjobposition.odt'; if (file_exists($src) && !file_exists($dest)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -450,8 +450,6 @@ class modRecruitment extends DolibarrModules $sql = array_merge($sql, array( "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'standard_".strtolower($myTmpObjectKey)."' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".$conf->entity, "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('standard_".strtolower($myTmpObjectKey)."','".strtolower($myTmpObjectKey)."',".$conf->entity.")", - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'generic_".strtolower($myTmpObjectKey)."_odt' AND type = '".strtolower($myTmpObjectKey)."' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('generic_".strtolower($myTmpObjectKey)."_odt', '".strtolower($myTmpObjectKey)."', ".$conf->entity.")" )); } } diff --git a/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php b/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php index 84bfd30401c..089aa720fa7 100644 --- a/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php +++ b/htdocs/recruitment/core/modules/recruitment/modules_recruitmentcandidature.php @@ -51,7 +51,7 @@ abstract class ModelePDFRecruitmentCandidature extends CommonDocGenerator // phpcs:enable global $conf; - $type = 'recruitmentjobposition'; + $type = 'recruitmentjobcandidature'; $list = array(); include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; From 6131d5a2b4a0c1fc9d9a616e4041fa7744022831 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 22 May 2022 01:19:00 +0200 Subject: [PATCH 060/174] Fix scrutinizer --- htdocs/expedition/class/expedition.class.php | 63 ---------------- .../fournisseur.commande.dispatch.class.php | 7 ++ htdocs/reception/card.php | 12 ++-- htdocs/reception/class/reception.class.php | 71 +------------------ 4 files changed, 16 insertions(+), 137 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index acb54dde6f3..9035413b533 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -2069,69 +2069,6 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Update/create delivery method. - * - * @param string $id id method to activate - * - * @return void - */ - public function update_delivery_method($id = '') - { - // phpcs:enable - if ($id == '') { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)"; - $sql .= " VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; - $resql = $this->db->query($sql); - } else { - $sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET"; - $sql .= " code='".$this->db->escape($this->update['code'])."'"; - $sql .= ",libelle='".$this->db->escape($this->update['libelle'])."'"; - $sql .= ",description='".$this->db->escape($this->update['description'])."'"; - $sql .= ",tracking='".$this->db->escape($this->update['tracking'])."'"; - $sql .= " WHERE rowid=".((int) $id); - $resql = $this->db->query($sql); - } - if ($resql < 0) { - dol_print_error($this->db, ''); - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Activate delivery method. - * - * @param int $id id method to activate - * @return void - */ - public function activ_delivery_method($id) - { - // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1'; - $sql .= " WHERE rowid = ".((int) $id); - - $resql = $this->db->query($sql); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * DesActivate delivery method. - * - * @param int $id id method to desactivate - * - * @return void - */ - public function disable_delivery_method($id) - { - // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0'; - $sql .= " WHERE rowid= ".((int) $id); - - $resql = $this->db->query($sql); - } - - /** * Forge an set tracking url * diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index 2ed936ee1f6..5bfafff57b5 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -80,6 +80,13 @@ class CommandeFournisseurDispatch extends CommonObjectLine public $fk_commandefourndet; public $qty; + public $qty_asked; + + public $libelle; + public $desc; + public $tva_tx; + public $vat_src_code; + public $ref_supplier; /** * @var int ID diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index cdd82525b6e..f5ce925efc3 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -270,9 +270,9 @@ if (empty($reshook)) { $object->origin_id = $origin_id; $object->fk_project = GETPOST('projectid', 'int'); $object->weight = GETPOST('weight', 'int') == '' ? null : GETPOST('weight', 'int'); - $object->sizeH = GETPOST('sizeH', 'int') == '' ? null : GETPOST('sizeH', 'int'); - $object->sizeW = GETPOST('sizeW', 'int') == '' ? null : GETPOST('sizeW', 'int'); - $object->sizeS = GETPOST('sizeS', 'int') == '' ? null : GETPOST('sizeS', 'int'); + $object->trueHeight = GETPOST('trueHeight', 'int') == '' ? null : GETPOST('trueHeight', 'int'); + $object->trueWidth = GETPOST('trueWidth', 'int') == '' ? null : GETPOST('trueWidth', 'int'); + $object->trueDepth = GETPOST('trueDepth', 'int') == '' ? null : GETPOST('trueDepth', 'int'); $object->size_units = GETPOST('size_units', 'int'); $object->weight_units = GETPOST('weight_units', 'int'); @@ -849,9 +849,9 @@ if ($action == 'create') { // Dim print ''; print $langs->trans("Width").' x '.$langs->trans("Height").' x '.$langs->trans("Depth"); - print ' '; - print ' x '; - print ' x '; + print ' '; + print ' x '; + print ' x '; print ' '; $text = $formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units', 'int'), 0, 2); $htmltext = $langs->trans("KeepEmptyForAutoCalculation"); diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 2ff316ecb58..eea65c440e1 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -273,9 +273,9 @@ class Reception extends CommonObject $sql .= ", ".($this->shipping_method_id > 0 ? ((int) $this->shipping_method_id) : "null"); $sql .= ", '".$this->db->escape($this->tracking_number)."'"; $sql .= ", ".(is_null($this->weight) ? "NULL" : ((double) $this->weight)); - $sql .= ", ".(is_null($this->sizeS) ? "NULL" : ((double) $this->sizeS)); // TODO Should use this->trueDepth - $sql .= ", ".(is_null($this->sizeW) ? "NULL" : ((double) $this->sizeW)); // TODO Should use this->trueWidth - $sql .= ", ".(is_null($this->sizeH) ? "NULL" : ((double) $this->sizeH)); // TODO Should use this->trueHeight + $sql .= ", ".(is_null($this->trueDepth) ? "NULL" : ((double) $this->trueDepth)); + $sql .= ", ".(is_null($this->trueWidth) ? "NULL" : ((double) $this->trueWidth)); + $sql .= ", ".(is_null($this->trueHeight) ? "NULL" : ((double) $this->trueHeight)); $sql .= ", ".(is_null($this->weight_units) ? "NULL" : ((double) $this->weight_units)); $sql .= ", ".(is_null($this->size_units) ? "NULL" : ((double) $this->size_units)); $sql .= ", ".(!empty($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null"); @@ -744,7 +744,6 @@ class Reception extends CommonObject if (!empty($this->origin) && $this->origin_id > 0 && ($this->origin == 'order_supplier' || $this->origin == 'commandeFournisseur')) { if (empty($this->commandeFournisseur)) { - $this->commandeFournisseur = null; $this->fetch_origin(); if (empty($this->commandeFournisseur->lines)) { $res = $this->commandeFournisseur->fetch_lines(); @@ -1485,70 +1484,6 @@ class Reception extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Update/create delivery method. - * - * @param string $id id method to activate - * - * @return void - */ - public function update_delivery_method($id = '') - { - // phpcs:enable - if ($id == '') { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)"; - $sql .= " VALUES ('".$this->db->escape($this->update['code'])."','".$this->db->escape($this->update['libelle'])."','".$this->db->escape($this->update['description'])."','".$this->db->escape($this->update['tracking'])."')"; - $resql = $this->db->query($sql); - } else { - $sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode SET"; - $sql .= " code='".$this->db->escape($this->update['code'])."'"; - $sql .= ",libelle='".$this->db->escape($this->update['libelle'])."'"; - $sql .= ",description='".$this->db->escape($this->update['description'])."'"; - $sql .= ",tracking='".$this->db->escape($this->update['tracking'])."'"; - $sql .= " WHERE rowid=".((int) $id); - $resql = $this->db->query($sql); - } - if ($resql < 0) { - dol_print_error($this->db, ''); - } - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Activate delivery method. - * - * @param int $id id method to activate - * - * @return void - */ - public function activ_delivery_method($id) - { - // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1'; - $sql .= " WHERE rowid = ".((int) $id); - - $resql = $this->db->query($sql); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * DesActivate delivery method. - * - * @param int $id id method to desactivate - * - * @return void - */ - public function disable_delivery_method($id) - { - // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0'; - $sql .= " WHERE rowid = ".((int) $id); - - $resql = $this->db->query($sql); - } - - /** * Forge an set tracking url * From c1473b55149d6ae578a75712dded5ee7668662dc Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Sun, 22 May 2022 01:21:52 +0200 Subject: [PATCH 061/174] fix #18338: Undefined property $ficheinter --- htdocs/comm/propal/card.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index a77e242379f..bf0c63e5b11 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -121,7 +121,9 @@ $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights-> $usercancreateorder = $user->rights->commande->creer; $usercancreateinvoice = $user->rights->facture->creer; $usercancreatecontract = $user->rights->contrat->creer; -$usercancreateintervention = $user->rights->ficheinter->creer; +if ($conf->ficheinter->enabled) { + $usercancreateintervention = $user->rights->ficheinter->creer; +} $usercancreatepurchaseorder = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer); $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php From 0559cc08ac1c33cb110213578f048cff65bda16e Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 22 May 2022 01:28:27 +0200 Subject: [PATCH 062/174] Fix scrutinizer remove unused functions --- htdocs/compta/index.php | 2 - htdocs/core/lib/invoice.lib.php | 240 -------------------------------- 2 files changed, 242 deletions(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 207f806dc74..8cef74e4fc7 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -102,11 +102,9 @@ print load_fiche_titre($langs->trans("AccountancyTreasuryArea"), '', 'bill'); print '
'; -//print getCustomerInvoicePieChart($socid); print getNumberInvoicesPieChart('customers'); print '
'; print getNumberInvoicesPieChart('fourn'); -//print getPurchaseInvoicePieChart($socid); print '
'; print getCustomerInvoiceDraftTable($max, $socid); print '
'; diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index 7c24d17d61e..786483e257b 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -245,246 +245,6 @@ function supplier_invoice_rec_prepare_head($object) return $head; } -/** - * Return a HTML table that contains a pie chart of customer invoices - * - * @param int $socid (Optional) Show only results from the customer with this id - * @return string A HTML table that contains a pie chart of customer invoices - */ -function getCustomerInvoicePieChart($socid = 0) -{ - global $conf, $db, $langs, $user; - - if (empty($conf->facture->enabled) || empty($user->rights->facture->lire)) { - return ''; - } - - $sql = "SELECT count(f.rowid), f.fk_statut"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."facture as f"; - if (empty($user->rights->societe->client->voir) && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } - $sql .= " WHERE f.fk_soc = s.rowid"; - $sql .= " AND f.entity IN (".getEntity('facture').")"; - if ($user->socid) { - $sql .= ' AND f.fk_soc = '.((int) $user->socid); - } - if (empty($user->rights->societe->client->voir) && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - $sql .= " GROUP BY f.fk_statut"; - - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - return ''; - } - - $num = $db->num_rows($resql); - $i = 0; - - $total = 0; - $vals = array(); - - while ($i < $num) { - $row = $db->fetch_row($resql); - if ($row) { - $vals[$row[1]] = $row[0]; - $total += $row[0]; - } - - $i++; - } - - $db->free($resql); - - include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - - $result = '
'; - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - - $objectstatic = new Facture($db); - $array = array(Facture::STATUS_DRAFT, Facture::STATUS_VALIDATED, Facture::STATUS_CLOSED, Facture::STATUS_ABANDONED); - $dataseries = array(); - - foreach ($array as $status) { - $objectstatic->statut = $status; - $objectstatic->paye = $status == Facture::STATUS_CLOSED ? -1 : 0; - - $dataseries[] = array($objectstatic->getLibStatut(1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if ($status == Facture::STATUS_DRAFT) { - $colorseries[$status] = '-'.$badgeStatus0; - } - if ($status == Facture::STATUS_VALIDATED) { - $colorseries[$status] = $badgeStatus1; - } - if ($status == Facture::STATUS_CLOSED) { - $colorseries[$status] = $badgeStatus9; - } - if ($status == Facture::STATUS_ABANDONED) { - $colorseries[$status] = $badgeStatus6; - } - - if (!$conf->use_javascript_ajax) { - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - } - } - - if ($conf->use_javascript_ajax) { - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(['pie']); - $dolgraph->setHeight('150'); - $dolgraph->setWidth('300'); - $dolgraph->draw('idgraphcustomerinvoices'); - - $result .= ''; - $result .= ''; - $result .= ''; - } - - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - - $result .= '
'.$langs->trans("Statistics").' - '.$langs->trans("CustomerInvoice").'
'.$objectstatic->getLibStatut(0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
'.$dolgraph->show($total ? 0 : 1).'
'.$langs->trans("Total").''.$total.'
'; - $result .= '
'; - - return $result; -} - - -/** - * Return a HTML table that contains a pie chart of supplier invoices - * - * @param int $socid (Optional) Show only results from the supplier with this id - * @return string A HTML table that contains a pie chart of supplier invoices - */ -function getPurchaseInvoicePieChart($socid = 0) -{ - global $conf, $db, $langs, $user; - - if (!((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire))) { - return ''; - } - - $sql = "SELECT count(f.rowid), f.fk_statut"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f"; - if (empty($user->rights->societe->client->voir) && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - } - $sql .= " WHERE f.fk_soc = s.rowid"; - $sql .= " AND f.entity IN (".getEntity('facture_fourn').")"; - if ($user->socid) { - $sql .= ' AND f.fk_soc = '.((int) $user->socid); - } - if (empty($user->rights->societe->client->voir) && !$socid) { - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); - } - $sql .= " GROUP BY f.fk_statut"; - - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - return ''; - } - - $num = $db->num_rows($resql); - $i = 0; - - $total = 0; - $vals = array(); - - while ($i < $num) { - $row = $db->fetch_row($resql); - if ($row) { - $vals[$row[1]] = $row[0]; - $total += $row[0]; - } - - $i++; - } - - $db->free($resql); - - include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - - $result = '
'; - $result .= ''; - - $result .= ''; - $result .= ''; - $result .= ''; - - $objectstatic = new FactureFournisseur($db); - $array = array(FactureFournisseur::STATUS_DRAFT, FactureFournisseur::STATUS_VALIDATED, FactureFournisseur::STATUS_CLOSED, FactureFournisseur::STATUS_ABANDONED); - $dataseries = array(); - - foreach ($array as $status) { - $objectstatic->statut = $status; - $objectstatic->paye = $status == FactureFournisseur::STATUS_CLOSED ? -1 : 0; - - $dataseries[] = array($objectstatic->getLibStatut(1), (isset($vals[$status]) ? (int) $vals[$status] : 0)); - if ($status == FactureFournisseur::STATUS_DRAFT) { - $colorseries[$status] = '-'.$badgeStatus0; - } - if ($status == FactureFournisseur::STATUS_VALIDATED) { - $colorseries[$status] = $badgeStatus1; - } - if ($status == FactureFournisseur::STATUS_CLOSED) { - $colorseries[$status] = $badgeStatus9; - } - if ($status == FactureFournisseur::STATUS_ABANDONED) { - $colorseries[$status] = $badgeStatus6; - } - - if (!$conf->use_javascript_ajax) { - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - } - } - - if ($conf->use_javascript_ajax) { - $dolgraph = new DolGraph(); - $dolgraph->SetData($dataseries); - $dolgraph->SetDataColor(array_values($colorseries)); - $dolgraph->setShowLegend(2); - $dolgraph->setShowPercent(1); - $dolgraph->SetType(['pie']); - $dolgraph->setHeight('150'); - $dolgraph->setWidth('300'); - $dolgraph->draw('idgraphpurchaseinvoices'); - - $result .= ''; - $result .= ''; - $result .= ''; - } - - $result .= ''; - $result .= ''; - $result .= ''; - $result .= ''; - - $result .= '
'.$langs->trans("Statistics").' - '.$langs->trans("SupplierInvoice").'
'.$objectstatic->getLibStatut(0).''.(isset($vals[$status]) ? $vals[$status] : 0).'
'.$dolgraph->show($total ? 0 : 1).'
'.$langs->trans("Total").''.$total.'
'; - $result .= '
'; - - return $result; -} - /** * Return an HTML table that contains a pie chart of the number of customers or supplier invoices * From 4a222fe5d5e91c946abb92ffe6bf2acb76c31e01 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Sun, 22 May 2022 01:38:32 +0200 Subject: [PATCH 063/174] fix potential warning ($conf->ficheinter->enabled) --- htdocs/comm/propal/card.php | 2 +- htdocs/commande/card.php | 2 +- htdocs/ticket/card.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index bf0c63e5b11..3e9c2cb4eeb 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -121,7 +121,7 @@ $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights-> $usercancreateorder = $user->rights->commande->creer; $usercancreateinvoice = $user->rights->facture->creer; $usercancreatecontract = $user->rights->contrat->creer; -if ($conf->ficheinter->enabled) { +if (!empty($conf->ficheinter->enabled)) { $usercancreateintervention = $user->rights->ficheinter->creer; } $usercancreatepurchaseorder = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 3ed5ede556c..3e5ec08a0f3 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2525,7 +2525,7 @@ if ($action == 'create' && $usercancreate) { } // Create intervention - if ($conf->ficheinter->enabled) { + if (!empty($conf->ficheinter->enabled)) { $langs->load("interventions"); if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index ab2c2794e38..9c1a7c709b7 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -1047,7 +1047,7 @@ if ($action == 'create' || $action == 'presend') { print ''; // Timing (Duration sum of linked fichinter) - if ($conf->ficheinter->enabled) { + if (!empty($conf->ficheinter->enabled)) { $object->fetchObjectLinked(); $num = count($object->linkedObjects); $timing = 0; From 5a489e4594d189be410ddb34c42f0a13634c4ec6 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 22 May 2022 01:43:45 +0200 Subject: [PATCH 064/174] Fix scrutinizer --- htdocs/expensereport/class/expensereport.class.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 1ed0e7a30f5..9a69784adce 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -112,6 +112,9 @@ class ExpenseReport extends CommonObject public $fk_user_validator; // User that is defined to approve // Validation + /* @deprecated */ + public $datevalid; + public $date_valid; // User making validation public $fk_user_valid; public $user_valid_infos; @@ -1806,8 +1809,6 @@ class ExpenseReport extends CommonObject // We don't know seller and buyer for expense reports $seller = $mysoc; // We use same than current company (expense report are often done in same country) $seller->tva_assuj = 1; // Most seller uses vat - $seller->localtax1_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company - $seller->localtax2_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company $buyer = new Societe($this->db); $localtaxes_type = getLocalTaxesFromRate($vatrate, 0, $buyer, $seller); @@ -1891,10 +1892,7 @@ class ExpenseReport extends CommonObject if (!is_object($seller)) { $seller = $mysoc; // We use same than current company (expense report are often done in same country) $seller->tva_assuj = 1; // Most seller uses vat - $seller->localtax1_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company - $seller->localtax2_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company } - //$buyer = new Societe($this->db); $expensereportrule = new ExpenseReportRule($db); $rulestocheck = $expensereportrule->getAllRule($this->line->fk_c_type_fees, $this->line->date, $this->fk_user_author); @@ -1979,10 +1977,7 @@ class ExpenseReport extends CommonObject if (!is_object($seller)) { $seller = $mysoc; // We use same than current company (expense report are often done in same country) $seller->tva_assuj = 1; // Most seller uses vat - $seller->localtax1_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company - $seller->localtax2_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company } - //$buyer = new Societe($this->db); $expenseik = new ExpenseReportIk($this->db); $range = $expenseik->getRangeByUser($userauthor, $this->line->fk_c_exp_tax_cat); @@ -2618,9 +2613,11 @@ class ExpenseReportLine extends CommonObjectLine public $projet_ref; public $projet_title; + public $rang; public $vatrate; public $vat_src_code; + public $tva_tx; public $localtax1_tx; public $localtax2_tx; public $localtax1_type; From 45bc1ff28748b8f4193bd0cba6acf32538f824c5 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Sun, 22 May 2022 01:50:01 +0200 Subject: [PATCH 065/174] fix #18339 : Attempt to read property creer --- htdocs/comm/propal/card.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index a77e242379f..501be1bbca1 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -121,7 +121,9 @@ $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights-> $usercancreateorder = $user->rights->commande->creer; $usercancreateinvoice = $user->rights->facture->creer; $usercancreatecontract = $user->rights->contrat->creer; -$usercancreateintervention = $user->rights->ficheinter->creer; +if (!empty($conf->ficheinter->enabled)) { + $usercancreateintervention = $user->rights->ficheinter->creer; +} $usercancreatepurchaseorder = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer); $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php From 1ca1afd73402b5e57167583c8c1b1f39c2d790f3 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Sun, 22 May 2022 01:50:10 +0200 Subject: [PATCH 066/174] fix #18339 : Attempt to read property creer --- htdocs/comm/propal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 501be1bbca1..3e9c2cb4eeb 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -122,7 +122,7 @@ $usercancreateorder = $user->rights->commande->creer; $usercancreateinvoice = $user->rights->facture->creer; $usercancreatecontract = $user->rights->contrat->creer; if (!empty($conf->ficheinter->enabled)) { - $usercancreateintervention = $user->rights->ficheinter->creer; + $usercancreateintervention = $user->rights->ficheinter->creer; } $usercancreatepurchaseorder = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer); From c3fb7647c5f8cf4d4cd8d744af1fecc2f5e2cbed Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sun, 22 May 2022 02:30:35 +0200 Subject: [PATCH 067/174] Fix delete customer payment --- htdocs/compta/paiement/card.php | 2 +- htdocs/core/lib/security.lib.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index b53debd79ba..47897902a9c 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -48,7 +48,7 @@ $object = new Paiement($db); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$result = restrictedArea($user, $object->element, $object->id, 'paiement', ''); +$result = restrictedArea($user, $object->element, $object->id, 'paiement'); // Security check if ($user->socid) $socid = $user->socid; diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index f8bde1ce489..c1eda701604 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -185,7 +185,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft"); //print "user_id=".$user->id.", features=".$features.", feature2=".$feature2.", objectid=".$objectid; - //print ", dbtablename=".$dbtablename.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select; + //print ", dbtablename=".$tableandshare.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select; //print ", perm: ".$features."->".$feature2."=".($user->rights->$features->$feature2->lire)."
"; $parentfortableentity = ''; @@ -374,6 +374,8 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f } elseif ($feature == 'salaries') { if (!$user->rights->salaries->delete) $deleteok = 0; + } elseif ($feature == 'payment') { + if (!$user->rights->facture->paiement) $deleteok = 0; } elseif ($feature == 'payment_supplier') { if (!$user->rights->fournisseur->facture->creer) { $deleteok = 0; } From 977907c07bc9bd5b139a2ee4458b70ce751bfa6a Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 22 May 2022 06:47:28 +0200 Subject: [PATCH 068/174] Asset module - Fix advanced rights --- htdocs/asset/model/accountancy_codes.php | 4 ++-- htdocs/asset/model/agenda.php | 4 ++-- htdocs/asset/model/card.php | 6 +++--- htdocs/asset/model/depreciation_options.php | 4 ++-- htdocs/asset/model/list.php | 17 ++++++++++------- htdocs/asset/model/note.php | 4 ++-- htdocs/core/menus/init_menu_auguria.sql | 6 +++--- htdocs/core/menus/standard/eldy.lib.php | 6 +++--- 8 files changed, 27 insertions(+), 24 deletions(-) diff --git a/htdocs/asset/model/accountancy_codes.php b/htdocs/asset/model/accountancy_codes.php index fd5999b20b0..7582b61177e 100644 --- a/htdocs/asset/model/accountancy_codes.php +++ b/htdocs/asset/model/accountancy_codes.php @@ -52,8 +52,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; } -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/asset/model/agenda.php b/htdocs/asset/model/agenda.php index cd0365a1418..a915f540ce9 100644 --- a/htdocs/asset/model/agenda.php +++ b/htdocs/asset/model/agenda.php @@ -80,8 +80,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity] . "/model/" . $object->id; } -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/asset/model/card.php b/htdocs/asset/model/card.php index 89843f0fc4e..f4cf1074dd2 100644 --- a/htdocs/asset/model/card.php +++ b/htdocs/asset/model/card.php @@ -68,9 +68,9 @@ if (empty($action) && empty($id) && empty($ref)) { // Load object include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->delete))) || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->delete))) || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); $permissionnote = $permissiontoadd; // Used by the include of actions_setnotes.inc.php $permissiondellink = $permissiontoadd; // Used by the include of actions_dellink.inc.php $upload_dir = $conf->asset->multidir_output[isset($object->entity) ? $object->entity : 1]; diff --git a/htdocs/asset/model/depreciation_options.php b/htdocs/asset/model/depreciation_options.php index f5bc751663b..c34bd38dc46 100644 --- a/htdocs/asset/model/depreciation_options.php +++ b/htdocs/asset/model/depreciation_options.php @@ -52,8 +52,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; } -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/asset/model/list.php b/htdocs/asset/model/list.php index a6423bb3a73..3972975910a 100644 --- a/htdocs/asset/model/list.php +++ b/htdocs/asset/model/list.php @@ -121,9 +121,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); -$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->delete))); +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); +$permissiontodelete = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->delete) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->delete))); // Security check if (empty($conf->asset->enabled)) { @@ -131,15 +131,18 @@ if (empty($conf->asset->enabled)) { } // Security check (enable the most restrictive one) -if ($user->socid > 0) accessforbidden(); -$socid = 0; if ($user->socid > 0) $socid = $user->socid; +if ($user->socid > 0) { + accessforbidden(); +} +$socid = 0; +if ($user->socid > 0) { + $socid = $user->socid; +} $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); restrictedArea($user, 'asset', $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft); if (empty($conf->asset->enabled)) accessforbidden(); if (!$permissiontoread) accessforbidden(); - - /* * Actions */ diff --git a/htdocs/asset/model/note.php b/htdocs/asset/model/note.php index 4af8407976f..8c88feba449 100644 --- a/htdocs/asset/model/note.php +++ b/htdocs/asset/model/note.php @@ -50,8 +50,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity] . "/" . $object->id; } -$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read))); -$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); +$permissiontoadd = ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); // Used by the include of actions_addupdatedelete.inc.php $permissionnote = $permissiontoadd; // Used by the include of actions_setnotes.inc.php // Security check (enable the most restrictive one) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 9a91aa58ac1..9270b946199 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -365,9 +365,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled', __HANDLER__, 'left', 3000__+MAX_llx_menu__, 'accountancy', 'asset', 9__+MAX_llx_menu__, '/asset/list.php?mainmenu=accountancy&leftmenu=asset', 'MenuAssets', 1, 'assets', '$user->rights->asset->read', '', 0, 20, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3001__+MAX_llx_menu__, 'asset', '', 3000__+MAX_llx_menu__, '/asset/card.php?mainmenu=accountancy&leftmenu=asset&action=create', 'MenuNewAsset', 2, 'assets', '$user->rights->asset->write', '', 0, 21, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3003__+MAX_llx_menu__, 'asset', '', 3000__+MAX_llx_menu__, '/asset/list.php?mainmenu=accountancy&leftmenu=asset', 'MenuListAssets', 2, 'assets', '$user->rights->asset->read', '', 0, 22, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3004__+MAX_llx_menu__, 'asset', 'asset_type', 3000__+MAX_llx_menu__, '/asset/type.php?mainmenu=accountancy&leftmenu=asset', 'MenuTypeAssets', 2, 'assets', '$user->rights->asset->read', '', 0, 23, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3005__+MAX_llx_menu__, 'asset', '', 3004__+MAX_llx_menu__, '/asset/type.php?mainmenu=accountancy&action=create', 'MenuNewTypeAssets', 3, 'assets', '$user->rights->asset->setup_advance', '', 0, 24, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3006__+MAX_llx_menu__, 'asset', '', 3004__+MAX_llx_menu__, '/asset/type.php?mainmenu=accountancy', 'MenuListTypeAssets', 3, 'assets', '$user->rights->asset->read', '', 0, 25, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3004__+MAX_llx_menu__, 'asset', 'asset_type', 3000__+MAX_llx_menu__, '/asset/type.php?mainmenu=accountancy&leftmenu=asset', 'MenuTypeAssets', 2, 'assets', '($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->asset->model_advance->read:$user->rights->asset->read)', '', 0, 23, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3005__+MAX_llx_menu__, 'asset', '', 3004__+MAX_llx_menu__, '/asset/type.php?mainmenu=accountancy&action=create', 'MenuNewTypeAssets', 3, 'assets', '($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->asset->model_advance->write:$user->rights->asset->write)', '', 0, 24, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->asset->enabled && $leftmenu=="asset"', __HANDLER__, 'left', 3006__+MAX_llx_menu__, 'asset', '', 3004__+MAX_llx_menu__, '/asset/type.php?mainmenu=accountancy', 'MenuListTypeAssets', 3, 'assets', '($conf->global->MAIN_USE_ADVANCED_PERMS?$user->rights->asset->model_advance->read:$user->rights->asset->read)', '', 0, 25, __ENTITY__); -- Check deposit insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'empty($conf->global->BANK_DISABLE_CHECK_DEPOSIT) && ! empty($conf->banque->enabled) && (! empty($conf->facture->enabled) || ! empty($conf->global->MAIN_MENU_CHEQUE_DEPOSIT_ON))', __HANDLER__, 'left', 1711__+MAX_llx_menu__, 'accountancy', 'checks', 14__+MAX_llx_menu__, '/compta/paiement/cheque/index.php?mainmenu=bank&leftmenu=checks', 'MenuChequeDeposits', 0, 'bills', '$user->rights->banque->lire', '', 2, 9, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index d48402ab0fb..3dc1ab6c4fd 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1879,10 +1879,10 @@ function get_left_menu_accountancy($mainmenu, &$newmenu, $usemenuhider = 1, $lef $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuAssets"), 0, $user->rights->asset->read, '', $mainmenu, 'asset', 100, '', '', '', img_picto('', 'payment', 'class="paddingright pictofixedwidth"')); $newmenu->add("/asset/card.php?leftmenu=asset&action=create", $langs->trans("MenuNewAsset"), 1, $user->rights->asset->write); $newmenu->add("/asset/list.php?leftmenu=asset&mainmenu=accountancy", $langs->trans("MenuListAssets"), 1, $user->rights->asset->read); - $newmenu->add("/asset/model/list.php?leftmenu=asset_model", $langs->trans("MenuAssetModels"), 1, (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read)), '', $mainmenu, 'asset_model'); + $newmenu->add("/asset/model/list.php?leftmenu=asset_model", $langs->trans("MenuAssetModels"), 1, (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read)), '', $mainmenu, 'asset_model'); if ($usemenuhider || empty($leftmenu) || preg_match('/asset_model/', $leftmenu)) { - $newmenu->add("/asset/model/card.php?leftmenu=asset_model&action=create", $langs->trans("MenuNewAssetModel"), 2, (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->write))); - $newmenu->add("/asset/model/list.php?leftmenu=asset_model", $langs->trans("MenuListAssetModels"), 2, (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->setup_advance->read))); + $newmenu->add("/asset/model/card.php?leftmenu=asset_model&action=create", $langs->trans("MenuNewAssetModel"), 2, (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->write) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->write))); + $newmenu->add("/asset/model/list.php?leftmenu=asset_model", $langs->trans("MenuListAssetModels"), 2, (empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->asset->read) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->asset->model_advance->read))); } } } From 7b919f1513111da267b7d25aa8d53651edd50a41 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 22 May 2022 07:08:39 +0200 Subject: [PATCH 069/174] Field fk_pays don't exist & fix sql error --- htdocs/asset/class/assetmodel.class.php | 1 - htdocs/asset/model/list.php | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/asset/class/assetmodel.class.php b/htdocs/asset/class/assetmodel.class.php index 6390ad74c18..077f33936e8 100644 --- a/htdocs/asset/class/assetmodel.class.php +++ b/htdocs/asset/class/assetmodel.class.php @@ -105,7 +105,6 @@ class AssetModel extends CommonObject 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'validate'=>'1'), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'showoncombobox'=>'2', 'validate'=>'1',), 'asset_type' => array('type'=>'smallint', 'label'=>'AssetType', 'enabled'=>'1', 'position'=>40, 'notnull'=>1, 'visible'=>1, 'arrayofkeyval'=>array('0'=>'AssetTypeIntangible', '1'=>'AssetTypeTangible', '2'=>'AssetTypeInProgress', '3'=>'AssetTypeFinancial'), 'validate'=>'1',), - 'fk_pays' =>array('type'=>'integer:Ccountry:core/class/ccountry.class.php', 'label'=>'Country', 'enabled'=>1, 'visible'=>1, 'position'=>50), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>300, 'notnull'=>0, 'visible'=>0, 'validate'=>'1',), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>301, 'notnull'=>0, 'visible'=>0, 'validate'=>'1',), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), diff --git a/htdocs/asset/model/list.php b/htdocs/asset/model/list.php index 3972975910a..a55d5f49f9a 100644 --- a/htdocs/asset/model/list.php +++ b/htdocs/asset/model/list.php @@ -303,19 +303,20 @@ $sql .= !empty($hookmanager->resPrint) ? (" HAVING 1=1 " . $hookmanager->resPrin $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { /* This old and fast method to get and count full list returns all record so use a high amount of memory. - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); */ - /* The slow method does not consume memory on mysql (not tested on pgsql) */ - /*$resql = $db->query($sql, 0, 'auto', 1); - while ($db->fetch_object($resql)) { - $nbtotalofrecords++; - }*/ /* The fast and low memory method to get and count full list converts the sql into a sql count */ $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $resql = $db->query($sqlforcount); - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; From f65f63b5629c4240318cdd7e89c68c64c4b60b83 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 May 2022 12:38:52 +0200 Subject: [PATCH 070/174] FIX Zatca QR code must use company name/vat --- htdocs/core/class/commoninvoice.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 795c0550ae1..4ac01ca31dd 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -820,7 +820,7 @@ abstract class CommonInvoice extends CommonObject */ public function buildZATCAQRString() { - global $conf; + global $conf, $mysoc; $tmplang = new Translate('', $conf); $tmplang->setDefaultLang('en_US'); @@ -857,8 +857,8 @@ abstract class CommonInvoice extends CommonObject */ // Using TLV format - $s = pack('C1', 1).pack('C1', strlen($this->thirdparty->name)).$this->thirdparty->name; - $s .= pack('C1', 2).pack('C1', strlen($this->thirdparty->tva_intra)).$this->thirdparty->tva_intra; + $s = pack('C1', 1).pack('C1', strlen($this->thirdparty->name)).$mysoc->name; + $s .= pack('C1', 2).pack('C1', strlen($this->thirdparty->tva_intra)).$mysoc->tva_intra; $s .= pack('C1', 3).pack('C1', strlen($datestring)).$datestring; $s .= pack('C1', 4).pack('C1', strlen($pricewithtaxstring)).$pricewithtaxstring; $s .= pack('C1', 5).pack('C1', strlen($pricetaxstring)).$pricetaxstring; From d3f1332b24fe448cd18987eafc8d34eb2d4306f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 May 2022 13:02:51 +0200 Subject: [PATCH 071/174] FIX ZATCA regression --- htdocs/core/class/commoninvoice.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 1173ef50f81..5bc56458aef 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -885,8 +885,8 @@ abstract class CommonInvoice extends CommonObject */ // Using TLV format - $s = pack('C1', 1).pack('C1', strlen($this->thirdparty->name)).$mysoc->name; - $s .= pack('C1', 2).pack('C1', strlen($this->thirdparty->tva_intra)).$mysoc->tva_intra; + $s = pack('C1', 1).pack('C1', strlen($mysoc->name)).$mysoc->name; + $s .= pack('C1', 2).pack('C1', strlen($mysoc->tva_intra)).$mysoc->tva_intra; $s .= pack('C1', 3).pack('C1', strlen($datestring)).$datestring; $s .= pack('C1', 4).pack('C1', strlen($pricewithtaxstring)).$pricewithtaxstring; $s .= pack('C1', 5).pack('C1', strlen($pricetaxstring)).$pricetaxstring; From 96867fac4f37f5d5fcd1a841cbf4a2f846e93149 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 May 2022 13:02:51 +0200 Subject: [PATCH 072/174] FIX ZATCA regression --- htdocs/core/class/commoninvoice.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 4ac01ca31dd..6b617e2e08e 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -857,8 +857,8 @@ abstract class CommonInvoice extends CommonObject */ // Using TLV format - $s = pack('C1', 1).pack('C1', strlen($this->thirdparty->name)).$mysoc->name; - $s .= pack('C1', 2).pack('C1', strlen($this->thirdparty->tva_intra)).$mysoc->tva_intra; + $s = pack('C1', 1).pack('C1', strlen($mysoc->name)).$mysoc->name; + $s .= pack('C1', 2).pack('C1', strlen($mysoc->tva_intra)).$mysoc->tva_intra; $s .= pack('C1', 3).pack('C1', strlen($datestring)).$datestring; $s .= pack('C1', 4).pack('C1', strlen($pricewithtaxstring)).$pricewithtaxstring; $s .= pack('C1', 5).pack('C1', strlen($pricetaxstring)).$pricetaxstring; From 648c524eb5c76f56f0d9e90455f0746e71acfb18 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Sun, 22 May 2022 14:45:56 +0200 Subject: [PATCH 073/174] Fix php error --- htdocs/admin/mails_templates.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index d96e0706223..3d5125fab5d 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -619,6 +619,7 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } +if (!empty($search)) { foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { foreach ($search[$key] as $skey) { @@ -630,6 +631,7 @@ foreach ($search as $key => $val) { $param .= '&search_'.$key.'='.urlencode($search[$key]); } } +} if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } From c4e19824e8470efde193ef290fc4f21c951f59d2 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sun, 22 May 2022 15:11:09 +0200 Subject: [PATCH 074/174] fix : The property lib does not exist on PaymentVAT --- htdocs/compta/tva/class/paymentvat.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index cbdb4887869..b7500fffaa0 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -101,6 +101,13 @@ class PaymentVAT extends CommonObject */ public $chid; + /** + * @var string lib + * @deprecated + * @see $label + */ + public $lib; + /** * @var integer|string datepaye */ From 2bbdd56fef06a897ca0bb2c9b617ec9f5087b815 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sun, 22 May 2022 15:26:12 +0200 Subject: [PATCH 075/174] fix : The property totalpaye does not exist on Tva --- htdocs/compta/tva/class/tva.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index b30cc185a98..6b8fe0b8c05 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -62,6 +62,11 @@ class Tva extends CommonObject public $type_payment; public $num_payment; + /** + * @var integer|string totalpaye + */ + public $totalpaye; + /** * @var string label */ From 6d8fc453af7fffd88085b7d56fcbfef642b4df41 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Sun, 22 May 2022 15:39:49 +0200 Subject: [PATCH 076/174] fix : The property civilite does not exist on Contact --- htdocs/contact/class/contact.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 587972fa83b..922da9c30a8 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -130,6 +130,13 @@ class Contact extends CommonObject public $civility_code; public $civility; + /** + * @var string The civilite code, not an integer + * @deprecated + * @see $civility_code + */ + public $civilite; + /** * @var string Address */ From f43f2ab6703905cd988cf87df70d76c87a5b005c Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Sun, 22 May 2022 15:44:57 +0200 Subject: [PATCH 077/174] push phpunit to of the function --- htdocs/core/lib/files.lib.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 7b0aa332ccb..f768833cd39 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -981,13 +981,13 @@ function dol_move_dir($srcdir, $destdir, $overwriteifexists = 1, $indexdatabase global $user, $db, $conf; $result = false; - dol_syslog("files.lib.php::dol_dir_move srcdir=".$srcdir." destdir=".$destdir." overwritifexists=".$overwriteifexists); + dol_syslog("files.lib.php::dol_move_dir srcdir=".$srcdir." destdir=".$destdir." overwritifexists=".$overwriteifexists." indexdatabase=".$indexdatabase." renamedircontent=".$renamedircontent); $srcexists = dol_is_dir($srcdir); $srcbasename = basename($srcdir); $destexists = dol_is_dir($destdir); if (!$srcexists) { - dol_syslog("files.lib.php::dol_dir_move srcdir does not exists. we ignore the move request."); + dol_syslog("files.lib.php::dol_move_dir srcdir does not exists. we ignore the move request."); return false; } @@ -1004,14 +1004,15 @@ function dol_move_dir($srcdir, $destdir, $overwriteifexists = 1, $indexdatabase if (!empty($files) && is_array($files)) { foreach ($files as $key => $file) { if (!file_exists($file["fullname"])) continue; - $oldpath = $file["fullname"]; + $filepath = $file["path"]; + $oldname = $file["name"]; - $newpath = str_replace($srcbasename, $destbasename, $oldpath); - if (!empty($newpath)) { - if (dol_is_dir($oldpath)) { - $res = dol_move_dir($oldpath, $newpath, $overwriteifexists, $indexdatabase, $renamedircontent); + $newname = str_replace($srcbasename, $destbasename, $oldname); + if (!empty($newname) && $newname !== $oldname) { + if ($file["type"] == "dir") { + $res = dol_move_dir($filepath.'/'.$oldname, $filepath.'/'.$newname, $overwriteifexists, $indexdatabase, $renamedircontent); } else { - $res = dol_move($oldpath, $newpath); + $res = dol_move($filepath.'/'.$oldname, $filepath.'/'.$newname); } if (!$res) { return $result; @@ -1023,7 +1024,6 @@ function dol_move_dir($srcdir, $destdir, $overwriteifexists = 1, $indexdatabase } } } - return $result; } From 5c757c30be1918465035b66ae2d1e9d8ad83429f Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Sun, 22 May 2022 15:46:04 +0200 Subject: [PATCH 078/174] part2 of test --- test/phpunit/FilesLibTest.php | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 48a00c8214d..8c819c6de64 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -559,4 +559,72 @@ class FilesLibTest extends PHPUnit\Framework\TestCase $user->rights->facture->lire = $savpermlire; $user->rights->facture->creer = $savpermcreer; } + + /** + * testDolDirMove + * + * @return void + */ + public function testDolDirMove() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + // To test a move of empty directory that should work + $dirsrcpath = $conf->admin->dir_temp.'/directory'; + $dirdestpath = $conf->admin->dir_temp.'/directory2'; + $file=dirname(__FILE__).'/Example_import_company_1.csv'; + dol_mkdir($dirsrcpath); + dol_delete_dir_recursive($dirdestpath, 0, 1); + $result=dol_move_dir($dirsrcpath, $dirdestpath, 1, 1, 1); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result, 'move of directory with empty directory'); + + // To test a move on existing directory with overwrite + dol_mkdir($dirsrcpath); + $result=dol_move_dir($dirsrcpath, $dirdestpath, 1, 1, 1); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result, 'move of directory on existing directory with empty directory'); + + // To test a move on existing directory without overwrite + dol_mkdir($dirsrcpath); + $result=dol_move_dir($dirsrcpath, $dirdestpath, 0, 1, 1); + print __METHOD__." result=".$result."\n"; + $this->assertFalse($result, 'move of directory on existing directory without overwrite'); + + // To test a move with a file to rename in src directory + dol_mkdir($dirsrcpath); + dol_delete_dir_recursive($dirdestpath, 0, 1); + dol_copy($file, $dirsrcpath.'/directory_file.csv'); + $result=dol_move_dir($dirsrcpath, $dirdestpath, 1, 1, 1); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result, 'move of directory with file in directory'); + + // To test a move without a file to rename in src directory + dol_mkdir($dirsrcpath); + dol_delete_dir_recursive($dirdestpath, 0, 1); + dol_copy($file, $dirsrcpath.'/file.csv'); + $result=dol_move_dir($dirsrcpath, $dirdestpath, 1, 1, 1); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result, 'move of directory with file whitout rename needed in directory'); + + // To test a move with a directory to rename in src directory + dol_mkdir($dirsrcpath); + dol_delete_dir_recursive($dirdestpath, 0, 1); + dol_mkdir($dirsrcpath.'/directory'); + $result=dol_move_dir($dirsrcpath, $dirdestpath, 1, 1, 1); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result, 'move of directory with file with rename needed in directory'); + + // To test a move without a directory to rename in src directory + dol_mkdir($dirsrcpath); + dol_delete_dir_recursive($dirdestpath, 0, 1); + dol_mkdir($dirsrcpath.'/notorename'); + $result=dol_move_dir($dirsrcpath, $dirdestpath, 1, 1, 1); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result, 'move of directory with directory whitout rename needed in directory'); + } } From 7b4dae8773678c7c6bdcf3b27bba02ca3f133040 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 May 2022 16:16:17 +0200 Subject: [PATCH 079/174] CSS --- htdocs/comm/action/list.php | 63 ++++++++++++++----- htdocs/core/class/html.form.class.php | 6 +- htdocs/core/class/html.formprojet.class.php | 14 +++-- htdocs/core/lib/agenda.lib.php | 17 +++-- .../class/html.formresource.class.php | 14 ++--- 5 files changed, 77 insertions(+), 37 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 7d8861aded3..2e80a92acd1 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -183,7 +183,8 @@ if ($user->socid && $socid) { */ if (GETPOST('cancel', 'alpha')) { - $mode = 'list'; $massaction = ''; + $mode = 'list'; + $massaction = ''; } if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) { @@ -268,7 +269,7 @@ if (empty($reshook)) { } /* - * View + * View */ $form = new Form($db); @@ -282,7 +283,8 @@ $nav .= ' trans("Agenda"); +llxHeader('', $title, $help_url); // Define list of all external calendars $listofextcals = array(); @@ -570,11 +572,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $nbtotalofrecords++; }*/ /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); $resql = $db->query($sqlforcount); $objforcount = $db->fetch_object($resql); $nbtotalofrecords = $objforcount->nbtotalofrecords; - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } @@ -804,44 +806,57 @@ print ''; $searchpicto = $form->showFilterButtons(); print $searchpicto; print ''; -print "\n"; +print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; + +// Fields title label +// -------------------------------------------------------------------- print ''; if (!empty($arrayfields['a.id']['checked'])) { print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['owner']['checked'])) { print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['c.libelle']['checked'])) { print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['a.label']['checked'])) { print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['a.note']['checked'])) { print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } //if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) if (!empty($arrayfields['a.datep']['checked'])) { print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['a.datep2']['checked'])) { print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['s.nom']['checked'])) { print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['a.fk_contact']['checked'])) { print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['a.fk_element']['checked'])) { print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; } - // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook @@ -869,9 +884,21 @@ $caction = new CActionComm($db); $arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1); $contactListCache = array(); -while ($i < min($num, $limit)) { +// Loop on record +// -------------------------------------------------------------------- +$i = 0; +//$savnbfield = $totalarray['nbfield']; +//$totalarray['nbfield'] = 0; +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); - + if (empty($obj)) { + break; // Should not happen + } + + // Store properties in $object + $object->setVarsFromFetchObj($obj); + // Discard auto action if option is on if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') { $i++; @@ -1087,12 +1114,20 @@ while ($i < min($num, $limit)) { } print ''; - print "\n"; + print ''."\n"; + $i++; } -print ""; -print '
'; -print ''; +// If no record found +if ($num == 0) { + print ''.$langs->trans("NoRecordFound").''; +} + + +print ''."\n"; +print '
'."\n"; + +print ''."\n"; $db->free($resql); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 31f69878dda..8a3093b0f0a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1279,7 +1279,6 @@ class Form // mode 1 $urloption = 'htmlname='.urlencode(str_replace('.', '_', $htmlname)).'&outjson=1&filter='.urlencode($filter).(empty($excludeids) ? '' : '&excludeids='.join(',', $excludeids)).($showtype ? '&showtype='.urlencode($showtype) : ''); - $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); $out .= ''; if (empty($hidelabel)) { @@ -1294,6 +1293,8 @@ class Form if ($hidelabel == 3) { $out .= img_picto($langs->trans("Search"), 'search'); } + + $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/societe/ajax/company.php', $urloption, $conf->global->COMPANY_USE_SEARCH_TO_SELECT, 0, $ajaxoptions); } else { // Immediate load of all database $out .= $this->select_thirdparty_list($selected, $htmlname, $filter, $showempty, $showtype, $forcecombo, $events, '', 0, $limit, $morecss, $moreparam, $multiple, $excludeids); @@ -9435,7 +9436,6 @@ class Form if ($resql) { // Enhance with select2 include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $out .= ajax_combobox($htmlname); $out .= ''; + + $out .= ajax_combobox($htmlname); } else { dol_print_error($this->db); } diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 27a8c9de3eb..47bbdec0fb2 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -191,14 +191,9 @@ class FormProjets $resql = $this->db->query($sql); if ($resql) { - // Use select2 selector if (!empty($conf->use_javascript_ajax)) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus); - $out .= $comboenhancement; $morecss .= ' minwidth100'; } - if (empty($option_only)) { $out .= ''; } + + // Use select2 selector + if (!empty($conf->use_javascript_ajax)) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $comboenhancement = ajax_combobox($htmlid, array(), 0, $forcefocus); + $out .= $comboenhancement; + $morecss .= ' minwidth100'; + } + if (empty($nooutput)) { print $out; return ''; diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 488010609f9..6feee8c35d5 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -71,25 +71,24 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh if ($canedit) { print '
'; - // Type $multiselect = 0; if (!empty($conf->global->MAIN_ENABLE_MULTISELECT_TYPE)) { // We use an option here because it adds bugs when used on agenda page "peruser" and "list" $multiselect = (!empty($conf->global->AGENDA_USE_EVENT_TYPE)); } - print img_picto($langs->trans("ActionType"), 'square', 'class="fawidth30 inline-block" style="color: #ddd;"'); - print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 0, $multiselect, 0, 'maxwidth500'); + print img_picto($langs->trans("ActionType"), 'square', 'class="pictofixedwidth inline-block" style="color: #ddd;"'); + print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : -1), 0, $multiselect, 0, 'maxwidth500 widthcentpercentminusx'); print '
'; // Assigned to user print '
'; - print img_picto($langs->trans("ActionsToDoBy"), 'user', 'class="fawidth30 inline-block"'); + print img_picto($langs->trans("ActionsToDoBy"), 'user', 'class="pictofixedwidth inline-block"'); print $form->select_dolusers($filtert, 'search_filtert', 1, '', !$canedit, '', '', 0, 0, 0, '', 0, '', 'minwidth150 maxwidth500 widthcentpercentminusxx'); print '
'; // Assigned to user group print '
'; - print img_picto($langs->trans("ToUserOfGroup"), 'object_group', 'class="fawidth30 inline-block"'); + print img_picto($langs->trans("ToUserOfGroup"), 'object_group', 'class="pictofixedwidth inline-block"'); print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', !$canedit, '', '', '0', false, 'minwidth100 maxwidth500 widthcentpercentminusxx'); print '
'; @@ -99,7 +98,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh // Resource print '
'; - print img_picto($langs->trans("Resource"), 'object_resource', 'class="fawidth30 inline-block"'); + print img_picto($langs->trans("Resource"), 'object_resource', 'class="pictofixedwidth inline-block"'); print $formresource->select_resource_list($resourceid, "search_resourceid", '', 1, 0, 0, null, '', 2, 0, 'maxwidth500'); print '
'; } @@ -107,7 +106,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh if (!empty($conf->societe->enabled) && !empty($user->rights->societe->lire)) { print '
'; - print img_picto($langs->trans("ThirdParty"), 'company', 'class="fawidth30 inline-block"'); + print img_picto($langs->trans("ThirdParty"), 'company', 'class="pictofixedwidth inline-block"'); print $form->select_company($socid, 'search_socid', '', ' ', 0, 0, null, 0, 'minwidth100 maxwidth500'); print '
'; } @@ -117,7 +116,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh $formproject = new FormProjets($db); print '
'; - print img_picto($langs->trans("Project"), 'project', 'class="fawidth30 inline-block"'); + print img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth inline-block"'); print $formproject->select_projects($socid ? $socid : -1, $pid, 'search_projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500'); print '
'; } @@ -125,7 +124,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh if ($canedit && !preg_match('/list/', $_SERVER["PHP_SELF"])) { // Status print '
'; - print img_picto($langs->trans("Status"), 'setup', 'class="fawidth30 inline-block"'); + print img_picto($langs->trans("Status"), 'setup', 'class="pictofixedwidth inline-block"'); $formactions->form_select_status_action('formaction', $status, 1, 'search_status', 1, 2, 'minwidth100'); print '
'; } diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 705c3a70788..8b4e32c05d2 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -101,13 +101,6 @@ class FormResource } if ($resourcestat) { - if (!empty($conf->use_javascript_ajax) && !empty($conf->global->RESOURCE_USE_SEARCH_TO_SELECT) && !$forcecombo) { - //$minLength = (is_numeric($conf->global->RESOURCE_USE_SEARCH_TO_SELECT)?$conf->global->RESOURCE_USE_SEARCH_TO_SELECT:2); - $out .= ajax_combobox($htmlname, $event, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT); - } else { - $out .= ajax_combobox($htmlname); - } - // Construct $out and $outarray $out .= ''."\n"; + if (!empty($conf->use_javascript_ajax) && !empty($conf->global->RESOURCE_USE_SEARCH_TO_SELECT) && !$forcecombo) { + //$minLength = (is_numeric($conf->global->RESOURCE_USE_SEARCH_TO_SELECT)?$conf->global->RESOURCE_USE_SEARCH_TO_SELECT:2); + $out .= ajax_combobox($htmlname, $event, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT); + } else { + $out .= ajax_combobox($htmlname); + } + if ($outputmode != 2) { $out .= '     '; From 3d5b322d9866987e5188bc85d02ede84509e063f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 May 2022 16:27:42 +0200 Subject: [PATCH 080/174] Debug v16 --- htdocs/comm/action/list.php | 19 ++++++++++--------- htdocs/core/modules/action/rapport.pdf.php | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 2e80a92acd1..34dd94664e7 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -276,6 +276,10 @@ $form = new Form($db); $userstatic = new User($db); $formactions = new FormActions($db); +$actionstatic = new ActionComm($db); +$societestatic = new Societe($db); +$contactstatic = new Contact($db); + $nav = ''; $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0); $nav .= ' '; @@ -597,12 +601,6 @@ if (!$resql) { $num = $db->num_rows($resql); - -$actionstatic = new ActionComm($db); -$societestatic = new Societe($db); - -$num = $db->num_rows($resql); - $arrayofselected = is_array($toselect) ? $toselect : array(); // Local calendar @@ -864,18 +862,21 @@ print $hookmanager->resPrint; if (!empty($arrayfields['a.datec']['checked'])) { print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['a.tms']['checked'])) { print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; } if (!empty($arrayfields['a.percent']['checked'])) { print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder); + $totalarray['nbfield']++; } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); +$totalarray['nbfield']++; print "\n"; -$contactstatic = new Contact($db); $now = dol_now(); $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; @@ -895,10 +896,10 @@ while ($i < $imaxinloop) { if (empty($obj)) { break; // Should not happen } - + // Store properties in $object $object->setVarsFromFetchObj($obj); - + // Discard auto action if option is on if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') { $i++; diff --git a/htdocs/core/modules/action/rapport.pdf.php b/htdocs/core/modules/action/rapport.pdf.php index 3626b36d7e3..2b4ec29c880 100644 --- a/htdocs/core/modules/action/rapport.pdf.php +++ b/htdocs/core/modules/action/rapport.pdf.php @@ -133,7 +133,7 @@ class CommActionRapport $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products")); $dir = $conf->agenda->dir_temp."/"; - $file = $dir."actions-".$this->month."-".$this->year.".pdf"; + $file = $dir."actions-".sprintf("%02d", $this->month)."-".sprintf("%04d", $this->year).".pdf"; if (!file_exists($dir)) { if (dol_mkdir($dir) < 0) { From 8bacb6c7551361662cc90a1e78a38a981a55c05e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 May 2022 17:09:08 +0200 Subject: [PATCH 081/174] Fix name of var --- htdocs/compta/charges/index.php | 12 ++--- htdocs/compta/facture/card.php | 46 +++++++++--------- .../facture/class/api_invoices.class.php | 8 ++-- htdocs/compta/facture/class/facture.class.php | 10 ++-- htdocs/compta/facture/contact.php | 4 +- htdocs/compta/facture/document.php | 4 +- htdocs/compta/facture/info.php | 4 +- htdocs/compta/facture/list.php | 4 +- htdocs/compta/facture/note.php | 4 +- htdocs/compta/facture/prelevement.php | 12 ++--- htdocs/compta/localtax/index.php | 8 ++-- .../class/bonprelevement.class.php | 4 +- htdocs/compta/recap-compta.php | 4 +- htdocs/compta/sociales/card.php | 18 +++---- .../sociales/class/chargesociales.class.php | 1 + htdocs/compta/sociales/document.php | 4 +- htdocs/compta/sociales/info.php | 5 +- htdocs/compta/sociales/note.php | 4 +- htdocs/compta/sociales/payments.php | 12 ++--- htdocs/compta/tva/card.php | 18 +++---- htdocs/compta/tva/class/tva.class.php | 2 + htdocs/compta/tva/document.php | 3 +- htdocs/compta/tva/index.php | 8 ++-- htdocs/compta/tva/payments.php | 12 ++--- htdocs/core/class/commoninvoice.class.php | 8 ++-- htdocs/core/lib/functions.lib.php | 4 +- .../class/api_supplier_invoices.class.php | 4 +- htdocs/fourn/facture/card.php | 48 +++++++++---------- htdocs/fourn/facture/contact.php | 2 +- htdocs/fourn/facture/document.php | 4 +- htdocs/fourn/facture/info.php | 2 +- htdocs/fourn/facture/list.php | 4 +- htdocs/fourn/facture/note.php | 2 +- htdocs/fourn/recap-fourn.php | 6 +-- htdocs/public/payment/paymentok.php | 8 +++- htdocs/salaries/card.php | 18 +++---- htdocs/stripe/class/actions_stripe.class.php | 6 ++- 37 files changed, 172 insertions(+), 155 deletions(-) diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 78f9eae72a0..c16b6523d1f 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -153,7 +153,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $sql = "SELECT c.id, c.libelle as label,"; $sql .= " cs.rowid, cs.libelle, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total,"; - $sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,"; + $sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaid, pc.num_paiement as num_payment, pc.fk_bank,"; $sql .= " pct.code as payment_code,"; $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c,"; @@ -185,7 +185,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $i = 0; $total = 0; $totalnb = 0; - $totalpaye = 0; + $totalpaid = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -239,15 +239,15 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { } // Paid print ''; - if ($obj->totalpaye) { - print price($obj->totalpaye); + if ($obj->totalpaid) { + print price($obj->totalpaid); } print ''; print ''; $total = $total + $obj->total; $totalnb = $totalnb + $obj->nb; - $totalpaye = $totalpaye + $obj->totalpaye; + $totalpaid = $totalpaid + $obj->totalpaid; $i++; } print ''.$langs->trans("Total").''; @@ -258,7 +258,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { if (!empty($conf->banque->enabled)) { print ''; } - print ''.price($totalpaye).""; + print ''.price($totalpaid).""; print ""; } else { dol_print_error($db); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 0f8d0b37d53..a29f7af563e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -725,14 +725,14 @@ if (empty($reshook)) { while ($i < $num) { $objp = $db->fetch_object($result); - $totalpaye += $objp->amount; + $totalpaid += $objp->amount; $i++; } } else { dol_print_error($db, ''); } - $resteapayer = $object->total_ttc - $totalpaye; + $resteapayer = $object->total_ttc - $totalpaid; // We check that invlice lines are transferred into accountancy $ventilExportCompta = $object->getVentilExportCompta(); @@ -1255,10 +1255,10 @@ if (empty($reshook)) { if (GETPOST('invoiceAvoirWithPaymentRestAmount', 'int') == 1 && $id > 0) { if ($facture_source->fetch($object->fk_facture_source) > 0) { - $totalpaye = $facture_source->getSommePaiement(); + $totalpaid = $facture_source->getSommePaiement(); $totalcreditnotes = $facture_source->getSumCreditNotesUsed(); $totaldeposits = $facture_source->getSumDepositsUsed(); - $remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits); + $remain_to_pay = abs($facture_source->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits); $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'), $remain_to_pay, 1, 0, 0, 0, 0, 0, '', '', 'TTC'); } @@ -3899,24 +3899,24 @@ if ($action == 'create') { } $selleruserevenustamp = $mysoc->useRevenueStamp(); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); $totalcreditnotes = $object->getSumCreditNotesUsed(); $totaldeposits = $object->getSumDepositsUsed(); - //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits." + //print "totalpaid=".$totalpaid." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits." // selleruserrevenuestamp=".$selleruserevenustamp; // We can also use bcadd to avoid pb with floating points // For example print 239.2 - 229.3 - 9.9; does not return 0. - // $resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); + // $resteapayer=bcadd($object->total_ttc,$totalpaid,$conf->global->MAIN_MAX_DECIMALS_TOT); // $resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); - $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $resteapayer = price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); // Multicurrency if (!empty($conf->multicurrency->enabled)) { - $multicurrency_totalpaye = $object->getSommePaiement(1); + $multicurrency_totalpaid = $object->getSommePaiement(1); $multicurrency_totalcreditnotes = $object->getSumCreditNotesUsed(1); $multicurrency_totaldeposits = $object->getSumDepositsUsed(1); - $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaye - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT'); + $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT'); // Code to fix case of corrupted data if ($resteapayer == 0 && $multicurrency_resteapayer != 0) { $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); @@ -4317,7 +4317,7 @@ if ($action == 'create') { } $morehtmlref .= '
'; - $object->totalpaid = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', ''); @@ -4926,7 +4926,7 @@ if ($action == 'create') { $total_next_ht = $total_next_ttc = 0; foreach ($object->tab_next_situation_invoice as $next_invoice) { - $totalpaye = $next_invoice->getSommePaiement(); + $totalpaid = $next_invoice->getSommePaiement(); $total_next_ht += $next_invoice->total_ht; $total_next_ttc += $next_invoice->total_ttc; @@ -4939,7 +4939,7 @@ if ($action == 'create') { } print ''.price($next_invoice->total_ht).''; print ''.price($next_invoice->total_ttc).''; - print ''.$next_invoice->getLibStatut(3, $totalpaye).''; + print ''.$next_invoice->getLibStatut(3, $totalpaid).''; print ''; } @@ -5072,7 +5072,7 @@ if ($action == 'create') { } else { print $langs->trans('AlreadyPaid'); } - print ''.price($totalpaye).' '; + print ''.price($totalpaid).' '; $resteapayeraffiche = $resteapayer; $cssforamountpaymentcomplete = 'amountpaymentcomplete'; @@ -5125,7 +5125,7 @@ if ($action == 'create') { print ''; print $form->textwithpicto($langs->trans("Discount"), $langs->trans("HelpEscompte"), - 1); print ''; - print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' '; + print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' '; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } @@ -5135,7 +5135,7 @@ if ($action == 'create') { print ''; print $form->textwithpicto($langs->trans("Abandoned"), $langs->trans("HelpAbandonBadCustomer"), - 1); print ''; - print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' '; + print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' '; // $resteapayeraffiche=0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } @@ -5145,7 +5145,7 @@ if ($action == 'create') { print ''; print $form->textwithpicto($langs->trans("ProductReturned"), $langs->trans("HelpAbandonProductReturned"), - 1); print ''; - print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' '; + print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' '; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } @@ -5159,7 +5159,7 @@ if ($action == 'create') { print ''; print $form->textwithpicto($langs->trans("Abandoned"), $text, - 1); print ''; - print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye, 'MT')).' '; + print ''.price(price2num($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid, 'MT')).' '; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } @@ -5220,7 +5220,7 @@ if ($action == 'create') { // Total already paid back print ''; print ''.$langs->trans('AlreadyPaidBack').''; - print ''.price($sign * $totalpaye).' '; + print ''.price($sign * $totalpaid).' '; // Billed print ''.$langs->trans("Billed").''.price($sign * $object->total_ttc).' '; @@ -5498,8 +5498,8 @@ if ($action == 'create') { } } - $sumofpayment = $totalpaye; - $sumofpaymentall = $totalpaye + $totalcreditnotes + $totaldeposits; + $sumofpayment = $totalpaid; + $sumofpaymentall = $totalpaid + $totalcreditnotes + $totaldeposits; // Reverse back money or convert to reduction if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_SITUATION) { @@ -5551,7 +5551,7 @@ if ($action == 'create') { // Classify 'closed not completely paid' (possible if validated and not yet filed paid) if ($object->statut == Facture::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0 && (empty($conf->global->INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID) || $resteapayer != $object->total_ttc) && $usercanissuepayment) { - if ($totalpaye > 0 || $totalcreditnotes > 0) { + if ($totalpaid > 0 || $totalcreditnotes > 0) { // If one payment or one credit note was linked to this invoice print ''.$langs->trans('ClassifyPaidPartially').''; } else { @@ -5575,7 +5575,7 @@ if ($action == 'create') { // For situation invoice with excess received if ($object->statut > Facture::STATUS_DRAFT && $object->type == Facture::TYPE_SITUATION - && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) > 0 + && ($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits) > 0 && $usercancreate && !$objectidnext && $object->is_last_in_cycle() diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 8a8a9667a28..31bda2015dc 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1425,10 +1425,10 @@ class Invoices extends DolibarrApi } // Calculate amount to pay - $totalpaye = $this->invoice->getSommePaiement(); + $totalpaid = $this->invoice->getSommePaiement(); $totalcreditnotes = $this->invoice->getSumCreditNotesUsed(); $totaldeposits = $this->invoice->getSumDepositsUsed(); - $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $resteapayer = price2num($this->invoice->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); $this->db->begin(); @@ -1567,10 +1567,10 @@ class Invoices extends DolibarrApi } // Calculate amount to pay - $totalpaye = $this->invoice->getSommePaiement($is_multicurrency); + $totalpaid = $this->invoice->getSommePaiement($is_multicurrency); $totalcreditnotes = $this->invoice->getSumCreditNotesUsed($is_multicurrency); $totaldeposits = $this->invoice->getSumDepositsUsed($is_multicurrency); - $remainstopay = $amount = price2num($total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $remainstopay = $amount = price2num($total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); if (!$is_multicurrency && $amountarray["amount"] != 'remain') { $amount = price2num($amountarray["amount"], 'MT'); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 64d83cb2123..a2c22d7f878 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -5214,13 +5214,13 @@ class Facture extends CommonInvoice $hasDelay = $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay); if ($hasDelay && !empty($this->retained_warranty) && !empty($this->retained_warranty_date_limit)) { - $totalpaye = $this->getSommePaiement(); - $totalpaye = floatval($totalpaye); + $totalpaid = $this->getSommePaiement(); + $totalpaid = floatval($totalpaid); $RetainedWarrantyAmount = $this->getRetainedWarrantyAmount(); - if ($totalpaye >= 0 && $RetainedWarrantyAmount >= 0) { - if (($totalpaye < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) { + if ($totalpaid >= 0 && $RetainedWarrantyAmount >= 0) { + if (($totalpaid < $this->total_ttc - $RetainedWarrantyAmount) && $this->date_lim_reglement < ($now - $conf->facture->client->warning_delay)) { $hasDelay = 1; - } elseif ($totalpaye < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay)) { + } elseif ($totalpaid < $this->total_ttc && $this->retained_warranty_date_limit < ($now - $conf->facture->client->warning_delay)) { $hasDelay = 1; } else { $hasDelay = 0; diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 301f16fb4a5..45ce97a480f 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -122,7 +122,7 @@ if ($id > 0 || !empty($ref)) { $head = facture_prepare_head($object); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); print dol_get_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer'), -1, 'bill'); @@ -171,7 +171,7 @@ if ($id > 0 || !empty($ref)) { } $morehtmlref .= ''; - $object->totalpaid = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 03e4a0b4577..f55e9c4b36f 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -117,7 +117,7 @@ if ($id > 0 || !empty($ref)) { $head = facture_prepare_head($object); print dol_get_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'), -1, 'bill'); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); // Build file list $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); @@ -172,7 +172,7 @@ if ($id > 0 || !empty($ref)) { } $morehtmlref .= ''; - $object->totalpaid = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index f524d49eb97..ceea7dcbb62 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -84,7 +84,7 @@ $object->info($object->id); $head = facture_prepare_head($object); print dol_get_fiche_head($head, 'info', $langs->trans("InvoiceCustomer"), -1, 'bill'); -$totalpaye = $object->getSommePaiement(); +$totalpaid = $object->getSommePaiement(); // Invoice content @@ -131,7 +131,7 @@ if (!empty($conf->projet->enabled)) { } $morehtmlref .= ''; -$object->totalpaid = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status +$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 6fd1e2a7322..9f68696a317 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -472,10 +472,10 @@ if ($action == 'makepayment_confirm' && !empty($user->rights->facture->paiement) $objecttmp = new Facture($db); $result = $objecttmp->fetch($toselectid); if ($result > 0) { - $totalpaye = $objecttmp->getSommePaiement(); + $totalpaid = $objecttmp->getSommePaiement(); $totalcreditnotes = $objecttmp->getSumCreditNotesUsed(); $totaldeposits = $objecttmp->getSumDepositsUsed(); - $objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); if ($objecttmp->statut == Facture::STATUS_DRAFT) { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("Draft"), $objecttmp->errors, 'errors'); diff --git a/htdocs/compta/facture/note.php b/htdocs/compta/facture/note.php index fe3bb736ea4..cab6d3ac680 100644 --- a/htdocs/compta/facture/note.php +++ b/htdocs/compta/facture/note.php @@ -99,7 +99,7 @@ if ($id > 0 || !empty($ref)) { $head = facture_prepare_head($object); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); print dol_get_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), -1, 'bill'); @@ -148,7 +148,7 @@ if ($id > 0 || !empty($ref)) { } $morehtmlref .= ''; - $object->totalpaid = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 33d6af875ff..9123a62cec2 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -236,16 +236,16 @@ llxHeader('', $title, $helpurl); if ($object->id > 0) { $selleruserevenustamp = $mysoc->useRevenueStamp(); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); $totalcreditnotes = $object->getSumCreditNotesUsed(); $totaldeposits = $object->getSumDepositsUsed(); - //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; + //print "totalpaid=".$totalpaid." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; // We can also use bcadd to avoid pb with floating points // For example print 239.2 - 229.3 - 9.9; does not return 0. - //$resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); + //$resteapayer=bcadd($object->total_ttc,$totalpaid,$conf->global->MAIN_MAX_DECIMALS_TOT); //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); - $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $resteapayer = price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); if ($object->paye) { $resteapayer = 0; @@ -384,7 +384,7 @@ if ($object->id > 0) { } $morehtmlref .= ''; - $object->totalpaid = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $moreparam, 0, '', ''); @@ -667,7 +667,7 @@ if ($object->id > 0) { // Total with tax print ''.$langs->trans('AmountTTC').''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).''; - $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $resteapayer = price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); // TODO Replace this by an include with same code to show already done payment visible in invoice card print ''.$langs->trans('RemainderToPay').''.price($resteapayer, 1, '', 1, - 1, - 1, $conf->currency).''; diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 234073cdb38..28d095715c2 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -293,7 +293,7 @@ $mend = $tmp['mon']; $total = 0; $subtotalcoll = 0; -$subtotalpaye = 0; +$subtotalpaid = 0; $subtotal = 0; $i = 0; $mcursor = 0; @@ -536,7 +536,7 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ print ''.price(price2num($x_paye_sum, 'MT')).''; $subtotalcoll = $subtotalcoll + $x_coll_sum; - $subtotalpaye = $subtotalpaye + $x_paye_sum; + $subtotalpaid = $subtotalpaid + $x_paye_sum; $diff = $x_coll_sum - $x_paye_sum; $total = $total + $diff; @@ -552,12 +552,12 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) { // $ print ''; print ''.$langs->trans("SubTotal").':'; print ''.price(price2num($subtotalcoll, 'MT')).''; - print ''.price(price2num($subtotalpaye, 'MT')).''; + print ''.price(price2num($subtotalpaid, 'MT')).''; print ''.price(price2num($subtotal, 'MT')).''; print ' '; $i = 0; $subtotalcoll = 0; - $subtotalpaye = 0; + $subtotalpaid = 0; $subtotal = 0; } } diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index df142fb6531..8cde488a2e0 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -394,10 +394,10 @@ class BonPrelevement extends CommonObject $amounts[$fac->id] = $facs[$i][1]; $amountsperthirdparty[$fac->socid][$fac->id] = $facs[$i][1]; - $totalpaye = $fac->getSommePaiement(); + $totalpaid = $fac->getSommePaiement(); $totalcreditnotes = $fac->getSumCreditNotesUsed(); $totaldeposits = $fac->getSumDepositsUsed(); - $alreadypayed = $totalpaye + $totalcreditnotes + $totaldeposits; + $alreadypayed = $totalpaid + $totalcreditnotes + $totaldeposits; // @TODO Move this after creation of payment if (price2num($alreadypayed + $facs[$i][1], 'MT') == $fac->total_ttc) { diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index d98a6aab251..8b2bf351094 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -158,7 +158,7 @@ if ($id > 0) { print $fac->error."
"; continue; } - $totalpaye = $fac->getSommePaiement(); + $totalpaid = $fac->getSommePaiement(); $userstatic->id = $objf->userid; $userstatic->login = $objf->login; @@ -168,7 +168,7 @@ if ($id > 0) { 'date' => $fac->date, 'datefieldforsort' => $fac->date.'-'.$fac->ref, 'link' => $fac->getNomUrl(1), - 'status' => $fac->getLibStatut(2, $totalpaye), + 'status' => $fac->getLibStatut(2, $totalpaid), 'amount' => $fac->total_ttc, 'author' => $userstatic->getLoginUrl(1) ); diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index b586d4c88a6..f16b7f2960c 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -166,8 +166,8 @@ if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) { // Delete social contribution if ($action == 'confirm_delete' && $confirm == 'yes') { $object->fetch($id); - $totalpaye = $object->getSommePaiement(); - if (empty($totalpaye)) { + $totalpaid = $object->getSommePaiement(); + if (empty($totalpaid)) { $result = $object->delete($user); if ($result > 0) { header("Location: list.php"); @@ -454,7 +454,7 @@ if ($id > 0) { if ($result > 0) { $head = tax_prepare_head($object); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); // Clone confirmation if ($action === 'clone') { @@ -576,7 +576,7 @@ if ($id > 0) { $linkback = ''.$langs->trans("BackToList").''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); @@ -690,7 +690,7 @@ if ($id > 0) { //print $sql; $resql = $db->query($sql); if ($resql) { - $totalpaye = 0; + $totalpaid = 0; $num = $db->num_rows($resql); $i = 0; @@ -748,7 +748,7 @@ if ($id > 0) { } print ''.price($objp->amount)."\n"; print ""; - $totalpaye += $objp->amount; + $totalpaid += $objp->amount; $i++; } } else { @@ -757,10 +757,10 @@ if ($id > 0) { print ''; } - print ''.$langs->trans("AlreadyPaid").' :'.price($totalpaye)."\n"; + print ''.$langs->trans("AlreadyPaid").' :'.price($totalpaid)."\n"; print ''.$langs->trans("AmountExpected").' :'.price($object->amount)."\n"; - $resteapayer = $object->amount - $totalpaye; + $resteapayer = $object->amount - $totalpaid; $cssforamountpaymentcomplete = 'amountpaymentcomplete'; print ''.$langs->trans("RemainderToPay")." :"; @@ -820,7 +820,7 @@ if ($id > 0) { } // Delete - if ($user->rights->tax->charges->supprimer && empty($totalpaye)) { + if ($user->rights->tax->charges->supprimer && empty($totalpaid)) { print ''; } else { print ''; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 41e036ae937..3b9019868ec 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -118,6 +118,7 @@ class ChargeSociales extends CommonObject */ public $total; + public $totalpaid; const STATUS_UNPAID = 0; const STATUS_PAID = 1; diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index 6918b2c84ee..3de8687433f 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -139,7 +139,9 @@ if ($object->id) { $linkback = ''.$langs->trans("BackToList").''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $alreadypayed; // To give a chance to dol_banner_tab to use already paid amount to show correct status + + $morehtmlright = ''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); diff --git a/htdocs/compta/sociales/info.php b/htdocs/compta/sociales/info.php index 4c49a3008c6..8363459171b 100644 --- a/htdocs/compta/sociales/info.php +++ b/htdocs/compta/sociales/info.php @@ -81,6 +81,8 @@ $object->info($id); $head = tax_prepare_head($object); +$alreadypayed = $object->getSommePaiement(); + print dol_get_fiche_head($head, 'info', $langs->trans("SocialContribution"), -1, $object->picto); $morehtmlref = '
'; @@ -106,8 +108,9 @@ $morehtmlref .= '
'; $linkback = ''.$langs->trans("BackToList").''; -$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status +$object->totalpaid = $alreadypayed; // To give a chance to dol_banner_tab to use already paid amount to show correct status +$morehtmlright = ''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); print '
'; diff --git a/htdocs/compta/sociales/note.php b/htdocs/compta/sociales/note.php index cf9d0cbdec5..0447d3168b1 100644 --- a/htdocs/compta/sociales/note.php +++ b/htdocs/compta/sociales/note.php @@ -113,7 +113,9 @@ if ($id > 0 || !empty($ref)) { // ------------------------------------------------------------ $linkback = ''.$langs->trans("BackToList").''; - //$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + //$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + + $morehtmlright = ''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index 43e9d5d4668..d2646d241ea 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -137,7 +137,7 @@ print ''; $sql = "SELECT c.id, c.libelle as type_label,"; $sql .= " cs.rowid, cs.libelle as label_sc, cs.fk_type as type, cs.periode, cs.date_ech, cs.amount as total, cs.paye,"; -$sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaye, pc.num_paiement as num_payment, pc.fk_bank,"; +$sql .= " pc.rowid as pid, pc.datep, pc.amount as totalpaid, pc.num_paiement as num_payment, pc.fk_bank,"; $sql .= " pct.code as payment_code,"; $sql .= " u.rowid uid, u.lastname, u.firstname, u.email, u.login, u.admin,"; $sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel, ba.iban_prefix as iban, ba.bic, ba.currency_code, ba.clos"; @@ -253,7 +253,7 @@ if (!$resql) { $i = 0; $total = 0; $totalnb = 0; -$totalpaye = 0; +$totalpaid = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -346,8 +346,8 @@ while ($i < min($num, $limit)) { // Paid print ''; - if ($obj->totalpaye) { - print ''.price($obj->totalpaye).''; + if ($obj->totalpaid) { + print ''.price($obj->totalpaid).''; } print ''; @@ -357,7 +357,7 @@ while ($i < min($num, $limit)) { $total = $total + $obj->total; $totalnb = $totalnb + $obj->nb; - $totalpaye = $totalpaye + $obj->totalpaye; + $totalpaid = $totalpaid + $obj->totalpaid; $i++; } @@ -373,7 +373,7 @@ if (!empty($conf->banque->enabled)) { print ''; print ''; } -print ''.price($totalpaye).""; +print ''.price($totalpaid).""; print ''; print ""; diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 26f8e754dd2..e40b9b9b409 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -273,9 +273,9 @@ if ($action == 'add' && !$cancel) { if ($action == 'confirm_delete' && $confirm == 'yes') { $result = $object->fetch($id); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); - if (empty($totalpaye)) { + if (empty($totalpaid)) { $db->begin(); $ret = $object->delete($user); @@ -540,7 +540,7 @@ if ($action == 'create') { if ($id > 0) { $head = vat_prepare_head($object); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); // Clone confirmation if ($action === 'clone') { @@ -580,7 +580,7 @@ if ($id > 0) { $linkback = ''.$langs->trans("BackToList").''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); @@ -683,7 +683,7 @@ if ($id > 0) { //print $sql; $resql = $db->query($sql); if ($resql) { - $totalpaye = 0; + $totalpaid = 0; $num = $db->num_rows($resql); $i = 0; @@ -735,7 +735,7 @@ if ($id > 0) { } print ''.price($objp->amount)."\n"; print ""; - $totalpaye += $objp->amount; + $totalpaid += $objp->amount; $i++; } } else { @@ -744,10 +744,10 @@ if ($id > 0) { print ''; } - print ''.$langs->trans("AlreadyPaid")." :".price($totalpaye)."\n"; + print ''.$langs->trans("AlreadyPaid")." :".price($totalpaid)."\n"; print ''.$langs->trans("AmountExpected")." :".price($object->amount)."\n"; - $resteapayer = $object->amount - $totalpaye; + $resteapayer = $object->amount - $totalpaid; $cssforamountpaymentcomplete = 'amountpaymentcomplete'; print ''.$langs->trans("RemainderToPay")." :"; @@ -810,7 +810,7 @@ if ($id > 0) { print '"; } - if (!empty($user->rights->tax->charges->supprimer) && empty($totalpaye)) { + if (!empty($user->rights->tax->charges->supprimer) && empty($totalpaid)) { print ''; } else { print ''; diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index b30cc185a98..d2e145c7e34 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -62,6 +62,8 @@ class Tva extends CommonObject public $type_payment; public $num_payment; + public $totalpaid; + /** * @var string label */ diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index a0573cf2812..22b3f988a70 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -125,8 +125,9 @@ if ($object->id) { $linkback = ''.$langs->trans("BackToList").''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $morehtmlright = ''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); print '
'; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index fed0cf209c1..16b24361160 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -255,7 +255,7 @@ if ($refresh === true) { //var_dump($m); $total = 0; $subtotalcoll = 0; - $subtotalpaye = 0; + $subtotalpaid = 0; $subtotal = 0; $i = 0; $mcursor = 0; @@ -481,7 +481,7 @@ if ($refresh === true) { print '' . price(price2num($x_paye_sum, 'MT')) . ''; $subtotalcoll = $subtotalcoll + $x_coll_sum; - $subtotalpaye = $subtotalpaye + $x_paye_sum; + $subtotalpaid = $subtotalpaid + $x_paye_sum; $diff = $x_coll_sum - $x_paye_sum; $total = $total + $diff; @@ -498,12 +498,12 @@ if ($refresh === true) { print ''; print '' . $langs->trans("SubTotal") . ':'; print '' . price(price2num($subtotalcoll, 'MT')) . ''; - print '' . price(price2num($subtotalpaye, 'MT')) . ''; + print '' . price(price2num($subtotalpaid, 'MT')) . ''; print '' . price(price2num($subtotal, 'MT')) . ''; print ' '; $i = 0; $subtotalcoll = 0; - $subtotalpaye = 0; + $subtotalpaid = 0; $subtotal = 0; } } diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index cf91df3a775..5b104955716 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -141,7 +141,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $sql = "SELECT tva.rowid, tva.label as label, b.fk_account, ptva.fk_bank"; $sql .= ", tva.datev"; $sql .= ", tva.amount as total,"; - $sql .= " ptva.rowid as pid, ptva.datep, ptva.amount as totalpaye, ptva.num_paiement as num_payment,"; + $sql .= " ptva.rowid as pid, ptva.datep, ptva.amount as totalpaid, ptva.num_paiement as num_payment,"; $sql .= " pct.code as payment_code"; $sql .= " FROM ".MAIN_DB_PREFIX."tva as tva,"; $sql .= " ".MAIN_DB_PREFIX."payment_vat as ptva"; @@ -175,7 +175,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { $i = 0; $total = 0; $totalnb = 0; - $totalpaye = 0; + $totalpaid = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); @@ -237,15 +237,15 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { print ''.price($obj->total).''; // Paid print ''; - if ($obj->totalpaye) { - print price($obj->totalpaye); + if ($obj->totalpaid) { + print price($obj->totalpaid); } print ''; print ''; $total = $total + $obj->total; $totalnb = $totalnb + $obj->nb; - $totalpaye = $totalpaye + $obj->totalpaye; + $totalpaid = $totalpaid + $obj->totalpaid; $i++; } @@ -260,7 +260,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { } print ' '; print ' '; - print ''.price($totalpaye).""; + print ''.price($totalpaid).""; print ""; } else { dol_print_error($db); diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 5bc56458aef..155b2ca5819 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -742,17 +742,17 @@ abstract class CommonInvoice extends CommonObject if ($row[0] == 0) { $now = dol_now(); - $totalpaye = $this->getSommePaiement(); + $totalpaid = $this->getSommePaiement(); $totalcreditnotes = $this->getSumCreditNotesUsed(); $totaldeposits = $this->getSumDepositsUsed(); - //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; + //print "totalpaid=".$totalpaid." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits; // We can also use bcadd to avoid pb with floating points // For example print 239.2 - 229.3 - 9.9; does not return 0. - //$resteapayer=bcadd($this->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); + //$resteapayer=bcadd($this->total_ttc,$totalpaid,$conf->global->MAIN_MAX_DECIMALS_TOT); //$resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); if (empty($amount)) { - $amount = price2num($this->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $amount = price2num($this->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); } if (is_numeric($amount) && $amount != 0) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b400a4e7c1b..627fcb6b8ae 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2115,9 +2115,9 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $morehtmlstatus .= ''.$object->getLibStatut(6, 1).''; } } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan', 'tva', 'salary'))) { - $tmptxt = $object->getLibStatut(6, $object->totalpaye); + $tmptxt = $object->getLibStatut(6, $object->totalpaid); if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) { - $tmptxt = $object->getLibStatut(5, $object->totalpaye); + $tmptxt = $object->getLibStatut(5, $object->totalpaid); } $morehtmlstatus .= $tmptxt; } elseif ($object->element == 'contrat' || $object->element == 'contract') { diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 154da0dce93..9497a3daa5f 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -450,9 +450,9 @@ class SupplierInvoices extends DolibarrApi } // Calculate amount to pay - $totalpaye = $this->invoice->getSommePaiement(); + $totalpaid = $this->invoice->getSommePaiement(); $totaldeposits = $this->invoice->getSumDepositsUsed(); - $resteapayer = price2num($this->invoice->total_ttc - $totalpaye - $totaldeposits, 'MT'); + $resteapayer = price2num($this->invoice->total_ttc - $totalpaid - $totaldeposits, 'MT'); $this->db->begin(); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index b4193004a13..5ae7e8b9dd5 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -880,10 +880,10 @@ if (empty($reshook)) { if (GETPOST('invoiceAvoirWithPaymentRestAmount', 'int') == 1 && $id > 0) { $facture_source = new FactureFournisseur($db); // fetch origin object if not previously defined if ($facture_source->fetch($object->fk_facture_source) > 0) { - $totalpaye = $facture_source->getSommePaiement(); + $totalpaid = $facture_source->getSommePaiement(); $totalcreditnotes = $facture_source->getSumCreditNotesUsed(); $totaldeposits = $facture_source->getSumDepositsUsed(); - $remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits); + $remain_to_pay = abs($facture_source->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits); $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'), $remain_to_pay, 0, 0, 0, 1, 0, 0, '', '', 'TTC'); } @@ -1712,8 +1712,8 @@ if (empty($reshook)) { // Set invoice to draft status $object->fetch($id); - $totalpaye = $object->getSommePaiement(); - $resteapayer = $object->total_ttc - $totalpaye; + $totalpaid = $object->getSommePaiement(); + $resteapayer = $object->total_ttc - $totalpaid; // We check that lines of invoices are exported in accountancy $ventilExportCompta = $object->getVentilExportCompta(); @@ -2597,24 +2597,24 @@ if ($action == 'create') { $societe = $object->thirdparty; - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); $totalcreditnotes = $object->getSumCreditNotesUsed(); $totaldeposits = $object->getSumDepositsUsed(); - // print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits." + // print "totalpaid=".$totalpaid." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits." // selleruserrevenuestamp=".$selleruserevenustamp; // We can also use bcadd to avoid pb with floating points // For example print 239.2 - 229.3 - 9.9; does not return 0. - // $resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); + // $resteapayer=bcadd($object->total_ttc,$totalpaid,$conf->global->MAIN_MAX_DECIMALS_TOT); // $resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); - $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $resteapayer = price2num($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); // Multicurrency if (!empty($conf->multicurrency->enabled)) { - $multicurrency_totalpaye = $object->getSommePaiement(1); + $multicurrency_totalpaid = $object->getSommePaiement(1); $multicurrency_totalcreditnotes = $object->getSumCreditNotesUsed(1); $multicurrency_totaldeposits = $object->getSumDepositsUsed(1); - $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaye - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT'); + $multicurrency_resteapayer = price2num($object->multicurrency_total_ttc - $multicurrency_totalpaid - $multicurrency_totalcreditnotes - $multicurrency_totaldeposits, 'MT'); // Code to fix case of corrupted data if ($resteapayer == 0 && $multicurrency_resteapayer != 0) { $resteapayer = price2num($multicurrency_resteapayer / $object->multicurrency_tx, 'MT'); @@ -2894,7 +2894,7 @@ if ($action == 'create') { } $morehtmlref .= '
'; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -3227,7 +3227,7 @@ if ($action == 'create') { // List of payments - $totalpaye = 0; + $totalpaid = 0; $sign = 1; if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE) { @@ -3333,7 +3333,7 @@ if ($action == 'create') { } print ''; print ''; - $totalpaye += $objp->amount; + $totalpaid += $objp->amount; $i++; } } else { @@ -3343,10 +3343,10 @@ if ($action == 'create') { /* if ($object->paye == 0) { - print ''.$langs->trans('AlreadyPaid').' :'.price($totalpaye).''; + print ''.$langs->trans('AlreadyPaid').' :'.price($totalpaid).''; print ''.$langs->trans("Billed").' :'.price($object->total_ttc).''; - $resteapayer = $object->total_ttc - $totalpaye; + $resteapayer = $object->total_ttc - $totalpaid; print ''.$langs->trans('RemainderToPay').' :'; print ''.price($resteapayer).''; @@ -3368,9 +3368,9 @@ if ($action == 'create') { print $langs->trans('AlreadyPaid'); } print ''; - print ' 0) ? ' class="amountalreadypaid"' : '').'>'.price($totalpaye).' '; + print ' 0) ? ' class="amountalreadypaid"' : '').'>'.price($totalpaid).' '; - //$resteapayer = $object->total_ttc - $totalpaye; + //$resteapayer = $object->total_ttc - $totalpaid; $resteapayeraffiche = $resteapayer; $cssforamountpaymentcomplete = 'amountpaymentcomplete'; @@ -3422,7 +3422,7 @@ if ($action == 'create') { print ''; print $form->textwithpicto($langs->trans("Discount"), $langs->trans("HelpEscompte"), - 1); print ''; - print ''.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' '; + print ''.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).' '; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } @@ -3432,7 +3432,7 @@ if ($action == 'create') { print ''; print $form->textwithpicto($langs->trans("Abandoned"), $langs->trans("HelpAbandonBadCustomer"), - 1); print ''; - print ''.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' '; + print ''.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).' '; // $resteapayeraffiche=0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } @@ -3442,7 +3442,7 @@ if ($action == 'create') { print ''; print $form->textwithpicto($langs->trans("ProductReturned"), $langs->trans("HelpAbandonProductReturned"), - 1); print ''; - print ''.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' '; + print ''.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).' '; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } @@ -3456,7 +3456,7 @@ if ($action == 'create') { print ''; print $form->textwithpicto($langs->trans("Abandoned"), $text, - 1); print ''; - print ''.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaye).' '; + print ''.price($object->total_ttc - $creditnoteamount - $depositamount - $totalpaid).' '; $resteapayeraffiche = 0; $cssforamountpaymentcomplete = 'amountpaymentneutral'; } @@ -3498,7 +3498,7 @@ if ($action == 'create') { // Total already paid back print ''; print $langs->trans('AlreadyPaidBack'); - print ' :'.price($sign * $totalpaye).' '; + print ' :'.price($sign * $totalpaid).' '; // Billed print ''.$langs->trans("Billed").' :'.price($sign * $object->total_ttc).' '; @@ -3691,7 +3691,7 @@ if ($action == 'create') { } // For standard invoice with excess paid - if ($object->type == FactureFournisseur::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits) < 0 && $usercancreate && empty($discount->id)) { + if ($object->type == FactureFournisseur::TYPE_STANDARD && empty($object->paye) && ($object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits) < 0 && $usercancreate && empty($discount->id)) { print ''.$langs->trans('ConvertExcessPaidToReduc').''; } // For credit note @@ -3718,7 +3718,7 @@ if ($action == 'create') { // Classify 'closed not completely paid' (possible if validated and not yet filed paid) if ($object->statut == FactureFournisseur::STATUS_VALIDATED && $object->paye == 0 && $resteapayer > 0 && (empty($conf->global->SUPPLIER_INVOICE_CAN_SET_PAID_EVEN_IF_PARTIALLY_PAID) || $object->total_ttc != $resteapayer)) { - if ($totalpaye > 0 || $totalcreditnotes > 0) { + if ($totalpaid > 0 || $totalcreditnotes > 0) { // If one payment or one credit note was linked to this invoice print ''.$langs->trans('ClassifyPaidPartially').''; } else { diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index 387e3fc39b8..8224fcc9c00 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -172,7 +172,7 @@ if ($id > 0 || !empty($ref)) { } $morehtmlref .= '
'; - $object->totalpaye = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index e08449b376b..5b7d797a02f 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -102,7 +102,7 @@ if ($object->id > 0) { $head = facturefourn_prepare_head($object); print dol_get_fiche_head($head, 'documents', $langs->trans('SupplierInvoice'), -1, 'supplier_invoice'); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); $linkback = ''.$langs->trans("BackToList").''; @@ -150,7 +150,7 @@ if ($object->id > 0) { } $morehtmlref .= ''; - $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); diff --git a/htdocs/fourn/facture/info.php b/htdocs/fourn/facture/info.php index 42031bc7fd9..0cbf0f17512 100644 --- a/htdocs/fourn/facture/info.php +++ b/htdocs/fourn/facture/info.php @@ -116,7 +116,7 @@ if (!empty($conf->projet->enabled)) { } $morehtmlref .= ''; -$object->totalpaye = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status +$object->totalpaid = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index a851e95e089..70a7334196a 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -323,10 +323,10 @@ if (empty($reshook)) { $objecttmp = new FactureFournisseur($db); $result = $objecttmp->fetch($toselectid); if ($result > 0) { - $totalpaye = $objecttmp->getSommePaiement(); + $totalpaid = $objecttmp->getSommePaiement(); $totalcreditnotes = $objecttmp->getSumCreditNotesUsed(); $totaldeposits = $objecttmp->getSumDepositsUsed(); - $objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); + $objecttmp->resteapayer = price2num($objecttmp->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits, 'MT'); if ($objecttmp->statut == FactureFournisseur::STATUS_DRAFT) { $error++; setEventMessages($objecttmp->ref.' '.$langs->trans("Draft"), $objecttmp->errors, 'errors'); diff --git a/htdocs/fourn/facture/note.php b/htdocs/fourn/facture/note.php index 3b14dfeaf28..59902947cef 100644 --- a/htdocs/fourn/facture/note.php +++ b/htdocs/fourn/facture/note.php @@ -144,7 +144,7 @@ if ($object->id > 0) { } $morehtmlref .= ''; - $object->totalpaye = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status + $object->totalpaid = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php index 353083bd717..993d772a641 100644 --- a/htdocs/fourn/recap-fourn.php +++ b/htdocs/fourn/recap-fourn.php @@ -108,14 +108,14 @@ if ($socid > 0) { print $fac->error."
"; continue; } - $totalpaye = $fac->getSommePaiement(); + $totalpaid = $fac->getSommePaiement(); print ''; - print "".dol_print_date($fac->date)."\n"; + print ''.dol_print_date($fac->date)."\n"; print "id\">".img_object($langs->trans("ShowBill"), "bill")." ".$fac->ref."\n"; - print ''.$fac->getLibStatut(2, $totalpaye).''; + print ''.$fac->getLibStatut(2, $totalpaid).''; print ''.price($fac->total_ttc)."\n"; $solde = $solde + $fac->total_ttc; diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index c03aeb4b526..5553ee464c7 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -1051,8 +1051,10 @@ if ($ispaymentok) { include_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php'; $paiement = new PaymentDonation($db); + $totalpaid = $FinalPaymentAmt; + if ($currencyCodeType == $conf->currency) { - $paiement->amounts = array($object->id => $FinalPaymentAmt); // Array with all payments dispatching with donation + $paiement->amounts = array($object->id => $totalpaid); // Array with all payments dispatching with donation } else { // PaymentDonation does not support multi currency $postactionmessages[] = 'Payment donation can\'t be payed with diffent currency than '.$conf->currency; @@ -1078,7 +1080,9 @@ if ($ispaymentok) { $postactionmessages[] = 'Payment created'; $ispostactionok = 1; - if ($totalpayed >= $don->getRemainToPay()) $don->setPaid($don->id); + if ($totalpaid >= $don->getRemainToPay()) { + $don->setPaid($don->id); + } } } diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php index e5da198c17f..00591b5a32f 100644 --- a/htdocs/salaries/card.php +++ b/htdocs/salaries/card.php @@ -323,9 +323,9 @@ if ($action == 'add' && empty($cancel)) { if ($action == 'confirm_delete') { $result = $object->fetch($id); - $totalpaye = $object->getSommePaiement(); + $totalpaid = $object->getSommePaiement(); - if (empty($totalpaye)) { + if (empty($totalpaid)) { $db->begin(); $ret = $object->delete($user); @@ -827,8 +827,8 @@ if ($id) { $morehtmlref .= ''; - $totalpaye = $object->getSommePaiement(); - $object->totalpaye = $totalpaye; + $totalpaid = $object->getSommePaiement(); + $object->totalpaid = $totalpaid; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); @@ -945,7 +945,7 @@ if ($id) { //print $sql; $resql = $db->query($sql); if ($resql) { - $totalpaye = 0; + $totalpaid = 0; $num = $db->num_rows($resql); $i = 0; $total = 0; @@ -994,7 +994,7 @@ if ($id) { } print ''.price($objp->amount)."\n"; print ""; - $totalpaye += $objp->amount; + $totalpaid += $objp->amount; $i++; } } else { @@ -1003,10 +1003,10 @@ if ($id) { print ''; } - print ''.$langs->trans("AlreadyPaid")." :".price($totalpaye)."\n"; + print ''.$langs->trans("AlreadyPaid")." :".price($totalpaid)."\n"; print ''.$langs->trans("AmountExpected")." :".price($object->amount)."\n"; - $resteapayer = $object->amount - $totalpaye; + $resteapayer = $object->amount - $totalpaid; $cssforamountpaymentcomplete = 'amountpaymentcomplete'; print ''.$langs->trans("RemainderToPay")." :"; @@ -1067,7 +1067,7 @@ if ($id) { print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER["PHP_SELF"].'?action=clone&token='.newToken().'&id='.$object->id, ''); } - if (!empty($user->rights->salaries->delete) && empty($totalpaye)) { + if (!empty($user->rights->salaries->delete) && empty($totalpaid)) { print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, ''); } else { print dolGetButtonAction($langs->trans('DisabledBecausePayments'), $langs->trans('Delete'), 'default', $_SERVER['PHP_SELF'].'#', '', false); diff --git a/htdocs/stripe/class/actions_stripe.class.php b/htdocs/stripe/class/actions_stripe.class.php index f1a7a5c7877..0d8b5e03435 100644 --- a/htdocs/stripe/class/actions_stripe.class.php +++ b/htdocs/stripe/class/actions_stripe.class.php @@ -175,6 +175,8 @@ class ActionsStripeconnect $sql .= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf'; $sql .= ' WHERE pf.fk_facture = '.((int) $object->id); + $totalpaid = 0; + $result = $this->db->query($sql); if ($result) { $i = 0; @@ -182,14 +184,14 @@ class ActionsStripeconnect while ($i < $num) { $objp = $this->db->fetch_object($result); - $totalpaye += $objp->amount; + $totalpaid += $objp->amount; $i++; } } else { dol_print_error($this->db, ''); } - $resteapayer = $object->total_ttc - $totalpaye; + $resteapayer = $object->total_ttc - $totalpaid; // Request a direct debit order if ($object->statut > Facture::STATUS_DRAFT && $object->statut < Facture::STATUS_ABANDONED && $object->paye == 0) { $stripe = new Stripe($this->db); From deb969e2f3184d954dd960ca2f876f2cb1efec31 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 May 2022 17:11:41 +0200 Subject: [PATCH 082/174] Var not used --- htdocs/compta/tva/class/tva.class.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index c112d8cb01b..f54ed42fb06 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -62,12 +62,10 @@ class Tva extends CommonObject public $type_payment; public $num_payment; - public $totalpaid; - /** - * @var integer|string totalpaye + * @var integer|string totalpaid */ - public $totalpaye; + public $totalpaid; /** * @var string label From a193474fa38046605fdca8cfabcad92a315242f8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 May 2022 17:15:43 +0200 Subject: [PATCH 083/174] Update card.php --- htdocs/comm/propal/card.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 3e9c2cb4eeb..cb7e512bc36 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -121,9 +121,7 @@ $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights-> $usercancreateorder = $user->rights->commande->creer; $usercancreateinvoice = $user->rights->facture->creer; $usercancreatecontract = $user->rights->contrat->creer; -if (!empty($conf->ficheinter->enabled)) { - $usercancreateintervention = $user->rights->ficheinter->creer; -} +$usercancreateintervention = empty($conf->ficheinter->enabled) ? 0 : $user->rights->ficheinter->creer; $usercancreatepurchaseorder = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer); $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php From 460687504cb1b1973a04e6c0aa490883afd35bc2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 May 2022 17:16:48 +0200 Subject: [PATCH 084/174] Update card.php --- htdocs/comm/propal/card.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 3e9c2cb4eeb..cb7e512bc36 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -121,9 +121,7 @@ $usercansend = (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights-> $usercancreateorder = $user->rights->commande->creer; $usercancreateinvoice = $user->rights->facture->creer; $usercancreatecontract = $user->rights->contrat->creer; -if (!empty($conf->ficheinter->enabled)) { - $usercancreateintervention = $user->rights->ficheinter->creer; -} +$usercancreateintervention = empty($conf->ficheinter->enabled) ? 0 : $user->rights->ficheinter->creer; $usercancreatepurchaseorder = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer); $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php From ee4329327dbbb76ec3e732f0b28e5045f749a3b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 May 2022 17:23:10 +0200 Subject: [PATCH 085/174] Fix dependencies for scrutinizer --- .scrutinizer.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 3cffed355fa..6c50557f7c0 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -21,6 +21,8 @@ filter: - htdocs/includes/* - node_modules/* - test/* + dependency_paths: + - htdocs/includes/* paths: - htdocs/* - scripts/* From 7d5d242da074e207645748581737c5a7f192cced Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 22 May 2022 17:24:55 +0200 Subject: [PATCH 086/174] Fix dependencies for scrutinizer --- .scrutinizer.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 6c50557f7c0..67b4b346b6c 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -18,7 +18,6 @@ filter: - dev/* - doc/* - documents/* - - htdocs/includes/* - node_modules/* - test/* dependency_paths: From bc9859c7bded895cf6563e9afb6404b77f0cc4ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 00:12:16 +0200 Subject: [PATCH 087/174] Fix phpcs --- htdocs/admin/mails_templates.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 3d5125fab5d..abc434ed58f 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -57,6 +57,7 @@ $langs->loadLangs($langsArray); $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; $massaction = GETPOST('massaction', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation +$mode = GETPOST('mode', 'aZ09'); $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'alpha'); @@ -619,19 +620,19 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } -if (!empty($search)) { -foreach ($search as $key => $val) { - if (is_array($search[$key]) && count($search[$key])) { - foreach ($search[$key] as $skey) { - if ($skey != '') { - $param .= '&search_'.$key.'[]='.urlencode($skey); +if (!empty($search) && is_array($search)) { + foreach ($search as $key => $val) { + if (is_array($search[$key]) && count($search[$key])) { + foreach ($search[$key] as $skey) { + if ($skey != '') { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } } + } elseif ($search[$key] != '') { + $param .= '&search_'.$key.'='.urlencode($search[$key]); } - } elseif ($search[$key] != '') { - $param .= '&search_'.$key.'='.urlencode($search[$key]); } } -} if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } From 36ccc52554c368b3b317e1dc4f9f4c16129cccad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 00:19:15 +0200 Subject: [PATCH 088/174] Doc --- htdocs/core/triggers/interface_80_modStripe_Stripe.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php index dfac4c5b84d..54ee9929cb2 100644 --- a/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php +++ b/htdocs/core/triggers/interface_80_modStripe_Stripe.class.php @@ -202,8 +202,8 @@ class InterfaceStripe extends DolibarrTriggers $this->db->query($sql); } - // If payment mode is linked to Stripee, we update/delete Stripe too - if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') { + // If payment mode is linked to Stripe, we update/delete Stripe too + if ($action == 'COMPANYPAYMENTMODE_CREATE' && $object->type == 'card') { // For creation of credit card, we do not create in Stripe automatically } if ($action == 'COMPANYPAYMENTMODE_MODIFY' && $object->type == 'card') { @@ -222,6 +222,7 @@ class InterfaceStripe extends DolibarrTriggers } if ($customer) { + dol_syslog("We got the customer, so now we update the credit card", LOG_DEBUG); $card = $stripe->cardStripe($customer, $object, $stripeacc, $servicestatus); if ($card) { $card->metadata = array('dol_id'=>$object->id, 'dol_version'=>DOL_VERSION, 'dol_entity'=>$conf->entity, 'ipaddress'=>(empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR'])); From e271616bea77ee33ce69718d3d5cff8f9f63c949 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 00:22:26 +0200 Subject: [PATCH 089/174] Scrutinizer --- htdocs/comm/mailing/class/mailing.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 0c2bf539384..c944d9ab216 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -185,6 +185,11 @@ class Mailing extends CommonObject */ public $substitutionarray; + /** + * @var array substitutionarrayfortest + */ + public $substitutionarrayfortest; + /** * Constructor From 00e65eb106b8efdbd9fd98cb8cac1b02adaa6224 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 00:49:59 +0200 Subject: [PATCH 090/174] Fix bad management when inserting contacts of actioncomm --- htdocs/comm/action/class/actioncomm.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index aeb20e6c7b4..a406bb56463 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1220,11 +1220,14 @@ class ActionComm extends CommonObject if (!empty($this->socpeopleassigned)) { $already_inserted = array(); - foreach (array_keys($this->socpeopleassigned) as $id) { + foreach (array_keys($this->socpeopleassigned) as $key => $val) { + if (!is_array($val)) { // For backward compatibility when val=id + $val = array('id'=>$val); + } if (!empty($already_inserted[$val['id']])) continue; $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)"; - $sql .= " VALUES(".((int) $this->id).", 'socpeople', ".((int) $id).", 0, 0, 0)"; + $sql .= " VALUES(".((int) $this->id).", 'socpeople', ".((int) $val['id']).", 0, 0, 0)"; $resql = $this->db->query($sql); if (!$resql) { From 9b64f0485783277645aafb2183fb0f6c2ecb6a91 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 00:57:02 +0200 Subject: [PATCH 091/174] Fix label --- htdocs/projet/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 0b57c4ed306..4f7cb3ce7a0 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1092,7 +1092,7 @@ if ($action == 'create' && $user->rights->projet->creer) { print img_picto($langs->trans('SharedProject'), 'world', 'class="paddingrightonly"'); print $langs->trans('SharedProject'); } else { - print img_picto($langs->trans('SharedProject'), 'private', 'class="paddingrightonly"'); + print img_picto($langs->trans('PrivateProject'), 'private', 'class="paddingrightonly"'); print $langs->trans('PrivateProject'); } print ''; @@ -1207,7 +1207,7 @@ if ($action == 'create' && $user->rights->projet->creer) { { var element = jQuery("#opp_status option:selected"); var defaultpercent = element.attr("defaultpercent"); - var defaultcloseproject = '.$defaultcheckedwhenoppclose.'; + var defaultcloseproject = '.((int) $defaultcheckedwhenoppclose).'; var elemcode = element.attr("elemcode"); var oldpercent = \''.dol_escape_js($object->opp_percent).'\'; From d0aef6857c2d7173f00162ee189c3300119c920b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 01:02:59 +0200 Subject: [PATCH 092/174] Add missing fields for css on extrafields --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 5 +++++ htdocs/install/mysql/tables/llx_extrafields.sql | 3 +++ 2 files changed, 8 insertions(+) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 8668063d775..f5889bafc1e 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -379,3 +379,8 @@ ALTER TABLE llx_fichinter ADD COLUMN ref_client varchar(255) after ref_ext; ALTER TABLE llx_c_holiday_types ADD COLUMN sortorder smallint; ALTER TABLE llx_expedition MODIFY COLUMN ref_customer varchar(255); + +ALTER TABLE llx_extrafields ADD COLUMN css varchar(128); +ALTER TABLE llx_extrafields ADD COLUMN cssview varchar(128); +ALTER TABLE llx_extrafields ADD COLUMN csslist varchar(128); + diff --git a/htdocs/install/mysql/tables/llx_extrafields.sql b/htdocs/install/mysql/tables/llx_extrafields.sql index 1ade8502bf5..33a317d4abd 100644 --- a/htdocs/install/mysql/tables/llx_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_extrafields.sql @@ -40,6 +40,9 @@ create table llx_extrafields totalizable boolean DEFAULT FALSE, -- is extrafield totalizable on list langs varchar(64), -- example: fileofmymodule@mymodule help text, -- to store help tooltip + css varchar(128), -- to store css on create/update forms + cssview varchar(128), -- to store css on view form + csslist varchar(128), -- to store css on list fk_user_author integer, -- user making creation fk_user_modif integer, -- user making last change datec datetime, -- date de creation From 35edd3ac6e5310ab3c823c2c9a7e7419382cfa91 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 01:10:37 +0200 Subject: [PATCH 093/174] Fix bad test --- htdocs/core/class/html.formfile.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 07bd8ac5a5f..36fd84367ae 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1340,7 +1340,8 @@ class FormFile print ''."\n"; // Do we have entry into database ? print ''."\n"; - print ''; + print ''; + // File name print ''; From bbebb9ef5ad2b7dd97c0932909f52271856d28e4 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Mon, 23 May 2022 08:29:04 +0200 Subject: [PATCH 094/174] fix #20989 : modResource depends on modResource --- htdocs/core/modules/modResource.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index 2c59b6b3172..b43ead29e7f 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -91,7 +91,7 @@ class modResource extends DolibarrModules // Dependencies // List of modules id that must be enabled if this module is enabled - $this->depends = array('modResource'); + $this->depends = array(); // List of modules id to disable if this one is disabled $this->requiredby = array('modPlace'); // Minimum version of PHP required by module From 23468929dfee10ceb6394ef58cb56fe92ae9a74f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 09:13:37 +0200 Subject: [PATCH 095/174] Clean code --- htdocs/compta/tva/payments.php | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index 5b104955716..0279acdeaa4 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -5,7 +5,7 @@ * Copyright (C) 2011-2016 Alexandre Spangaro * Copyright (C) 2011-2014 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2021 Gauthier VERDOL + * Copyright (C) 2021 Gauthier VERDOL * * 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 @@ -180,6 +180,10 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); + $tva->id = $obj->rowid; + $tva->ref = $obj->rowid; + $tva->label = $obj->label; + $payment_vat_static->id = $obj->pid; $payment_vat_static->ref = $obj->pid; @@ -190,31 +194,32 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { // VAT print ''; - $tva->id = $obj->rowid; - $tva->ref = $obj->rowid; - $tva->label = $obj->label; print $tva->getNomUrl(1, '20'); print ''; // Label - print ''.$obj->label.''; + print ''.dol_escape_htmltag($obj->label).''; // Date - $date = $obj->datev; - print ''.dol_print_date($date, 'day').''; + $date = $db->jdate($obj->datev); + print ''.dol_print_date($date, 'day').''; // Date payment - print ''.dol_print_date($db->jdate($obj->datep), 'day').''; + $datep = $db->jdate($obj->datep); + print ''.dol_print_date($datep, 'day').''; // Type payment - print ''; + $labelpaymenttype = ''; if ($obj->payment_code) { - print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + $labelpaymenttype = $langs->trans("PaymentTypeShort".$obj->payment_code).' '; } + + print ''; + print dol_escape_htmltag($labelpaymenttype); print ''; // Chq number - print ''.$obj->num_payment.''; + print ''.dol_escape_htmltag($obj->num_payment).''; if (!empty($conf->banque->enabled)) { // Bank transaction @@ -231,10 +236,9 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) { print ''; } - // Type - //print ''.$obj->type_label.''; // Expected to pay print ''.price($obj->total).''; + // Paid print ''; if ($obj->totalpaid) { From 109181c4ea028d15b300390dd9e57e8802685f5a Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Fri, 22 Apr 2022 13:47:58 +0200 Subject: [PATCH 096/174] fix #20651 : multilang contact support --- htdocs/contact/card.php | 51 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 28a61ce5190..bec9388a0ed 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -40,6 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; @@ -219,7 +220,10 @@ if (empty($reshook)) $object->birthday = dol_mktime(0, 0, 0, GETPOST("birthdaymonth", 'int'), GETPOST("birthdayday", 'int'), GETPOST("birthdayyear", 'int')); $object->birthday_alert = GETPOST("birthday_alert", 'alpha'); - // Fill array 'array_options' with data from add form + //Default language + $object->default_lang = GETPOST('default_lang'); + + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { @@ -402,7 +406,10 @@ if (empty($reshook)) $object->roles = GETPOST("roles", 'array'); // Note GETPOSTISSET("role") is null when combo is empty - // Fill array 'array_options' with data from add form + //Default language + $object->default_lang = GETPOST('default_lang'); + + // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET'); if ($ret < 0) $error++; @@ -521,6 +528,7 @@ $help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('', $title, $help_url); $form = new Form($db); +$formadmin = new FormAdmin($db); $formcompany = new FormCompany($db); $countrynotdefined = $langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; @@ -843,6 +851,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print $form->selectarray('priv', $selectarray, (GETPOST("priv", 'alpha') ?GETPOST("priv", 'alpha') : $object->priv), 0); print ''; + //Default language + if (!empty($conf->global->MAIN_MULTILANGS)) + { + print ''.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; + print $formadmin->select_language(GETPOST('default_lang', 'alpha') ?GETPOST('default_lang', 'alpha') : ($object->default_lang ? $object->default_lang : ''), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone', 0, 0, 0, null, 1); + + print ''; + print ''; + } + // Categories if (!empty($conf->categorie->enabled) && !empty($user->rights->categorie->lire)) { print ''.$form->editfieldkey('Categories', 'contcats', '', $object, 0).''; @@ -1125,6 +1143,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print $form->selectarray('priv', $selectarray, $object->priv, 0); print ''; + //Default language + if (!empty($conf->global->MAIN_MULTILANGS)) + { + print ''.$form->editfieldkey('DefaultLang', 'default_lang', '', $object, 0).''."\n"; + print $formadmin->select_language($object->default_lang, 'default_lang', 0, 0, 1, 0, 0, '', 0, 0, 0, null, 1); + + print ''; + print ''; + } + // Note Public print ''; $doleditor = new DolEditor('note_public', $object->note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); @@ -1353,9 +1381,22 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) print ''; } - print ''.$langs->trans("ContactVisibility").''; - print $object->LibPubPriv($object->priv); - print ''; + // Default language + if (!empty($conf->global->MAIN_MULTILANGS)) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + print ''.$langs->trans("DefaultLang").''; + //$s=picto_from_langcode($object->default_lang); + //print ($s?$s.' ':''); + $langs->load("languages"); + $labellang = ($object->default_lang ? $langs->trans('Language_'.$object->default_lang.'_'.strtoupper($object->default_lang)) : ''); + print $labellang; + print ''; + } + + print ''.$langs->trans("ContactVisibility").''; + print $object->LibPubPriv($object->priv); + print ''; print ''; print ''; From f276c66614987fc729307cb3892dcacea365748d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 09:45:42 +0200 Subject: [PATCH 097/174] NEWW Add selection of the mode to show icon/text in setup --- htdocs/admin/ihm.php | 11 ++++-- htdocs/core/lib/usergroups.lib.php | 62 ++++++++++++++++-------------- htdocs/langs/en_US/admin.lang | 7 +++- 3 files changed, 47 insertions(+), 33 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 5605fa4fb63..fcf3116a971 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -101,9 +101,14 @@ if ($action == 'update') { if ($mode == 'template') { dolibarr_set_const($db, "MAIN_THEME", GETPOST("main_theme", 'aZ09'), 'chaine', 0, '', $conf->entity); - /*$val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE'); - if (! $val) dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity); - else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'), 'chaine', 0, '', $conf->entity);*/ + if (GETPOSTISSET('THEME_TOPMENU_DISABLE_IMAGE')) { + $val=GETPOST('THEME_TOPMENU_DISABLE_IMAGE'); + if (!$val) { + dolibarr_del_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'), 'chaine', 0, '', $conf->entity); + } + } $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'), array())))); if ($val == '') { diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 0589ca6c1c5..3883ae11fb4 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -450,26 +450,6 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; } - // Show logo - if ($foruserprofile) { - // Nothing - } else { - // Show logo - print ''.$langs->trans("EnableShowLogo").''; - if ($edit) { - print ajax_constantonoff('MAIN_SHOW_LOGO', array(), null, 0, 0, 1); - //print $form->selectyesno('MAIN_SHOW_LOGO', $conf->global->MAIN_SHOW_LOGO, 1); - } else { - print yn($conf->global->MAIN_SHOW_LOGO); - } - print ''; - print ''; - /* - print ''.$langs->trans("EnableShowLogo").'' . yn($conf->global->MAIN_SHOW_LOGO) . ''; - print "";*/ - } - - // TopMenuDisableImages if ($foruserprofile) { /* @@ -493,26 +473,51 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) if ($edit) print '
('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; print '';*/ } else { - $default = $langs->trans('No'); + $listoftopmenumodes = array( + '0' => $langs->transnoentitiesnoconv("IconAndText"), + '1' => $langs->transnoentitiesnoconv("TextOnly"), + '2' => $langs->transnoentitiesnoconv("IconOnlyAllTextsOnHover"), + '3' => $langs->transnoentitiesnoconv("IconOnlyTextOnHover"), + '4' => $langs->transnoentitiesnoconv("IconOnly"), + ); print ''; print ''.$langs->trans("TopMenuDisableImages").''; print ''; if ($edit) { - print ajax_constantonoff('THEME_TOPMENU_DISABLE_IMAGE', array(), null, 0, 0, 1); - //print $form->selectyesno('THEME_TOPMENU_DISABLE_IMAGE', $conf->global->THEME_TOPMENU_DISABLE_IMAGE, 1); + //print ajax_constantonoff('THEME_TOPMENU_DISABLE_IMAGE', array(), null, 0, 0, 1); + print $form->selectarray('THEME_TOPMENU_DISABLE_IMAGE', $listoftopmenumodes, $conf->global->THEME_TOPMENU_DISABLE_IMAGE); } else { - print yn($conf->global->THEME_TOPMENU_DISABLE_IMAGE); + $listoftopmenumodes[$conf->global->THEME_TOPMENU_DISABLE_IMAGE]; + //print yn($conf->global->THEME_TOPMENU_DISABLE_IMAGE); } - print '   '.$langs->trans("Default").': '.$default.' '; - print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); + print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes")); print ''; print ''; } + // Show logo + if ($foruserprofile) { + // Nothing + } else { + // Show logo + print ''.$langs->trans("EnableShowLogo").''; + if ($edit) { + print ajax_constantonoff('MAIN_SHOW_LOGO', array(), null, 0, 0, 1); + //print $form->selectyesno('MAIN_SHOW_LOGO', $conf->global->MAIN_SHOW_LOGO, 1); + } else { + print yn($conf->global->MAIN_SHOW_LOGO); + } + print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes")); + print ''; + print ''; + /* + print ''.$langs->trans("EnableShowLogo").'' . yn($conf->global->MAIN_SHOW_LOGO) . ''; + print "";*/ + } + // BorderTableActive if ($foruserprofile) { } else { - $default = $langs->trans('No'); print ''; print ''.$langs->trans("UseBorderOnTable").''; print ''; @@ -522,8 +527,7 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) } else { print yn($conf->global->THEME_ELDY_USEBORDERONTABLE); } - print '   '.$langs->trans("Default").': '.$default.' '; - print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis")); + print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes")); print ''; print ''; } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d122e9ca7d1..c7814211344 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2254,4 +2254,9 @@ ReadOnlyMode=Is instance in "Read Only" mode DEBUGBAR_USE_LOG_FILE=Use the dolibarr.log file to trap Logs UsingLogFileShowAllRecordOfSubrequestButIsSlower=Use the dolibarr.log file to trap Logs instead of live memory catching. It allows to catch all logs instead of only log of current process (so including the one of ajax subrequests pages) but will make your instance very very slow. Not recommended. FixedOrPercent=Fixed (use keyword 'fixed') or percent (use keyword 'percent') -DefaultOpportunityStatus=Default opportunity status (first status when lead is created) \ No newline at end of file +DefaultOpportunityStatus=Default opportunity status (first status when lead is created) +IconAndText=Icon and text +TextOnly=Text only +IconOnlyAllTextsOnHover=Icon only - All texts appears under icon on mouse hover menu bar +IconOnlyTextOnHover=Icon only - Text of icon appears under icon on mouse hover the icon +IconOnly=Icon only - Text on tooltip only From 4f572a89d32072c99e39ffadaa0a4e7ba27d9fb7 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 23 May 2022 11:50:06 +0200 Subject: [PATCH 098/174] FIX : Unidentified lines array on reception card --- htdocs/reception/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 9a679c067f8..00b7445cfd3 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1649,7 +1649,7 @@ if ($action == 'create') { print '
'; print '
'; - print ''; + print '
'; print ''; // # if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { From 1a6903f677d0cd3675681929d92262e37aae2805 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 11:56:39 +0200 Subject: [PATCH 099/174] Debug v16 --- htdocs/contact/card.php | 2 +- htdocs/contact/list.php | 12 +- .../knowledgerecord_list.php | 156 ++++++++++++------ htdocs/langs/en_US/main.lang | 3 +- htdocs/main.inc.php | 22 ++- .../modulebuilder/template/myobject_list.php | 3 +- htdocs/partnership/partnership_card.php | 2 +- 7 files changed, 134 insertions(+), 66 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 1cef1901917..d3cd004ab5f 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -635,7 +635,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $object->country = $tmparray['label']; } - $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("AddContact") : $langs->trans("AddContactAddress")); + $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("NewContact") : $langs->trans("NewContactAddress")); $linkback = ''; print load_fiche_titre($title, $linkback, 'address'); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 93d61f8a903..e68274ecff2 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -132,31 +132,31 @@ if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('b } $offset = $limit * $page; -$titre = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("ListOfContacts") : $langs->trans("ListOfContactsAddresses")); +$title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses")); if ($type == "p") { if (empty($contextpage) || $contextpage == 'contactlist') { $contextpage = 'contactprospectlist'; } - $titre .= ' ('.$langs->trans("ThirdPartyProspects").')'; + $title .= ' ('.$langs->trans("ThirdPartyProspects").')'; $urlfiche = "card.php"; } if ($type == "c") { if (empty($contextpage) || $contextpage == 'contactlist') { $contextpage = 'contactcustomerlist'; } - $titre .= ' ('.$langs->trans("ThirdPartyCustomers").')'; + $title .= ' ('.$langs->trans("ThirdPartyCustomers").')'; $urlfiche = "card.php"; } elseif ($type == "f") { if (empty($contextpage) || $contextpage == 'contactlist') { $contextpage = 'contactsupplierlist'; } - $titre .= ' ('.$langs->trans("ThirdPartySuppliers").')'; + $title .= ' ('.$langs->trans("ThirdPartySuppliers").')'; $urlfiche = "card.php"; } elseif ($type == "o") { if (empty($contextpage) || $contextpage == 'contactlist') { $contextpage = 'contactotherlist'; } - $titre .= ' ('.$langs->trans("OthersNotLinkedToThirdParty").')'; + $title .= ' ('.$langs->trans("OthersNotLinkedToThirdParty").')'; $urlfiche = ""; } @@ -709,7 +709,7 @@ print ''; print ''; print ''; -print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'address', 0, $newcardbutton, '', $limit, 0, 0, 1); $topicmail = "Information"; $modelmail = "contact"; diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index 9204672ba5a..b903ab83acc 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -95,7 +95,7 @@ if (!$sortorder) { } // Initialize array of search criterias -$search_all = GETPOST('search_all', 'alphanohtml') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'); +$search_all = GETPOST('search_all', 'alphanohtml'); $search = array(); foreach ($object->fields as $key => $val) { if (GETPOST('search_'.$key, 'alpha') !== '') { @@ -124,11 +124,11 @@ $arrayfields = array(); foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field if (!empty($val['visible'])) { - $visible = (int) dol_eval($val['visible'], 1, 1, '1'); + $visible = (int) dol_eval($val['visible'], 1); $arrayfields['t.'.$key] = array( 'label'=>$val['label'], 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')), + 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), 'position'=>$val['position'], 'help'=> isset($val['help']) ? $val['help'] : '' ); @@ -234,13 +234,13 @@ $sql .= $object->getFieldList('t'); // Add fields from extrafields 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.', ' : ''); + $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 .= preg_replace('/^,/', ',', $hookmanager->resPrint); +$sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { @@ -278,10 +278,10 @@ foreach ($search as $key => $val) { $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t.".$columnName." >= '".$db->idate($search[$key])."'"; + $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; } if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'"; + $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; } } } @@ -340,35 +340,34 @@ $sql.=$hookmanager->resPrint; $sql=preg_replace('/,\s*$/','', $sql); */ -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } -// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { - $num = $nbtotalofrecords; -} else { - if ($limit) { - $sql .= $db->plimit($limit + 1, $offset); - } - $resql = $db->query($sql); - if (!$resql) { - dol_print_error($db); - exit; - } - - $num = $db->num_rows($resql); +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); } +$resql = $db->query($sql); +if (!$resql) { + dol_print_error($db); + exit; +} + +$num = $db->num_rows($resql); + + // Direct jump if only one record found if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); @@ -381,12 +380,15 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ // Output page // -------------------------------------------------------------------- -llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'classforhorizontalscrolloftabs'); +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -396,9 +398,11 @@ if ($limit > 0 && $limit != $conf->liste_limit) { foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { foreach ($search[$key] as $skey) { - $param .= '&search_'.$key.'[]='.urlencode($skey); + if ($skey != '') { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } } - } else { + } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } } @@ -455,10 +459,13 @@ $trackid = 'xxxx'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { + $setupstring = ''; foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); + $setupstring .= $key."=".$val.";"; } - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; + print ''."\n"; + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } $moreforfilter = ''; @@ -503,6 +510,13 @@ print '
'; +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} foreach ($object->fields as $key => $val) { $searchkey = empty($search[$key]) ? '' : $search[$key]; $cssforfield = (empty($val['css']) ? '' : $val['css']); @@ -512,16 +526,16 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; } @@ -545,16 +561,23 @@ $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print ''; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { @@ -563,11 +586,13 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } + $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label if (!empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + $totalarray['nbfield']++; } } // Extra fields @@ -577,7 +602,10 @@ $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$ $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} +$totalarray['nbfield']++; print ''."\n"; @@ -595,8 +623,10 @@ if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_a // Loop on record // -------------------------------------------------------------------- $i = 0; -$totalarray = array(); -while ($i < ($limit ? min($num, $limit) : $num)) { +$savnbfield = $totalarray['nbfield']; +$totalarray['nbfield'] = 0; +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); if (empty($obj)) { break; // Should not happen @@ -606,8 +636,20 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $object->setVarsFromFetchObj($obj); // Show here line of result - print ''; - $totalarray['nbfield'] = 0; + $j = 0; + print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { @@ -622,14 +664,20 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) { + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; + print ''; if ($key == 'status') { print $object->getLibStatut(5); + } elseif ($key == 'rowid') { + print $object->showOutputField($val, $key, $object->id, ''); } elseif ($key == 'fk_user_creat') { if ($object->fk_user_creat > 0) { if (isset($conf->cache['user'][$object->fk_user_creat])) { @@ -695,15 +743,17 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column - print ''; } - print ''; if (!$i) { $totalarray['nbfield']++; } @@ -724,14 +774,14 @@ if ($num == 0) { $colspan++; } } - print ''; + print ''; } $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $searchkey, $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) { - print $object->showInputField($val, $key, $searchkey, '', '', 'search_', 'maxwidth125', 1); + print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { print '
'; print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -530,9 +544,11 @@ foreach ($object->fields as $key => $val) { print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); print '
'; } elseif ($key == 'lang') { - print $formadmin->select_language($searchkey, 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin = new FormAdmin($db); + print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); } else { - print ''; + print ''; } print '
'; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { // 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($object->id, $arrayofselected)) { + $selected = 1; + } + 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 - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; + if (empty($conf->global->MAIN_CHECKBOX_LEFT_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 + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'."\n"; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 97111df74cd..af9894a7897 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1175,4 +1175,5 @@ ConfirmAllocateCommercialQuestion=Are you sure you want to assign the %s selecte CommercialsAffected=Sales representatives affected CommercialAffected=Sales representative affected YourMessage=Votre message -YourMessageHasBeenReceived=Your message has been received. We will answer or contact you as soon as possible. \ No newline at end of file +YourMessageHasBeenReceived=Your message has been received. We will answer or contact you as soon as possible. +UrlToCheck=Url to check \ No newline at end of file diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 4581814f0f8..0093db5331c 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -2399,6 +2399,14 @@ function printDropdownQuickadd() $items = array( 'items' => array( + array( + "url" => "/adherents/card.php?action=create&mainmenu=members", + "title" => "MenuNewMember@members", + "name" => "Adherent@members", + "picto" => "object_member", + "activation" => !empty($conf->adherent->enabled) && $user->rights->adherent->creer, // vs hooking + "position" => 5, + ), array( "url" => "/societe/card.php?action=create&mainmenu=companies", "title" => "MenuNewThirdParty@companies", @@ -2452,7 +2460,7 @@ function printDropdownQuickadd() "url" => "/supplier_proposal/card.php?action=create&mainmenu=commercial", "title" => "SupplierProposalNew@supplier_proposal", "name" => "SupplierProposal@supplier_proposal", - "picto" => "object_propal", + "picto" => "supplier_proposal", "activation" => !empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposal->creer, // vs hooking "position" => 70, ), @@ -2460,7 +2468,7 @@ function printDropdownQuickadd() "url" => "/fourn/commande/card.php?action=create&mainmenu=commercial", "title" => "NewSupplierOrderShort@orders", "name" => "SupplierOrder@orders", - "picto" => "object_order", + "picto" => "supplier_order", "activation" => (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->creer) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->creer), // vs hooking "position" => 80, ), @@ -2468,7 +2476,7 @@ function printDropdownQuickadd() "url" => "/fourn/facture/card.php?action=create&mainmenu=billing", "title" => "NewBill@bills", "name" => "SupplierBill@bills", - "picto" => "object_bill", + "picto" => "supplier_invoice", "activation" => (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->creer) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->creer), // vs hooking "position" => 90, ), @@ -2488,6 +2496,14 @@ function printDropdownQuickadd() "activation" => !empty($conf->service->enabled) && $user->rights->service->creer, // vs hooking "position" => 110, ), + array( + "url" => "/user/card.php?action=create&type=1&mainmenu=home", + "title" => "AddUser@users", + "name" => "User@users", + "picto" => "user", + "activation" => $user->rights->user->user->creer, // vs hooking + "position" => 500, + ), ), ); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index e319f86e059..c03302551e3 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -562,7 +562,8 @@ if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { print ''; } foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); + $searchkey = empty($search[$key]) ? '' : $search[$key]; + $cssforfield = (empty($val['css']) ? '' : $val['css']); if ($key == 'status') { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php index 29a70edb8ab..34896b46541 100644 --- a/htdocs/partnership/partnership_card.php +++ b/htdocs/partnership/partnership_card.php @@ -260,7 +260,7 @@ llxHeader('', $title, $help_url); // Part to create if ($action == 'create') { - print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Partnership")), '', 'object_'.$object->picto); + print load_fiche_titre($langs->trans("NewPartnership"), '', 'object_'.$object->picto); print '
'; print ''; From 71ed1ec602691baa9c54f9b53b8a138160ace74a Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 23 May 2022 12:07:37 +0200 Subject: [PATCH 100/174] Product lot document management should not use batch but ref (is lot id) --- htdocs/product/stock/productlot_card.php | 9 ++++++++- htdocs/product/stock/productlot_document.php | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index eb6084e5f22..263d9d2c6c8 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -28,6 +28,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; @@ -90,7 +91,13 @@ if ($id || $ref) { $batch = $tmp[1]; } $object->fetch($id, $productid, $batch); - $object->ref = $object->batch; // For document management ( it use $object->ref) + $object->ref = $object->batch; // Old system for document management ( it uses $object->ref) + $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + if (empty($filearray)) { + // If no files linked yet, use new system on lot id. (Batch is not unique and can be same on different product) + $object->fetch($id, $productid, $batch); + } } // Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index 789b03aa6ce..dbe2dd517f4 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -83,10 +83,16 @@ if ($id || $ref) { $batch = $tmp[1]; } $object->fetch($id, $productid, $batch); - $object->ref = $object->batch; // For document management ( it use $object->ref) + $object->ref = $object->batch; // Old system for document management ( it uses $object->ref) if (!empty($conf->productbatch->enabled)) { $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + if (empty($filearray)) { + // If no files linked yet, use new system on lot id. (Batch is not unique and can be same on different product) + $object->fetch($id, $productid, $batch); + $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart); + } } } From 2cd52b6ea230af9027f654e3e8adec2d60a78e6b Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 23 May 2022 12:24:51 +0200 Subject: [PATCH 101/174] FIX : no thead and tbody on reception lines array --- htdocs/reception/card.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 00b7445cfd3..60bcde11055 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1650,6 +1650,7 @@ if ($action == 'create') { print '
'; print ''; + print ''; print ''; // # if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { @@ -1714,6 +1715,7 @@ if ($action == 'create') { print ''; } print "\n"; + print ''; $var = false; @@ -1779,9 +1781,10 @@ if ($action == 'create') { $arrayofpurchaselinealreadyoutput = array(); // Loop on each product to send/sent. Warning: $lines must be sorted by ->fk_commandefourndet (it is a regroupment key on output) + print ''; for ($i = 0; $i < $num_prod; $i++) { print ''; // id of order line - print ''; + print ''; // # if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { @@ -1799,7 +1802,7 @@ if ($action == 'create') { $label = (!empty($lines[$i]->product->label) ? $lines[$i]->product->label : $lines[$i]->product->product_label); } - print '\n"; } else { - print "
'; + print ''; if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) { $text = $lines[$i]->product->getNomUrl(1); $text .= ' - '.$label; @@ -1812,7 +1815,7 @@ if ($action == 'create') { } print ""; + print ''; if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) { if ($lines[$i]->product_type == Product::TYPE_SERVICE) { $text = img_object($langs->trans('Service'), 'service'); @@ -1840,7 +1843,7 @@ if ($action == 'create') { // Qty ordered - print ''; + print ''; if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) { print $lines[$i]->qty_asked; } @@ -1848,7 +1851,7 @@ if ($action == 'create') { // Qty in other receptions (with reception and warehouse used) if ($origin && $origin_id > 0) { - print ''; + print ''; if (!array_key_exists($lines[$i]->fk_commandefourndet, $arrayofpurchaselinealreadyoutput)) { foreach ($alreadysent as $key => $val) { if ($lines[$i]->fk_commandefourndet == $key) { @@ -1919,7 +1922,7 @@ if ($action == 'create') { print '
'; } else { // Qty to receive or received - print ''.$lines[$i]->qty.''; + print ''.$lines[$i]->qty.''; // Warehouse source if (!empty($conf->stock->enabled)) { @@ -1939,7 +1942,7 @@ if ($action == 'create') { if (!empty($conf->productbatch->enabled)) { if (isset($lines[$i]->batch)) { print ''; - print ''; + print ''; $detail = ''; if ($lines[$i]->product->status_batch) { $detail .= $langs->trans("Batch").': '.$lines[$i]->batch; @@ -1963,7 +1966,7 @@ if ($action == 'create') { } // Weight - print ''; + print ''; if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { print $lines[$i]->product->weight * $lines[$i]->qty.' '.measuringUnitString(0, "weight", $lines[$i]->product->weight_units); } else { @@ -1972,7 +1975,7 @@ if ($action == 'create') { print ''; // Volume - print ''; + print ''; if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { print $lines[$i]->product->volume * $lines[$i]->qty.' '.measuringUnitString(0, "volume", $lines[$i]->product->volume_units); } else { @@ -2020,6 +2023,7 @@ if ($action == 'create') { } } } + print ''; // TODO Show also lines ordered but not delivered From 48151b47a677beb36dd9c891b47f17f6684dbf0b Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Mon, 23 May 2022 12:31:37 +0200 Subject: [PATCH 102/174] FIX mvt origin --- htdocs/mrp/mo_movements.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index 7bb040abe1f..634f1caa092 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -934,7 +934,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } if (!empty($arrayfields['origin']['checked'])) { // Origin of movement - print ''.dol_escape_htmltag($origin).''; + print ''.$origin.''; } if (!empty($arrayfields['m.fk_projet']['checked'])) { // fk_project From 9ed75d01bda254fc205c576e419b9cfb562386de Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Mon, 23 May 2022 12:43:30 +0200 Subject: [PATCH 103/174] fix missing token on mo card --- htdocs/mrp/mo_card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 48f64b2601c..2a8fa13be52 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -602,7 +602,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($object->status == $object::STATUS_VALIDATED) { if ($permissiontoadd) { // TODO Add test that production has not started - print ''.$langs->trans("SetToDraft").''; + print ''.$langs->trans("SetToDraft").''; } } @@ -641,16 +641,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $nbProduced += $lineproduced['qty']; } if ($nbProduced > 0) { // If production has started, we can close it - print ''.$langs->trans("Close").''."\n"; + print ''.$langs->trans("Close").''."\n"; } else { print 'transnoentitiesnoconv("Production")).'">'.$langs->trans("Close").''."\n"; } - print ''.$langs->trans("Cancel").''."\n"; + print ''.$langs->trans("Cancel").''."\n"; } if ($object->status == $object::STATUS_PRODUCED || $object->status == $object::STATUS_CANCELED) { - print ''.$langs->trans("ReOpen").''."\n"; + print ''.$langs->trans("ReOpen").''."\n"; } } From 6de1f6bbac68bc5ad24f3d1c6c481b4ab60ab4ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 15:12:15 +0200 Subject: [PATCH 104/174] Generic message --- htdocs/langs/en_US/admin.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index c7814211344..69ef87aca0d 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2048,7 +2048,7 @@ COMPANY_AQUARIUM_CLEAN_REGEX=Regex filter to clean value (COMPANY_AQUARIUM_CLEAN COMPANY_DIGITARIA_CLEAN_REGEX=Regex filter to clean value (COMPANY_DIGITARIA_CLEAN_REGEX) COMPANY_DIGITARIA_UNIQUE_CODE=Duplicate not allowed GDPRContact=Data Protection Officer (DPO, Data Privacy or GDPR contact) -GDPRContactDesc=If you store data about European companies/citizens, you can name the contact who is responsible for the General Data Protection Regulation here +GDPRContactDesc=If you store personal data in your Information System, you can name the contact who is responsible for the General Data Protection Regulation here HelpOnTooltip=Help text to show on tooltip HelpOnTooltipDesc=Put text or a translation key here for the text to show in a tooltip when this field appears in a form YouCanDeleteFileOnServerWith=You can delete this file on the server with Command Line:
%s From 8574f36e352bea8afacbcbcefc68b875c8a258de Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 23 May 2022 15:25:31 +0200 Subject: [PATCH 105/174] dol_dir_list fast mode --- htdocs/product/stock/productlot_card.php | 2 +- htdocs/product/stock/productlot_document.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 263d9d2c6c8..6e6f8991e83 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -93,7 +93,7 @@ if ($id || $ref) { $object->fetch($id, $productid, $batch); $object->ref = $object->batch; // Old system for document management ( it uses $object->ref) $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart); - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $filearray = dol_dir_list($upload_dir, "files"); if (empty($filearray)) { // If no files linked yet, use new system on lot id. (Batch is not unique and can be same on different product) $object->fetch($id, $productid, $batch); diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index dbe2dd517f4..89ba063e8d7 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -87,7 +87,7 @@ if ($id || $ref) { if (!empty($conf->productbatch->enabled)) { $upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart); - $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); + $filearray = dol_dir_list($upload_dir, "files"); if (empty($filearray)) { // If no files linked yet, use new system on lot id. (Batch is not unique and can be same on different product) $object->fetch($id, $productid, $batch); From 8172cb5b974e4a585c600f03a0f895afe48e8313 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Mon, 23 May 2022 19:37:42 +0200 Subject: [PATCH 106/174] Add get knowledgerecord categorie with REST API --- .../class/api_knowledgemanagement.class.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php index 5d26fa90137..d8629547658 100644 --- a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php +++ b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php @@ -19,6 +19,7 @@ use Luracast\Restler\RestException; dol_include_once('/knowledgemanagement/class/knowledgerecord.class.php'); +dol_include_once('/categories/class/categorie.class.php'); @@ -85,6 +86,39 @@ class KnowledgeManagement extends DolibarrApi return $this->_cleanObjectDatas($this->knowledgerecord); } + /** + * Get categories for a knowledgerecord object + * + * @param int $id ID of knowledgerecord object + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * + * @return mixed + * + * @url GET /knowledgerecords/{id}/categories + */ + public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + { + if (!DolibarrApiAccess::$user->rights->categorie->lire) { + throw new RestException(401); + } + + $categories = new Categorie($this->db); + + $result = $categories->getListForItem($id, 'knowledgemanagement', $sortfield, $sortorder, $limit, $page); + + if (empty($result)) { + throw new RestException(404, 'No category found'); + } + + if ($result < 0) { + throw new RestException(503, 'Error when retrieve category list : '.array_merge(array($categories->error), $categories->errors)); + } + + return $result; + } /** * List knowledgerecords From b693a2f10ca9efa83c23e84b5888cbadaf81821b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 19:43:31 +0200 Subject: [PATCH 107/174] Fix typo --- htdocs/compta/cashcontrol/cashcontrol_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 149710c975b..9197eebceb2 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -647,7 +647,7 @@ if (empty($action) || $action == "view" || $action == "close") { print ''; print '
'; - print '
>'; + print '
'; print '
'; print ''; From eaa01706042ee5881c79f4874c44218c695032c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 23 May 2022 20:05:30 +0200 Subject: [PATCH 108/174] Trans --- htdocs/compta/cashcontrol/cashcontrol_card.php | 4 ++-- htdocs/langs/en_US/banks.lang | 4 ++-- htdocs/langs/en_US/cashdesk.lang | 8 ++++---- htdocs/langs/en_US/other.lang | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 9197eebceb2..2b6b027d7ce 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -659,11 +659,11 @@ if (empty($action) || $action == "view" || $action == "close") { print ''; print '"; foreach ($arrayofpaymentmode as $key => $val) { print '"; } diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index a3e0bc2f901..10ba859e71f 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -172,8 +172,8 @@ SEPAMandate=SEPA mandate YourSEPAMandate=Your SEPA mandate FindYourSEPAMandate=This is your SEPA mandate to authorize our company to make direct debit order to your bank. Return it signed (scan of the signed document) or send it by mail to AutoReportLastAccountStatement=Automatically fill the field 'number of bank statement' with last statement number when making reconciliation -CashControl=POS cash desk control -NewCashFence=New cash desk opening or closing +CashControl=POS cash control +NewCashFence=New cash control (opening or closing) BankColorizeMovement=Colorize movements BankColorizeMovementDesc=If this function is enable, you can choose specific background color for debit or credit movements BankColorizeMovementName1=Background color for debit movement diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index dc02f4e9325..8f7f7548de0 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -50,8 +50,8 @@ Footer=Footer AmountAtEndOfPeriod=Amount at end of period (day, month or year) TheoricalAmount=Theorical amount RealAmount=Real amount -CashFence=Cash desk closing -CashFenceDone=Cash desk closing done for the period +CashFence=Cash box closing +CashFenceDone=Cash box closing done for the period NbOfInvoices=Nb of invoices Paymentnumpad=Type of Pad to enter payment Numberspad=Numbers Pad @@ -102,8 +102,8 @@ CashDeskGenericMaskCodes6 =
{TN} tag is used to add the terminal numb TakeposGroupSameProduct=Group same products lines StartAParallelSale=Start a new parallel sale SaleStartedAt=Sale started at %s -ControlCashOpening=Open the "Control cash" popup when opening the POS -CloseCashFence=Close cash desk control +ControlCashOpening=Open the "Control cash box" popup when opening the POS +CloseCashFence=Close cash box control CashReport=Cash report MainPrinterToUse=Main printer to use OrderPrinterToUse=Order printer to use diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 587231f752f..9857ad821ed 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -110,7 +110,7 @@ ChooseYourDemoProfilMore=...or build your own profile
(manual module selectio DemoFundation=Manage members of a foundation DemoFundation2=Manage members and bank account of a foundation DemoCompanyServiceOnly=Company or freelance selling service only -DemoCompanyShopWithCashDesk=Manage a shop with a cash desk +DemoCompanyShopWithCashDesk=Manage a shop with a cash box DemoCompanyProductAndStocks=Shop selling products with Point Of Sales DemoCompanyManufacturing=Company manufacturing products DemoCompanyAll=Company with multiple activities (all main modules) From 351913811046bee61b8dc36fb4b1c144ce47568e Mon Sep 17 00:00:00 2001 From: Ilias Patsiaouras Date: Mon, 23 May 2022 20:26:08 +0200 Subject: [PATCH 109/174] add option to parse extrafield (options_) in emailcollector --- htdocs/emailcollector/class/emailcollector.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 032ee4b534b..2c4741e29b7 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -900,9 +900,17 @@ class EmailCollector extends CommonObject // Overwrite param $tmpproperty $valueextracted = isset($regforval[count($regforval) - 1]) ?trim($regforval[count($regforval) - 1]) : null; if (strtolower($sourcefield) == 'header') { - $object->$tmpproperty = $this->decodeSMTPSubject($valueextracted); + if (preg_match('/^options_/', $tmpproperty)) { + $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $this->decodeSMTPSubject($valueextracted); + } else { + $object->$tmpproperty = $this->decodeSMTPSubject($valueextracted); + } } else { - $object->$tmpproperty = $valueextracted; + if (preg_match('/^options_/', $tmpproperty)) { + $object->array_options[preg_replace('/^options_/', '', $tmpproperty)] = $this->decodeSMTPSubject($valueextracted); + } else { + $object->$tmpproperty = $this->decodeSMTPSubject($valueextracted); + } } } else { // Regex not found From 3058d6ff0b468a2034e99e5cac79c890bec46ced Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Mon, 23 May 2022 20:41:22 +0200 Subject: [PATCH 110/174] FIX : bad object name --- htdocs/societe/partnership.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/societe/partnership.php b/htdocs/societe/partnership.php index 05079d263a9..d9b3d3127f9 100644 --- a/htdocs/societe/partnership.php +++ b/htdocs/societe/partnership.php @@ -1,6 +1,7 @@ * Copyright (C) 2021 NextGestion + * Copyright (C) 2022 Charlene Benke * * 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 @@ -180,25 +181,25 @@ if ($id > 0) { print '
'.$langs->trans("InitialBankBalance").' - '.$langs->trans("Cash").''; - print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency); + print ''.price($object->opening, 0, $langs, 1, -1, -1, $conf->currency).''; print "
'.$langs->trans($val).''; - print price($object->$key, 0, $langs, 1, -1, -1, $conf->currency); + print ''.price($object->$key, 0, $langs, 1, -1, -1, $conf->currency).''; print "
'; if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field - print ''; + print ''; } - if ($societe->client) { + if ($object->client) { print ''; } - if ($societe->fournisseur) { + if ($object->fournisseur) { print '
'.$langs->trans('Prefix').''.$societe->prefix_comm.'
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; print $langs->trans('CustomerCode').''; - print showValueWithClipboardCPButton(dol_escape_htmltag($societe->code_client)); - $tmpcheck = $societe->check_codeclient(); + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); + $tmpcheck = $object->check_codeclient(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' ('.$langs->trans("WrongCustomerCode").')'; } print '
'; print $langs->trans('SupplierCode').''; - print showValueWithClipboardCPButton(dol_escape_htmltag($societe->code_fournisseur)); - $tmpcheck = $societe->check_codefournisseur(); + print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur)); + $tmpcheck = $object->check_codefournisseur(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' ('.$langs->trans("WrongSupplierCode").')'; } From 32202d870436baa74b601a76058c67565e75b30c Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Mon, 23 May 2022 21:18:42 +0200 Subject: [PATCH 111/174] FIX V8 : warning if $objectsrc not defined --- htdocs/fichinter/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index eeb5261ef19..86a39149fe1 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -5,7 +5,7 @@ * Copyright (C) 2011-2020 Juanjo Menent * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2018 Ferran Marcet - * Copyright (C) 2014-2018 Charlene Benke + * Copyright (C) 2014-2022 Charlene Benke * Copyright (C) 2015-2016 Abbes Bahfir * Copyright (C) 2018 Philippe Grand * Copyright (C) 2020 Frédéric France @@ -79,6 +79,7 @@ $hookmanager->initHooks(array('interventioncard', 'globalcard')); $object = new Fichinter($db); $extrafields = new ExtraFields($db); +$objectsrc = null; $extrafields->fetch_name_optionals_label($object->table_element); From 977f77cc181dbac5751e4ac4e8adae0814ab111a Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Mon, 23 May 2022 21:22:34 +0200 Subject: [PATCH 112/174] $note_private getpost need --- htdocs/fichinter/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 86a39149fe1..ac3ac3fb124 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -65,6 +65,7 @@ $mesg = GETPOST('msg', 'alpha'); $origin = GETPOST('origin', 'alpha'); $originid = (GETPOST('originid', 'int') ?GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility $note_public = GETPOST('note_public', 'restricthtml'); +$note_private = GETPOST('note_private', 'restricthtml'); $lineid = GETPOST('line_id', 'int'); $error = 0; From d8f0e42c67e700967e92d021b80e2fd0f1c043b8 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 23 May 2022 19:28:28 +0000 Subject: [PATCH 113/174] Fixing style errors. --- htdocs/fichinter/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index ac3ac3fb124..b7ee235c907 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -80,7 +80,7 @@ $hookmanager->initHooks(array('interventioncard', 'globalcard')); $object = new Fichinter($db); $extrafields = new ExtraFields($db); -$objectsrc = null; +$objectsrc = null; $extrafields->fetch_name_optionals_label($object->table_element); From 9b50b63850c113f935bb09c9e3fb1bcfb2d5355f Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Mon, 23 May 2022 21:58:29 +0200 Subject: [PATCH 114/174] FIX PHP V8 warning $sameunits not initialy defined no default_lang needed (and field not present on stock class --- htdocs/product/stock/card.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index c2f8ddb4470..07ce1cde96e 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -6,6 +6,8 @@ * Copyright (C) 2016 Francis Appels * Copyright (C) 2021 Noé Cendrier * Copyright (C) 2021 Frédéric France + * Copyright (C) 2022 Charlene Benke + * * 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 @@ -679,6 +681,8 @@ if ($action == 'create') { if ($resql) { $num = $db->num_rows($resql); $i = 0; + $sameunits = true; + while ($i < $num) { $objp = $db->fetch_object($resql); @@ -960,7 +964,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete') { $delallowed = $usercancreate; $modulepart = 'stock'; - print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); + print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', 0, '', '', '', $object); $somethingshown = $formfile->numoffiles; print '
'; From dce6271f23e75cc89894e2ccef6fbedc541ddb24 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Mon, 23 May 2022 23:23:02 +0200 Subject: [PATCH 115/174] burundi : add vat rates --- htdocs/install/mysql/data/llx_c_tva.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index b041e07b95f..d78fea4ad4d 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -400,5 +400,7 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (23 --delete from llx_c_tva where rowid = 1181; -- to delete a record that does not follow rules for rowid (fk_pays+'1') --insert into llx_c_tva(rowid, fk_pays, taux, recuperableonly, note, active) SELECT CONCAT(c.rowid, '1'), c.rowid, 0, 0, 'No VAT', 1 from llx_c_country as c where c.rowid not in (select fk_pays from llx_c_tva); - - +-- BURUNDI (id country=61) -- https://www.objectif-import-export.fr/fr/marches-internationaux/fiche-pays/burundi/presentation-fiscalite +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2335,61, '0','0','No VAT',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2336,61, '10','0','VAT 10%',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2337,61, '18','0','VAT 18%',1); From e8ed75cac391242803e76dee74964586e52a3e9a Mon Sep 17 00:00:00 2001 From: atm-orian Date: Tue, 24 May 2022 11:34:39 +0200 Subject: [PATCH 116/174] redirection OF avec des enfants par Orian --- htdocs/mrp/mo_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index da6025bb420..b93bbae189d 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -162,7 +162,7 @@ if (empty($reshook)) { $res = $object->add_object_linked('mo', $mo_parent->id); } - header("Location: ".dol_buildpath('/mrp/mo_list.php', 1)); + header("Location: ".dol_buildpath('/mrp/mo_card.php?id='.$moline->fk_mo, 1)); exit; } From 30e300fbc8967fc6296109f8ee23849c0f3ef319 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 May 2022 11:52:55 +0200 Subject: [PATCH 117/174] FIX Remove warning during dump --- htdocs/core/class/utils.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 8b74609bfa3..86b1ebd414d 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -276,7 +276,7 @@ class Utils $param = $dolibarr_main_db_name." -h ".$dolibarr_main_db_host; $param .= " -u ".$dolibarr_main_db_user; if (!empty($dolibarr_main_db_port)) { - $param .= " -P ".$dolibarr_main_db_port; + $param .= " -P ".$dolibarr_main_db_port." --protocol=tcp"; } if (GETPOST("use_transaction", "alpha")) { $param .= " --single-transaction"; From 43be07030084e42a9974f29d454ba431c9a2085b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 May 2022 11:54:05 +0200 Subject: [PATCH 118/174] PHP8.1 strftime("%Y%m%d%H%M") => dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser') --- htdocs/admin/tools/dolibarr_export.php | 4 ++-- htdocs/core/class/utils.class.php | 2 +- htdocs/core/lib/functions.lib.php | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 83d750e1209..9ccf9eaecfa 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -439,7 +439,7 @@ if (in_array($type, array('pgsql'))) { $prefix = 'pg_dump'; $ext = 'sql'; } -$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.'.$ext; +$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser').'.'.$ext; print ''; print '
'; print '
'; @@ -594,7 +594,7 @@ print load_fiche_titre($title); print '
'; $prefix = 'documents'; $ext = 'zip'; -$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M"); +$file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser'); print '
'; print '
'; diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 86b1ebd414d..c55d78b0caf 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -233,7 +233,7 @@ class Utils $prefix = 'pg_dump'; $ext = 'sql'; } - $file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.strftime("%Y%m%d%H%M").'.'.$ext; + $file = $prefix.'_'.$dolibarr_main_db_name.'_'.dol_sanitizeFileName(DOL_VERSION).'_'.dol_print_date(dol_now('gmt'), "dayhourlogsmall", 'tzuser').'.'.$ext; } $outputdir = $conf->admin->dir_output.'/backup'; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 627fcb6b8ae..712a65b32c1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2453,6 +2453,9 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = } elseif ($format == 'dayhourlog') { // Format not sensitive to language $format = '%Y%m%d%H%M%S'; + } elseif ($format == 'dayhourlogsmall') { + // Format not sensitive to language + $format = '%Y%m%d%H%M'; } elseif ($format == 'dayhourldap') { $format = '%Y%m%d%H%M%SZ'; } elseif ($format == 'dayhourxcard') { From 58d82841e38951df84150086a6fe9ca9cf16b28b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 May 2022 12:11:51 +0200 Subject: [PATCH 119/174] css --- htdocs/admin/tools/dolibarr_export.php | 8 ++++---- htdocs/core/class/html.formfile.class.php | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/tools/dolibarr_export.php b/htdocs/admin/tools/dolibarr_export.php index 9ccf9eaecfa..7d02aea0e73 100644 --- a/htdocs/admin/tools/dolibarr_export.php +++ b/htdocs/admin/tools/dolibarr_export.php @@ -559,10 +559,10 @@ print '
'; print "
\n"; -print '
'; +print '
'; $filearray = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1); -$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'backup/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousDumpFiles")); +$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'backup/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousDumpFiles"), '', 0, -1, '', '', 'ASC', 1, 0, -1, 'style="height:480px; overflow: auto;"'); print '
'; print '
'; @@ -639,10 +639,10 @@ print '
'; print '
'; -print '
'; +print '
'; $filearray = dol_dir_list($conf->admin->dir_output.'/documents', 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1); -$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'documents/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousArchiveFiles")); +$result = $formfile->list_of_documents($filearray, null, 'systemtools', '', 1, 'documents/', 1, 0, $langs->trans("NoBackupFileAvailable"), 0, $langs->trans("PreviousArchiveFiles"), '', 0, -1, '', '', 'ASC', 1, 0, -1, 'style="height:250px; overflow: auto;"'); print '
'; print '
'; diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 36fd84367ae..f3b42a4789e 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -1162,12 +1162,13 @@ class FormFile * @param string $sortfield Sort field ('name', 'size', 'position', ...) * @param string $sortorder Sort order ('ASC' or 'DESC') * @param int $disablemove 1=Disable move button, 0=Position move is possible. - * @param int $addfilterfields Add line with filters + * @param int $addfilterfields Add the line with filters * @param int $disablecrop Disable crop feature on images (-1 = auto, prefer to set it explicitely to 0 or 1) + * @param string $moreattrondiv More attributes on the div for responsive. Example 'style="height:280px; overflow: auto;"' * @return int <0 if KO, nb of files shown if OK * @see list_of_autoecmfiles() */ - public function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permonobject = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0, $permtoeditline = -1, $upload_dir = '', $sortfield = '', $sortorder = 'ASC', $disablemove = 1, $addfilterfields = 0, $disablecrop = -1) + public function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permonobject = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0, $permtoeditline = -1, $upload_dir = '', $sortfield = '', $sortorder = 'ASC', $disablemove = 1, $addfilterfields = 0, $disablecrop = -1, $moreattrondiv = '') { // phpcs:enable global $user, $conf, $langs, $hookmanager, $form; @@ -1272,7 +1273,7 @@ class FormFile print ''; } - print '
'; + print '
'; print ''."\n"; if (!empty($addfilterfields)) { From 5534284d9bc9d3943919903cae13fab8c96a4f51 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 May 2022 12:36:11 +0200 Subject: [PATCH 120/174] css --- htdocs/takepos/css/pos.css.php | 5 +++-- htdocs/takepos/invoice.php | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/htdocs/takepos/css/pos.css.php b/htdocs/takepos/css/pos.css.php index 45130981876..1b8ef0bdcc2 100644 --- a/htdocs/takepos/css/pos.css.php +++ b/htdocs/takepos/css/pos.css.php @@ -436,8 +436,9 @@ tr.selected, tr.selected td { /* font-weight: bold; */ background-color: rgb(240,230,210) !important; } -.order { - color: limegreen; +.order td { + color: green; + /* background-color: #f5f5f5; */ } .colorwhite { diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 6aca4e01a5d..9f22cc20b40 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -804,7 +804,7 @@ if (empty($reshook)) { $printer->orderprinter = 1; echo ""; } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='1' and fk_facture=".$invoice->id; // Set as printed @@ -836,7 +836,7 @@ if (empty($reshook)) { $printer->orderprinter = 2; echo ""; } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='2' and fk_facture=".$invoice->id; // Set as printed @@ -868,7 +868,7 @@ if (empty($reshook)) { $printer->orderprinter = 3; echo ""; } $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet set special_code='4' where special_code='3' and fk_facture=".$invoice->id; // Set as printed @@ -1444,7 +1444,11 @@ if ($placeid > 0) { if ($line->special_code == "4") { $htmlsupplements[$line->fk_parent_line] .= ' order'; } - $htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'">'; + $htmlsupplements[$line->fk_parent_line] .= '" id="'.$line->id.'"'; + if ($line->special_code == "4") { + $htmlsupplements[$line->fk_parent_line] .= ' title="'.dol_escape_htmltag("AlreadyPrinted").'"'; + } + $htmlsupplements[$line->fk_parent_line] .= '>'; $htmlsupplements[$line->fk_parent_line] .= ''; print ''; @@ -1647,7 +1649,7 @@ if ($step == 5 && $datatoimport) { // Keys for data UPDATE (not INSERT of new data) print '
'; $htmlsupplements[$line->fk_parent_line] .= img_picto('', 'rightarrow'); if ($line->product_label) { @@ -1483,7 +1487,11 @@ if ($placeid > 0) { if ($line->special_code == "4") { $htmlforlines .= ' order'; } - $htmlforlines .= '" id="'.$line->id.'">'; + $htmlforlines .= '" id="'.$line->id.'"'; + if ($line->special_code == "4") { + $htmlforlines .= ' title="'.dol_escape_htmltag("AlreadyPrinted").'"'; + } + $htmlforlines .= '>'; $htmlforlines .= ''; if (!empty($_SESSION["basiclayout"]) && $_SESSION["basiclayout"] == 1) { $htmlforlines .= ''.$line->qty." x "; From b8764c48044a9481e10db0dbb7e650feb8314023 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 May 2022 12:48:48 +0200 Subject: [PATCH 121/174] Doc --- htdocs/takepos/floors.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/htdocs/takepos/floors.php b/htdocs/takepos/floors.php index 73e84109116..9dc4f843b5b 100644 --- a/htdocs/takepos/floors.php +++ b/htdocs/takepos/floors.php @@ -128,22 +128,20 @@ top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); From 536f888ba2ec09b6306ad018f51371604b65b1c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 May 2022 12:59:27 +0200 Subject: [PATCH 122/174] Fix search hook in takepos --- htdocs/takepos/ajax/ajax.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/takepos/ajax/ajax.php b/htdocs/takepos/ajax/ajax.php index 5168c370592..9f7483319b3 100644 --- a/htdocs/takepos/ajax/ajax.php +++ b/htdocs/takepos/ajax/ajax.php @@ -103,7 +103,7 @@ if ($action == 'getProducts') { 'rowid' => $thirdparty->id, 'name' => $thirdparty->name, 'barcode' => $thirdparty->barcode, - 'object' => 'thirdparty' + 'object' => 'thirdparty' ); echo json_encode($rows); exit; @@ -267,6 +267,7 @@ if ($action == 'getProducts') { $resql = $db->query($sql); if ($resql) { $rows = array(); + while ($obj = $db->fetch_object($resql)) { $objProd = new Product($db); $objProd->fetch($obj->rowid); @@ -303,17 +304,23 @@ if ($action == 'getProducts') { $parameters=array(); $parameters['row'] = $row; $parameters['obj'] = $obj; - $reshook = $hookmanager->executeHooks('completeAjaxReturnArray', $parameters); if ($reshook > 0) { // replace - $row = $hookmanager->resArray; + if (count($hookmanager->resArray)) { + $row = $hookmanager->resArray; + } else { + $row = array(); + } } else { // add - $rows[] = $hookmanager->resArray; + if (count($hookmanager->resArray)) { + $rows[] = $hookmanager->resArray; + } + $rows[] = $row; } - $rows[] = $row; } + echo json_encode($rows); } else { echo 'Failed to search product : '.$db->lasterror(); From 52b23c748c1b3273034fcc7d4a895f1df12b6914 Mon Sep 17 00:00:00 2001 From: jpb Date: Tue, 24 May 2022 15:13:22 +0200 Subject: [PATCH 123/174] change same left menu name on GRH top menu --- htdocs/core/menus/standard/eldy.lib.php | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 3dc1ab6c4fd..e4b6762af8b 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -807,7 +807,6 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM if ($mainmenu == 'hrm') { get_left_menu_hrm($mainmenu, $newmenu, $usemenuhider, $leftmenu, $type_user); } - /* * Menu TOOLS */ @@ -2262,19 +2261,19 @@ function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = // Load translation files required by the page $langs->loadLangs(array("holiday", "trips")); - $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=hrm", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'hrm', 0, '', '', '', img_picto('', 'holiday', 'class="pictofixedwidth"')); - $newmenu->add("/holiday/card.php?mainmenu=hrm&leftmenu=holiday&action=create", $langs->trans("New"), 1, $user->rights->holiday->write); - $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=hrm", $langs->trans("List"), 1, $user->rights->holiday->read); - if ($usemenuhider || empty($leftmenu) || $leftmenu == "hrm") { - $newmenu->add("/holiday/list.php?search_status=1&mainmenu=hrm&leftmenu=hrm", $langs->trans("DraftCP"), 2, $user->rights->holiday->read); - $newmenu->add("/holiday/list.php?search_status=2&mainmenu=hrm&leftmenu=hrm", $langs->trans("ToReviewCP"), 2, $user->rights->holiday->read); - $newmenu->add("/holiday/list.php?search_status=3&mainmenu=hrm&leftmenu=hrm", $langs->trans("ApprovedCP"), 2, $user->rights->holiday->read); - $newmenu->add("/holiday/list.php?search_status=4&mainmenu=hrm&leftmenu=hrm", $langs->trans("CancelCP"), 2, $user->rights->holiday->read); - $newmenu->add("/holiday/list.php?search_status=5&mainmenu=hrm&leftmenu=hrm", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read); + $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'holiday', 0, '', '', '', img_picto('', 'holiday', 'class="pictofixedwidth"')); + $newmenu->add("/holiday/card.php?mainmenu=hrm&leftmenu=holiday&action=create", $langs->trans("New"), 1, $user->rights->holiday->write, '',$mainmenu); + $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("List"), 1, $user->rights->holiday->read, '',$mainmenu); + if ($usemenuhider || empty($leftmenu) || $leftmenu == "holiday") { + $newmenu->add("/holiday/list.php?search_status=1&mainmenu=hrm&leftmenu=holiday", $langs->trans("DraftCP"), 2, $user->rights->holiday->read,'',$mainmenu,'holiday_sm'); + $newmenu->add("/holiday/list.php?search_status=2&mainmenu=hrm&leftmenu=holiday", $langs->trans("ToReviewCP"), 2, $user->rights->holiday->read, '',$mainmenu,'holiday_sm'); + $newmenu->add("/holiday/list.php?search_status=3&mainmenu=hrm&leftmenu=holiday", $langs->trans("ApprovedCP"), 2, $user->rights->holiday->read, '',$mainmenu,'holiday_sm'); + $newmenu->add("/holiday/list.php?search_status=4&mainmenu=hrm&leftmenu=holiday", $langs->trans("CancelCP"), 2, $user->rights->holiday->read, '',$mainmenu,'holiday_sm'); + $newmenu->add("/holiday/list.php?search_status=5&mainmenu=hrm&leftmenu=holiday", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read, '',$mainmenu,'holiday_sm'); } - $newmenu->add("/holiday/define_holiday.php?mainmenu=hrm&action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read); - $newmenu->add("/holiday/month_report.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->readall); - $newmenu->add("/holiday/view_log.php?mainmenu=hrm&leftmenu=holiday&action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday); + $newmenu->add("/holiday/define_holiday.php?mainmenu=hrm&action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read, '',$mainmenu,'holiday_sm'); + $newmenu->add("/holiday/month_report.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->readall, '',$mainmenu,'holiday_sm'); + $newmenu->add("/holiday/view_log.php?mainmenu=hrm&leftmenu=holiday&action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday, '',$mainmenu,'holiday_sm'); } // Trips and expenses (old module) @@ -2316,6 +2315,7 @@ function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = } } + /** * Get left Menu TOOLS * From f0fa315a7b6bc955e1221d4eeb71e07f315ebf27 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 24 May 2022 13:24:31 +0000 Subject: [PATCH 124/174] Fixing style errors. --- htdocs/core/menus/standard/eldy.lib.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index e4b6762af8b..b3788d776a0 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -2262,18 +2262,18 @@ function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu = $langs->loadLangs(array("holiday", "trips")); $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("CPTitreMenu"), 0, $user->rights->holiday->read, '', $mainmenu, 'holiday', 0, '', '', '', img_picto('', 'holiday', 'class="pictofixedwidth"')); - $newmenu->add("/holiday/card.php?mainmenu=hrm&leftmenu=holiday&action=create", $langs->trans("New"), 1, $user->rights->holiday->write, '',$mainmenu); - $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("List"), 1, $user->rights->holiday->read, '',$mainmenu); + $newmenu->add("/holiday/card.php?mainmenu=hrm&leftmenu=holiday&action=create", $langs->trans("New"), 1, $user->rights->holiday->write, '', $mainmenu); + $newmenu->add("/holiday/list.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("List"), 1, $user->rights->holiday->read, '', $mainmenu); if ($usemenuhider || empty($leftmenu) || $leftmenu == "holiday") { - $newmenu->add("/holiday/list.php?search_status=1&mainmenu=hrm&leftmenu=holiday", $langs->trans("DraftCP"), 2, $user->rights->holiday->read,'',$mainmenu,'holiday_sm'); - $newmenu->add("/holiday/list.php?search_status=2&mainmenu=hrm&leftmenu=holiday", $langs->trans("ToReviewCP"), 2, $user->rights->holiday->read, '',$mainmenu,'holiday_sm'); - $newmenu->add("/holiday/list.php?search_status=3&mainmenu=hrm&leftmenu=holiday", $langs->trans("ApprovedCP"), 2, $user->rights->holiday->read, '',$mainmenu,'holiday_sm'); - $newmenu->add("/holiday/list.php?search_status=4&mainmenu=hrm&leftmenu=holiday", $langs->trans("CancelCP"), 2, $user->rights->holiday->read, '',$mainmenu,'holiday_sm'); - $newmenu->add("/holiday/list.php?search_status=5&mainmenu=hrm&leftmenu=holiday", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read, '',$mainmenu,'holiday_sm'); + $newmenu->add("/holiday/list.php?search_status=1&mainmenu=hrm&leftmenu=holiday", $langs->trans("DraftCP"), 2, $user->rights->holiday->read, '', $mainmenu, 'holiday_sm'); + $newmenu->add("/holiday/list.php?search_status=2&mainmenu=hrm&leftmenu=holiday", $langs->trans("ToReviewCP"), 2, $user->rights->holiday->read, '', $mainmenu, 'holiday_sm'); + $newmenu->add("/holiday/list.php?search_status=3&mainmenu=hrm&leftmenu=holiday", $langs->trans("ApprovedCP"), 2, $user->rights->holiday->read, '', $mainmenu, 'holiday_sm'); + $newmenu->add("/holiday/list.php?search_status=4&mainmenu=hrm&leftmenu=holiday", $langs->trans("CancelCP"), 2, $user->rights->holiday->read, '', $mainmenu, 'holiday_sm'); + $newmenu->add("/holiday/list.php?search_status=5&mainmenu=hrm&leftmenu=holiday", $langs->trans("RefuseCP"), 2, $user->rights->holiday->read, '', $mainmenu, 'holiday_sm'); } - $newmenu->add("/holiday/define_holiday.php?mainmenu=hrm&action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read, '',$mainmenu,'holiday_sm'); - $newmenu->add("/holiday/month_report.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->readall, '',$mainmenu,'holiday_sm'); - $newmenu->add("/holiday/view_log.php?mainmenu=hrm&leftmenu=holiday&action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday, '',$mainmenu,'holiday_sm'); + $newmenu->add("/holiday/define_holiday.php?mainmenu=hrm&action=request", $langs->trans("MenuConfCP"), 1, $user->rights->holiday->read, '', $mainmenu, 'holiday_sm'); + $newmenu->add("/holiday/month_report.php?mainmenu=hrm&leftmenu=holiday", $langs->trans("MenuReportMonth"), 1, $user->rights->holiday->readall, '', $mainmenu, 'holiday_sm'); + $newmenu->add("/holiday/view_log.php?mainmenu=hrm&leftmenu=holiday&action=request", $langs->trans("MenuLogCP"), 1, $user->rights->holiday->define_holiday, '', $mainmenu, 'holiday_sm'); } // Trips and expenses (old module) From 1a231433942c34e341349fca220b2d084ecfe399 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 May 2022 16:02:37 +0200 Subject: [PATCH 125/174] Fix autoincrement column --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index f5889bafc1e..0dea9cc2e05 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -35,6 +35,20 @@ -- VMYSQL4.3 ALTER TABLE llx_c_civility CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- VMYSQL4.3 ALTER TABLE llx_c_payment_term CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; + +-- VPGSQL8.2 CREATE SEQUENCE llx_c_civility_rowid_seq OWNED BY llx_c_civility.rowid; +-- VPGSQL8.2 ALTER TABLE llx_c_civility ADD PRIMARY KEY (rowid); +-- VPGSQL8.2 ALTER TABLE llx_c_civility ALTER COLUMN rowid SET DEFAULT nextval('llx_c_civility_rowid_seq'); +-- VPGSQL8.2 SELECT setval('llx_c_civility_rowid_seq', MAX(rowid)) FROM llx_c_civility; + +-- VPGSQL8.2 CREATE SEQUENCE llx_c_payment_term_rowid_seq OWNED BY llx_c_payment_term.rowid; +-- VPGSQL8.2 ALTER TABLE llx_c_payment_term ADD PRIMARY KEY (rowid); +-- VPGSQL8.2 ALTER TABLE llx_c_payment_term ALTER COLUMN rowid SET DEFAULT nextval('llx_c_payment_term_rowid_seq'); +-- VPGSQL8.2 SELECT setval('llx_c_payment_term_rowid_seq', MAX(rowid)) FROM llx_c_payment_term; + + + ALTER TABLE llx_c_transport_mode ADD UNIQUE INDEX uk_c_transport_mode (code, entity); ALTER TABLE llx_c_shipment_mode MODIFY COLUMN tracking varchar(255) NULL; From e3aa26e5c2253d4524e5d7bd6ad2f8043479a150 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 May 2022 16:10:33 +0200 Subject: [PATCH 126/174] Fix creation of primary key --- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 0dea9cc2e05..5112b484f24 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -14,7 +14,9 @@ -- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field); -- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table; -- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex; --- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (mysql): +-- -- VMYSQL4.3 ALTER TABLE llx_table ADD PRIMARY KEY(rowid); +-- -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; -- To make pk to be auto increment (postgres): -- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid; -- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid); @@ -33,8 +35,10 @@ -- Missing in v15 or lower +-- VMYSQL4.3 ALTER TABLE llx_c_civility ADD PRIMARY KEY(rowid); -- VMYSQL4.3 ALTER TABLE llx_c_civility CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- VMYSQL4.3 ALTER TABLE llx_c_payment_term ADD PRIMARY KEY(rowid); -- VMYSQL4.3 ALTER TABLE llx_c_payment_term CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; -- VPGSQL8.2 CREATE SEQUENCE llx_c_civility_rowid_seq OWNED BY llx_c_civility.rowid; From a01edddb5194dd08bf7bdcc01cb5861a8a4ecc93 Mon Sep 17 00:00:00 2001 From: ATM john Date: Tue, 24 May 2022 20:56:03 +0200 Subject: [PATCH 127/174] Small css fix --- htdocs/theme/eldy/info-box.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 2d33a716692..77270b9d818 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -10,7 +10,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) { */ .info-box-module.--external span.info-box-icon-version { - background: #bbb; + background: rgba(0,0,0,0.2); } .info-box-module.--external.--need-update span.info-box-icon-version{ From e89c80651b42a32de89d547b502bc85556266bae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 May 2022 21:09:12 +0200 Subject: [PATCH 128/174] Update card.php --- htdocs/product/stock/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 07ce1cde96e..252763ef43b 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -7,7 +7,6 @@ * Copyright (C) 2021 Noé Cendrier * Copyright (C) 2021 Frédéric France * Copyright (C) 2022 Charlene Benke - * * 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 From 51a53985fdbdc692aa7aba36aa28baa3b16dde37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 May 2022 21:25:47 +0200 Subject: [PATCH 129/174] Fix warning --- htdocs/societe/agenda.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 1aa7093299d..bebe542a6f9 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -147,7 +147,7 @@ if ($socid > 0) { $objcon = new stdClass(); $out = ''; - $permok = $user->rights->agenda->myactions->create; + $permok = $user->hasRight('agenda', 'myactions', 'create'); if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') { $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : '')); From 959278e315f2558ef74fdf8e1d315588a92b8cd0 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Tue, 24 May 2022 22:36:16 +0200 Subject: [PATCH 130/174] php V8 warning --- htdocs/comm/card.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 411efc5ae93..d0cb4d7be2f 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -827,7 +827,7 @@ if ($object->id > 0) { $sql .= ", p.total_tva"; $sql .= ", p.total_ttc"; $sql .= ", p.ref, p.ref_client, p.remise"; - $sql .= ", p.datep as dp, p.fin_validite as date_limit"; + $sql .= ", p.datep as dp, p.fin_validite as date_limit, p.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; $sql .= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id"; $sql .= " AND s.rowid = ".((int) $object->id); @@ -887,7 +887,7 @@ if ($object->id > 0) { } } $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf'; - print $formfile->showPreview($file_list, $propal_static->element, $relativepath, 0, $param); + print $formfile->showPreview($file_list, $propal_static->element, $relativepath, 0); } // $filename = dol_sanitizeFileName($objp->ref); // $filedir = $conf->propal->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); @@ -1226,7 +1226,7 @@ if ($object->id > 0) { * Latest interventions */ if (!empty($conf->ficheinter->enabled) && $user->rights->ficheinter->lire) { - $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate"; + $sql = "SELECT s.nom, s.rowid, f.rowid as id, f.ref, f.fk_statut, f.duree as duration, f.datei as startdate, f.entity"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as f"; $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND s.rowid = ".((int) $object->id); @@ -1261,7 +1261,7 @@ if ($object->id > 0) { print ''; print $fichinter_static->getNomUrl(1); // Preview - $filedir = $conf->fichinter->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); + $filedir = $conf->ficheinter->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); $file_list = null; if (!empty($filedir)) { $file_list = dol_dir_list($filedir, 'files', 0, '', '(\.meta|_preview.*.*\.png)$', 'date', SORT_DESC); @@ -1283,7 +1283,7 @@ if ($object->id > 0) { } } $relativepath = dol_sanitizeFileName($objp->ref).'/'.dol_sanitizeFileName($objp->ref).'.pdf'; - print $formfile->showPreview($file_list, $fichinter_static->element, $relativepath, 0, $param); + print $formfile->showPreview($file_list, $fichinter_static->element, $relativepath, 0); } // $filename = dol_sanitizeFileName($objp->ref); // $filedir = $conf->fichinter->multidir_output[$objp->entity].'/'.dol_sanitizeFileName($objp->ref); From 9ebfd30dccb23c0d9776caa03c443b5f90d8e741 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Tue, 24 May 2022 22:42:32 +0200 Subject: [PATCH 131/174] PHP V8 warning --- htdocs/contact/agenda.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 0eed6ba6219..28e6f7be9c0 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -251,17 +251,18 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $objthirdparty = $object->thirdparty; $out = ''; - $permok = $user->rights->agenda->myactions->create; - if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { - if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') { - $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : ''); - } - $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&percentage=-1&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : '')); - $out .= '&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog')); - } - $newcardbutton = ''; if (!empty($conf->agenda->enabled)) { + + $permok = $user->rights->agenda->myactions->create; + if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { + if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') { + $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : ''); + } + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&percentage=-1&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : '')); + $out .= '&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog')); + } + if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) { $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); } From f17ae94206bcbee850c2358ecbce64ff0d3e5bfb Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Tue, 24 May 2022 22:46:43 +0200 Subject: [PATCH 132/174] php V8 Warning --- htdocs/contact/consumption.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 7f1d9bdc64b..dc4b56b2763 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -366,7 +366,7 @@ $param .= "&socid=".urlencode($socid); $param .= "&type_element=".urlencode($type_element); $total_qty = 0; - +$num=0; if ($sql_select) { $resql = $db->query($sql); if (!$resql) { From 82cf96fb78151732163485a6294539a57b30f462 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 24 May 2022 20:47:24 +0000 Subject: [PATCH 133/174] Fixing style errors. --- htdocs/contact/agenda.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 28e6f7be9c0..98b6ccea3b1 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -253,7 +253,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $out = ''; $newcardbutton = ''; if (!empty($conf->agenda->enabled)) { - $permok = $user->rights->agenda->myactions->create; if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') { From 17c53373127a52ace5b9cf7cd16003c49f555c84 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Tue, 24 May 2022 22:53:26 +0200 Subject: [PATCH 134/174] PHP V8 Warning --- htdocs/product/agenda.php | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/htdocs/product/agenda.php b/htdocs/product/agenda.php index ec8a6dd4951..b595bd3b9cb 100644 --- a/htdocs/product/agenda.php +++ b/htdocs/product/agenda.php @@ -186,25 +186,16 @@ if ($id > 0 || $ref) { $objcon = new stdClass(); $out = ''; - $permok = $user->rights->agenda->myactions->create; - if ((!empty($objproduct->id) || !empty($objcon->id)) && $permok) { - //$out.='trans("AddAnAction").' '; - //$out.=img_picto($langs->trans("AddAnAction"),'filenew'); - //$out.=""; - } - - - //print '
'; - //print '
'; - - $morehtmlcenter = ''; if (!empty($conf->agenda->enabled)) { + $permok = $user->rights->agenda->myactions->create; + if ((!empty($objproduct->id) || !empty($objcon->id)) && $permok) { + if (get_class($objproduct) == 'Product') { + $out .= '&prodid='.$objproduct->id.'&origin=product&originid='.$id; + } + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&backtopage='.$_SERVER["PHP_SELF"].'?id='.$object->id.'&percentage=-1'; + } + $linktocreatetimeBtnStatus = !empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create); $morehtmlcenter = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out, '', $linktocreatetimeBtnStatus); } From baae99fbb409c13a23d07e5f14e1ab0a2e872ad2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 May 2022 08:54:40 +0200 Subject: [PATCH 135/174] Support ZATCA --- ChangeLog | 1 + .../class/accountancyexport.class.php | 4 +- htdocs/admin/pdf_other.php | 38 ++++++++++++++++--- .../cheque/class/remisecheque.class.php | 3 +- htdocs/langs/en_US/admin.lang | 2 + 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index f4945b44df0..9b7b6c79b86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,7 @@ For users: NEW: PHP 8.1 compatibility NEW: Support for recurring purchase invoices. NEW: #20292 Include German public holidays +NEW: Can show ZATCA QRCode on PDFs NEW: #17123 added ExtraFields for Stock Mouvement NEW: #20609 : new massaction to assign a sale representatives on a selection of thirdparties NEW: #20653 edit discount pourcentage for all lines in one shot diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 2cb4c5fba1c..c8c4099e67e 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -111,7 +111,7 @@ class AccountancyExport */ public function getType() { - global $langs; + global $langs, $hookmanager; $listofexporttypes = array( self::$EXPORT_TYPE_CONFIGURABLE => $langs->trans('Modelcsv_configurable'), @@ -137,7 +137,7 @@ class AccountancyExport ); // allow modules to define export formats - global $hookmanager; + $parameters = array(); $reshook = $hookmanager->executeHooks('getType', $parameters, $listofexporttypes); ksort($listofexporttypes, SORT_NUMERIC); diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index 72acf7fbf4f..5a51535e04d 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -60,6 +60,9 @@ if ($action == 'update') { if (GETPOSTISSET('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')) { dolibarr_set_const($db, "MAIN_DOCUMENTS_WITH_PICTURE_WIDTH", GETPOST("MAIN_DOCUMENTS_WITH_PICTURE_WIDTH", 'int'), 'chaine', 0, '', $conf->entity); } + if (GETPOSTISSET('INVOICE_ADD_ZATCA_QR_CODE')) { + dolibarr_set_const($db, "INVOICE_ADD_ZATCA_QR_CODE", GETPOST("INVOICE_ADD_ZATCA_QR_CODE", 'int'), 'chaine', 0, '', $conf->entity); + } setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -90,19 +93,19 @@ $tooltiptext = ''; print ''.$form->textwithpicto($langs->trans("PDFOtherDesc"), $tooltiptext)."
\n"; print "
\n"; +print ''; +print ''; +print ''; + if (!empty($conf->propal->enabled)) { print load_fiche_titre($langs->trans("Proposal"), '', ''); - print ''; - print ''; - print ''; - print '
'; print ''; print ''; - print ''; + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_GENERATE_PROPOSALS_WITH_PICTURE"); - print ' ('.$langs->trans("RandomlySelectedIfSeveral").')'; + print '
'; + print $form->textwithpicto($langs->trans("MAIN_GENERATE_PROPOSALS_WITH_PICTURE"), $langs->trans("RandomlySelectedIfSeveral")); print ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('MAIN_GENERATE_PROPOSALS_WITH_PICTURE'); @@ -112,6 +115,29 @@ if (!empty($conf->propal->enabled)) { } print '
'; + print '
'; +} + + +if (!empty($conf->facture->enabled)) { + print load_fiche_titre($langs->trans("Invoices"), '', ''); + + print '
'; + print ''; + print ''; + + print ''; + /* print ''; // Contract - if ($conf->contrat->enabled) { + if (!empty($conf->contrat->enabled)) { $langs->load('contracts'); print ''; print ''; From 1632b37045e7d5214f8876a681e332dd53fcd2cc Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 25 May 2022 16:35:42 +0200 Subject: [PATCH 139/174] fix : error of import model in import --- htdocs/imports/import.php | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 50955c367a7..bac7c56cbaa 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -153,18 +153,6 @@ $htmlother = new FormOther($db); $formfile = new FormFile($db); // Init $array_match_file_to_database from _SESSION -$serialized_array_match_file_to_database = isset($_SESSION["dol_array_match_file_to_database"]) ? $_SESSION["dol_array_match_file_to_database"] : ''; -$array_match_file_to_database = array(); -$fieldsarray = explode(',', $serialized_array_match_file_to_database); -foreach ($fieldsarray as $elem) { - $tabelem = explode('=', $elem, 2); - $key = $tabelem[0]; - $val = (isset($tabelem[1]) ? $tabelem[1] : ''); - if ($key && $val) { - $array_match_file_to_database[$key] = $val; - } -} - if (empty($array_match_file_to_database)) { $serialized_array_match_file_to_database = isset($_SESSION["dol_array_match_file_to_database_select"]) ? $_SESSION["dol_array_match_file_to_database_select"] : ''; $array_match_file_to_database = array(); @@ -1166,10 +1154,10 @@ if ($step == 4 && $datatoimport) { //var_dump($code); //var_dump($tmpselectioninsession); //if ($tmpselectioninsession[$j] == $code) { - if ($tmpselectioninsession[($i+1)] == $tmpcode) { + if (!empty($tmpselectioninsession[($i+1)]) && $tmpselectioninsession[($i+1)] == $tmpcode) { print ' selected'; } - print ' data-debug="'.$tmpcode.'-'.$code.'-'.$j.'-'.$tmpselectioninsession[($i+1)].'"'; + print ' data-debug="'.$tmpcode.'-'.$code.'-'.$j.'-'.(!empty($tmpselectioninsession[($i+1)]) ? $tmpselectioninsession[($i+1)] : "").'"'; } print ' data-html="'.dol_escape_htmltag($label).'"'; print '>'; From d0b6daaf4c56de7449e8683c2293cae6eea405c4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 May 2022 16:50:09 +0200 Subject: [PATCH 140/174] Fix length of field --- htdocs/core/class/html.formcompany.class.php | 4 ++-- htdocs/install/mysql/migration/15.0.0-16.0.0.sql | 1 + htdocs/install/mysql/tables/llx_c_stcomm.sql | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index f976fac978d..32f2a9b1007 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -183,7 +183,7 @@ class FormCompany extends Form if (!empty($htmlname) && $user->admin) { print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } - print ''; + print ''; print ''; } @@ -234,7 +234,7 @@ class FormCompany extends Form if (!empty($htmlname) && $user->admin) { print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } - print ''; + print ''; print ''; } diff --git a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql index 8668063d775..98add8f18fb 100644 --- a/htdocs/install/mysql/migration/15.0.0-16.0.0.sql +++ b/htdocs/install/mysql/migration/15.0.0-16.0.0.sql @@ -118,6 +118,7 @@ ALTER TABLE llx_bank ADD COLUMN amount_main_currency double(24,8) NULL; -- v16 +ALTER TABLE llx_c_stcomm MODIFY COLUMN code VARCHAR(24) NOT NULL; ALTER TABLE llx_societe_account DROP FOREIGN KEY llx_societe_account_fk_website; UPDATE llx_cronjob set label = 'RecurringInvoicesJob' where label = 'RecurringInvoices'; diff --git a/htdocs/install/mysql/tables/llx_c_stcomm.sql b/htdocs/install/mysql/tables/llx_c_stcomm.sql index aa5d58a280f..f94ba35be7b 100644 --- a/htdocs/install/mysql/tables/llx_c_stcomm.sql +++ b/htdocs/install/mysql/tables/llx_c_stcomm.sql @@ -21,7 +21,7 @@ create table llx_c_stcomm ( id integer PRIMARY KEY, - code varchar(12) NOT NULL, + code varchar(24) NOT NULL, libelle varchar(128), picto varchar(128), active tinyint default 1 NOT NULL From a8ca233712590dc2ba40752b7e65dce19d3b2b9d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 May 2022 17:55:23 +0200 Subject: [PATCH 141/174] css --- htdocs/theme/eldy/dropdown.inc.php | 2 +- htdocs/theme/md/dropdown.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/dropdown.inc.php b/htdocs/theme/eldy/dropdown.inc.php index 338b4cf2759..0ca47fbd2bb 100644 --- a/htdocs/theme/eldy/dropdown.inc.php +++ b/htdocs/theme/eldy/dropdown.inc.php @@ -396,7 +396,7 @@ a.dropdown-item { content: "\f35d"; } -.dropdown-item.active, .dropdown-item:hover, .dropdown-item:focus { +.dropdown-item.active, .dropdown-item:hover, .dropdown-item:hover span::before, .dropdown-item:focus { color: # !important; text-decoration: none; background: rgb(); diff --git a/htdocs/theme/md/dropdown.inc.php b/htdocs/theme/md/dropdown.inc.php index 615951bbbd9..1f60f0b7c2a 100644 --- a/htdocs/theme/md/dropdown.inc.php +++ b/htdocs/theme/md/dropdown.inc.php @@ -400,7 +400,7 @@ a.dropdown-item { content: "\f35d"; } -.dropdown-item.active, .dropdown-item:hover, .dropdown-item:focus { +.dropdown-item.active, .dropdown-item:hover, .dropdown-item:hover::before, .dropdown-item:hover span::before, .dropdown-item:focus { color: # !important; text-decoration: none; background: rgb(); From 068112bccd4f961fc03435d7486d0abf5174dde7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 May 2022 18:17:53 +0200 Subject: [PATCH 142/174] Fix trans --- htdocs/imports/import.php | 10 ++++++---- htdocs/langs/en_US/exports.lang | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index bac7c56cbaa..741f8eb1dd6 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -480,7 +480,7 @@ if ($step == 2 && $datatoimport) { $filetoimport = ''; // Add format informations and link to download example - print ''; $list = $objmodelimport->liste_modeles($db); @@ -490,9 +490,11 @@ if ($step == 2 && $datatoimport) { $text = $objmodelimport->getDriverDescForKey($key); print ''; print ''; // Action button print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print $form->textwithpicto($langs->trans("INVOICE_ADD_ZATCA_QR_CODE"), $langs->trans("INVOICE_ADD_ZATCA_QR_CODEMore")); + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('INVOICE_ADD_ZATCA_QR_CODE'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("INVOICE_ADD_ZATCA_QR_CODE", $arrval, $conf->global->INVOICE_ADD_ZATCA_QR_CODE); + } + print '
'.$langs->trans("MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING").''; if ($conf->use_javascript_ajax) { diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 451a18ab05b..3fb82f05cb9 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -200,8 +200,9 @@ class RemiseCheque extends CommonObject } } + $lines = array(); + if ($this->id > 0 && $this->errno == 0) { - $lines = array(); $sql = "SELECT b.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= " WHERE b.fk_type = 'CHQ'"; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 69ef87aca0d..d36dbfd7733 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2260,3 +2260,5 @@ TextOnly=Text only IconOnlyAllTextsOnHover=Icon only - All texts appears under icon on mouse hover menu bar IconOnlyTextOnHover=Icon only - Text of icon appears under icon on mouse hover the icon IconOnly=Icon only - Text on tooltip only +INVOICE_ADD_ZATCA_QR_CODE=Show the ZATCA QR code on invoices +INVOICE_ADD_ZATCA_QR_CODEMore=Some Arabic countries need this QR Code on their invoices From 27e97b68ce2dd314e6a3a047e1a367ef4a280928 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Wed, 25 May 2022 09:56:13 +0200 Subject: [PATCH 136/174] fix PHP V8 warning --- htdocs/fichinter/card.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index b7ee235c907..edbffca0df5 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -778,7 +778,7 @@ if (empty($reshook)) { $form = new Form($db); $formfile = new FormFile($db); -if ($conf->contrat->enabled) { +if (!empty($conf->contrat->enabled)) { $formcontract = new FormContract($db); } if (!empty($conf->projet->enabled)) { @@ -1229,7 +1229,7 @@ if ($action == 'create') { print '
'; @@ -1512,7 +1512,7 @@ if ($action == 'create') { // editeur wysiwyg if (empty($conf->global->FICHINTER_EMPTY_LINE_DESC)) { require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor = new DolEditor('np_desc', GETPOST('np_desc', 'restricthtml'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, ROWS_2, '90%'); + $doleditor = new DolEditor('np_desc', GETPOST('np_desc', 'restricthtml'), '', 100, 'dolibarr_details', '', false, true, !empty($conf->global->FCKEDITOR_ENABLE_DETAILS), ROWS_2, '90%'); $doleditor->Create(); } From 31b99e5f34e3a2a1123d7f4984c88fe9751a996d Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Wed, 25 May 2022 12:43:04 +0200 Subject: [PATCH 137/174] Update ChangeLog - Sorting order - typing error - one deletion: NEW: MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const in email collector -- deleted because duplication of: NEW: add MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const to remove header stored by email collector --- ChangeLog | 59 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b7b6c79b86..37957f61c1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -406,8 +406,9 @@ NEW: Increase size of params of actions for emailcollector NEW: Invoice list - Use complete country select field with EEC or not NEW: mass action delete, no more break if at least one object has child NEW: mass action paid on customer invoice list -NEW: massaction validate on supplier orders list -NEW: Mass action send email to all attendees of an event. +NEW: mass action validate on supplier orders list +NEW: mass action send email to all attendees of an event +NEW: mass action to switch status on sale / on purchase of a product NEW: expense reports: conf to pre-fill start/end dates with bounds of current month NEW: Option "Add a link on the PDF to make the online payment" NEW: More options to generate PDF (show Frame option, width of picture option) @@ -428,7 +429,7 @@ NEW: when multiple order linked to facture, show list into note. NEW: when we delete several objects with massaction, if somes object has child we must see which objects are concerned and nevertheless delete objects which can be deleted NEW: Editing a page in website module keep old page with name .back NEW: External backups can be downloaded from the "About info page". -NEW: Add massaction to switch status on sale / on purchase of a product. + Modules @@ -436,36 +437,49 @@ NEW: Stable module Knowledge Management NEW: Experimental module Event Organization Management NEW: Experimental module Workstations Management NEW: Development of module Partnership Management +OLD: module SimplePOS has been completely removed -> use TakePOS For developers: --------------- +API: +NEW: #18319 REST API - Shipment: Add 'close' action / endpoint / POST method. +NEW: add API /approve and /makeOrder for purchase orders +NEW: API for knowledgemanagement +NEW: API get list of legal form of business +NEW: API list of staff units +NEW: Hidden option API_DISABLE_COMPRESSION is now visible in API setup page. + +Hook: +NEW: add hook 'beforeBodyClose' +NEW: add hook 'hookGetEntity' +NEW: add hook 'menuLeftMenuItems' to filter the leftmenu items +NEW: add hook 'printUnderHeaderPDFline' on invoice PDF templates (can be used for example to add a barcode or more information on header of invoices). +NEW: add hookmanager on note pages +NEW: hook after rank update +NEW: 'printFieldListFrom' hook call on several lists + +ModuleBuilder: +NEW: add the property "copytoclipboard" in modulebuilder +NEW: Use lang selector when using a field key 'lang' in modulebuilder + +Options: +NEW: add options MAIN_IBAN_IS_NEVER_MANDATORY, MAIN_IBAN_NOT_MANDATORY, PROPAL_NOT_BILLABLE, PROPAL_REOPEN_UNSIGNED_ONLY, PROPOSAL_ARE_NOT_BILLABLE, TICKETS_MESSAGE_FORCE_MAIL + +Trigger: +NEW: add action trigger for member excluded + + NEW: Introduce method hasRight NEW: Can use textarea field into a confirm popup. NEW: Can use the result_mode of mysqli driver. Save memory for list count -NEW: #18319 REST API - Shipment: Add 'close' action / endpoint / POST method. -NEW: Add API /approve and /makeOrder for purchase orders. -NEW: add action trigger for member excluded -NEW: add option MAIN_IBAN_IS_NEVER_MANDATORY, MAIN_IBAN_NOT_MANDATORY, PROPAL_NOT_BILLABLE, PROPAL_REOPEN_UNSIGNED_ONLY, PROPOSAL_ARE_NOT_BILLABLE, TICKETS_MESSAGE_FORCE_MAIL -NEW: Add code codebar column on serial/lot structure -NEW: Add date_valid and date_approve columns in the list of supplier orders -NEW: add hook `beforeBodyClose` -NEW: Add hook hookGetEntity. -NEW: add hookmanager on note pages -NEW: add hook 'menuLeftMenuItems' to filter the leftmenu items -NEW: Add the property "copytoclipboard" in modulebuilder -NEW: api for knowledgemanagement -NEW: API get list of legal form of business -NEW: API list of staff units -NEW: hook after rank update -NEW: printFieldListFrom hook call on several lists -NEW: Use lang selector when using a field key 'lang' in modulebuilder +NEW: add code codebar column on serial/lot structure +NEW: add date_valid and date_approve columns in the list of supplier orders NEW: we need to be able to put more filters on deleteByParentField() function NEW: make it easier to set the `keyword`, `keywords` and `description` attributes of an ecm file object NEW: Experimental feature to manage user sessions in database -NEW: Hidden option API_DISABLE_COMPRESSION is now visible in API setup page. -NEW: Add hook printUnderHeaderPDFline on invoice PDF templates (can be used for example to add a barcode or more information on header of invoices). + Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * ALL EXTERNAL MODULES THAT WERE NOT CORRECTLY DEVELOPPED WILL NOT WORK ON V15 (All modules that forgot to manage the security token field @@ -1322,7 +1336,6 @@ NEW: introduce constant FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM NEW: introducing new modal boxes in TakePOS NEW: keep TakePOS terminal when login/logout NEW: link on balance to the ledger -NEW: MAIN_EMAILCOLLECTOR_MAIL_WITHOUT_HEADER const in email collector NEW: manage errors on update extra fields in ticket card NEW: mass-actions for the event list view NEW: more filter for "View change logs" From b1481d8495752b9f70abeeaea883321d2815184f Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 25 May 2022 16:05:02 +0200 Subject: [PATCH 138/174] Fix : socialnetworks import in db --- htdocs/core/modules/import/import_csv.modules.php | 15 +++++++++------ htdocs/imports/import.php | 12 ++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 0000189c998..40b13da0599 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -715,19 +715,16 @@ class ImportCsv extends ModeleImports } if (!empty($newval) && $arrayrecord[($key - 1)]['type'] > 0) { $socialkey = array_search("socialnetworks", $listfields); + $socialnetwork = explode("_", $fieldname)[1]; if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { - $socialnetwork = explode("_", $fieldname)[1]; $json = new stdClass(); $json->$socialnetwork = $newval; - $newvalue = json_encode($json); - $listvalues[$socialkey] = "'".$this->db->escape($newvalue)."'"; + $listvalues[$socialkey] = json_encode($json); } else { - $socialnetwork = explode("_", $fieldname)[1]; $jsondata = $listvalues[$socialkey]; - $jsondata = str_replace("'", "", $jsondata); $json = json_decode($jsondata); $json->$socialnetwork = $newval; - $listvalues[$socialkey] = "'".$this->db->escape(json_encode($json))."'"; + $listvalues[$socialkey] = json_encode($json); } } } else { @@ -745,6 +742,12 @@ class ImportCsv extends ModeleImports $i++; } + // We db escape social network field because he isn't in field creation + if (in_array("socialnetworks", $listfields)) { + $socialkey = array_search("socialnetworks", $listfields); + $tmpsql = $listvalues[$socialkey]; + $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; + } // We add hidden fields (but only if there is at least one field to add into table) // We process here all the fields that were declared into the array ->import_fieldshidden_array of the descriptor file. // Previously we processed the ->import_fields_array. diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 46a14450f3e..50955c367a7 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1072,14 +1072,14 @@ if ($step == 4 && $datatoimport) { if (!$line["imported"]) { $optionsnotused .= $text; } - $optionsall[$code] = array('label'=>$langs->trans($line["label"]), 'required'=>(empty($line["required"]) ? 0 : 1), 'position'=>$line['position']); + $optionsall[$code] = array('label'=>$langs->trans($line["label"]), 'required'=>(empty($line["required"]) ? 0 : 1), 'position'=>!empty($line['position']) ? $line['position'] : 0); } // $optionsall is an array of all possible fields. key=>array('label'=>..., 'xxx') $height = '32px'; //needs px for css height attribute below $i = 0; $mandatoryfieldshavesource = true; - + $more = ""; //var_dump($fieldstarget); //var_dump($optionsall); //exit; @@ -1100,7 +1100,7 @@ if ($step == 4 && $datatoimport) { $entity = (!empty($objimport->array_import_entities[0][$code]) ? $objimport->array_import_entities[0][$code] : $objimport->array_import_icon[0]); $tablealias = preg_replace('/(\..*)$/i', '', $code); - $tablename = $objimport->array_import_tables[0][$tablealias]; + $tablename = !empty($objimport->array_import_tables[0][$tablealias]) ? $objimport->array_import_tables[0][$tablealias] : ""; $entityicon = !empty($entitytoicon[$entity]) ? $entitytoicon[$entity] : $entity; // $entityicon must string name of picto of the field like 'project', 'company', 'contact', 'modulename', ... $entitylang = $entitytolang[$entity] ? $entitytolang[$entity] : $objimport->array_import_label[0]; // $entitylang must be a translation key to describe object the field is related to, like 'Company', 'Contact', 'MyModyle', ... @@ -1118,8 +1118,8 @@ if ($step == 4 && $datatoimport) { //var_dump($_SESSION['dol_array_match_file_to_database']); //var_dump($modetoautofillmapping); - print ''; + if (!empty($line["imported"])) { print ''; } else { print ''; @@ -1234,7 +1234,7 @@ if ($step == 4 && $datatoimport) { $htmltext .= $langs->trans("DataCodeIDSourceIsInsertedInto").'
'; } } - $htmltext .= $langs->trans("FieldTitle").": ".$langs->trans($line["label"])."
"; + $htmltext .= $langs->trans("FieldTitle").": ".$langs->trans($fieldstarget[$arraykeysfieldtarget[$code-1]]["label"])."
"; $htmltext .= $langs->trans("Table")." -> ".$langs->trans("Field").': '.$tablename." -> ".preg_replace('/^.*\./', '', $code)."
"; print $form->textwithpicto($more, $htmltext); print '
'; + print '
'; print $langs->trans("FileMustHaveOneOfFollowingFormat"); print '
'.$form->textwithpicto($objmodelimport->getDriverLabelForKey($key), $text).''; - print img_picto('', 'download', 'class="paddingright opacitymedium"').''.$langs->trans("DownloadEmptyExample"); + print img_picto('', 'download', 'class="paddingright opacitymedium"'); + print ''; + print $langs->trans("DownloadEmptyExample"); print ''; - print ' ('.$langs->trans("StarAreMandatory").')'; + print $form->textwithpicto('', $langs->trans("StarAreMandatory")); print ''; @@ -581,7 +583,7 @@ if ($step == 3 && $datatoimport) { print ''; print img_picto('', 'download', 'class="paddingright opacitymedium"').''.$langs->trans("DownloadEmptyExample"); print ''; - print ' ('.$langs->trans("StarAreMandatory").')'; + print $form->textwithpicto('', $langs->trans("StarAreMandatory")); print '
'; diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index e7ac91e5722..9dc400f91f7 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -53,8 +53,8 @@ TypeOfLineServiceOrProduct=Type of line (0=product, 1=service) FileWithDataToImport=File with data to import FileToImport=Source file to import FileMustHaveOneOfFollowingFormat=File to import must have one of following formats -DownloadEmptyExample=Download template file with field content information -StarAreMandatory=* are mandatory fields +DownloadEmptyExample=Download a template file with examples and information on fields you can import +StarAreMandatory=Into the template file, all fields with a * are mandatory fields ChooseFormatOfFileToImport=Choose the file format to use as import file format by clicking on the %s icon to select it... ChooseFileToImport=Upload file then click on the %s icon to select file as source import file... SourceFileFormat=Source file format From bf88d64d5b4481dba65b17d26fa12bf0c2bbbca1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 May 2022 18:55:03 +0200 Subject: [PATCH 143/174] Look and feel v16 --- htdocs/imports/import.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 741f8eb1dd6..427e6a4dea6 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -490,8 +490,8 @@ if ($step == 2 && $datatoimport) { $text = $objmodelimport->getDriverDescForKey($key); print '
'.$form->textwithpicto($objmodelimport->getDriverLabelForKey($key), $text).''; - print img_picto('', 'download', 'class="paddingright opacitymedium"'); print ''; + print img_picto('', 'download', 'class="paddingright opacitymedium"'); print $langs->trans("DownloadEmptyExample"); print ''; print $form->textwithpicto('', $langs->trans("StarAreMandatory")); @@ -581,7 +581,9 @@ if ($step == 3 && $datatoimport) { $text = $objmodelimport->getDriverDescForKey($format); print $form->textwithpicto($objmodelimport->getDriverLabelForKey($format), $text); print ''; - print img_picto('', 'download', 'class="paddingright opacitymedium"').''.$langs->trans("DownloadEmptyExample"); + print ''; + print img_picto('', 'download', 'class="paddingright opacitymedium"'); + print $langs->trans("DownloadEmptyExample"); print ''; print $form->textwithpicto('', $langs->trans("StarAreMandatory")); print '
'; - print $langs->trans("KeysToUseForUpdates"); + print $form->textwithpicto($langs->trans("KeysToUseForUpdates"), $langs->trans("SelectPrimaryColumnsForUpdateAttempt")); print ''; if ($action == 'launchsimu') { if (count($updatekeys)) { @@ -1662,7 +1664,7 @@ if ($step == 5 && $datatoimport) { } else { if (is_array($objimport->array_import_updatekeys[0]) && count($objimport->array_import_updatekeys[0])) { //TODO dropdown UL is created inside nested SPANS print $form->multiselectarray('updatekeys', $objimport->array_import_updatekeys[0], $updatekeys, 0, 0, '', 1, '80%'); - print $form->textwithpicto("", $langs->trans("SelectPrimaryColumnsForUpdateAttempt")); + //print $form->textwithpicto("", $langs->trans("SelectPrimaryColumnsForUpdateAttempt")); } else { print ''.$langs->trans("UpdateNotYetSupportedForThisImport").''; } From 9c5ee2d0b92bc09bc082638047562675b65ce9f8 Mon Sep 17 00:00:00 2001 From: Neal Joos Date: Wed, 25 May 2022 22:50:16 +0200 Subject: [PATCH 144/174] fix broken links fixed DoliWamp and DoliDeb links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5559613eaa2..9250259aa20 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,8 @@ Other licenses apply for some included dependencies. See [COPYRIGHT](https://git If you have low technical skills and you're looking to install Dolibarr ERP/CRM in just a few clicks, you can use one of the packaged versions: -- [DoliWamp for Windows](https://wiki.dolibarr.org/index.php/Dolibarr_for_Windows_DoliWamp) -- [DoliDeb for Debian](https://wiki.dolibarr.org/index.php/Dolibarr_for_Ubuntu_or_Debian) +- [DoliWamp for Windows](https://wiki.dolibarr.org/index.php?title=Dolibarr_for_Windows_(DoliWamp)) +- [DoliDeb for Debian](https://wiki.dolibarr.org/index.php?title=Dolibarr_for_Ubuntu_or_Debian) - DoliRpm for Redhat, Fedora, OpenSuse, Mandriva or Mageia Releases can be downloaded from [official website](https://www.dolibarr.org/). From 271fb43bc6ddc630460247615c846bc033157bf5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 May 2022 23:08:53 +0200 Subject: [PATCH 145/174] FIX Import of fk_stcomm --- htdocs/core/class/cgenericdic.class.php | 478 ++++++++++++++++++ htdocs/core/class/ctypent.class.php | 10 +- htdocs/core/class/ctyperesource.class.php | 17 - .../modules/import/import_csv.modules.php | 17 +- .../modules/import/import_xlsx.modules.php | 47 +- htdocs/core/modules/modSociete.class.php | 23 +- 6 files changed, 543 insertions(+), 49 deletions(-) create mode 100644 htdocs/core/class/cgenericdic.class.php diff --git a/htdocs/core/class/cgenericdic.class.php b/htdocs/core/class/cgenericdic.class.php new file mode 100644 index 00000000000..deda1c1952b --- /dev/null +++ b/htdocs/core/class/cgenericdic.class.php @@ -0,0 +1,478 @@ + + * Copyright (C) 2014-2016 Juanjo Menent + * Copyright (C) 2016 Florian Henry + * Copyright (C) 2015 Raphaël Doursenaud + * + * 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/class/cgenericdic.class.php + * \ingroup resource + */ + +/** + * Class CGenericDic + * + * @see CommonObject + */ +class CGenericDic +{ + /** + * @var string Id to identify managed objects + */ + public $element = 'undefined'; // Will be defined into constructor + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'undefined'; // Will be defined into constructor + + /** + * @var CtyperesourceLine[] Lines + */ + public $lines = array(); + + public $code; + + /** + * @var string Type resource label + */ + public $label; + + public $active; + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + $this->db = $db; + + // Don't forget to set this->element and this->table_element after the construction + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $fieldlabel = 'label'; + if ($this->table_element == 'c_stcomm') { + $fieldlabel = 'libelle'; + } + + $error = 0; + + // Clean parameters + + if (isset($this->code)) { + $this->code = trim($this->code); + } + if (isset($this->label)) { + $this->label = trim($this->label); + } + if (isset($this->active)) { + $this->active = trim($this->active); + } + + // Insert request + $sql = 'INSERT INTO '.$this->db->prefix().$this->table_element.'('; + $sql .= 'code,'; + $sql .= $fieldlabel; + $sql .= 'active'; + $sql .= ') VALUES ('; + $sql .= ' '.(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").','; + $sql .= ' '.(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").','; + $sql .= ' '.(!isset($this->active) ? 'NULL' : $this->active); + $sql .= ')'; + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + } + + if (!$error) { + $this->id = $this->db->last_insert_id($this->db->prefix().$this->table_element); + + // Uncomment this and change CTYPERESOURCE to your own tag if you + // want this action to call a trigger. + //if (!$notrigger) { + + // // Call triggers + // $result=$this->call_trigger('CTYPERESOURCE_CREATE',$user); + // if ($result < 0) $error++; + // // End call triggers + //} + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return -1 * $error; + } else { + $this->db->commit(); + + return $this->id; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $code code + * @param string $label Label + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $code = '', $label = '') + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $fieldrowid = 'rowid'; + $fieldlabel = 'label'; + if ($this->table_element == 'c_stcomm') { + $fieldrowid = 'id'; + $fieldlabel = 'libelle'; + } + + $sql = "SELECT"; + $sql .= " t.".$fieldrowid.","; + $sql .= " t.code,"; + $sql .= " t.".$fieldlabel." as label,"; + $sql .= " t.active"; + $sql .= " FROM ".$this->db->prefix().$this->table_element." as t"; + if ($id) { + $sql .= " WHERE t.".$fieldrowid." = ".((int) $id); + } elseif ($code) { + $sql .= " WHERE t.code = '".$this->db->escape($code)."'"; + } elseif ($label) { + $sql .= " WHERE t.label = '".$this->db->escape($label)."'"; + } + + $resql = $this->db->query($sql); + if ($resql) { + $numrows = $this->db->num_rows($resql); + if ($numrows) { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->$fieldrowid; + + $this->code = $obj->code; + $this->label = $obj->label; + $this->active = $obj->active; + } + + // Retrieve all extrafields for invoice + // fetch optionals attributes and labels + // $this->fetch_optionals(); + + // $this->fetch_lines(); + + $this->db->free($resql); + + if ($numrows) { + return 1; + } else { + return 0; + } + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit offset limit + * @param int $offset offset limit + * @param array $filter filter array + * @param string $filtermode filter mode (AND or OR) + * + * @return int <0 if KO, >0 if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $fieldrowid = 'rowid'; + $fieldlabel = 'label'; + if ($this->table_element == 'c_stcomm') { + $fieldrowid = 'id'; + $fieldlabel = 'libelle'; + } + + $sql = "SELECT"; + $sql .= " t.".$fieldrowid.","; + $sql .= " t.code,"; + $sql .= " t.".$fieldlabel." as label,"; + $sql .= " t.active"; + $sql .= " FROM ".$this->db->prefix().$this->table_element." as t"; + + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; + } + } + + if (count($sqlwhere) > 0) { + $sql .= ' WHERE '.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere); + } + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= $this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + + while ($obj = $this->db->fetch_object($resql)) { + $line = new self($this->db); + + $line->id = $obj->$fieldrowid; + + $line->code = $obj->code; + $line->label = $obj->label; + $line->active = $obj->active; + } + $this->db->free($resql); + + return $num; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $fieldrowid = 'rowid'; + $fieldlabel = 'label'; + if ($this->table_element == 'c_stcomm') { + $fieldrowid = 'id'; + $fieldlabel = 'libelle'; + } + + // Clean parameters + + if (isset($this->code)) { + $this->code = trim($this->code); + } + if (isset($this->label)) { + $this->label = trim($this->label); + } + if (isset($this->active)) { + $this->active = trim($this->active); + } + + // Check parameters + // Put here code to add a control on parameters values + + // Update request + $sql = "UPDATE ".$this->db->prefix().$this->table_element.' SET'; + $sql .= " code = ".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").','; + $sql .= " ".$fieldlabel.' = '.(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").','; + $sql .= " active = ".(isset($this->active) ? $this->active : "null"); + $sql .= " WHERE ".$fieldrowid.' = '.((int) $this->id); + + $this->db->begin(); + + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + } + + // Uncomment this and change CTYPERESOURCE to your own tag if you + // want this action calls a trigger. + //if (!$error && !$notrigger) { + + // // Call triggers + // $result=$this->call_trigger('CTYPERESOURCE_MODIFY',$user); + // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + // // End call triggers + //} + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return -1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $fieldrowid = 'rowid'; + + $error = 0; + + $this->db->begin(); + + // Uncomment this and change CTYPERESOURCE to your own tag if you + // want this action calls a trigger. + //if (!$error && !$notrigger) { + + // // Call triggers + // $result=$this->call_trigger('CTYPERESOURCE_DELETE',$user); + // if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail} + // // End call triggers + //} + + // If you need to delete child tables to, you can insert them here + + if (!$error) { + $sql = 'DELETE FROM '.$this->db->prefix().$this->table_element; + $sql .= ' WHERE '.$fieldrowid.' = '.((int) $this->id); + + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + } + } + + // Commit or rollback + if ($error) { + $this->db->rollback(); + + return -1 * $error; + } else { + $this->db->commit(); + + return 1; + } + } + + /** + * Load an object from its id and create a new one in database + * + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone + */ + public function createFromClone(User $user, $fromid) + { + dol_syslog(__METHOD__, LOG_DEBUG); + + $error = 0; + $object = new Ctyperesource($this->db); + + $this->db->begin(); + + // Load source object + $object->fetch($fromid); + // Reset object + $object->id = 0; + + // Clear fields + // ... + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->create($user); + + // Other options + if ($result < 0) { + $error++; + $this->errors = $object->errors; + dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR); + } + + unset($object->context['createfromclone']); + + // End + if (!$error) { + $this->db->commit(); + + return $object->id; + } else { + $this->db->rollback(); + + return -1; + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->id = 0; + + $this->code = 'CODE'; + $this->label = 'Label'; + $this->active = 1; + } +} diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index 6de7de7d5cb..324bfcb36a0 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -99,30 +99,22 @@ class Ctypent // extends CommonObject $this->module = trim($this->module); } - - // Check parameters // Put here code to add control on parameters values // Insert request $sql = "INSERT INTO ".$this->db->prefix()."c_typent("; - $sql .= "id,"; $sql .= "code,"; $sql .= "libelle,"; $sql .= "active,"; $sql .= "module"; - - $sql .= ") VALUES ("; - $sql .= " ".(!isset($this->id) ? 'NULL' : "'".$this->db->escape($this->id)."'").","; $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; $sql .= " ".(!isset($this->libelle) ? 'NULL' : "'".$this->db->escape($this->libelle)."'").","; $sql .= " ".(!isset($this->active) ? 'NULL' : "'".$this->db->escape($this->active)."'").","; $sql .= " ".(!isset($this->module) ? 'NULL' : "'".$this->db->escape($this->module)."'").""; - - $sql .= ")"; $this->db->begin(); @@ -276,7 +268,7 @@ class Ctypent // extends CommonObject $error = 0; $sql = "DELETE FROM ".$this->db->prefix()."c_typent"; - $sql .= " WHERE id=".$this->id; + $sql .= " WHERE id = ".$this->id; $this->db->begin(); diff --git a/htdocs/core/class/ctyperesource.class.php b/htdocs/core/class/ctyperesource.class.php index 4a4e5c3d2cb..be83877098c 100644 --- a/htdocs/core/class/ctyperesource.class.php +++ b/htdocs/core/class/ctyperesource.class.php @@ -26,8 +26,6 @@ /** * Class Ctyperesource * - * Put here description of your class - * * @see CommonObject */ class Ctyperesource @@ -93,26 +91,15 @@ class Ctyperesource $this->active = trim($this->active); } - - - // Check parameters - // Put here code to add control on parameters values - // Insert request $sql = 'INSERT INTO '.$this->db->prefix().$this->table_element.'('; - $sql .= 'code,'; $sql .= 'label'; $sql .= 'active'; - - $sql .= ') VALUES ('; - $sql .= ' '.(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").','; $sql .= ' '.(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").','; $sql .= ' '.(!isset($this->active) ? 'NULL' : $this->active); - - $sql .= ')'; $this->db->begin(); @@ -177,7 +164,6 @@ class Ctyperesource $sql .= " WHERE t.label = '".$this->db->escape($label)."'"; } - $resql = $this->db->query($sql); if ($resql) { $numrows = $this->db->num_rows($resql); @@ -308,12 +294,9 @@ class Ctyperesource // Update request $sql = 'UPDATE '.$this->db->prefix().$this->table_element.' SET'; - $sql .= ' code = '.(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").','; $sql .= ' label = '.(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").','; $sql .= ' active = '.(isset($this->active) ? $this->active : "null"); - - $sql .= ' WHERE rowid='.((int) $this->id); $this->db->begin(); diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 40b13da0599..16568288aa4 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -393,6 +393,9 @@ class ImportCsv extends ModeleImports $newval = $arrayrecord[($key - 1)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value } + //var_dump($newval);var_dump($val); + //var_dump($objimport->array_import_convertvalue[0][$val]); + // Make some tests on $newval // Is it a required field ? @@ -417,7 +420,7 @@ class ImportCsv extends ModeleImports } $newval = preg_replace('/^(id|ref):/i', '', $newval); // Remove id: or ref: that was used to force if field is id or ref - //print 'Val is now '.$newval.' and is type '.$isidorref."
\n"; + //print 'Newval is now "'.$newval.'" and is type '.$isidorref."
\n"; if ($isidorref == 'ref') { // If value into input import file is a ref, we apply the function defined into descriptor $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); @@ -432,6 +435,11 @@ class ImportCsv extends ModeleImports break; } $classinstance = new $class($this->db); + if ($class == 'CGenericDic') { + $classinstance->element = $objimport->array_import_convertvalue[0][$val]['element']; + $classinstance->table_element = $objimport->array_import_convertvalue[0][$val]['table_element']; + } + // Try the fetch from code or ref $param_array = array('', $newval); if ($class == 'AccountingAccount') { @@ -601,7 +609,7 @@ class ImportCsv extends ModeleImports $modForNumber = new $classModForNumber; $tmpobject = null; - // Set the object when we can + // Set the object with the date property when we can if (!empty($objimport->array_import_convertvalue[0][$val]['classobject'])) { $pathForObject = $objimport->array_import_convertvalue[0][$val]['pathobject']; require_once DOL_DOCUMENT_ROOT.$pathForObject; @@ -748,8 +756,9 @@ class ImportCsv extends ModeleImports $tmpsql = $listvalues[$socialkey]; $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; } + // We add hidden fields (but only if there is at least one field to add into table) - // We process here all the fields that were declared into the array ->import_fieldshidden_array of the descriptor file. + // We process here all the fields that were declared into the array $this->import_fieldshidden_array of the descriptor file. // Previously we processed the ->import_fields_array. if (!empty($listfields) && is_array($objimport->array_import_fieldshidden[0])) { // Loop on each hidden fields to add them into listfields/listvalues @@ -858,7 +867,7 @@ class ImportCsv extends ModeleImports if (empty($keyfield)) { $keyfield = 'rowid'; } - $sqlSelect .= " WHERE ".$keyfield.' = '.((int) $lastinsertid); + $sqlSelect .= " WHERE ".$keyfield." = ".((int) $lastinsertid); $resql = $this->db->query($sqlSelect); if ($resql) { diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 257a9a13c6a..d16a9a764eb 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -86,6 +86,10 @@ class ImportXlsx extends ModeleImports public $cachefieldtable = array(); // Array to cache list of value found into fields@tables + public $nbinsert = 0; // # of insert done during the import + + public $nbupdate = 0; // # of update done during the import + public $workbook; // temporary import file public $record; // current record @@ -111,20 +115,19 @@ class ImportXlsx extends ModeleImports $this->extension = 'xlsx'; // Extension for generated file by this driver $this->picto = 'mime/xls'; // Picto (This is not used by the example file code as Mime type, too bad ...) $this->version = '1.0'; // Driver version + // If driver use an external library, put its name here require_once DOL_DOCUMENT_ROOT.'/includes/phpoffice/phpspreadsheet/src/autoloader.php'; require_once DOL_DOCUMENT_ROOT.'/includes/Psr/autoloader.php'; require_once PHPEXCELNEW_PATH.'Spreadsheet.php'; $this->workbook = new Spreadsheet(); - //if ($this->id == 'excel2007new') - { + // If driver use an external library, put its name here if (!class_exists('ZipArchive')) { // For Excel2007 $langs->load("errors"); $this->error = $langs->trans('ErrorPHPNeedModule', 'zip'); return -1; } - } $this->label_lib = 'PhpSpreadSheet'; $this->version_lib = '1.8.0'; @@ -363,8 +366,6 @@ class ImportXlsx extends ModeleImports $warning = 0; $this->errors = array(); $this->warnings = array(); - $this->nbinsert = 0; - $this->nbupdate = 0; //dol_syslog("import_csv.modules maxfields=".$maxfields." importid=".$importid); @@ -438,6 +439,9 @@ class ImportXlsx extends ModeleImports $newval = $arrayrecord[($key)]['val']; // If type of field into input file is not empty string (so defined into input file), we get value } + //var_dump($newval);var_dump($val); + //var_dump($objimport->array_import_convertvalue[0][$val]); + // Make some tests on $newval // Is it a required field ? @@ -461,7 +465,7 @@ class ImportXlsx extends ModeleImports $isidorref = 'ref'; } $newval = preg_replace('/^(id|ref):/i', '', $newval); // Remove id: or ref: that was used to force if field is id or ref - //print 'Val is now '.$newval.' and is type '.$isidorref."
\n"; + //print 'Newval is now "'.$newval.'" and is type '.$isidorref."
\n"; if ($isidorref == 'ref') { // If value into input import file is a ref, we apply the function defined into descriptor $file = (empty($objimport->array_import_convertvalue[0][$val]['classfile']) ? $objimport->array_import_convertvalue[0][$val]['file'] : $objimport->array_import_convertvalue[0][$val]['classfile']); @@ -476,6 +480,11 @@ class ImportXlsx extends ModeleImports break; } $classinstance = new $class($this->db); + if ($class == 'CGenericDic') { + $classinstance->element = $objimport->array_import_convertvalue[0][$val]['element']; + $classinstance->table_element = $objimport->array_import_convertvalue[0][$val]['table_element']; + } + // Try the fetch from code or ref $param_array = array('', $newval); if ($class == 'AccountingAccount') { @@ -674,7 +683,7 @@ class ImportXlsx extends ModeleImports break; } $classinstance = new $class($this->db); - $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord)); + $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $listfields, $key)); $newval = $res; // We get new value computed. } elseif ($objimport->array_import_convertvalue[0][$val]['rule'] == 'numeric') { $newval = price2num($newval); @@ -758,19 +767,16 @@ class ImportXlsx extends ModeleImports } if (!empty($newval) && $arrayrecord[($key)]['type'] > 0) { $socialkey = array_search("socialnetworks", $listfields); + $socialnetwork = explode("_", $fieldname)[1]; if (empty($listvalues[$socialkey]) || $listvalues[$socialkey] == "null") { - $socialnetwork = explode("_", $fieldname)[1]; $json = new stdClass(); $json->$socialnetwork = $newval; - $newvalue = json_encode($json); - $listvalues[$socialkey] = $newvalue; + $listvalues[$socialkey] = json_encode($json); } else { - $socialnetwork = explode("_", $fieldname)[1]; $jsondata = $listvalues[$socialkey]; - $jsondata = str_replace("'", "", $jsondata); $json = json_decode($jsondata); - $json->$socialnetwork = $this->db->escape($newval); - $listvalues[$socialkey] = "'".$this->db->escape(json_encode($json))."'"; + $json->$socialnetwork = $newval; + $listvalues[$socialkey] = json_encode($json); } } } else { @@ -789,6 +795,13 @@ class ImportXlsx extends ModeleImports $i++; } + // We db escape social network field because he isn't in field creation + if (in_array("socialnetworks", $listfields)) { + $socialkey = array_search("socialnetworks", $listfields); + $tmpsql = $listvalues[$socialkey]; + $listvalues[$socialkey] = "'".$this->db->escape($tmpsql)."'"; + } + // We add hidden fields (but only if there is at least one field to add into table) // We process here all the fields that were declared into the array $this->import_fieldshidden_array of the descriptor file. // Previously we processed the ->import_fields_array. @@ -825,7 +838,7 @@ class ImportXlsx extends ModeleImports break; } $classinstance = new $class($this->db); - $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $fieldname, &$listfields, &$listvalues)); + $res = call_user_func_array(array($classinstance, $method), array(&$arrayrecord, $listfields, $key)); $fieldArr = explode('.', $fieldname); if (count($fieldArr) > 0) { $fieldname = $fieldArr[1]; @@ -898,7 +911,7 @@ class ImportXlsx extends ModeleImports if (empty($keyfield)) { $keyfield = 'rowid'; } - $sqlSelect .= "WHERE " . $keyfield . " = " .((int) $lastinsertid); + $sqlSelect .= "WHERE ".$keyfield." = ".((int) $lastinsertid); $resql = $this->db->query($sqlSelect); if ($resql) { @@ -925,7 +938,7 @@ class ImportXlsx extends ModeleImports $data = array_combine($listfields, $listvalues); $set = array(); foreach ($data as $key => $val) { - $set[] = $key . ' = ' . $val; + $set[] = $key." = ".$val; } $sqlstart .= " SET " . implode(', ', $set); diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index a9eb5899fc8..a6d9b95d19c 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -586,7 +586,26 @@ class modSociete extends DolibarrModules 'class' => 'Account', 'method' => 'fetch', 'element' => 'BankAccount' - // ), + ), + 's.fk_stcomm' => array( + 'rule' => 'fetchidfromcodeid', + 'classfile' => '/core/class/cgenericdic.class.php', + 'class' => 'CGenericDic', + 'method' => 'fetch', + 'dict' => 'DictionaryProspectStatus', + 'element' => 'c_stcomm', + 'table_element' => 'c_stcomm' + ), + /* + 's.fk_prospectlevel' => array( + 'rule' => 'fetchidfromcodeid', + 'classfile' => '/core/class/cgenericdic.class.php', + 'class' => 'CGenericDic', + 'method' => 'fetch', + 'dict' => 'DictionaryProspectLevel', + 'element' => 'c_prospectlevel', + 'table_element' => 'c_prospectlevel' + ),*/ // TODO // 's.fk_incoterms' => array( // 'rule' => 'fetchidfromcodeid', @@ -594,7 +613,7 @@ class modSociete extends DolibarrModules // 'class' => 'Cincoterm', // 'method' => 'fetch', // 'dict' => 'IncotermLabel' - ) + // ) ); //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); $this->import_regex_array[$r] = array(//field order as per structure of table llx_societe From c79de819d37193ecd35bdbbad3b8f0e513980646 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 May 2022 23:27:26 +0200 Subject: [PATCH 146/174] FIX Missing import_key in member list --- htdocs/adherents/list.php | 93 +++++++++++++++++++++++++++------------ htdocs/societe/list.php | 25 +++++++---- 2 files changed, 82 insertions(+), 36 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 72f75cdf4c8..ec6e7ac5f29 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -1,7 +1,7 @@ * Copyright (C) 2002-2003 Jean-Louis Bergamo - * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2004-2022 Laurent Destailleur * Copyright (C) 2013-2015 Raphaël Doursenaud * Copyright (C) 2014-2016 Juanjo Menent * Copyright (C) 2018 Alexandre Spangaro @@ -63,6 +63,7 @@ $search_email = GETPOST("search_email", 'alpha'); $search_categ = GETPOST("search_categ", 'int'); $search_filter = GETPOST("search_filter", 'alpha'); $search_status = GETPOST("search_status", 'intcomma'); +$search_import_key = trim(GETPOST("search_import_key", "alpha")); $catid = GETPOST("catid", 'int'); $optioncss = GETPOST('optioncss', 'alpha'); $socid = GETPOST('socid', 'int'); @@ -156,7 +157,8 @@ $arrayfields = array( 'd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'd.birth'=>array('label'=>$langs->trans("Birthday"), 'checked'=>0, 'position'=>500), 'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), - 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000) + 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), + 'd.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100), ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; @@ -213,6 +215,7 @@ if (empty($reshook)) { $search_categ = ""; $search_filter = ""; $search_status = ""; + $search_import_key = ''; $catid = ""; $sall = ""; $toselect = array(); @@ -318,7 +321,7 @@ $sql .= " d.rowid, d.ref, d.login, d.lastname, d.firstname, d.gender, d.societe $sql .= " d.civility, d.datefin, d.address, d.zip, d.town, d.state_id, d.country,"; $sql .= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.birth, d.public, d.photo,"; $sql .= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,"; -$sql .= " d.note_private, d.note_public,"; +$sql .= " d.note_private, d.note_public, d.import_key,"; $sql .= " s.nom,"; $sql .= " ".$db->ifsql("d.societe IS NULL", "s.nom", "d.societe")." as companyname,"; $sql .= " t.libelle as type, t.subscription,"; @@ -427,6 +430,9 @@ if ($search_phone_mobile) { if ($search_country) { $sql .= " AND d.country IN (".$db->sanitize($search_country).')'; } +if ($search_import_key) { + $sql .= natural_search("d.import_key", $search_import_key); +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -436,8 +442,6 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); - // Count total nb of records with no order and no limits $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -447,15 +451,20 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { } else { dol_print_error($db); } + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); +} + +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); } -// Add limit -$sql .= $db->plimit($limit + 1, $offset); -dol_syslog("get list", LOG_DEBUG); $resql = $db->query($sql); if (!$resql) { dol_print_error($db); @@ -464,6 +473,7 @@ if (!$resql) { $num = $db->num_rows($resql); + $arrayofselected = is_array($toselect) ? $toselect : array(); if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall) { @@ -473,7 +483,8 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ exit; } -llxHeader('', $title, 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'); +$help_url = 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros'; +llxHeader('', $title, $help_url); if (GETPOSTISSET("search_status")) { if ($search_status == '-1,1') { // TODO : check this test as -1 == Adherent::STATUS_DRAFT and -2 == Adherent::STATUS_EXLCUDED @@ -577,6 +588,9 @@ if ($search_filter && $search_filter != '-1') { if ($search_status != "" && $search_status != -3) { $param .= "&search_status=".urlencode($search_status); } +if ($search_import_key != '') { + $param .= '&search_import_key='.urlencode($search_import_key); +} if ($search_type > 0) { $param .= "&search_type=".urlencode($search_type); } @@ -603,7 +617,7 @@ if ($user->rights->societe->creer) { if ($user->rights->adherent->creer && $user->rights->user->user->creer) { $arrayofmassactions['createexternaluser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("CreateExternalUser"); } -if (in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) { +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -669,7 +683,6 @@ if ($massactionbutton) { print '
'; print ''."\n"; - // Line for filters fields print ''; @@ -807,15 +820,24 @@ if (!empty($arrayfields['d.statut']['checked'])) { print $form->selectarray('search_status', $liststatus, $search_status, -3); print ''; } -// Action column -print ''; - +if (!empty($arrayfields['d.import_key']['checked'])) { + print ''; +} +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + // Action column + print ''; +} print "\n"; print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch actioncolumn '); +} if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { print_liste_field_titre("ID", $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder); } @@ -895,7 +917,12 @@ if (!empty($arrayfields['d.tms']['checked'])) { if (!empty($arrayfields['d.statut']['checked'])) { print_liste_field_titre($arrayfields['d.statut']['label'], $_SERVER["PHP_SELF"], "d.statut", "", $param, 'class="right"', $sortfield, $sortorder); } -print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); +if (!empty($arrayfields['d.import_key']['checked'])) { + print_liste_field_titre($arrayfields['d.import_key']['label'], $_SERVER["PHP_SELF"], "d.import_key", "", $param, '', $sortfield, $sortorder, 'center '); +} +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); +} print "\n"; $i = 0; @@ -936,7 +963,7 @@ while ($i < min($num, $limit)) { print ''; if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) { - print ''; + print ''; if (!$i) { $totalarray['nbfield']++; } @@ -1172,21 +1199,31 @@ while ($i < min($num, $limit)) { $totalarray['nbfield']++; } } - // Action column - print '\n"; + if (!$i) { + $totalarray['nbfield']++; } - print ''; } - print ''; + // Action column + if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } if (!$i) { $totalarray['nbfield']++; } - print "\n"; + print ''."\n"; $i++; } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 91368ec9dc7..c2ad5852842 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -678,20 +678,28 @@ $parameters = array('fieldstosearchall' => $fieldstosearchall); $reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; -$sql .= $db->order($sortfield, $sortorder); - -// Count total nb of records +// Count total nb of records with no order and no limits $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $resql = $db->query($sql); + if ($resql) { + $nbtotalofrecords = $db->num_rows($resql); + } else { + dol_print_error($db); + } + if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} $resql = $db->query($sql); if (!$resql) { @@ -701,6 +709,7 @@ if (!$resql) { $num = $db->num_rows($resql); + $arrayofselected = is_array($toselect) ? $toselect : array(); if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ($search_all != '' || $search_cti != '') && $action != 'list') { @@ -860,8 +869,8 @@ if (GETPOST('delsoc')) { // List of mass actions available $arrayofmassactions = array( -'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), -// 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), + 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), + //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->societe->creer) { From 343056dcbd6fc7d929d3b8b20f77cc29b6dea8f9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 May 2022 23:43:16 +0200 Subject: [PATCH 147/174] Debug v16 --- htdocs/adherents/list.php | 4 ++-- htdocs/core/lib/functions.lib.php | 20 +++++++++----------- htdocs/theme/eldy/global.inc.php | 3 ++- htdocs/theme/md/style.css.php | 3 ++- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index ec6e7ac5f29..8bf7f7af6a6 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -1200,8 +1200,8 @@ while ($i < min($num, $limit)) { } } if (!empty($arrayfields['d.import_key']['checked'])) { - print '\n"; if (!$i) { $totalarray['nbfield']++; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e2bcda01b6a..7b343bcdfee 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4958,10 +4958,10 @@ function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin $liste_titre = 'liste_titre_sel'; } - $out .= '<'.$tag.' class="'.$prefix.$liste_titre.'" '.$moreattrib; + $tagstart = '<'.$tag.' class="'.$prefix.$liste_titre.'" '.$moreattrib; //$out .= (($field && empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && preg_match('/^[a-zA-Z_0-9\s\.\-:&;]*$/', $name)) ? ' title="'.dol_escape_htmltag($langs->trans($name)).'"' : ''); - $out .= ($name && empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && empty($forcenowrapcolumntitle) && !dol_textishtml($name)) ? ' title="'.dol_escape_htmltag($langs->trans($name)).'"' : ''; - $out .= '>'; + $tagstart .= ($name && empty($conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE) && empty($forcenowrapcolumntitle) && !dol_textishtml($name)) ? ' title="'.dol_escape_htmltag($langs->trans($name)).'"' : ''; + $tagstart .= '>'; if (empty($thead) && $field && empty($disablesortlink)) { // If this is a sort field $options = preg_replace('/sortfield=([a-zA-Z0-9,\s\.]+)/i', '', (is_scalar($moreparam) ? $moreparam : '')); @@ -4975,12 +4975,10 @@ function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin if ($field1 != $sortfield1) { // We are on another field than current sorted field if (preg_match('/^DESC/i', $sortorder)) { $sortordertouseinlink .= str_repeat('desc,', count(explode(',', $field))); - } else // We reverse the var $sortordertouseinlink - { + } else { // We reverse the var $sortordertouseinlink $sortordertouseinlink .= str_repeat('asc,', count(explode(',', $field))); } - } else // We are on field that is the first current sorting criteria - { + } else { // We are on field that is the first current sorting criteria if (preg_match('/^ASC/i', $sortorder)) { // We reverse the var $sortordertouseinlink $sortordertouseinlink .= str_repeat('desc,', count(explode(',', $field))); } else { @@ -5019,19 +5017,19 @@ function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin if (preg_match('/^DESC/', $sortorder)) { //$out.= ''.img_down("A-Z",0).''; //$out.= ''.img_up("Z-A",1).''; - $sortimg .= ''.img_up("Z-A", 0, 'paddingleft').''; + $sortimg .= ''.img_up("Z-A", 0, 'paddingright').''; } if (preg_match('/^ASC/', $sortorder)) { //$out.= ''.img_down("A-Z",1).''; //$out.= ''.img_up("Z-A",0).''; - $sortimg .= ''.img_down("A-Z", 0, 'paddingleft').''; + $sortimg .= ''.img_down("A-Z", 0, 'paddingright').''; } } } - $out .= $sortimg; + $tagend = ''; - $out .= ''; + $out = $tagstart.$sortimg.$out.$tagend; return $out; } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 19abdd3ba9b..9eb615d2355 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -149,7 +149,8 @@ select.vmenusearchselectcombo { background-color: unset; } -table.liste th.wrapcolumntitle.liste_titre:not(.maxwidthsearch), table.liste td.wrapcolumntitle.liste_titre:not(.maxwidthsearch) { +table.liste th.wrapcolumntitle.liste_titre:not(.maxwidthsearch), table.liste td.wrapcolumntitle.liste_titre:not(.maxwidthsearch), +table.liste th.wrapcolumntitle.liste_titre_sel:not(.maxwidthsearch), table.liste td.wrapcolumntitle.liste_titre_sel:not(.maxwidthsearch) { overflow: hidden; white-space: nowrap; max-width: 100px; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 261e89c64be..73337ba0284 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -403,7 +403,8 @@ textarea.cke_source:focus box-shadow: none; } -th.wrapcolumntitle.liste_titre:not(.maxwidthsearch), td.wrapcolumntitle.liste_titre:not(.maxwidthsearch) { +th.wrapcolumntitle.liste_titre:not(.maxwidthsearch), td.wrapcolumntitle.liste_titre:not(.maxwidthsearch), +th.wrapcolumntitle.liste_titre_sel:not(.maxwidthsearch), td.wrapcolumntitle.liste_titre_sel:not(.maxwidthsearch) { overflow: hidden; white-space: nowrap; max-width: 120px; From 2b5e21379b4eb95de16cf3292e96fe22219af6e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 25 May 2022 23:54:03 +0200 Subject: [PATCH 148/174] Fix phpcs --- htdocs/core/class/cgenericdic.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/cgenericdic.class.php b/htdocs/core/class/cgenericdic.class.php index deda1c1952b..ab1023b81f5 100644 --- a/htdocs/core/class/cgenericdic.class.php +++ b/htdocs/core/class/cgenericdic.class.php @@ -251,7 +251,7 @@ class CGenericDic } if (count($sqlwhere) > 0) { - $sql .= ' WHERE '.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere); + $sql .= " WHERE ".implode(' '.$this->db->escape($filtermode).' ', $sqlwhere); } if (!empty($sortfield)) { $sql .= $this->db->order($sortfield, $sortorder); @@ -323,9 +323,9 @@ class CGenericDic // Update request $sql = "UPDATE ".$this->db->prefix().$this->table_element.' SET'; $sql .= " code = ".(isset($this->code) ? "'".$this->db->escape($this->code)."'" : "null").','; - $sql .= " ".$fieldlabel.' = '.(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").','; + $sql .= " ".$fieldlabel." = ".(isset($this->label) ? "'".$this->db->escape($this->label)."'" : "null").','; $sql .= " active = ".(isset($this->active) ? $this->active : "null"); - $sql .= " WHERE ".$fieldrowid.' = '.((int) $this->id); + $sql .= " WHERE ".$fieldrowid." = ".((int) $this->id); $this->db->begin(); @@ -389,8 +389,8 @@ class CGenericDic // If you need to delete child tables to, you can insert them here if (!$error) { - $sql = 'DELETE FROM '.$this->db->prefix().$this->table_element; - $sql .= ' WHERE '.$fieldrowid.' = '.((int) $this->id); + $sql = "DELETE FROM ".$this->db->prefix().$this->table_element; + $sql .= " WHERE ".$fieldrowid." = ".((int) $this->id); $resql = $this->db->query($sql); if (!$resql) { From b93b9a784c2c274fe05cd3756412a8e6cc507e40 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 26 May 2022 00:30:35 +0200 Subject: [PATCH 149/174] Trans --- htdocs/admin/dict.php | 24 ++++++++++++++---------- htdocs/core/lib/functions.lib.php | 24 +++++++++++++++++------- htdocs/langs/en_US/admin.lang | 3 ++- htdocs/societe/list.php | 3 ++- 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 00eebf78f10..796e64223c4 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1490,11 +1490,13 @@ if ($id > 0) { } if ($valuetoshow != '') { + $tooltiphelp = (isset($tabcomplete[$tabname[$id]]['help'][$value]) ? $tabcomplete[$tabname[$id]]['help'][$value] : ''); + $tdsoffields .= ''; - if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { - $tdsoffields .= ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; - } elseif (!empty($tabhelp[$id][$value])) { - $tdsoffields .= $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); + if ($tooltiphelp && preg_match('/^http(s*):/i', $tooltiphelp)) { + $tdsoffields .= ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; + } elseif ($tooltiphelp) { + $tdsoffields .= $form->textwithpicto($valuetoshow, $tooltiphelp); } else { $tdsoffields .= $valuetoshow; } @@ -1643,8 +1645,8 @@ if ($id > 0) { continue; } - if (in_array($value, array('label', 'libelle', 'libelle_facture')) && empty($tabhelp[$id][$value])) { - $tabhelp[$id][$value] = $langs->trans('LabelUsedByDefault'); + if (in_array($value, array('label', 'libelle', 'libelle_facture')) && empty($tabcomplete[$tabname[$id]]['help'][$value])) { + $tabcomplete[$tabname[$id]]['help'][$value] = $langs->trans('LabelUsedByDefault'); } // Determines the name of the field in relation to the possible names @@ -1850,10 +1852,12 @@ if ($id > 0) { // Show field title if ($showfield) { - if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { - $newvaluetoshow = ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; - } elseif (!empty($tabhelp[$id][$value])) { - $newvaluetoshow = $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); + $tooltiphelp = (isset($tabcomplete[$tabname[$id]]['help'][$value]) ? $tabcomplete[$tabname[$id]]['help'][$value] : ''); + + if ($tooltiphelp && preg_match('/^http(s*):/i', $tooltiphelp)) { + $newvaluetoshow = ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; + } elseif ($tooltiphelp) { + $newvaluetoshow = $form->textwithpicto($valuetoshow, $tooltiphelp); } else { $newvaluetoshow = $valuetoshow; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7b343bcdfee..978d385fcda 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3768,6 +3768,7 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $srconly = 0, $notitle = 0, $alt = '', $morecss = '', $marginleftonlyshort = 2) { global $conf, $langs; + // We forge fullpathpicto for image to $path/img/$picto. By default, we take DOL_URL_ROOT/theme/$conf->theme/img/$picto $url = DOL_URL_ROOT; $theme = isset($conf->theme) ? $conf->theme : null; @@ -3786,15 +3787,25 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ } } else { $pictowithouttext = preg_replace('/(\.png|\.gif|\.svg)$/', '', $picto); + $pictowithouttext = str_replace('object_', '', $pictowithouttext); - if (strpos($pictowithouttext, 'fontawesome_') !== false) { - $pictowithouttext = explode('_', $pictowithouttext); + if (strpos($pictowithouttext, 'fontawesome_') !== false || preg_match('/^fa-/', $pictowithouttext)) { + // This is a font awesome image 'fonwtawesome_xxx' or 'fa-xxx' + $pictowithouttext = str_replace('fa-', '', $pictowithouttext); + $pictowithouttextarray = explode('_', $pictowithouttext); $marginleftonlyshort = 0; - $fakey = 'fa-'.$pictowithouttext[1]; - $fa = $pictowithouttext[2] ? $pictowithouttext[2] : 'fa'; - $facolor = $pictowithouttext[3] ? $pictowithouttext[3] : ''; - $fasize = $pictowithouttext[4] ? $pictowithouttext[4] : ''; + if (!empty($pictowithouttextarray[1])) { + $fakey = 'fa-'.$pictowithouttextarray[1]; + $fa = empty($pictowithouttextarray[2]) ? 'fa' : $pictowithouttextarray[2]; + $facolor = empty($pictowithouttextarray[3]) ? '' : $pictowithouttextarray[3]; + $fasize = empty($pictowithouttextarray[4]) ? '' : $pictowithouttextarray[4]; + } else { + $fakey = 'fa-'.$pictowithouttext; + $fa = 'fa'; + $facolor = ''; + $fasize = ''; + } // This snippet only needed since function img_edit accepts only one additional parameter: no separate one for css only. // class/style need to be extracted to avoid duplicate class/style validation errors when $moreatt is added to the end of the attributes. @@ -3820,7 +3831,6 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ return $enabledisablehtml; } - $pictowithouttext = str_replace('object_', '', $pictowithouttext); if (empty($srconly) && in_array($pictowithouttext, array( '1downarrow', '1uparrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected', 'accountancy', 'accounting_account', 'account', 'accountline', 'action', 'add', 'address', 'angle-double-down', 'angle-double-up', 'asset', diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index d36dbfd7733..808049978eb 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1949,7 +1949,7 @@ EnterAnyCode=This field contains a reference to identify the line. Enter any val Enter0or1=Enter 0 or 1 UnicodeCurrency=Enter here between braces, list of byte number that represent the currency symbol. For example: for $, enter [36] - for brazil real R$ [82,36] - for €, enter [8364] ColorFormat=The RGB color is in HEX format, eg: FF0000 -PictoHelp=Icon name in dolibarr format ('image.png' if into the current theme directory, 'image.png@nom_du_module' if into the directory /img/ of a module) +PictoHelp=Icon name in format:
- image.png for an image file into the current theme directory
- image.png@module if file is into the directory /img/ of a module
- fa-xxx for a FontAwesome fa-xxx picto
- fonwtawesome_xxx_fa_color_size for a FontAwesome fa-xxx picto (with prefix, color and size set) PositionIntoComboList=Position of line into combo lists SellTaxRate=Sales tax rate RecuperableOnly=Yes for VAT "Not Perceived but Recoverable" dedicated for some state in France. Keep value to "No" in all other cases. @@ -2262,3 +2262,4 @@ IconOnlyTextOnHover=Icon only - Text of icon appears under icon on mouse hover t IconOnly=Icon only - Text on tooltip only INVOICE_ADD_ZATCA_QR_CODE=Show the ZATCA QR code on invoices INVOICE_ADD_ZATCA_QR_CODEMore=Some Arabic countries need this QR Code on their invoices +UrlSocialNetworksDesc=Url link of social network. Use {socialid} for the variable part that contains the social network ID. \ No newline at end of file diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index c2ad5852842..a92ca5ed11c 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1677,7 +1677,8 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['s.fk_stcomm']['checked'])) { // Prospect status print '
'; print ''; if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_USE_AUXILIARY_ON_DEPOSIT)) { From ebfc5666988b76da0087fbc7d8d795cf37c2f490 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Fri, 27 May 2022 16:16:41 +0200 Subject: [PATCH 152/174] php V8 warning --- htdocs/admin/supplier_proposal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/supplier_proposal.php b/htdocs/admin/supplier_proposal.php index 9bd684afb22..80f2c6a62f4 100644 --- a/htdocs/admin/supplier_proposal.php +++ b/htdocs/admin/supplier_proposal.php @@ -498,7 +498,7 @@ print '\n"; print ''; -if ($conf->banque->enabled) { +if (!empty($conf->banque->enabled)) { print ''; print "\n"; // Use vat for invoice creation -if ($conf->facture->enabled) { +if (!empty($conf->facture->enabled)) { print ''; if (!empty($conf->banque->enabled)) { print ''; if ($object->thirdparty->client) { $thirdTypeArray['customer'] = $langs->trans("customer"); - if ($conf->propal->enabled && $user->rights->propal->lire) { + if (!empty($conf->propal->enabled) && $user->rights->propal->lire) { $elementTypeArray['propal'] = $langs->transnoentitiesnoconv('Proposals'); } - if ($conf->commande->enabled && $user->rights->commande->lire) { + if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $elementTypeArray['order'] = $langs->transnoentitiesnoconv('Orders'); } - if ($conf->facture->enabled && $user->rights->facture->lire) { + if (!empty($conf->facture->enabled) && $user->rights->facture->lire) { $elementTypeArray['invoice'] = $langs->transnoentitiesnoconv('Invoices'); } - if ($conf->contrat->enabled && $user->rights->contrat->lire) { + if (!empty($conf->contrat->enabled) && $user->rights->contrat->lire) { $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts'); } } From 4c96921a5f38c8f31756cdf7e224ccd9fb07fe68 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Sat, 28 May 2022 09:54:59 +0200 Subject: [PATCH 157/174] php 8 fix warning --- htdocs/core/class/html.formticket.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 5600f51f5e2..31a48f38cf4 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -346,7 +346,7 @@ class FormTicket } } - if ($conf->knowledgemanagement->enabled) { + if (!empty($conf->knowledgemanagement->enabled)) { // KM Articles print ''; print ' From b1c4aa07f09fb5cbb2de8c47c1542aada89ef77a Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Sat, 28 May 2022 09:58:54 +0200 Subject: [PATCH 158/174] fix php 8 warning --- htdocs/admin/stock.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index e8f59727c07..a5e83155f03 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -394,7 +394,7 @@ print "\n"; print "\n"; // Option to force stock to be enough before adding a line into document -if ($conf->invoice->enabled) { +if (!empty($conf->invoice->enabled)) { print ''; print ''; print '\n"; } -if ($conf->order->enabled) { +if (!empty($conf->order->enabled)) { print ''; print ''; print '\n"; } -if ($conf->expedition->enabled) { +if (!empty($conf->expedition->enabled)) { print ''; print ''; print '"; - print ''; print ''; - print ''; + print ''; + print ''; print ''; print "\n"; $i++; From 2c9c55bc7526466d266549ae9e44f0fe93ff5685 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 May 2022 16:52:39 +0200 Subject: [PATCH 164/174] Fix filter on dates --- htdocs/product/reassortlot.php | 739 ++++++++++++++++++--------------- 1 file changed, 415 insertions(+), 324 deletions(-) diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index c5463e3e4e2..031ef60ff6e 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -33,11 +33,18 @@ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'productbatch')); -$action = GETPOST('action', 'aZ09'); +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... +$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search +$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page +$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$mode = GETPOST('mode', 'aZ'); + $sref = GETPOST("sref", 'alpha'); $snom = GETPOST("snom", 'alpha'); $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); @@ -52,25 +59,21 @@ $fourn_id = GETPOST("fourn_id", 'int'); $sbarcode = GETPOST("sbarcode", 'int'); $search_stock_physique = GETPOST('search_stock_physique', 'alpha'); +// Load variable for pagination +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0) { +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; } -if (!$sortfield) { - $sortfield = "p.ref"; -} -if (!$sortorder) { - $sortorder = "ASC"; -} -$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -if (empty($page) || $page == -1) { - $page = 0; -} // If $page is not defined, or '' or -1 $offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; -// Load sale and categ filters +// Initialize array of search criterias +$object = new Product($db); $search_sale = GETPOST("search_sale"); if (GETPOSTISSET('catid')) { $search_categ = GETPOST('catid', 'int'); @@ -78,6 +81,33 @@ if (GETPOSTISSET('catid')) { $search_categ = GETPOST('search_categ', 'int'); } +// Fetch optionals attributes and labels +$extrafields->fetch_name_optionals_label($object->table_element); +//$extrafields->fetch_name_optionals_label($object->table_element_line); + +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); + +// Default sort order (if not yet defined by previous GETPOST) +if (!$sortfield) { + reset($object->fields); // Reset is required to avoid key() to return null. + $sortfield = "p.".key($object->fields); // Set here default search field. By default 1st field in definition. +} +if (!$sortorder) { + $sortorder = "ASC"; +} + +// Initialize array of search criterias +$search = array(); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha') !== '') { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); + $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); + } +} + // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $canvas = GETPOST("canvas"); $objcanvas = null; @@ -98,21 +128,62 @@ $result = restrictedArea($user, 'produit|service', 0, 'product&product'); * Actions */ -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers - $sref = ""; - $snom = ""; - $sall = ""; - $tosell = ""; - $tobuy = ""; - $search_sale = ""; - $search_categ = ""; - $toolowstock = ''; - $search_batch = ''; - $search_warehouse = ''; - $fourn_id = ''; - $sbarcode = ''; - $search_stock_physique = ''; +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; + $massaction = ''; } +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} + +if (empty($reshook)) { + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers + foreach ($object->fields as $key => $val) { + $search[$key] = ''; + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = ''; + $search[$key.'_dtend'] = ''; + } + } + $sref = ""; + $snom = ""; + $sall = ""; + $tosell = ""; + $tobuy = ""; + $search_sale = ""; + $search_categ = ""; + $toolowstock = ''; + $search_batch = ''; + $search_warehouse = ''; + $fourn_id = ''; + $sbarcode = ''; + $search_stock_physique = ''; + $toselect = array(); + $search_array_options = array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + /*$objectclass = 'MyObject'; + $objectlabel = 'MyObject'; + $uploaddir = $conf->mymodule->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + */ +} + /* @@ -122,8 +193,12 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $form = new Form($db); $htmlother = new FormOther($db); +$now = dol_now(); + $helpurl = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; $title = $langs->trans("ProductsAndServices"); +$morejs = array(); +$morecss = array(); $sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,'; $sql .= ' p.fk_product_type, p.tms as datem,'; @@ -217,318 +292,334 @@ if ($search_stock_physique != '') { if (!empty($sql_having)) { $sql .= $sql_having; } -$sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0 + + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } + $db->free($resql); } -$sql .= $db->plimit($limit + 1, $offset); +// Complete request and execute it with limit +$sql .= $db->order($sortfield, $sortorder); +if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); +} $resql = $db->query($sql); -if ($resql) { - $num = $db->num_rows($resql); - - $i = 0; - - if ($num == 1 && GETPOST('autojumpifoneonly') && ($sall or $snom or $sref)) { - $objp = $db->fetch_object($resql); - header("Location: card.php?id=$objp->rowid"); - exit; - } - - if (isset($type)) { - if ($type == 1) { - $texte = $langs->trans("Services"); - } else { - $texte = $langs->trans("Products"); - } - } else { - $texte = $langs->trans("ProductsAndServices"); - } - $texte .= ' ('.$langs->trans("StocksByLotSerial").')'; - - $param = ''; - if ($limit > 0 && $limit != $conf->liste_limit) { - $param .= '&limit='.urlencode($limit); - } - if ($sall) { - $param .= "&sall=".urlencode($sall); - } - if ($tosell) { - $param .= "&tosell=".urlencode($tosell); - } - if ($tobuy) { - $param .= "&tobuy=".urlencode($tobuy); - } - if ($type != '') { - $param .= "&type=".urlencode($type); - } - if ($fourn_id) { - $param .= "&fourn_id=".urlencode($fourn_id); - } - if ($snom) { - $param .= "&snom=".urlencode($snom); - } - if ($sref) { - $param .= "&sref=".urlencode($sref); - } - if ($search_batch) { - $param .= "&search_batch=".urlencode($search_batch); - } - if ($sbarcode) { - $param .= "&sbarcode=".urlencode($sbarcode); - } - if ($search_warehouse) { - $param .= "&search_warehouse=".urlencode($search_warehouse); - } - if ($toolowstock) { - $param .= "&toolowstock=".urlencode($toolowstock); - } - if ($search_sale) { - $param .= "&search_sale=".urlencode($search_sale); - } - if (!empty($search_categ) && $search_categ != '-1') { - $param .= "&search_categ=".urlencode($search_categ); - } - if ($search_stock_physique) { - $param .= '&search_stock_physique=' . urlencode($search_stock_physique); - } - /*if ($eatby) $param.="&eatby=".$eatby; - if ($sellby) $param.="&sellby=".$sellby;*/ - - llxHeader("", $title, $helpurl, $texte); - - print '
'; - print ''; - print ''; - print ''; - print ''; - - print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'product', 0, '', '', $limit, 0, 0, 1); - - - if ($search_categ > 0) { - print "
"; - $c = new Categorie($db); - $c->fetch($search_categ); - $ways = $c->print_all_ways(' > ', 'product/reassortlot.php'); - print " > ".$ways[0]."
\n"; - print "

"; - } - - // Filter on categories - $moreforfilter = ''; - if (!empty($conf->categorie->enabled)) { - $moreforfilter .= '
'; - $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); - $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1); - $moreforfilter .= '
'; - } - //$moreforfilter.=$langs->trans("StockTooLow").' '; - - if (!empty($moreforfilter)) { - print '
'; - print $moreforfilter; - $parameters = array(); - $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '
'; - } - - - print '
'; - print '
'; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + print ''; + print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'.$obj->rowid.''.$obj->rowid.''; - if ($massactionbutton || $massaction) { // 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; + if (!empty($arrayfields['d.import_key']['checked'])) { + print ''; + print $obj->import_key; + print "'; + if ($massactionbutton || $massaction) { // 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; + } + print ''; + } + print '
'; - print $obj->import_key; + print ''; + print dol_escape_htmltag($obj->import_key); print "
'; - print '
'.$companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); + print '
'; + print $companystatic->LibProspCommStatut($obj->stcomm_id, 2, $prospectstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto); print '
-
'; foreach ($prospectstatic->cacheprospectstatus as $key => $val) { $titlealt = 'default'; From 8f736b3ecb1aaa30d8ca90a981b323d9b343c68b Mon Sep 17 00:00:00 2001 From: DATUC Date: Thu, 26 May 2022 12:57:27 +0100 Subject: [PATCH 150/174] Local CM adjust Local ref update --- htdocs/langs/en_US/companies.lang | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 8f44b999a3a..c4a964b6b62 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -163,14 +163,14 @@ ProfId5CL=- ProfId6CL=- ProfId1CM=Id. prof. 1 (Trade Register) ProfId2CM=Id. prof. 2 (Taxpayer No.) -ProfId3CM=Id. prof. 3 (Decree of creation) -ProfId4CM=Id. prof. 4 (Certificate of deposits) +ProfId3CM=Id. prof. 3 (No. of creation decree) +ProfId4CM=Id. prof. 4 (Deposit certificate No.) ProfId5CM=Id. prof. 5 (Others) ProfId6CM=- ProfId1ShortCM=Trade Register ProfId2ShortCM=Taxpayer No. -ProfId3ShortCM=Decree of creation -ProfId4ShortCM=Certificate of deposits +ProfId3ShortCM=No. of creation decree +ProfId4ShortCM=Deposit certificate No. ProfId5ShortCM=Others ProfId6ShortCM=- ProfId1CO=Prof Id 1 (R.U.T.) From d14faf86a028b4a93aabd6d81a640d9cb6252534 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Fri, 27 May 2022 16:14:36 +0200 Subject: [PATCH 151/174] php V8 warning fix --- htdocs/accountancy/admin/defaultaccounts.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index 6d7d92ce22b..583b12368dc 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -81,22 +81,22 @@ $list_account[] = '---Others---'; $list_account[] = 'ACCOUNTING_VAT_BUY_ACCOUNT'; $list_account[] = 'ACCOUNTING_VAT_SOLD_ACCOUNT'; $list_account[] = 'ACCOUNTING_VAT_PAY_ACCOUNT'; -if ($conf->banque->enabled) { +if (!empty($conf->banque->enabled)) { $list_account[] = 'ACCOUNTING_ACCOUNT_TRANSFER_CASH'; } -if ($conf->don->enabled) { +if (!empty($conf->don->enabled)) { $list_account[] = 'DONATION_ACCOUNTINGACCOUNT'; } -if ($conf->adherent->enabled) { +if (!empty($conf->adherent->enabled)) { $list_account[] = 'ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT'; } -if ($conf->loan->enabled) { +if (!empty($conf->loan->enabled)) { $list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_CAPITAL'; $list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INTEREST'; $list_account[] = 'LOAN_ACCOUNTING_ACCOUNT_INSURANCE'; } $list_account[] = 'ACCOUNTING_ACCOUNT_SUSPENSE'; -if ($conf->societe->enabled) { +if (!empty($conf->societe->enabled)) { $list_account[] = '---Deposits---'; $list_account[] = 'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT'; } @@ -246,7 +246,7 @@ foreach ($list_account as $key) { } } -if ($conf->societe->enabled) { +if (!empty($conf->societe->enabled)) { print '
' . img_picto('', 'bill', 'class="pictofixedwidth"') . $langs->trans("UseAuxiliaryAccountOnCustomerDeposit") . '
'; print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_SUPPLIER_PROPOSAL").' '; if (!empty($conf->use_javascript_ajax)) { From 0bf09e0fb263715f48c4650800d197196efd53c1 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Fri, 27 May 2022 16:22:01 +0200 Subject: [PATCH 153/174] php V8 fix warning --- htdocs/blockedlog/class/blockedlog.class.php | 66 +++++++------------- 1 file changed, 22 insertions(+), 44 deletions(-) diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 578e1afa497..a313d28d938 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -1,6 +1,7 @@ - * Copyright (C) 2017-2020 Laurent Destailleur +/* Copyright (C) 2017 ATM Consulting + * Copyright (C) 2017-2020 Laurent Destailleur + * Copyright (C) 2022 charlene benke * * 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 @@ -139,76 +140,53 @@ class BlockedLog $this->trackedevents = array(); - if ($conf->facture->enabled) { + if (!empty($conf->facture->enabled)) { $this->trackedevents['BILL_VALIDATE'] = 'logBILL_VALIDATE'; - } - if ($conf->facture->enabled) { $this->trackedevents['BILL_DELETE'] = 'logBILL_DELETE'; - } - if ($conf->facture->enabled) { $this->trackedevents['BILL_SENTBYMAIL'] = 'logBILL_SENTBYMAIL'; - } - if ($conf->facture->enabled) { $this->trackedevents['DOC_DOWNLOAD'] = 'BlockedLogBillDownload'; - } - if ($conf->facture->enabled) { $this->trackedevents['DOC_PREVIEW'] = 'BlockedLogBillPreview'; - } - if ($conf->facture->enabled) { $this->trackedevents['PAYMENT_CUSTOMER_CREATE'] = 'logPAYMENT_CUSTOMER_CREATE'; - } - if ($conf->facture->enabled) { $this->trackedevents['PAYMENT_CUSTOMER_DELETE'] = 'logPAYMENT_CUSTOMER_DELETE'; } /* Supplier - if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_VALIDATE']='BlockedLogSupplierBillValidate'; - if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_DELETE']='BlockedLogSupplierBillDelete'; - if ($conf->fournisseur->enabled) $this->trackedevents['BILL_SUPPLIER_SENTBYMAIL']='BlockedLogSupplierBillSentByEmail'; // Trigger key does not exists, we want just into array to list it as done - if ($conf->fournisseur->enabled) $this->trackedevents['SUPPLIER_DOC_DOWNLOAD']='BlockedLogSupplierBillDownload'; // Trigger key does not exists, we want just into array to list it as done - if ($conf->fournisseur->enabled) $this->trackedevents['SUPPLIER_DOC_PREVIEW']='BlockedLogSupplierBillPreview'; // Trigger key does not exists, we want just into array to list it as done + if (!empty($conf->fournisseur->enabled)) { + $this->trackedevents['BILL_SUPPLIER_VALIDATE']='BlockedLogSupplierBillValidate'; + $this->trackedevents['BILL_SUPPLIER_DELETE']='BlockedLogSupplierBillDelete'; + $this->trackedevents['BILL_SUPPLIER_SENTBYMAIL']='BlockedLogSupplierBillSentByEmail'; // Trigger key does not exists, we want just into array to list it as done + $this->trackedevents['SUPPLIER_DOC_DOWNLOAD']='BlockedLogSupplierBillDownload'; // Trigger key does not exists, we want just into array to list it as done + $this->trackedevents['SUPPLIER_DOC_PREVIEW']='BlockedLogSupplierBillPreview'; // Trigger key does not exists, we want just into array to list it as done - if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_CREATE']='BlockedLogSupplierBillPaymentCreate'; - if ($conf->fournisseur->enabled) $this->trackedevents['PAYMENT_SUPPLIER_DELETE']='BlockedLogsupplierBillPaymentCreate'; + $this->trackedevents['PAYMENT_SUPPLIER_CREATE']='BlockedLogSupplierBillPaymentCreate'; + $this->trackedevents['PAYMENT_SUPPLIER_DELETE']='BlockedLogsupplierBillPaymentCreate'; + } */ - if ($conf->don->enabled) { + if (!empty($conf->don->enabled)) { $this->trackedevents['DON_VALIDATE'] = 'logDON_VALIDATE'; - } - if ($conf->don->enabled) { $this->trackedevents['DON_DELETE'] = 'logDON_DELETE'; - } - //if ($conf->don->enabled) $this->trackedevents['DON_SENTBYMAIL']='logDON_SENTBYMAIL'; - - if ($conf->don->enabled) { + //$this->trackedevents['DON_SENTBYMAIL']='logDON_SENTBYMAIL'; $this->trackedevents['DONATION_PAYMENT_CREATE'] = 'logDONATION_PAYMENT_CREATE'; - } - if ($conf->don->enabled) { $this->trackedevents['DONATION_PAYMENT_DELETE'] = 'logDONATION_PAYMENT_DELETE'; } /* - if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_CREATE']='BlockedLogSalaryPaymentCreate'; - if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_MODIFY']='BlockedLogSalaryPaymentCreate'; - if ($conf->salary->enabled) $this->trackedevents['PAYMENT_SALARY_DELETE']='BlockedLogSalaryPaymentCreate'; + if (!empty($conf->salary->enabled)) { + $this->trackedevents['PAYMENT_SALARY_CREATE']='BlockedLogSalaryPaymentCreate'; + $this->trackedevents['PAYMENT_SALARY_MODIFY']='BlockedLogSalaryPaymentCreate'; + $this->trackedevents['PAYMENT_SALARY_DELETE']='BlockedLogSalaryPaymentCreate'; + } */ - if ($conf->adherent->enabled) { + if (!empty($conf->adherent->enabled)) { $this->trackedevents['MEMBER_SUBSCRIPTION_CREATE'] = 'logMEMBER_SUBSCRIPTION_CREATE'; - } - if ($conf->adherent->enabled) { $this->trackedevents['MEMBER_SUBSCRIPTION_MODIFY'] = 'logMEMBER_SUBSCRIPTION_MODIFY'; - } - if ($conf->adherent->enabled) { $this->trackedevents['MEMBER_SUBSCRIPTION_DELETE'] = 'logMEMBER_SUBSCRIPTION_DELETE'; } - if ($conf->banque->enabled) { + if (!empty($conf->banque->enabled)) { $this->trackedevents['PAYMENT_VARIOUS_CREATE'] = 'logPAYMENT_VARIOUS_CREATE'; - } - if ($conf->banque->enabled) { $this->trackedevents['PAYMENT_VARIOUS_MODIFY'] = 'logPAYMENT_VARIOUS_MODIFY'; - } - if ($conf->banque->enabled) { $this->trackedevents['PAYMENT_VARIOUS_DELETE'] = 'logPAYMENT_VARIOUS_DELETE'; } // $conf->global->BANK_ENABLE_POS_CASHCONTROL must be set to 1 by all external POS modules From d36175c523d62102999c750032629b7b05c7325b Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Fri, 27 May 2022 16:23:57 +0200 Subject: [PATCH 154/174] php V8 warning --- htdocs/core/menus/standard/auguria.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 556ee3e609a..ea6d21fe457 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -339,7 +339,7 @@ function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$t $newmenu = $menuArbo->menuLeftCharger($newmenu, $mainmenu, $leftmenu, ($user->socid ? 1 : 0), 'auguria', $tabMenu); // We update newmenu for special dynamic menus - if ($conf->banque->enabled && $user->rights->banque->lire && $mainmenu == 'bank') { // Entry for each bank account + if (!empty($conf->banque->enabled) && $user->rights->banque->lire && $mainmenu == 'bank') { // Entry for each bank account include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Required for to get Account::TYPE_CASH for example $sql = "SELECT rowid, label, courant, rappro, courant"; From c257d77dc30e4652c819d4486dfadfd93ce89b28 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Sat, 28 May 2022 09:47:21 +0200 Subject: [PATCH 155/174] php V8 warning --- htdocs/adherents/admin/member.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/admin/member.php b/htdocs/adherents/admin/member.php index ed2453ef793..bae229bc77b 100644 --- a/htdocs/adherents/admin/member.php +++ b/htdocs/adherents/admin/member.php @@ -108,7 +108,7 @@ if ($action == 'set_default') { $res3 = dolibarr_set_const($db, 'ADHERENT_CREATE_EXTERNAL_USER_LOGIN', GETPOST('ADHERENT_CREATE_EXTERNAL_USER_LOGIN', 'alpha'), 'chaine', 0, '', $conf->entity); $res4 = dolibarr_set_const($db, 'ADHERENT_BANK_USE', GETPOST('ADHERENT_BANK_USE', 'alpha'), 'chaine', 0, '', $conf->entity); // Use vat for invoice creation - if ($conf->facture->enabled) { + if (!empty($conf->facture->enabled)) { $res4 = dolibarr_set_const($db, 'ADHERENT_VAT_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_VAT_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); $res5 = dolibarr_set_const($db, 'ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', GETPOST('ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS', 'alpha'), 'chaine', 0, '', $conf->entity); if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { @@ -256,7 +256,7 @@ print '
'.$langs->trans("VATToUseForSubscriptions").''; From 0b3e32a2236f05f34c8dfa7fd6fe4a825a126f9b Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Sat, 28 May 2022 09:52:03 +0200 Subject: [PATCH 156/174] fix php v8 warning --- htdocs/contact/consumption.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index dc4b56b2763..b7fc682d2c6 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -153,16 +153,16 @@ print '
'.$langs->trans("StockMustBeEnoughForInvoice").''; @@ -408,7 +408,7 @@ if ($conf->invoice->enabled) { print "
'.$langs->trans("StockMustBeEnoughForOrder").''; @@ -422,7 +422,7 @@ if ($conf->order->enabled) { print "
'.$langs->trans("StockMustBeEnoughForShipment").''; From eba9f695c20538aa179fb3d376a99c00c92f7cb6 Mon Sep 17 00:00:00 2001 From: BENKE Charlene <1179011+defrance@users.noreply.github.com> Date: Sat, 28 May 2022 10:02:02 +0200 Subject: [PATCH 159/174] fix php 8 warning --- htdocs/admin/emailcollector_card.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index d01b160ca31..50e3faa7d51 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -1,5 +1,6 @@ + * Copyright (C) 2022 Charlene Benke * * 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 @@ -592,15 +593,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea 'recordjoinpiece'=>'AttachJoinedDocumentsToObject', 'recordevent'=>'RecordEvent'); $arrayoftypesnocondition = $arrayoftypes; - if ($conf->projet->enabled) { + if (!empty($conf->projet->enabled)) { $arrayoftypes['project'] = 'CreateLeadAndThirdParty'; } $arrayoftypesnocondition['project'] = 'CreateLeadAndThirdParty'; - if ($conf->ticket->enabled) { + if (!empty($conf->ticket->enabled)) { $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty'; } $arrayoftypesnocondition['ticket'] = 'CreateTicketAndThirdParty'; - if ($conf->recruitment->enabled) { + if (!empty($conf->recruitment->enabled)) { $arrayoftypes['candidature'] = 'CreateCandidature'; } $arrayoftypesnocondition['candidature'] = 'CreateCandidature'; From a961bb550778467d19bf9edc58f1eee88fa2cec7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 May 2022 11:31:41 +0200 Subject: [PATCH 160/174] Debug v16 --- htdocs/core/tpl/login.tpl.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index ccec4352e89..175fb080818 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -1,6 +1,6 @@ - * Copyright (C) 2011-2021 Laurent Destailleur + * Copyright (C) 2011-2022 Laurent Destailleur * * 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 @@ -18,7 +18,7 @@ // Need global variable $urllogo, $title and $titletruedolibarrversion to be defined by caller (like dol_loginfunction in security2.lib.php) // Caller can also set $morelogincontent = array(['options']=>array('js'=>..., 'table'=>...); - +// $titletruedolibarrversion must be defined if (!defined('NOBROWSERNOTIF')) { define('NOBROWSERNOTIF', 1); @@ -71,6 +71,9 @@ $php_self .= dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmlt if (!preg_match('/mainmenu=/', $php_self)) { $php_self .= (preg_match('/\?/', $php_self) ? '&' : '?').'mainmenu=home'; } +if (preg_match('/'.preg_quote('core/modules/oauth', '/').'/', $php_self)) { + $php_self = DOL_URL_ROOT.'/index.php?mainmenu=home'; +} // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second $arrayofjs = array( From dcfb0679c87698f0ed4911e84f31ff5b6970646d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 May 2022 12:24:11 +0200 Subject: [PATCH 161/174] FIX Look and field v16 for list of lot --- .../modulebuilder/template/myobject_list.php | 2 +- htdocs/product/stock/productlot_list.php | 236 ++++++++++++------ 2 files changed, 164 insertions(+), 74 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index c03302551e3..92f7f22f328 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -477,7 +477,7 @@ $arrayofmassactions = array( //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); -if ($permissiontodelete) { +if (!empty($permissiontodelete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 565b309b113..13695752ad0 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -76,7 +76,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { - $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. + $sortfield = "t.fk_product,t.batch"; // Set here default search field. By default 1st field in definition. } if (!$sortorder) { $sortorder = "ASC"; @@ -89,6 +89,10 @@ foreach ($object->fields as $key => $val) { if (GETPOST('search_'.$key, 'alpha') !== '') { $search[$key] = GETPOST('search_'.$key, 'alpha'); } + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); + $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); + } } // List of fields to search into when doing a "search in all" @@ -104,12 +108,13 @@ $arrayfields = array(); foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field if (!empty($val['visible'])) { - $visible = dol_eval($val['visible'], 1, 1, '1'); + $visible = (int) dol_eval($val['visible'], 1); $arrayfields['t.'.$key] = array( 'label'=>$val['label'], 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')), - 'position'=>$val['position'] + 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), + 'position'=>$val['position'], + 'help'=> isset($val['help']) ? $val['help'] : '' ); } } @@ -147,7 +152,8 @@ if (!$permissiontoread) accessforbidden(); */ if (GETPOST('cancel', 'alpha')) { - $action = 'list'; $massaction = ''; + $action = 'list'; + $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; @@ -167,6 +173,10 @@ if (empty($reshook)) { if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers foreach ($object->fields as $key => $val) { $search[$key] = ''; + if (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + $search[$key.'_dtstart'] = ''; + $search[$key.'_dtend'] = ''; + } } $toselect = array(); $search_array_options = array(); @@ -185,7 +195,7 @@ if (empty($reshook)) { /* - * VIEW + * View */ @@ -194,20 +204,19 @@ $form = new Form($db); $now = dol_now(); $help_url = 'EN:Module_Lot_/_Serial|FR:Module_Lot_/_Série'; - $title = $langs->trans('LotSerialList'); +$morejs = array(); +$morecss = array(); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) { - $sql .= "t.".$key.", "; -} +$sql .= $object->getFieldList('t'); // Add fields from extrafields 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.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : ''); } } // Add fields from hooks @@ -216,9 +225,13 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if ( !empty($extrafields->attributes[$object->table_element]['label']) && ($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (isset($extrafields->attributes[$object->table_element]['label']) && 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 (t.rowid = ef.fk_object)"; } +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; if ($object->ismultientitymanaged == 1) { $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; } else { @@ -237,17 +250,17 @@ foreach ($search as $key => $val) { $mode_search = 2; } if ($search[$key] != '') { - $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search)); } } else { if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t.".$columnName." >= '".$db->idate($search[$key])."'"; + $sql .= " AND t.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; } if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'"; + $sql .= " AND t.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; } } } @@ -265,21 +278,22 @@ $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters, $objec $sql .= $hookmanager->resPrint; /* If a group by is required - $sql.= " GROUP BY "; - foreach($object->fields as $key => $val) - { - $sql .= "t.".$key.", "; - } - // Add fields from extrafields - 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.', ' : ''); - } - // Add where from hooks - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook - $sql.=$hookmanager->resPrint; - $sql=preg_replace('/,\s*$/','', $sql); - */ +$sql.= " GROUP BY "; +foreach($object->fields as $key => $val) { + $sql .= "t.".$db->escape($key).", "; +} +// Add fields from extrafields +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.', ' : ''); + } +} +// Add where from hooks +$parameters=array(); +$reshook=$hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql.=$hookmanager->resPrint; +$sql=preg_replace('/,\s*$/','', $sql); +*/ // Count total nb of records $nbtotalofrecords = ''; @@ -290,14 +304,23 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { */ /* The slow method does not consume memory on mysql (not tested on pgsql) */ /*$resql = $db->query($sql, 0, 'auto', 1); - while ($db->fetch_object($resql)) { - $nbtotalofrecords++; - }*/ + while ($db->fetch_object($resql)) { + if (empty($nbtotalofrecords)) { + $nbtotalofrecords = 1; // We can't make +1 because init value is '' + } else { + $nbtotalofrecords++; + } + }*/ /* The fast and low memory method to get and count full list converts the sql into a sql count */ - $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); $resql = $db->query($sqlforcount); - $objforcount = $db->fetch_object($resql); - $nbtotalofrecords = $objforcount->nbtotalofrecords; + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; @@ -332,11 +355,14 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $ // Output page // -------------------------------------------------------------------- -llxHeader('', $title, $help_url); +llxHeader('', $title, $help_url, '', 0, 0, $morejs, $morecss, '', 'bodyforlist'); $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { $param .= '&contextpage='.urlencode($contextpage); } @@ -346,9 +372,11 @@ if ($limit > 0 && $limit != $conf->liste_limit) { foreach ($search as $key => $val) { if (is_array($search[$key]) && count($search[$key])) { foreach ($search[$key] as $skey) { - $param .= '&search_'.$key.'[]='.urlencode($skey); + if ($skey != '') { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } } - } else { + } elseif ($search[$key] != '') { $param .= '&search_'.$key.'='.urlencode($search[$key]); } } @@ -357,6 +385,10 @@ if ($optioncss != '') { } // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +// Add $param from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListSearchParam', $parameters, $object); // Note that $action and $object may have been modified by hook +$param .= $hookmanager->resPrint; // List of mass actions available $arrayofmassactions = array( @@ -382,8 +414,9 @@ print ''; print ''; print ''; -//print ''; +print ''; print ''; +print ''; $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/product/stock/productlot_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); @@ -397,10 +430,13 @@ $trackid = 'lot'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { + $setupstring = ''; foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); + $setupstring .= $key."=".$val.";"; } - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; + print ''."\n"; + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } $moreforfilter = ''; @@ -423,7 +459,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table @@ -433,7 +469,15 @@ print ''; +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} foreach ($object->fields as $key => $val) { + $searchkey = empty($search[$key]) ? '' : $search[$key]; $cssforfield = (empty($val['css']) ? '' : $val['css']); if ($key == 'status') { $cssforfield .= ($cssforfield ? ' ' : '').'center'; @@ -441,17 +485,28 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; } @@ -463,46 +518,61 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; +/*if (!empty($arrayfields['anotherfield']['checked'])) { + print ''; + }*/ // Action column -print ''; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print ''."\n"; +$totalarray = array(); +$totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['css']) ? '' : $val['css']); + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } + $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label if (!empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + $totalarray['nbfield']++; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} +$totalarray['nbfield']++; print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { +if (isset($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) { $needToFetchEachLine++; // There is at least one compute field that use $object @@ -514,9 +584,10 @@ if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_a // Loop on record // -------------------------------------------------------------------- $i = 0; -$totalarray = array(); +$savnbfield = $totalarray['nbfield']; $totalarray['nbfield'] = 0; -while ($i < ($limit ? min($num, $limit) : $num)) { +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); if (empty($obj)) { break; // Should not happen @@ -526,9 +597,22 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $object->setVarsFromFetchObj($obj); // Show here line of result - print ''; + $j = 0; + print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['css']) ? '' : $val['css']); + $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif ($key == 'status') { @@ -541,17 +625,21 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) { + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status')) && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; + print ''; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'rowid') { - print $object->id; + print $object->showOutputField($val, $key, $object->id, ''); } else { if ($key == 'batch') { print $object->getNomUrl(1); @@ -584,15 +672,17 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column - print ''; } - print ''; if (!$i) { $totalarray['nbfield']++; } @@ -613,14 +703,14 @@ if ($num == 0) { $colspan++; } } - print ''; + print ''; } $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { - print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - } elseif (strpos($val['type'], 'integer:') === 0) { - print $object->showInputField($val, $key, !empty($search[$key])?$search[$key]:0, '', '', 'search_', 'maxwidth150', 1); - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { - print ''; + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], (isset($search[$key]) ? $search[$key] : ''), $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { + print $object->showInputField($val, $key, (isset($search[$key]) ? $search[$key] : ''), '', '', 'search_', $cssforfield.' maxwidth250', 1); + } elseif (preg_match('/^(date|timestamp|datetime)/', $val['type'])) { + print '
'; + print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + } elseif ($key == 'lang') { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; + $formadmin = new FormAdmin($db); + print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth150 maxwidth200', 2); + } else { + print ''; } print '
'; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { // 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($object->id, $arrayofselected)) { + $selected = 1; + } + 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 - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; + if (empty($conf->global->MAIN_CHECKBOX_LEFT_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 + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print '
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'."\n"; From 59fcd9de13a304e8c56f2ac0f402d9cb3afcf291 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 May 2022 12:36:03 +0200 Subject: [PATCH 162/174] Fix trans --- htdocs/product/popuprop.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index b8118ba4884..cfa2f8fc2f6 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -181,7 +181,7 @@ $arrayofmode = array( 'commande' => 'Orders', 'facture' => 'Facture' ); -$title .= ' '.$form->selectarray('mode', $arrayofmode, $mode, 1); +$title .= ' '.$form->selectarray('mode', $arrayofmode, $mode, 1, 0, 0, '', 1); $title .= ' '; From 7ddf4ef315dafb578aa0763e9915889f99f1b1e1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 May 2022 12:50:25 +0200 Subject: [PATCH 163/174] Fix look and feel v16 --- htdocs/product/class/product.class.php | 4 +-- htdocs/product/popuprop.php | 40 +++++++++++++++----------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 7df8e437272..9358eb9c60d 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4896,14 +4896,14 @@ class Product extends CommonObject } if (!empty($conf->accounting->enabled)) { - if ($this->status) { + if ($this->status && isset($this->accountancy_code_sell)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; $label .= '
'; $label .= '
'.$langs->trans('ProductAccountancySellCode').': '.length_accountg($this->accountancy_code_sell); $label .= '
'.$langs->trans('ProductAccountancySellIntraCode').': '.length_accountg($this->accountancy_code_sell_intra); $label .= '
'.$langs->trans('ProductAccountancySellExportCode').': '.length_accountg($this->accountancy_code_sell_export); } - if ($this->status_buy) { + if ($this->status_buy && isset($this->accountancy_code_buy)) { include_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; if (empty($this->status)) { $label .= '
'; diff --git a/htdocs/product/popuprop.php b/htdocs/product/popuprop.php index cfa2f8fc2f6..b921f16d02e 100644 --- a/htdocs/product/popuprop.php +++ b/htdocs/product/popuprop.php @@ -68,6 +68,7 @@ restrictedArea($user, 'produit|service', 0, 'product&product', '', ''); */ $form = new Form($db); +$tmpproduct = new Product($db); $helpurl = ''; if ($type == '0') { @@ -124,7 +125,7 @@ $infoprod = array(); // Add lines for object -$sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type as type, SUM(pd.qty) as c"; +$sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type as type, p.tobuy, p.tosell, p.tobatch, p.barcode, SUM(pd.qty) as c"; $textforqty = 'Qty'; if ($mode == 'facture') { $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as pd"; @@ -141,7 +142,7 @@ $sql .= " AND p.rowid = pd.fk_product"; if ($type !== '') { $sql .= " AND fk_product_type = ".((int) $type); } -$sql .= " GROUP BY p.rowid, p.label, p.ref, p.fk_product_type"; +$sql .= " GROUP BY p.rowid, p.label, p.ref, p.fk_product_type, p.tobuy, p.tosell, p.tobatch, p.barcode"; $num = 0; $totalnboflines = 0; @@ -163,7 +164,7 @@ if (!empty($mode) && $mode != '-1') { while ($i < $num) { $objp = $db->fetch_object($resql); - $infoprod[$objp->rowid] = array('type'=>$objp->type, 'ref'=>$objp->ref, 'label'=>$objp->label); + $infoprod[$objp->rowid] = array('type'=>$objp->type, 'ref'=>$objp->ref, 'label'=>$objp->label, 'tobuy'=>$objp->tobuy, 'tosell'=>$objp->tobuy, 'tobatch'=>$objp->tobatch, 'barcode'=>$objp->barcode); $infoprod[$objp->rowid]['nbline'] = $objp->c; $i++; @@ -228,23 +229,28 @@ if ($mode && $mode != '-1') { } } + $tmpproduct->ref = $vals['ref']; + $tmpproduct->label = $vals['label']; + $tmpproduct->type = $vals['type']; + $tmpproduct->status = $vals['tosell']; + $tmpproduct->status_buy = $vals['tobuy']; + $tmpproduct->status_batch = $vals['tobatch']; + $tmpproduct->barcode = $vals['barcode']; + print "
'; - if ($vals['type'] == 1) { - print img_object($langs->trans("ShowService"), "service"); - } else { - print img_object($langs->trans("ShowProduct"), "product"); - } - print " "; - print $vals['ref'].''; - if ($vals['type'] == 1) { - print $langs->trans("Service"); - } else { - print $langs->trans("Product"); - } + print $tmpproduct->getNomUrl(1); print ''.$vals['label'].''; + $s = ''; + if ($vals['type'] == 1) { + $s .= img_picto($langs->trans("Service"), 'service', 'class="paddingleftonly paddingrightonly colorgrey"'); + } else { + $s .= img_picto($langs->trans("Product"), 'product', 'class="paddingleftonly paddingrightonly colorgrey"'); + } + print $s; + print ''.dol_escape_htmltag($vals['label']).''.$vals['nbline'].'
'; - - // Fields title search - print ''; - print ''; - print ''; - if (!empty($conf->service->enabled) && $type == 1) { - print ''; - } - print ''; - print ''; - if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print ''; - } - if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print ''; - } - // Physical stock - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - //Line for column titles - print ""; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", '', $param, "", $sortfield, $sortorder); - print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", '', $param, "", $sortfield, $sortorder); - if (!empty($conf->service->enabled) && $type == 1) { - print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", '', $param, "", $sortfield, $sortorder, 'center '); - } - print_liste_field_titre("Warehouse", $_SERVER["PHP_SELF"], "e.ref", '', $param, "", $sortfield, $sortorder); - //print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'',$sortfield,$sortorder, 'right ); - print_liste_field_titre("Batch", $_SERVER["PHP_SELF"], "pb.batch", '', $param, "", $sortfield, $sortorder, 'center '); - if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print_liste_field_titre("SellByDate", $_SERVER["PHP_SELF"], "pb.sellby", '', $param, "", $sortfield, $sortorder, 'center '); - } - if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print_liste_field_titre("EatByDate", $_SERVER["PHP_SELF"], "pb.eatby", '', $param, "", $sortfield, $sortorder, 'center '); - } - print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", '', $param, "", $sortfield, $sortorder, 'right '); - // TODO Add info of running suppliers/customers orders - //print_liste_field_titre("TheoreticalStock",$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'',$sortfield,$sortorder, 'right '); - print_liste_field_titre(''); - print_liste_field_titre("ProductStatusOnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre("ProductStatusOnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'right '); - print_liste_field_titre(''); - print "\n"; - - $product_static = new Product($db); - $product_lot_static = new Productlot($db); - $warehousetmp = new Entrepot($db); - - while ($i < min($num, $limit)) { - $objp = $db->fetch_object($resql); - - // Multilangs - if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active - $sql = "SELECT label"; - $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; - $sql .= " WHERE fk_product = ".((int) $objp->rowid); - $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'"; - $sql .= " LIMIT 1"; - - $result = $db->query($sql); - if ($result) { - $objtp = $db->fetch_object($result); - if (!empty($objtp->label)) { - $objp->label = $objtp->label; - } - } - } - - $product_static->ref = $objp->ref; - $product_static->id = $objp->rowid; - $product_static->label = $objp->label; - $product_static->type = $objp->fk_product_type; - $product_static->entity = $objp->entity; - $product_static->status = $objp->tosell; - $product_static->status_buy = $objp->tobuy; - $product_static->status_batch = $objp->tobatch; - - $product_lot_static->batch = $objp->batch; - $product_lot_static->product_id = $objp->rowid; - $product_lot_static->id = $objp->lotid; - $product_lot_static->eatby = $objp->eatby; - $product_lot_static->sellby = $objp->sellby; - - - $warehousetmp->id = $objp->fk_entrepot; - $warehousetmp->ref = $objp->warehouse_ref; - $warehousetmp->label = $objp->warehouse_ref; - $warehousetmp->fk_parent = $objp->warehouse_parent; - - print ''; - - // Ref - print ''; - - // Label - print ''; - - if (!empty($conf->service->enabled) && $type == 1) { - print ''; - } - //print ''; - //print ''; - //print ''; - - // Warehouse - print ''; - - // Lot - print ''; - - if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print ''; - } - - if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print ''; - } - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print "\n"; - $i++; - } - - print "
'; - print ''; - print ''; - print ''; - print ''; - print ' '; - print '  '; - print ''; - print '   '; - $searchpicto = $form->showFilterAndCheckAddButtons(0); - print $searchpicto; - print '
'; - print $product_static->getNomUrl(1, '', 16); - //if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow")); - print ''.$objp->label.''; - if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) { - print $regs[1].' '.$langs->trans("DurationYear"); - } elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) { - print $regs[1].' '.$langs->trans("DurationMonth"); - } elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) { - print $regs[1].' '.$langs->trans("DurationDay"); - } else { - print $objp->duration; - } - print ''.$objp->stock_theorique.''.$objp->seuil_stock_alerte.''.$objp->desiredstock.''; - if ($objp->fk_entrepot > 0) { - print $warehousetmp->getNomUrl(1); - } - print ''; - if ($product_lot_static->batch) { - print $product_lot_static->getNomUrl(1); - } - print ''.dol_print_date($db->jdate($objp->sellby), 'day').''.dol_print_date($db->jdate($objp->eatby), 'day').''; - //if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; - print $objp->stock_physique; - print ''; - print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"'); - print ''.$langs->trans("Movements").''; - print ''.$product_static->LibStatut($objp->statut, 5, 0).''.$product_static->LibStatut($objp->tobuy, 5, 1).'
"; - print '
'; - print ''; - - $db->free($resql); -} else { +if (!$resql) { dol_print_error($db); + exit; } +$num = $db->num_rows($resql); + +$i = 0; + +if ($num == 1 && GETPOST('autojumpifoneonly') && ($sall or $snom or $sref)) { + $objp = $db->fetch_object($resql); + header("Location: card.php?id=$objp->rowid"); + exit; +} + +if (isset($type)) { + if ($type == 1) { + $texte = $langs->trans("Services"); + } else { + $texte = $langs->trans("Products"); + } +} else { + $texte = $langs->trans("ProductsAndServices"); +} +$texte .= ' ('.$langs->trans("StocksByLotSerial").')'; + +$param = ''; +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if ($sall) { + $param .= "&sall=".urlencode($sall); +} +if ($tosell) { + $param .= "&tosell=".urlencode($tosell); +} +if ($tobuy) { + $param .= "&tobuy=".urlencode($tobuy); +} +if ($type != '') { + $param .= "&type=".urlencode($type); +} +if ($fourn_id) { + $param .= "&fourn_id=".urlencode($fourn_id); +} +if ($snom) { + $param .= "&snom=".urlencode($snom); +} +if ($sref) { + $param .= "&sref=".urlencode($sref); +} +if ($search_batch) { + $param .= "&search_batch=".urlencode($search_batch); +} +if ($sbarcode) { + $param .= "&sbarcode=".urlencode($sbarcode); +} +if ($search_warehouse) { + $param .= "&search_warehouse=".urlencode($search_warehouse); +} +if ($toolowstock) { + $param .= "&toolowstock=".urlencode($toolowstock); +} +if ($search_sale) { + $param .= "&search_sale=".urlencode($search_sale); +} +if (!empty($search_categ) && $search_categ != '-1') { + $param .= "&search_categ=".urlencode($search_categ); +} +if ($search_stock_physique) { + $param .= '&search_stock_physique=' . urlencode($search_stock_physique); +} +/*if ($eatby) $param.="&eatby=".$eatby; +if ($sellby) $param.="&sellby=".$sellby;*/ + +llxHeader("", $title, $helpurl, $texte); + +print '
'; +print ''; +print ''; +print ''; +print ''; + +print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'product', 0, '', '', $limit, 0, 0, 1); + + +if ($search_categ > 0) { + print "
"; + $c = new Categorie($db); + $c->fetch($search_categ); + $ways = $c->print_all_ways(' > ', 'product/reassortlot.php'); + print " > ".$ways[0]."
\n"; + print "

"; +} + +// Filter on categories +$moreforfilter = ''; +if (!empty($conf->categorie->enabled)) { + $moreforfilter .= '
'; + $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); + $moreforfilter .= $htmlother->select_categories(Categorie::TYPE_PRODUCT, $search_categ, 'search_categ', 1); + $moreforfilter .= '
'; +} +//$moreforfilter.=$langs->trans("StockTooLow").' '; + +if (!empty($moreforfilter)) { + print '
'; + print $moreforfilter; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + print '
'; +} + + +print '
'; +print ''; + +// Fields title search +// -------------------------------------------------------------------- +print ''; +print ''; +print ''; +if (!empty($conf->service->enabled) && $type == 1) { + print ''; +} +print ''; +print ''; +if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; +} +if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; +} +// Physical stock +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +//Line for column titles +print ""; +print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", '', $param, "", $sortfield, $sortorder); +print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", '', $param, "", $sortfield, $sortorder); +if (!empty($conf->service->enabled) && $type == 1) { + print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration", '', $param, "", $sortfield, $sortorder, 'center '); +} +print_liste_field_titre("Warehouse", $_SERVER["PHP_SELF"], "e.ref", '', $param, "", $sortfield, $sortorder); +//print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'',$sortfield,$sortorder, 'right ); +print_liste_field_titre("Batch", $_SERVER["PHP_SELF"], "pb.batch", '', $param, "", $sortfield, $sortorder, 'center '); +if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print_liste_field_titre("SellByDate", $_SERVER["PHP_SELF"], "pl.sellby", '', $param, "", $sortfield, $sortorder, 'center '); +} +if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print_liste_field_titre("EatByDate", $_SERVER["PHP_SELF"], "pl.eatby", '', $param, "", $sortfield, $sortorder, 'center '); +} +print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", '', $param, "", $sortfield, $sortorder, 'right '); +// TODO Add info of running suppliers/customers orders +//print_liste_field_titre("TheoreticalStock",$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'',$sortfield,$sortorder, 'right '); +print_liste_field_titre(''); +print_liste_field_titre("ProductStatusOnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'right '); +print_liste_field_titre("ProductStatusOnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'right '); +print_liste_field_titre(''); +print "\n"; + +$product_static = new Product($db); +$product_lot_static = new Productlot($db); +$warehousetmp = new Entrepot($db); + +// Loop on record +// -------------------------------------------------------------------- +$i = 0; +$savnbfield = $totalarray['nbfield']; +$totalarray['nbfield'] = 0; +$imaxinloop = ($limit ? min($num, $limit) : $num); +while ($i < $imaxinloop) { + $objp = $db->fetch_object($resql); + + // Multilangs + if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active + // TODO Use a cache + $sql = "SELECT label"; + $sql .= " FROM ".MAIN_DB_PREFIX."product_lang"; + $sql .= " WHERE fk_product = ".((int) $objp->rowid); + $sql .= " AND lang = '".$db->escape($langs->getDefaultLang())."'"; + $sql .= " LIMIT 1"; + + $result = $db->query($sql); + if ($result) { + $objtp = $db->fetch_object($result); + if (!empty($objtp->label)) { + $objp->label = $objtp->label; + } + } + } + + $product_static->ref = $objp->ref; + $product_static->id = $objp->rowid; + $product_static->label = $objp->label; + $product_static->type = $objp->fk_product_type; + $product_static->entity = $objp->entity; + $product_static->status = $objp->tosell; + $product_static->status_buy = $objp->tobuy; + $product_static->status_batch = $objp->tobatch; + + $product_lot_static->batch = $objp->batch; + $product_lot_static->product_id = $objp->rowid; + $product_lot_static->id = $objp->lotid; + $product_lot_static->eatby = $objp->eatby; + $product_lot_static->sellby = $objp->sellby; + + + $warehousetmp->id = $objp->fk_entrepot; + $warehousetmp->ref = $objp->warehouse_ref; + $warehousetmp->label = $objp->warehouse_ref; + $warehousetmp->fk_parent = $objp->warehouse_parent; + + print ''; + + // Ref + print ''; + + // Label + print ''; + + if (!empty($conf->service->enabled) && $type == 1) { + print ''; + } + //print ''; + //print ''; + //print ''; + + // Warehouse + print ''; + + // Lot + print ''; + + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } + + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print "\n"; + $i++; +} + +$db->free($resql); + +print '
'; +print ''; +print ''; +print ''; +print ''; + print ' '; + print '  '; +print ''; +print '   '; +$searchpicto = $form->showFilterAndCheckAddButtons(0); +print $searchpicto; +print '
'; + print $product_static->getNomUrl(1, '', 16); + //if ($objp->stock_theorique < $objp->seuil_stock_alerte) print ' '.img_warning($langs->trans("StockTooLow")); + print ''.$objp->label.''; + if (preg_match('/([0-9]+)y/i', $objp->duration, $regs)) { + print $regs[1].' '.$langs->trans("DurationYear"); + } elseif (preg_match('/([0-9]+)m/i', $objp->duration, $regs)) { + print $regs[1].' '.$langs->trans("DurationMonth"); + } elseif (preg_match('/([0-9]+)d/i', $objp->duration, $regs)) { + print $regs[1].' '.$langs->trans("DurationDay"); + } else { + print $objp->duration; + } + print ''.$objp->stock_theorique.''.$objp->seuil_stock_alerte.''.$objp->desiredstock.''; + if ($objp->fk_entrepot > 0) { + print $warehousetmp->getNomUrl(1); + } + print ''; + if ($product_lot_static->batch) { + print $product_lot_static->getNomUrl(1); + } + print ''.dol_print_date($db->jdate($objp->sellby), 'day').''.dol_print_date($db->jdate($objp->eatby), 'day').''; + //if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; + print $objp->stock_physique; + print ''; + print img_picto($langs->trans("StockMovement"), 'movement', 'class="pictofixedwidth"'); + print ''.$langs->trans("Movements").''; + print ''.$product_static->LibStatut($objp->statut, 5, 0).''.$product_static->LibStatut($objp->tobuy, 5, 1).'
'."\n"; +print '
'."\n"; + +print '
'."\n"; + + // End of page llxFooter(); $db->close(); From f6ad688dddbcb9336ec7366d89584f6f3f7d3554 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 May 2022 20:42:29 +0200 Subject: [PATCH 165/174] FIX module for emailing target selection must use a condition on module --- htdocs/comm/mailing/cibles.php | 10 ++++++---- .../core/modules/mailings/advthirdparties.modules.php | 2 ++ htdocs/core/modules/mailings/contacts1.modules.php | 2 ++ htdocs/core/modules/mailings/fraise.modules.php | 2 ++ htdocs/core/modules/mailings/modules_mailings.php | 5 +++++ htdocs/core/modules/mailings/partnership.modules.php | 2 ++ htdocs/core/modules/mailings/thirdparties.modules.php | 2 ++ .../mailings/thirdparties_services_expired.modules.php | 2 ++ .../mailings/mailinglist_mymodule_myobject.modules.php | 3 ++- 9 files changed, 25 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 9069b63179f..dd8ba5902ce 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -135,7 +135,7 @@ if (GETPOST('exportcsv', 'int')) { $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,"; $sql .= " mc.source_id, mc.source_type, mc.error_text"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; - $sql .= " WHERE mc.fk_mailing=".((int) $object->id); + $sql .= " WHERE mc.fk_mailing = ".((int) $object->id); $sql .= $db->order($sortfield, $sortorder); $resql = $db->query($sql); @@ -365,17 +365,19 @@ if ($object->fetch($id) >= 0) { $obj = new $classname($db); + // Check if qualified + $qualified = (is_null($obj->enabled) ? 1 : dol_eval($obj->enabled, 1)); + // Check dependencies - $qualified = (isset($obj->enabled) ? $obj->enabled : 1); foreach ($obj->require_module as $key) { - if (!$conf->$key->enabled || (!$user->admin && $obj->require_admin)) { + if (empty($conf->$key->enabled) || (empty($user->admin) && $obj->require_admin)) { $qualified = 0; //print "Les prerequis d'activation du module mailing ne sont pas respectes. Il ne sera pas actif"; break; } } - // Si le module mailing est qualifie + // If module is qualified if ($qualified) { $var = !$var; diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index 538e5389727..8c5491918dd 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -42,6 +42,8 @@ class mailing_advthirdparties extends MailingTargets */ public $db; + public $enabled = '$conf->societe->enabled'; + /** * Constructor diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 69b48fd6e32..04bc4131f69 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -38,6 +38,8 @@ class mailing_contacts1 extends MailingTargets public $require_module = array("societe"); // Module mailing actif si modules require_module actifs public $require_admin = 0; // Module mailing actif pour user admin ou non + public $enabled = '$conf->societe->enabled'; + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index aa7c218417b..b5b4f249107 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -41,6 +41,8 @@ class mailing_fraise extends MailingTargets public $require_module = array('adherent'); + public $enabled = '$conf->adherent->enabled'; + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 9df8d44daf1..dae8d1a12bf 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -36,6 +36,11 @@ class MailingTargets // This can't be abstract as it is used for some method */ public $db; + /** + * @var string Condition to be enabled + */ + public $enabled; + /** * @var string Error code (or message) */ diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php index b41a5e04c85..bb8e00a179f 100644 --- a/htdocs/core/modules/mailings/partnership.modules.php +++ b/htdocs/core/modules/mailings/partnership.modules.php @@ -41,6 +41,8 @@ class mailing_partnership extends MailingTargets */ public $db; + public $enabled = '$conf->partnership->enabled'; + /** * Constructor diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index a18103b40f9..afd8a05db02 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -31,6 +31,8 @@ class mailing_thirdparties extends MailingTargets public $require_module = array("societe"); // This module allows to select by categories must be also enabled if category module is not activated + public $enabled = '$conf->societe->enabled'; + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 09f4cf76ae6..9b417ecd95f 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -29,6 +29,8 @@ class mailing_thirdparties_services_expired extends MailingTargets public $require_module = array('contrat'); + public $enabled = '$conf->societe->enabled'; + /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php index b50f4acf741..290048785fd 100644 --- a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php @@ -24,7 +24,8 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets // CHANGE THIS: Set to 1 if selector is available for admin users only public $require_admin = 0; - public $enabled = 0; + public $enabled = '$conf->mymodule->enabled'; + public $require_module = array(); /** From 23eb0b3264981b3a7cb581afb7ffea37bce53354 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 28 May 2022 21:07:52 +0200 Subject: [PATCH 166/174] Clean code --- htdocs/core/class/html.form.class.php | 28 +++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 95ebe740f24..143d11c41f1 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -867,17 +867,17 @@ class Form /** * Return combo list of activated countries, into language of user * - * @param string $selected Id or Code or Label of preselected country - * @param string $htmlname Name of html select object - * @param string $htmloption More html options on select object - * @param integer $maxlength Max length for labels (0=no limit) - * @param string $morecss More css class - * @param string $usecodeaskey ''=Use id as key (default), 'code3'=Use code on 3 alpha as key, 'code2"=Use code on 2 alpha as key - * @param int $showempty Show empty choice - * @param int $disablefavorites 1=Disable favorites, - * @param int $addspecialentries 1=Add dedicated entries for group of countries (like 'European Economic Community', ...) - * @param array $exclude_country_code Array of country code (iso2) to exclude - * @param int $hideflags Hide flags + * @param string $selected Id or Code or Label of preselected country + * @param string $htmlname Name of html select object + * @param string $htmloption More html options on select object + * @param integer $maxlength Max length for labels (0=no limit) + * @param string $morecss More css class + * @param string $usecodeaskey ''=Use id as key (default), 'code3'=Use code on 3 alpha as key, 'code2"=Use code on 2 alpha as key + * @param int|string $showempty Show empty choice + * @param int $disablefavorites 1=Disable favorites, + * @param int $addspecialentries 1=Add dedicated entries for group of countries (like 'European Economic Community', ...) + * @param array $exclude_country_code Array of country code (iso2) to exclude + * @param int $hideflags Hide flags * @return string HTML string with select */ public function select_country($selected = '', $htmlname = 'country_id', $htmloption = '', $maxlength = 0, $morecss = 'minwidth300', $usecodeaskey = '', $showempty = 1, $disablefavorites = 0, $addspecialentries = 0, $exclude_country_code = array(), $hideflags = 0) @@ -926,7 +926,11 @@ class Form } if ($showempty) { - $out .= ''."\n"; + if (is_numeric($showempty)) { + $out .= ''."\n"; + } else { + $out .= ''."\n"; + } } if ($addspecialentries) { // Add dedicated entries for groups of countries From 61b69ca8350223aab3585d7087b7d6ae3bb016e9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 May 2022 09:37:03 +0200 Subject: [PATCH 167/174] FIX repeating error "token expired" --- htdocs/core/tpl/login.tpl.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 175fb080818..5965132d68c 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -74,6 +74,9 @@ if (!preg_match('/mainmenu=/', $php_self)) { if (preg_match('/'.preg_quote('core/modules/oauth', '/').'/', $php_self)) { $php_self = DOL_URL_ROOT.'/index.php?mainmenu=home'; } +$php_self = preg_replace('/(\?|&|&)action=[^&]+/', '\1', $php_self); +$php_self = preg_replace('/(\?|&|&)massaction=[^&]+/', '\1', $php_self); +$php_self = preg_replace('/(\?|&|&)token=[^&]+/', '\1', $php_self); // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second $arrayofjs = array( From 480452e2915c58ac76bba83bad36d76b201ef749 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 May 2022 09:58:36 +0200 Subject: [PATCH 168/174] FIX missing filters --- htdocs/comm/mailing/cibles.php | 2 +- .../mailings/advthirdparties.modules.php | 7 +- .../modules/mailings/contacts1.modules.php | 4 +- .../core/modules/mailings/example.modules.php | 4 +- .../core/modules/mailings/fraise.modules.php | 7 +- .../modules/mailings/modules_mailings.php | 4 +- .../modules/mailings/partnership.modules.php | 7 +- .../core/modules/mailings/pomme.modules.php | 7 +- .../modules/mailings/thirdparties.modules.php | 7 +- .../thirdparties_services_expired.modules.php | 4 +- .../modules/mailings/xinputfile.modules.php | 4 +- .../modules/mailings/xinputuser.modules.php | 4 +- htdocs/product/reassortlot.php | 121 ++++++++++++++++-- htdocs/product/stock/productlot_list.php | 14 +- 14 files changed, 146 insertions(+), 50 deletions(-) diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index dd8ba5902ce..95639a25997 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -404,7 +404,7 @@ if ($object->fetch($id) >= 0) { } print '
'; - if ($nbofrecipient >= 0) { + if ($nbofrecipient === '' || $nbofrecipient >= 0) { print $nbofrecipient; } else { print $langs->trans("Error").' '.img_error($obj->error); diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index 8c5491918dd..688db8b8e7f 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -200,8 +200,8 @@ class mailing_advthirdparties extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Not use here - * @return int Nb of recipients + * @param string $sql Not use here + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { @@ -212,8 +212,7 @@ class mailing_advthirdparties extends MailingTargets $sql .= " WHERE s.email != ''"; $sql .= " AND s.entity IN (".getEntity('societe').")"; - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients + // La requete doit retourner un champ "nb" pour etre comprise par parent::getNbOfRecipients return parent::getNbOfRecipients($sql); } diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 04bc4131f69..e3e349d2a17 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -94,8 +94,8 @@ class mailing_contacts1 extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Requete sql de comptage - * @return int + * @param string $sql Requete sql de comptage + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { diff --git a/htdocs/core/modules/mailings/example.modules.php b/htdocs/core/modules/mailings/example.modules.php index bd553e1fd5d..739ab773196 100644 --- a/htdocs/core/modules/mailings/example.modules.php +++ b/htdocs/core/modules/mailings/example.modules.php @@ -111,8 +111,8 @@ class mailing_example extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Requete sql de comptage - * @return int|string Number of recipient or '?' + * @param string $sql Requete sql de comptage + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index b5b4f249107..992539cc303 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -93,8 +93,8 @@ class mailing_fraise extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Requete sql de comptage - * @return int Nb of recipients + * @param string $sql Requete sql de comptage + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { @@ -102,8 +102,7 @@ class mailing_fraise extends MailingTargets $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql .= " WHERE (a.email IS NOT NULL AND a.email != '') AND a.entity IN (".getEntity('member').")"; - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients + // La requete doit retourner un champ "nb" pour etre comprise par parent::getNbOfRecipients return parent::getNbOfRecipients($sql); } diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index dae8d1a12bf..2064613d1e9 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -99,8 +99,8 @@ class MailingTargets // This can't be abstract as it is used for some method /** * Retourne nombre de destinataires * - * @param string $sql Sql request to count - * @return int Nb of recipient, or <0 if error + * @param string $sql Sql request to count + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql) { diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php index bb8e00a179f..7813d93f54d 100644 --- a/htdocs/core/modules/mailings/partnership.modules.php +++ b/htdocs/core/modules/mailings/partnership.modules.php @@ -166,8 +166,8 @@ class mailing_partnership extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Requete sql de comptage - * @return int Nb of recipients + * @param string $sql Requete sql de comptage + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { @@ -187,8 +187,7 @@ class mailing_partnership extends MailingTargets //print $sql; - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients + // La requete doit retourner un champ "nb" pour etre comprise par parent::getNbOfRecipients return parent::getNbOfRecipients($sql); } diff --git a/htdocs/core/modules/mailings/pomme.modules.php b/htdocs/core/modules/mailings/pomme.modules.php index 56d62449bcf..7fdcdeb0c60 100644 --- a/htdocs/core/modules/mailings/pomme.modules.php +++ b/htdocs/core/modules/mailings/pomme.modules.php @@ -89,8 +89,8 @@ class mailing_pomme extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql SQL request to use to count - * @return int Number of recipients + * @param string $sql SQL request to use to count + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { @@ -101,8 +101,7 @@ class mailing_pomme extends MailingTargets $sql .= " WHERE u.email != ''"; // u.email IS NOT NULL est implicite dans ce test $sql .= " AND u.entity IN (0,".$conf->entity.")"; - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients + // La requete doit retourner un champ "nb" pour etre comprise par parent::getNbOfRecipients return parent::getNbOfRecipients($sql); } diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index afd8a05db02..073d45439eb 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -211,8 +211,8 @@ class mailing_thirdparties extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Requete sql de comptage - * @return int Nb of recipients + * @param string $sql Requete sql de comptage + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { @@ -223,8 +223,7 @@ class mailing_thirdparties extends MailingTargets $sql .= " WHERE s.email <> ''"; $sql .= " AND s.entity IN (".getEntity('societe').")"; - // La requete doit retourner un champ "nb" pour etre comprise - // par parent::getNbOfRecipients + // La requete doit retourner un champ "nb" pour etre comprise par parent::getNbOfRecipients return parent::getNbOfRecipients($sql); } diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 9b417ecd95f..b5dec9cbbe0 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -184,8 +184,8 @@ class mailing_thirdparties_services_expired extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql SQL request to use to count - * @return int Number of recipients + * @param string $sql SQL request to use to count + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { diff --git a/htdocs/core/modules/mailings/xinputfile.modules.php b/htdocs/core/modules/mailings/xinputfile.modules.php index 3ece88d4c1d..77044ddb29e 100644 --- a/htdocs/core/modules/mailings/xinputfile.modules.php +++ b/htdocs/core/modules/mailings/xinputfile.modules.php @@ -77,8 +77,8 @@ class mailing_xinputfile extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Sql request to count - * @return string '' means NA + * @param string $sql Sql request to count + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { diff --git a/htdocs/core/modules/mailings/xinputuser.modules.php b/htdocs/core/modules/mailings/xinputuser.modules.php index b2874b43ca0..117a5722c3c 100644 --- a/htdocs/core/modules/mailings/xinputuser.modules.php +++ b/htdocs/core/modules/mailings/xinputuser.modules.php @@ -77,8 +77,8 @@ class mailing_xinputuser extends MailingTargets * For example if this selector is used to extract 500 different * emails from a text file, this function must return 500. * - * @param string $sql Sql request to count - * @return string '' means NA + * @param string $sql Sql request to count + * @return int|string Nb of recipient, or <0 if error, or '' if NA */ public function getNbOfRecipients($sql = '') { diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index 031ef60ff6e..690d3f3f261 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -96,6 +96,7 @@ if (!$sortorder) { $sortorder = "ASC"; } + // Initialize array of search criterias $search = array(); foreach ($object->fields as $key => $val) { @@ -107,6 +108,12 @@ foreach ($object->fields as $key => $val) { $search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); } } +$key = 'sellby'; +$search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); +$search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); +$key = 'eatby'; +$search[$key.'_dtstart'] = dol_mktime(0, 0, 0, GETPOST('search_'.$key.'_dtstartmonth', 'int'), GETPOST('search_'.$key.'_dtstartday', 'int'), GETPOST('search_'.$key.'_dtstartyear', 'int')); +$search[$key.'_dtend'] = dol_mktime(23, 59, 59, GETPOST('search_'.$key.'_dtendmonth', 'int'), GETPOST('search_'.$key.'_dtendday', 'int'), GETPOST('search_'.$key.'_dtendyear', 'int')); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $canvas = GETPOST("canvas"); @@ -155,6 +162,10 @@ if (empty($reshook)) { $search[$key.'_dtend'] = ''; } } + $search['sellby_dtstart'] = ''; + $search['eatby_dtstart'] = ''; + $search['sellby_dtend'] = ''; + $search['eatby_dtend'] = ''; $sref = ""; $snom = ""; $sall = ""; @@ -268,6 +279,37 @@ if ($search_warehouse) { if ($search_batch) { $sql .= natural_search("pb.batch", $search_batch); } + +foreach ($search as $key => $val) { + if (array_key_exists($key, $object->fields)) { + if ($key == 'status' && $search[$key] == -1) { + continue; + } + $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); + if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) { + if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) { + $search[$key] = ''; + } + $mode_search = 2; + } + if ($search[$key] != '') { + $sql .= natural_search("t.".$db->escape($key), $search[$key], (($key == 'status') ? 2 : $mode_search)); + } + } else { + if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { + $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); + if ($columnName == 'eatby' || $columnName == 'sellby') { + if (preg_match('/_dtstart$/', $key)) { + $sql .= " AND pl.".$db->escape($columnName)." >= '".$db->idate($search[$key])."'"; + } + if (preg_match('/_dtend$/', $key)) { + $sql .= " AND pl.".$db->escape($columnName)." <= '".$db->idate($search[$key])."'"; + } + } + } + } +} + $sql .= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,"; $sql .= " p.fk_product_type, p.tms,"; $sql .= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tosell, p.tobuy, p.tobatch,"; @@ -293,10 +335,13 @@ if (!empty($sql_having)) { $sql .= $sql_having; } +//print $sql; + +// Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); + $resql = $db->query($sql); + $nbtotalofrecords = $db->num_rows($resql); if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; @@ -339,9 +384,29 @@ if (isset($type)) { $texte .= ' ('.$langs->trans("StocksByLotSerial").')'; $param = ''; +if (!empty($mode)) { + $param .= '&mode='.urlencode($mode); +} +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} if ($limit > 0 && $limit != $conf->liste_limit) { $param .= '&limit='.urlencode($limit); } +foreach ($search as $key => $val) { + if (is_array($search[$key]) && count($search[$key])) { + foreach ($search[$key] as $skey) { + if ($skey != '') { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } + } + } elseif ($search[$key] != '') { + $param .= '&search_'.$key.'='.urlencode($search[$key]); + } +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} if ($sall) { $param .= "&sall=".urlencode($sall); } @@ -389,11 +454,18 @@ if ($sellby) $param.="&sellby=".$sellby;*/ llxHeader("", $title, $helpurl, $texte); -print '
'; +print ''."\n"; +if ($optioncss != '') { + print ''; +} print ''; +print ''; print ''; print ''; print ''; +print ''; +print ''; +print ''; print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'product', 0, '', '', $limit, 0, 0, 1); @@ -428,7 +500,7 @@ if (!empty($moreforfilter)) { print '
'; -print ''; +print '
'; // Fields title search // -------------------------------------------------------------------- @@ -447,10 +519,26 @@ if (!empty($conf->service->enabled) && $type == 1) { print ''; print ''; if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { - print ''; + print ''; } if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { - print ''; + print ''; } // Physical stock print ''; print ''; print ''; print ''; -print ''; -print ''; +// Action column +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} +print ''."\n"; -//Line for column titles -print ""; +$totalarray = array(); +$totalarray['nbfield'] = 0; + +// Fields title label +// -------------------------------------------------------------------- +print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref", '', $param, "", $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label", '', $param, "", $sortfield, $sortorder); if (!empty($conf->service->enabled) && $type == 1) { diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 13695752ad0..2743c4a5ea7 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -55,9 +55,10 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; -} // If $page is not defined, or '' or -1 +} $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -342,6 +343,7 @@ if (!$resql) { $num = $db->num_rows($resql); +$i = 0; // Direct jump if only one record found if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { @@ -439,6 +441,7 @@ if ($search_all) { print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } +// Filter on categories $moreforfilter = ''; /*$moreforfilter.='
'; $moreforfilter.= $langs->trans('MyFilter') . ': '; @@ -455,6 +458,9 @@ if (empty($reshook)) { if (!empty($moreforfilter)) { print '
'; print $moreforfilter; + $parameters = array(); + $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; print '
'; } @@ -462,13 +468,13 @@ $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table +print '
'; print '
 '; + $key = 'sellby'; + print '
'; + print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
 '; + $key = 'eatby'; + print '
'; + print $form->selectDate($search[$key.'_dtstart'] ? $search[$key.'_dtstart'] : '', "search_".$key."_dtstart", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From')); + print '
'; + print '
'; + print $form->selectDate($search[$key.'_dtend'] ? $search[$key.'_dtend'] : '', "search_".$key."_dtend", 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to')); + print '
'; + print '
'; @@ -459,14 +547,21 @@ print '   '; -$searchpicto = $form->showFilterAndCheckAddButtons(0); -print $searchpicto; -print '
'; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'."\n"; // Fields title search // -------------------------------------------------------------------- -print ''; +print ''; // Action column if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { print '
'; From 319eac2c4528d6e4d8c00fa4957402a6a7eaed36 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 May 2022 10:46:00 +0200 Subject: [PATCH 169/174] Fix trans --- htdocs/langs/en_US/main.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index af9894a7897..05d0ec1e060 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1176,4 +1176,5 @@ CommercialsAffected=Sales representatives affected CommercialAffected=Sales representative affected YourMessage=Votre message YourMessageHasBeenReceived=Your message has been received. We will answer or contact you as soon as possible. -UrlToCheck=Url to check \ No newline at end of file +UrlToCheck=Url to check +Automation=Automation \ No newline at end of file From 6a9c07de9f3bc1832601f102152c603921ce3807 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 29 May 2022 11:15:38 +0200 Subject: [PATCH 170/174] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9250259aa20..c476f14a8cc 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,8 @@ Other licenses apply for some included dependencies. See [COPYRIGHT](https://git If you have low technical skills and you're looking to install Dolibarr ERP/CRM in just a few clicks, you can use one of the packaged versions: -- [DoliWamp for Windows](https://wiki.dolibarr.org/index.php?title=Dolibarr_for_Windows_(DoliWamp)) -- [DoliDeb for Debian](https://wiki.dolibarr.org/index.php?title=Dolibarr_for_Ubuntu_or_Debian) +- [DoliWamp for Windows](https://wiki.dolibarr.org/index.php/Dolibarr_for_Windows_(DoliWamp)) +- [DoliDeb for Debian](https://wiki.dolibarr.org/index.php/Dolibarr_for_Ubuntu_or_Debian) - DoliRpm for Redhat, Fedora, OpenSuse, Mandriva or Mageia Releases can be downloaded from [official website](https://www.dolibarr.org/). From 396d1411e5ab3bf25222731c44d32a56019c1ed1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 30 May 2022 19:12:33 +0200 Subject: [PATCH 171/174] Fix default order --- htdocs/holiday/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index ed6e421d302..5978b6a31be 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -101,7 +101,7 @@ if (!$sortorder) { $sortorder = "DESC"; } if (!$sortfield) { - $sortfield = "cp.rowid"; + $sortfield = "cp.ref"; } $sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); From b95440b83f8bfbe50f95958876b69a36b4f983c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 May 2022 09:57:49 +0200 Subject: [PATCH 172/174] Fix picto phone --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9c9b457a533..96711456e2a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7383,7 +7383,7 @@ abstract class CommonObject } elseif ($type == 'url') { $value = dol_print_url($value, '_blank', 32, 1); } elseif ($type == 'phone') { - $value = dol_print_phone($value, '', 0, 0, '', ' ', 1); + $value = dol_print_phone($value, '', 0, 0, '', ' ', 'phone'); } elseif ($type == 'price') { if (!is_null($value) && $value !== '') { $value = price($value, 0, $langs, 0, 0, -1, $conf->currency); From 1655890f848e2cdbed00d2f65a18553213d4cf35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 May 2022 10:35:36 +0200 Subject: [PATCH 173/174] Debug v16 --- htdocs/admin/modules.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- .../modulebuilder/template/myobject_list.php | 3 +- .../class/recruitmentcandidature.class.php | 2 +- .../recruitmentcandidature_list.php | 108 +++++++++++++----- .../recruitmentjobposition_list.php | 2 +- htdocs/user/hierarchy.php | 35 +++--- htdocs/user/list.php | 6 +- 8 files changed, 110 insertions(+), 50 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index dbf4ca53686..0db1b26dc7d 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -528,8 +528,8 @@ if ($mode == 'common' || $mode == 'commonkanban') { $moreforfilter .= ''; //$moreforfilter .= '
'.$moreinfo.' '.$moreinfo2.'
'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 96711456e2a..d5e164c46a0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7378,7 +7378,7 @@ abstract class CommonObject $checked = ' checked '; } $value = ''; - } elseif ($type == 'mail') { + } elseif ($type == 'mail' || $type == 'email') { $value = dol_print_email($value, 0, 0, 0, 64, 1, 1); } elseif ($type == 'url') { $value = dol_print_url($value, '_blank', 32, 1); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 92f7f22f328..595dd077b0e 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -500,8 +500,8 @@ print ''; $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/mymodule/myobject_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); @@ -674,6 +674,7 @@ if (isset($extrafields->attributes[$object->table_element]['computed']) && is_ar // -------------------------------------------------------------------- $i = 0; $savnbfield = $totalarray['nbfield']; +$totalarray = array(); $totalarray['nbfield'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); while ($i < $imaxinloop) { diff --git a/htdocs/recruitment/class/recruitmentcandidature.class.php b/htdocs/recruitment/class/recruitmentcandidature.class.php index 835cfe0b7cd..1b4074a6798 100644 --- a/htdocs/recruitment/class/recruitmentcandidature.class.php +++ b/htdocs/recruitment/class/recruitmentcandidature.class.php @@ -120,7 +120,7 @@ class RecruitmentCandidature extends CommonObject 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,), 'lastname' => array('type'=>'varchar(128)', 'label'=>'Lastname', 'enabled'=>'1', 'position'=>20, 'notnull'=>0, 'visible'=>1,), 'firstname' => array('type'=>'varchar(128)', 'label'=>'Firstname', 'enabled'=>'1', 'position'=>21, 'notnull'=>0, 'visible'=>1,), - 'email' => array('type'=>'varchar(255)', 'label'=>'EMail', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'picto'=>'email'), + 'email' => array('type'=>'email', 'label'=>'EMail', 'enabled'=>'1', 'position'=>30, 'notnull'=>1, 'visible'=>1, 'picto'=>'email', 'csslist'=>'tdoverflowmax200'), 'phone' => array('type'=>'phone', 'label'=>'Phone', 'enabled'=>'1', 'position'=>31, 'notnull'=>0, 'visible'=>1, 'picto'=>'phone'), 'date_birth' => array('type'=>'date', 'label'=>'DateOfBirth', 'enabled'=>'1', 'position'=>70, 'visible'=>-1,), 'email_msgid' => array('type'=>'varchar(255)', 'label'=>'EmailMsgID', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'help'=>'EmailMsgIDDesc'), diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index 4ce262c8c92..9a0a21484b1 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -30,11 +30,11 @@ //if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). //if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) //if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK', '1'); // Do not check style html tag into posted data -//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no need to load and show top and left menu //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php //if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); // Do not load ajax.lib.php library //if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) +//if (! defined('NOIPCHECK')) define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip //if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT', 'auto'); // Force lang to a particular value //if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE', 'aloginmodule'); // Force authentication handler //if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN', '1'); // The main.inc.php does not make a redirect if not logged, instead show simple error message @@ -129,11 +129,11 @@ $arrayfields = array(); foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field if (!empty($val['visible'])) { - $visible = (int) dol_eval($val['visible'], 1, 1, '1'); + $visible = (int) dol_eval($val['visible'], 1); $arrayfields['t.'.$key] = array( 'label'=>$val['label'], 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>($visible != 3 && dol_eval($val['enabled'], 1, 1, '1')), + 'enabled'=>(abs($visible) != 3 && dol_eval($val['enabled'], 1)), 'position'=>$val['position'], 'help'=> isset($val['help']) ? $val['help'] : '' ); @@ -318,7 +318,7 @@ if (! empty($extrafields->attributes[$object->table_element]['label'])) { } // Add where from hooks $parameters=array(); -$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql = preg_replace('/,\s*$/', '', $sql); */ @@ -326,8 +326,15 @@ $sql = preg_replace('/,\s*$/', '', $sql); // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $resql = $db->query($sql); - $nbtotalofrecords = $db->num_rows($resql); + /* The fast and low memory method to get and count full list converts the sql into a sql count */ + $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql); + $resql = $db->query($sqlforcount); + if ($resql) { + $objforcount = $db->fetch_object($resql); + $nbtotalofrecords = $objforcount->nbtotalofrecords; + } else { + dol_print_error($db); + } if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; @@ -543,7 +550,7 @@ $arrayofmassactions = array( //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); -if ($permissiontodelete) { +if (!empty($permissiontodelete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { @@ -560,12 +567,17 @@ print ''; print ''; print ''; -//print ''; +print ''; print ''; print ''; print ''; -$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.((int) $id)), '', $permissiontoadd); + +$newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitleSeparator(); +$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.((int) $id)), '', $permissiontoadd); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -577,10 +589,13 @@ $trackid = 'recruitmentapplication'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { + $setupstring = ''; foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); + $setupstring .= $key."=".$val.";"; } - print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'; + print ''."\n"; + print '
'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'
'."\n"; } $moreforfilter = ''; @@ -603,7 +618,7 @@ if (!empty($moreforfilter)) { } $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; -$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields +$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN', '')); // This also change content of $arrayfields $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table @@ -613,8 +628,16 @@ print ''; +// Action column +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} foreach ($object->fields as $key => $val) { - $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); + $searchkey = empty($search[$key]) ? '' : $search[$key]; + $cssforfield = (empty($val['css']) ? '' : $val['css']); if ($key == 'status') { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { @@ -655,10 +678,12 @@ $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print ''; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; +} print ''."\n"; $totalarray = array(); @@ -667,6 +692,9 @@ $totalarray['nbfield'] = 0; // Fields title label // -------------------------------------------------------------------- print ''; +if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if ($key == 'status') { @@ -675,21 +703,25 @@ foreach ($object->fields as $key => $val) { $cssforfield .= ($cssforfield ? ' ' : '').'center'; } elseif (in_array($val['type'], array('timestamp'))) { $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID' && empty($val['arrayofkeyval'])) { $cssforfield .= ($cssforfield ? ' ' : '').'right'; } + $cssforfield = preg_replace('/small\s*/', '', $cssforfield); // the 'small' css must not be used for the title label if (!empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; + $totalarray['nbfield']++; } } // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); +$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column -print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +if (empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print getTitleFieldOfList(($mode != 'kanban' ? $selectedfields : ''), 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; +} $totalarray['nbfield']++; print ''."\n"; @@ -735,7 +767,19 @@ while ($i < $imaxinloop) { } else { // Show here line of result $j = 0; - print ''; + print ''; + // Action column + if (!empty($conf->global->MAIN_CHECKBOX_LEFT_COLUMN)) { + print ''; + } foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['csslist']) ? (empty($val['css']) ? '' : $val['css']) : $val['csslist']); if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { @@ -756,7 +800,11 @@ while ($i < $imaxinloop) { //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; if (!empty($arrayfields['t.'.$key]['checked'])) { - print ''; + print ''; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'rowid') { @@ -789,15 +837,17 @@ while ($i < $imaxinloop) { $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column - print ''; } - print ''; if (!$i) { $totalarray['nbfield']++; } @@ -826,7 +876,7 @@ if ($num == 0) { $db->free($resql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; + $searchpicto = $form->showFilterButtons('left'); + print $searchpicto; + print ''; -$searchpicto = $form->showFilterButtons(); -print $searchpicto; -print ''; + $searchpicto = $form->showFilterButtons(); + print $searchpicto; + print '
'; + if ($massactionbutton || $massaction) { // 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($object->id, $arrayofselected)) { + $selected = 1; + } + 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 - $selected = 0; - if (in_array($object->id, $arrayofselected)) { - $selected = 1; + if (empty($conf->global->MAIN_CHECKBOX_LEFT_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 + $selected = 0; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } + print ''; } - print ''; + print '
'."\n"; diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index cf4bdddb63d..4f63434f9cf 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -427,8 +427,8 @@ print ''; print ''; $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/^&mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/^&mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/^&mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/recruitment/recruitmentjobposition_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); diff --git a/htdocs/user/hierarchy.php b/htdocs/user/hierarchy.php index fa68b3e6cdf..92d0490f1c6 100644 --- a/htdocs/user/hierarchy.php +++ b/htdocs/user/hierarchy.php @@ -29,10 +29,6 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php'; -if (!$user->rights->user->user->lire && !$user->admin) { - accessforbidden(); -} - // Load translation files required by page $langs->loadLangs(array('users', 'companies')); @@ -51,7 +47,6 @@ $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("pa // Load mode employee $mode = GETPOST("mode", 'alpha'); -$userstatic = new User($db); $search_statut = GETPOST('search_statut', 'int'); if ($search_statut == '' || $search_statut == '0') { @@ -62,9 +57,16 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_statut = ""; } +$userstatic = new User($db); + // Define value to know what current user can do on users $canadduser = (!empty($user->admin) || $user->rights->user->user->creer); +if (!$user->rights->user->user->lire && !$user->admin) { + accessforbidden(); +} + +$childids = $user->getAllChildIds(1); /* @@ -73,19 +75,25 @@ $canadduser = (!empty($user->admin) || $user->rights->user->user->creer); $form = new Form($db); -$title = $langs->trans("Users").' - '.$langs->trans("HierarchicView"); +$help_url = 'EN:Module_Users|FR:Module_Utilisateurs|ES:Módulo_Usuarios|DE:Modul_Benutzer'; +$title = $langs->trans("Users"); $arrayofjs = array( '/includes/jquery/plugins/jquerytreeview/jquery.treeview.js', '/includes/jquery/plugins/jquerytreeview/lib/jquery.cookie.js', ); $arrayofcss = array('/includes/jquery/plugins/jquerytreeview/jquery.treeview.css'); -llxHeader('', $title, '', '', 0, 0, $arrayofjs, $arrayofcss, '', 'bodyforlist'); +llxHeader('', $title, $help_url, '', 0, 0, $arrayofjs, $arrayofcss, '', 'bodyforlist'); // Load hierarchy of users $user_arbo = $userstatic->get_full_tree(0, ($search_statut != '' && $search_statut >= 0) ? "statut = ".$search_statut : ''); + +// Count total nb of records +$nbtotalofrecords = count($user_arbo); + + if (!is_array($user_arbo) && $user_arbo < 0) { setEventMessages($userstatic->error, $userstatic->errors, 'warnings'); } else { @@ -142,12 +150,12 @@ if (!is_array($user_arbo) && $user_arbo < 0) { //var_dump($data); - $param = "search_statut=".urlencode($search_statut); + $param = "&search_statut=".urlencode($search_statut); $newcardbutton = ''; - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', DOL_URL_ROOT.'/user/list.php?mode=kanban'.(($search_statut != '' && $search_statut >= 0) ? '&search_statut='.$search_statut : '').preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); - $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars paddingleft imgforviewmode', DOL_URL_ROOT.'/user/list.php?mode=common'.(($search_statut != '' && $search_statut >= 0) ? '&search_statut='.$search_statut : '').preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); - $newcardbutton .= dolGetButtonTitle($langs->trans('HierarchicView'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/user/hierarchy.php?mode=hierarchy'.(($search_statut != '' && $search_statut >= 0) ? '&search_statut='.$search_statut : '').preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', (($mode == 'hierarchy') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars paddingleft imgforviewmode', DOL_URL_ROOT.'/user/list.php?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('HierarchicView'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/user/hierarchy.php?mode=hierarchy'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', (($mode == 'hierarchy') ? 2 : 1), array('morecss'=>'reposition')); + $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', DOL_URL_ROOT.'/user/list.php?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('NewUser'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/user/card.php?action=create'.($mode == 'employee' ? '&employee=1' : '').'&leftmenu=', '', $canadduser); @@ -155,18 +163,19 @@ if (!is_array($user_arbo) && $user_arbo < 0) { $num = 0; $limit = 0; - print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, '', 'user', 0, $newcardbutton, '', $limit, 0, 0, 1); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'user', 0, $newcardbutton, '', $limit, 0, 0, 1); print ''."\n"; if ($optioncss != '') { print ''; } print ''; + print ''; print ''; print ''; print ''; - print ''; print ''; + print ''; print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print ''; diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 0dc3317b1ef..3c97a7f7298 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -562,7 +562,7 @@ if ($search_api_key != '') { if ($search_supervisor > 0) { $param .= "&search_supervisor=".urlencode($search_supervisor); } -if ($search_statut != '' && $search_statut >= 0) { +if ($search_statut != '') { $param .= "&search_statut=".urlencode($search_statut); } if ($optioncss != '') { @@ -613,9 +613,9 @@ if (!empty($socid)) { } $newcardbutton = ''; +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars paddingleft imgforviewmode', DOL_URL_ROOT.'/user/list.php?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('HierarchicView'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/user/hierarchy.php?mode=hierarchy'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', (($mode == 'hierarchy') ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars paddingleft imgforviewmode', DOL_URL_ROOT.'/user/list.php?mode=common'.(($search_statut != '' && $search_statut >= 0) ? '&search_statut='.$search_statut : '').preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('HierarchicView'), '', 'fa fa-stream paddingleft imgforviewmode', DOL_URL_ROOT.'/user/hierarchy.php?mode=hierarchy'.(($search_statut != '' && $search_statut >= 0) ? '&search_statut='.$search_statut : '').preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', (($mode == 'hierarchy') ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('NewUser'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd); From 2d0958ba7f09f24bfda918a9761b3e7954d19b86 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 May 2022 11:00:21 +0200 Subject: [PATCH 174/174] Look and feel v16 --- htdocs/admin/bank.php | 18 ++++-------------- htdocs/compta/bank/list.php | 13 +++++++++++-- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/htdocs/admin/bank.php b/htdocs/admin/bank.php index e1e468b0cec..ef365881feb 100644 --- a/htdocs/admin/bank.php +++ b/htdocs/admin/bank.php @@ -53,8 +53,6 @@ $type = 'bankaccount'; // Order display of bank account if ($action == 'setbankorder') { if (dolibarr_set_const($db, "BANK_SHOW_ORDER_OPTION", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; } else { dol_print_error($db); } @@ -63,15 +61,11 @@ if ($action == 'setbankorder') { // Auto report last num releve on conciliate if ($action == 'setreportlastnumreleve') { if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 1, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; } else { dol_print_error($db); } } elseif ($action == 'unsetreportlastnumreleve') { if (dolibarr_set_const($db, "BANK_REPORT_LAST_NUM_RELEVE", 0, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; } else { dol_print_error($db); } @@ -80,15 +74,11 @@ if ($action == 'setreportlastnumreleve') { // Colorize movements if ($action == 'setbankcolorizemovement') { if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 1, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; } else { dol_print_error($db); } } elseif ($action == 'unsetbankcolorizemovement') { if (dolibarr_set_const($db, "BANK_COLORIZE_MOVEMENT", 0, 'chaine', 0, '', $conf->entity) > 0) { - header("Location: ".$_SERVER["PHP_SELF"]); - exit; } else { dol_print_error($db); } @@ -427,13 +417,13 @@ print ""; // Active if ($conf->global->BANK_COLORIZE_MOVEMENT) { print ''; } else { print '"; } @@ -483,13 +473,13 @@ print ''; // Active if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) { print ''; } else { print '"; } diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 90bc79483bf..8e6fb27d5f0 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -616,9 +616,18 @@ foreach ($accounts as $key => $type) { // Transactions to reconcile if (!empty($arrayfields['toreconcile']['checked'])) { - print '
'."\n"; - print ''; + print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; print ''."\n"; - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; print "'."\n"; - print ''; + print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; print ''."\n"; - print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; + print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; print "'; - $conciliate = $objecttmp->canBeConciliated(); + + $labeltoshow = ''; + if ($conciliate == -2) { + $labeltoshow = $langs->trans("CashAccount"); + } elseif ($conciliate == -3) { + $labeltoshow = $langs->trans("Closed"); + } elseif (empty($objecttmp->rappro)) { + $labeltoshow = $langs->trans("ConciliationDisabled"); + } + + print ''; if ($conciliate == -2) { print ''.$langs->trans("CashAccount").''; } elseif ($conciliate == -3) {