From 7b655a1ae2cc79c5da9abe5461fc5131e701fce1 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Mon, 21 Feb 2022 11:25:28 +0100 Subject: [PATCH 1/9] fix missing hooks and line total for totalizable extrafields --- htdocs/reception/list.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 8f07d1bede7..9f98202099a 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -491,6 +491,9 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.rowid = ee.fk_target"; if (!$user->rights->societe->client->voir && !$socid) { // Internal user with no permission to see all $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= " WHERE e.entity IN (".getEntity('reception').")"; if (!$user->rights->societe->client->voir && !$socid) { // Internal user with no permission to see all $sql .= " AND e.fk_soc = sc.fk_soc"; @@ -976,6 +979,9 @@ while ($i < min($num, $limit)) { { }*/ print "\n"; + if (!$i) { + $totalarray['nbfield']++; + } } if (!empty($arrayfields['l.ref']['checked']) || !empty($arrayfields['l.date_delivery']['checked'])) { @@ -1071,6 +1077,13 @@ if ($num == 0) { print ''.$langs->trans("NoRecordFound").''; } +// Show total line +include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; + +$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook +print $hookmanager->resPrint; + print ""; print ""; print ''; From 1574254dcfeecf2a500cdb777239894f809f2ecc Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 22 Feb 2022 17:13:26 +0100 Subject: [PATCH 2/9] FIX: viewimage.php: bad call to dol_check_secure_access_document() caused images to be blocked with multicompany from entities > 1 --- htdocs/viewimage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index 3cb23b36fbc..50836186c7f 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -185,7 +185,7 @@ $refname = basename(dirname($original_file)."/"); // Security check if (empty($modulepart)) accessforbidden('Bad value for parameter modulepart', 0, 0, 1); -$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $refname); +$check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, $user, $refname); $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $fullpath_original_file = $check_access['original_file']; // $fullpath_original_file is now a full path name From 0510d84263a9b4088a2855453736a32c0968d5c9 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 23 Feb 2022 06:08:20 +0100 Subject: [PATCH 3/9] FIX Invoice - When you create an invoice and defined a thirdparty, fk_account is not retrieved from company card --- htdocs/compta/facture/card.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 4230a22daaf..ff39e29ab00 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2898,6 +2898,9 @@ if ($action == 'create') { if (empty($mode_reglement_id)) { $mode_reglement_id = $soc->mode_reglement_id; } + if (empty($fk_account)) { + $fk_account = $soc->fk_account; + } if (!$remise_percent) { $remise_percent = $soc->remise_percent; } @@ -3005,6 +3008,11 @@ if ($action == 'create') { $mode_reglement_id = GETPOST("mode_reglement_id", 'int'); } + // when bank account is empty (means not override by payment mode form a other object, like third-party), try to use default value + if (empty($fk_account)) { + $fk_account = GETPOST("fk_account", 'int'); + } + if (!empty($soc->id)) { $absolute_discount = $soc->getAvailableDiscounts(); } @@ -3607,8 +3615,8 @@ if ($action == 'create') { // Bank Account if (!empty($conf->banque->enabled)) { print ''.$langs->trans('BankAccount').''; - $fk_account = GETPOST('fk_account', 'int'); - print img_picto('', 'bank_account', 'class="pictofixedwidth"').$form->select_comptes(($fk_account < 0 ? '' : $fk_account), 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); + print img_picto('', 'bank_account', 'class="pictofixedwidth"'); + print $form->select_comptes(GETPOSTISSET('fk_account') ? GETPOST('fk_account') : $fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); print ''; } From 18a8eac1cd4f79757abd6f48c86e486d6135cfcb Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sat, 26 Feb 2022 07:17:44 +0100 Subject: [PATCH 4/9] Modify fix --- htdocs/compta/facture/card.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ff39e29ab00..6fdccb366c2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3009,9 +3009,7 @@ if ($action == 'create') { } // when bank account is empty (means not override by payment mode form a other object, like third-party), try to use default value - if (empty($fk_account)) { - $fk_account = GETPOST("fk_account", 'int'); - } + $fk_account = GETPOSTISSET("fk_account") ? GETPOST("fk_account", 'int') : $fk_account; if (!empty($soc->id)) { $absolute_discount = $soc->getAvailableDiscounts(); @@ -3616,7 +3614,7 @@ if ($action == 'create') { if (!empty($conf->banque->enabled)) { print ''.$langs->trans('BankAccount').''; print img_picto('', 'bank_account', 'class="pictofixedwidth"'); - print $form->select_comptes(GETPOSTISSET('fk_account') ? GETPOST('fk_account') : $fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); + print $form->select_comptes($fk_account, 'fk_account', 0, '', 1, '', 0, 'maxwidth200 widthcentpercentminusx', 1); print ''; } From 9cf5bccf43620e1a74027d16e40fc4ed3dde00a9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 28 Feb 2022 18:13:29 +0100 Subject: [PATCH 5/9] FIX options should not exists on invoices --- htdocs/compta/facture/card-rec.php | 4 ++-- htdocs/compta/facture/card.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index b15599cc931..a41de0ce755 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -765,8 +765,8 @@ if (empty($reshook)) { // Define special_code for special lines $special_code = GETPOST('special_code', 'int'); - if (!GETPOST('qty', 'alpha')) { - $special_code = 3; + if ($special_code == 3) { + $special_code = 0; // Options should not exists on invoices } /*$line = new FactureLigne($db); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 4230a22daaf..cedb7cdc0de 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2371,9 +2371,9 @@ if (empty($reshook)) { } // Define special_code for special lines - $special_code = GETPOST('special_code'); - if (!GETPOST('qty')) { - $special_code = 3; + $special_code = GETPOST('special_code', 'int'); + if ($special_code == 3) { + $special_code = 0; // Options should not exists on invoices } $line = new FactureLigne($db); From 5eef80750abc217576cfd670717f724a14ba1e50 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Mon, 28 Feb 2022 18:37:47 +0100 Subject: [PATCH 6/9] fiw visibility can be an expression and can return 0 --- htdocs/core/tpl/extrafields_list_array_fields.tpl.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/tpl/extrafields_list_array_fields.tpl.php b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php index f7c9fc201f4..ac6d139033c 100644 --- a/htdocs/core/tpl/extrafields_list_array_fields.tpl.php +++ b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php @@ -18,13 +18,12 @@ if (!empty($extrafieldsobjectkey)) { // $extrafieldsobject is the $object->table if (empty($extrafieldsobjectprefix)) { $extrafieldsobjectprefix = 'ef.'; } - foreach ($extrafields->attributes[$extrafieldsobjectkey]['label'] as $key => $val) { if (!empty($extrafields->attributes[$extrafieldsobjectkey]['list'][$key])) { $arrayfields[$extrafieldsobjectprefix.$key] = array( 'label' => $extrafields->attributes[$extrafieldsobjectkey]['label'][$key], 'type' => $extrafields->attributes[$extrafieldsobjectkey]['type'][$key], - 'checked' => (($extrafields->attributes[$extrafieldsobjectkey]['list'][$key] < 0) ? 0 : 1), + 'checked' => ((dol_eval($extrafields->attributes[$extrafieldsobjectkey]['list'][$key],1) <= 0) ? 0 : 1), 'position' => $extrafields->attributes[$extrafieldsobjectkey]['pos'][$key], 'enabled' => (abs((int) $extrafields->attributes[$extrafieldsobjectkey]['list'][$key]) != 3 && $extrafields->attributes[$extrafieldsobjectkey]['perms'][$key]), 'langfile' => $extrafields->attributes[$extrafieldsobjectkey]['langfile'][$key], From bc8ea7571b12dcea5132899571ccccc2f728d897 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Mon, 28 Feb 2022 18:38:37 +0100 Subject: [PATCH 7/9] perms can be an expression and must be evaluated --- htdocs/core/tpl/extrafields_list_array_fields.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/extrafields_list_array_fields.tpl.php b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php index ac6d139033c..b633642a129 100644 --- a/htdocs/core/tpl/extrafields_list_array_fields.tpl.php +++ b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php @@ -25,7 +25,7 @@ if (!empty($extrafieldsobjectkey)) { // $extrafieldsobject is the $object->table 'type' => $extrafields->attributes[$extrafieldsobjectkey]['type'][$key], 'checked' => ((dol_eval($extrafields->attributes[$extrafieldsobjectkey]['list'][$key],1) <= 0) ? 0 : 1), 'position' => $extrafields->attributes[$extrafieldsobjectkey]['pos'][$key], - 'enabled' => (abs((int) $extrafields->attributes[$extrafieldsobjectkey]['list'][$key]) != 3 && $extrafields->attributes[$extrafieldsobjectkey]['perms'][$key]), + 'enabled' => (abs((int) $extrafields->attributes[$extrafieldsobjectkey]['list'][$key]) != 3 && dol_eval($extrafields->attributes[$extrafieldsobjectkey]['perms'][$key],1)), 'langfile' => $extrafields->attributes[$extrafieldsobjectkey]['langfile'][$key], 'help' => $extrafields->attributes[$extrafieldsobjectkey]['help'][$key], ); From c2047f1f5d4f4ca6c2daaba50fa37dd82d4e513c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 28 Feb 2022 17:46:20 +0000 Subject: [PATCH 8/9] Fixing style errors. --- htdocs/core/tpl/extrafields_list_array_fields.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/extrafields_list_array_fields.tpl.php b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php index b633642a129..36eeee89627 100644 --- a/htdocs/core/tpl/extrafields_list_array_fields.tpl.php +++ b/htdocs/core/tpl/extrafields_list_array_fields.tpl.php @@ -23,9 +23,9 @@ if (!empty($extrafieldsobjectkey)) { // $extrafieldsobject is the $object->table $arrayfields[$extrafieldsobjectprefix.$key] = array( 'label' => $extrafields->attributes[$extrafieldsobjectkey]['label'][$key], 'type' => $extrafields->attributes[$extrafieldsobjectkey]['type'][$key], - 'checked' => ((dol_eval($extrafields->attributes[$extrafieldsobjectkey]['list'][$key],1) <= 0) ? 0 : 1), + 'checked' => ((dol_eval($extrafields->attributes[$extrafieldsobjectkey]['list'][$key], 1) <= 0) ? 0 : 1), 'position' => $extrafields->attributes[$extrafieldsobjectkey]['pos'][$key], - 'enabled' => (abs((int) $extrafields->attributes[$extrafieldsobjectkey]['list'][$key]) != 3 && dol_eval($extrafields->attributes[$extrafieldsobjectkey]['perms'][$key],1)), + 'enabled' => (abs((int) $extrafields->attributes[$extrafieldsobjectkey]['list'][$key]) != 3 && dol_eval($extrafields->attributes[$extrafieldsobjectkey]['perms'][$key], 1)), 'langfile' => $extrafields->attributes[$extrafieldsobjectkey]['langfile'][$key], 'help' => $extrafields->attributes[$extrafieldsobjectkey]['help'][$key], ); From 548cad0508be84499a31c96e1c1c83ccdee35486 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Feb 2022 21:30:12 +0100 Subject: [PATCH 9/9] FIx #20110 --- htdocs/api/class/api.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 0a84de7b7c1..e4f093be87f 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -348,6 +348,9 @@ class DolibarrApi $operand = preg_replace('/[^a-z0-9\._]/i', '', trim($tmp[0])); $operator = strtoupper(preg_replace('/[^a-z<>=]/i', '', trim($tmp[1]))); + if ($operator == 'NOTLIKE') { + $operator = 'NOT LIKE'; + } $tmpescaped = trim($tmp[2]); $regbis = array();