From 08b355d7c3266cd5900fe240813668b794177a2f Mon Sep 17 00:00:00 2001 From: atm-arnaud Date: Thu, 17 Aug 2023 11:48:03 +0200 Subject: [PATCH 01/15] FIX Suppliers addlines never have VAT if buyprice for this supplier --- htdocs/core/tpl/objectline_create.tpl.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index adc490aeb09..a2e40d59716 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -775,7 +775,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { // Now set the VAT var stringforvatrateselection = tva_tx; - if (typeof default_vat_code != 'undefined' && default_vat_code != null) { + if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') { stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')'; } // Set vat rate if field is an input box @@ -997,7 +997,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { if (typeof default_vat_code === 'undefined') { default_vat_code = jQuery('#idprodfournprice').attr('data-default-vat-code');} // When select is done from HTML input with ajax autocomplete var stringforvatrateselection = tva_tx; - if (typeof default_vat_code != 'undefined' && default_vat_code != null) { + if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') { stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')'; } @@ -1059,7 +1059,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { if (typeof default_vat_code === 'undefined') { default_vat_code = jQuery('#idprodfournprice').attr('data-default-vat-code');} // When select is done from HTML input with ajax autocomplete var stringforvatrateselection = tva_tx; - if (typeof default_vat_code != 'undefined' && default_vat_code != null) { + if (typeof default_vat_code != 'undefined' && default_vat_code != null && default_vat_code != '') { stringforvatrateselection = stringforvatrateselection+' ('+default_vat_code+')'; } @@ -1072,7 +1072,6 @@ if (!empty($usemargins) && $user->rights->margins->creer) { $('#tva_tx option').removeAttr('selected'); console.log("stringforvatrateselection="+stringforvatrateselection+" -> value of option label for this key="+$('#tva_tx option[value="'+stringforvatrateselection+'"]').val()); $('#tva_tx option[value="'+stringforvatrateselection+'"]').prop('selected', true); - global->FCKEDITOR_ENABLE_DETAILS)) { From 2487d5cbc428208265b80230e0824cf72a46b0f9 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Thu, 17 Aug 2023 13:53:13 +0200 Subject: [PATCH 02/15] FIX : SQL request parenthesis --- htdocs/core/class/translate.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 3f2f756977d..4d41d33ebbb 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -480,7 +480,7 @@ class Translate if (!$found && !empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { // Overwrite translation with database read - $sql = "SELECT transkey, transvalue FROM ".$db->prefix()."overwrite_trans where lang='".$db->escape($this->defaultlang)."' OR lang IS NULL"; + $sql = "SELECT transkey, transvalue FROM ".$db->prefix()."overwrite_trans where (lang='".$db->escape($this->defaultlang)."' OR lang IS NULL)"; $sql .= " AND entity IN (0, ".getEntity('overwrite_trans').")"; $sql .= $db->order("lang", "DESC"); $resql = $db->query($sql); From 30ec5dfd75849bed3a2bf044a266a94bbdf91933 Mon Sep 17 00:00:00 2001 From: Adnan RIHAN Date: Sat, 19 Aug 2023 17:27:06 +0200 Subject: [PATCH 03/15] FIX TakePOS receipt preview in admin #25648 Receipt preview in admin shows header and footer repeating themselves because in preview, $constFreeText equals TAKEPOS_HEADER (as there is no $_SESSION['takeposterminal'] defined). Back compatibility for #25648 --- htdocs/takepos/receipt.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index fafee970bae..e8844fa764a 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -111,7 +111,7 @@ if (!empty($hookmanager->resPrint)) {

global->TAKEPOS_HEADER) || !empty($conf->global->{$constFreeText})) { $newfreetext = ''; $substitutionarray = getCommonSubstitutionArray($langs); @@ -316,7 +316,7 @@ if ($conf->global->TAKEPOS_PRINT_PAYMENT_METHOD) {

global->TAKEPOS_FOOTER) || !empty($conf->global->{$constFreeText})) { $newfreetext = ''; $substitutionarray = getCommonSubstitutionArray($langs); From ebed2211b60b1dfa40ebb2b6c60852963673e31a Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 23 Aug 2023 11:24:09 +0200 Subject: [PATCH 04/15] FIX reception odt dir output path --- .../reception/doc/doc_generic_reception_odt.modules.php | 6 +++--- htdocs/reception/class/reception.class.php | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 383ab491346..ecfea479c0d 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -229,7 +229,7 @@ class doc_generic_reception_odt extends ModelePdfReception $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); - if ($conf->reception->dir_output."/reception") { + if ($conf->reception->dir_output) { // If $object is id instead of object if (!is_object($object)) { $id = $object; @@ -243,7 +243,7 @@ class doc_generic_reception_odt extends ModelePdfReception $object->fetch_thirdparty(); - $dir = $conf->reception->dir_output."/reception"; + $dir = !empty($conf->reception->multidir_output[$object->entity]) ? $conf->reception->multidir_output[$object->entity] : $conf->reception->dir_output; $objectref = dol_sanitizeFileName($object->ref); if (!preg_match('/specimen/i', $objectref)) { $dir .= "/".$objectref; @@ -416,7 +416,7 @@ class doc_generic_reception_odt extends ModelePdfReception $linenumber = 0; foreach ($object->lines as $line) { $linenumber++; - $tmparray = $this->get_substitutionarray_reception_lines($line, $outputlangs); + $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines"); // Call the ODTSubstitutionLine hook $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line); diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 0be0ea7ba37..1fb43f226cb 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -377,7 +377,7 @@ class Reception extends CommonObject return -1; } - $sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_supplier, e.ref_ext, e.fk_user_author, e.fk_statut"; + $sql = "SELECT e.rowid, e.entity, e.ref, e.fk_soc as socid, e.date_creation, e.ref_supplier, e.ref_ext, e.fk_user_author, e.fk_statut"; $sql .= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; $sql .= ", e.date_reception as date_reception, e.model_pdf, e.date_delivery"; $sql .= ", e.fk_shipping_method, e.tracking_number"; @@ -409,6 +409,7 @@ class Reception extends CommonObject $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; + $this->entity = $obj->entity; $this->ref = $obj->ref; $this->socid = $obj->socid; $this->ref_supplier = $obj->ref_supplier; From e9273ea40353df945d334208a8f275e59fbce219 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Aug 2023 22:20:22 +0200 Subject: [PATCH 05/15] Fix javascript error --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index f4e83192ac4..025f8b45f25 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -869,7 +869,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) { } options += ''; }); - options += ''; + options += ''; console.log("finally selected defaultkey="+defaultkey+" defaultprice for buying price="+defaultprice); From c065675f5735403aa5cdafae8379f5c16fc2f643 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Aug 2023 23:41:16 +0200 Subject: [PATCH 06/15] FIX Bad calculation of localtax when price_base_type not defined. --- htdocs/compta/facture/card-rec.php | 2 +- htdocs/compta/facture/card.php | 2 +- htdocs/fourn/facture/card-rec.php | 2 +- htdocs/takepos/invoice.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index c2701a4e05d..71a612e71ba 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -517,7 +517,7 @@ if (empty($reshook)) { $pu_ht = $datapriceofproduct['pu_ht']; $pu_ttc = $datapriceofproduct['pu_ttc']; $price_min = $datapriceofproduct['price_min']; - $price_base_type = $datapriceofproduct['price_base_type']; + $price_base_type = empty($datapriceofproduct['price_base_type']) ? 'HT' : $datapriceofproduct['price_base_type']; $tva_tx = $datapriceofproduct['tva_tx']; $tva_npr = $datapriceofproduct['tva_npr']; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 5683c6f43f1..5a9829881a1 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2126,7 +2126,7 @@ if (empty($reshook)) { $pu_ht = $datapriceofproduct['pu_ht']; $pu_ttc = $datapriceofproduct['pu_ttc']; $price_min = $datapriceofproduct['price_min']; - $price_base_type = $datapriceofproduct['price_base_type']; + $price_base_type = empty($datapriceofproduct['price_base_type']) ? 'HT' : $datapriceofproduct['price_base_type']; $tva_tx = $datapriceofproduct['tva_tx']; $tva_npr = $datapriceofproduct['tva_npr']; diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index 860c4884649..b13228c20ed 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -547,7 +547,7 @@ if (empty($reshook)) { $pu_ht = $datapriceofproduct['pu_ht']; $pu_ttc = $datapriceofproduct['pu_ttc']; $price_min = $datapriceofproduct['price_min']; - $price_base_type = $datapriceofproduct['price_base_type']; + $price_base_type = empty($datapriceofproduct['price_base_type']) ? 'HT' : $datapriceofproduct['price_base_type']; $tva_tx = $datapriceofproduct['tva_tx']; $tva_npr = $datapriceofproduct['tva_npr']; diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 0494bf604d5..ed97e84c263 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -517,7 +517,7 @@ if (empty($reshook)) { $price = $datapriceofproduct['pu_ht']; $price_ttc = $datapriceofproduct['pu_ttc']; //$price_min = $datapriceofproduct['price_min']; - $price_base_type = $datapriceofproduct['price_base_type']; + $price_base_type = empty($datapriceofproduct['price_base_type']) ? 'HT' : $datapriceofproduct['price_base_type']; $tva_tx = $datapriceofproduct['tva_tx']; $tva_npr = $datapriceofproduct['tva_npr']; From e52bde9c94eae28cbab83e4211a0222e4644f6cb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Aug 2023 23:50:07 +0200 Subject: [PATCH 07/15] Fix php 5.6 compat broken --- htdocs/takepos/receipt.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index e8844fa764a..28d35f00deb 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -111,7 +111,7 @@ if (!empty($hookmanager->resPrint)) {

global->TAKEPOS_HEADER) || !empty($conf->global->{$constFreeText})) { $newfreetext = ''; $substitutionarray = getCommonSubstitutionArray($langs); @@ -316,7 +316,7 @@ if ($conf->global->TAKEPOS_PRINT_PAYMENT_METHOD) {

global->TAKEPOS_FOOTER) || !empty($conf->global->{$constFreeText})) { $newfreetext = ''; $substitutionarray = getCommonSubstitutionArray($langs); From 3b00c76cdd01421f3bc1e8d483efebb24bc17dca Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 25 Aug 2023 15:48:15 +0200 Subject: [PATCH 08/15] FIX avoid php8 warnings --- htdocs/product/card.php | 18 ++++++++++-------- htdocs/product/class/product.class.php | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 7a177ee4e1b..708e79f1453 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -141,17 +141,18 @@ if ($id > 0 || !empty($ref)) { if ($result < 0) { dol_print_error($db, $object->error, $object->errors); } + $entity = (!empty($object->entity) ? $object->entity : $conf->entity); if (isModEnabled("product")) { - $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); + $upload_dir = $conf->product->multidir_output[$entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); } elseif (isModEnabled("service")) { - $upload_dir = $conf->service->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); + $upload_dir = $conf->service->multidir_output[$entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); } if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) { // For backward compatiblity, we scan also old dirs if (isModEnabled("product")) { - $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; + $upload_dirold = $conf->product->multidir_output[$entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; } else { - $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; + $upload_dirold = $conf->service->multidir_output[$entity].'/'.substr(substr("000".$object->id, -2), 1, 1).'/'.substr(substr("000".$object->id, -2), 0, 1).'/'.$object->id."/photos"; } } } @@ -497,10 +498,11 @@ if (empty($reshook)) { if (!$error) { $units = GETPOST('units', 'int'); - $object->ref = $ref; - $object->label = GETPOST('label', $label_security_check); - $object->price_base_type = GETPOST('price_base_type', 'aZ09'); - $object->mandatory_period = !empty(GETPOST("mandatoryperiod", 'alpha')) ? 1 : 0; + $object->entity = $conf->entity; + $object->ref = $ref; + $object->label = GETPOST('label', $label_security_check); + $object->price_base_type = GETPOST('price_base_type', 'aZ09'); + $object->mandatory_period = !empty(GETPOST("mandatoryperiod", 'alpha')) ? 1 : 0; if ($object->price_base_type == 'TTC') { $object->price_ttc = GETPOST('price'); } else { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ce0d05fd048..1dde1364e33 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -770,7 +770,7 @@ class Product extends CommonObject $sql .= ", mandatory_period"; $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($now)."'"; - $sql .= ", ".((int) $conf->entity); + $sql .= ", ".(!empty($this->entity) ? (int) $this->entity : (int) $conf->entity); $sql .= ", '".$this->db->escape($this->ref)."'"; $sql .= ", ".(!empty($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null"); $sql .= ", ".price2num($price_min_ht); From 9b16c56074580016937ee9b7cc2ef084e5facb8a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Aug 2023 10:05:33 +0200 Subject: [PATCH 09/15] Fix warning --- htdocs/core/lib/invoice.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index b532b9db108..81572f5b8d9 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -176,7 +176,7 @@ function invoice_admin_prepare_head() $head[$h][2] = 'attributeslinesrec'; $h++; - if ($conf->global->INVOICE_USE_SITUATION) { // Warning, implementation is seriously bugged and a new one not compatible is expected to become stable + if (getDolGlobalInt('INVOICE_USE_SITUATION')) { // Warning, implementation is seriously bugged and a new one not compatible is expected to become stable $head[$h][0] = DOL_URL_ROOT.'/admin/facture_situation.php'; $head[$h][1] = $langs->trans("InvoiceSituation"); $head[$h][2] = 'situation'; From 4302a6bc04233aeaba8acef9b97b68a33ff3e68f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 27 Aug 2023 15:55:44 +0200 Subject: [PATCH 10/15] Fix empty on getDolGlobal --- htdocs/admin/mails.php | 2 +- htdocs/admin/sms.php | 2 +- htdocs/admin/ticket_public.php | 4 ++-- htdocs/core/lib/admin.lib.php | 8 ++++---- test/phpunit/CodingPhpTest.php | 14 ++++++++++++-- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index b2ff1822f28..73096056f98 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -656,7 +656,7 @@ if ($action == 'edit') { if (empty($conf->global->MAIN_DISABLE_ALL_MAILS)) { // Force e-mail recipient print ''.$langs->trans("MAIN_MAIL_FORCE_SENDTO").''.getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'); - if (!empty(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'))) { + if (getDolGlobalString('MAIN_MAIL_FORCE_SENDTO')) { if (!isValidEmail(getDolGlobalString('MAIN_MAIL_FORCE_SENDTO'))) { print img_warning($langs->trans("ErrorBadEMail")); } else { diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index 391ca42a6d3..3f0d8426f8f 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -221,7 +221,7 @@ if ($action == 'edit') { // Method print ''.$langs->trans("MAIN_SMS_SENDMODE").''; - $text = empty(getDolGlobalString('MAIN_SMS_SENDMODE')) ? '' : $listofmethods[getDolGlobalString('MAIN_SMS_SENDMODE')]; + $text = getDolGlobalString('MAIN_SMS_SENDMODE') ? $listofmethods[getDolGlobalString('MAIN_SMS_SENDMODE')] : ''; if (empty($text)) { $text = $langs->trans("Undefined").' '.img_warning(); } diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 1f32fec97aa..4aae87581d4 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -318,7 +318,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { // Check if email exists print ''.$langs->trans("TicketsEmailMustExist").''; print ''; - if (empty(getDolGlobalInt('TICKET_EMAIL_MUST_EXISTS'))) { + if (!getDolGlobalInt('TICKET_EMAIL_MUST_EXISTS')) { print '' . img_picto($langs->trans('Disabled'), 'switch_off') . ''; } else { print '' . img_picto($langs->trans('Enabled'), 'switch_on') . ''; @@ -334,7 +334,7 @@ if (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { /* print ''.$langs->trans("TicketCreateThirdPartyWithContactIfNotExist").''; print ''; - if (empty(getDolGlobalInt('TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST'))) { + if (!getDolGlobalInt('TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST')) { print '' . img_picto($langs->trans('Disabled'), 'switch_off') . ''; } else { print '' . img_picto($langs->trans('Enabled'), 'switch_on') . ''; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 008aa7d2670..8764c48a770 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1330,14 +1330,14 @@ function complete_dictionary_with_modules(&$taborder, &$tabname, &$tablib, &$tab // We discard modules according to features level (PS: if module is activated we always show it) $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i', '', get_class($objMod))); - if ($objMod->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2 && empty(getDolGlobalString($const_name))) { + if ($objMod->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2 && !getDolGlobalString($const_name)) { $modulequalified = 0; } - if ($objMod->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1 && empty(getDolGlobalString($const_name))) { + if ($objMod->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1 && !getDolGlobalString($const_name)) { $modulequalified = 0; } - //If module is not activated disqualified - if (empty(getDolGlobalString($const_name))) { + // If module is not activated disqualified + if (!getDolGlobalString($const_name)) { $modulequalified = 0; } diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 952d746960b..48927666b74 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -565,7 +565,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase $ok=false; break; } - $this->assertTrue($ok, 'Found code empty($user->hasRight in file '.$file['relativename'].'. empty() must not be used with hasRight.'); + $this->assertTrue($ok, 'Found code empty($user->hasRight in file '.$file['relativename'].'. empty() must not be used on a var not on a function.'); // Test we don't have empty(DolibarrApiAccess::$user->hasRight $ok=true; @@ -575,7 +575,17 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase $ok=false; break; } - $this->assertTrue($ok, 'Found code empty(DolibarrApiAccess::$user->hasRight in file '.$file['relativename'].'. empty() must not be used with hasRight.'); + $this->assertTrue($ok, 'Found code empty(DolibarrApiAccess::$user->hasRight in file '.$file['relativename'].'. empty() must not be used on a var not on a function.'); + + // Test we don't have empty($user->hasRight + $ok=true; + $matches=array(); + preg_match_all('/empty\(getDolGlobal/', $filecontent, $matches, PREG_SET_ORDER); + foreach ($matches as $key => $val) { + $ok=false; + break; + } + $this->assertTrue($ok, 'Found code empty(getDolGlobal... in file '.$file['relativename'].'. empty() must be used on a var not on a function.'); // Test we don't have @var array( $ok=true; From bac3c364360933a8914f1dfa1487fc05339ab274 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Aug 2023 13:47:00 +0200 Subject: [PATCH 11/15] Fix warning --- htdocs/knowledgemanagement/knowledgerecord_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index ac19a73045c..9d96e51fae6 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -519,7 +519,7 @@ if (empty($reshook)) { if (!empty($moreforfilter)) { print '

'; print $moreforfilter; - $parameters = array('type'=>$type); + $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; From 37276cae5f52c6d95c4d19977ec76fda7eb2a07c Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Tue, 29 Aug 2023 17:27:50 +0200 Subject: [PATCH 12/15] FIX: payment card: misleading message when delete button disabled --- htdocs/compta/paiement/card.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 59cb153bb54..004de242952 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -522,8 +522,14 @@ if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { } } +$params = array(); + +if (! empty($title_button)) { + $params['attr'] = array('title' => $title_button); +} + if ($user->socid == 0 && $action == '') { - print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $user->rights->facture->paiement && !$disable_delete); + print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $user->rights->facture->paiement && !$disable_delete, $params); } print ''; From bb36521c3d27786d0f821c234763c588e91047ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Aug 2023 23:53:26 +0200 Subject: [PATCH 13/15] Fix warnings --- htdocs/admin/ihm.php | 2 +- htdocs/admin/modules.php | 4 ++-- htdocs/main.inc.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 1026ea12442..44d2246b547 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -300,7 +300,7 @@ if ($action == 'update') { $_SESSION["mainmenu"] = ""; // The menu manager may have changed if (GETPOST('dol_resetcache')) { - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", ((int) $conf->global->MAIN_IHM_PARAMS_REV) + 1, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity); } header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".'&mode='.$mode.(GETPOSTISSET('page_y') ? '&page_y='.GETPOST('page_y', 'int') : '')); diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 51f05be23cb..9b5336a3ed5 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -258,7 +258,7 @@ if ($action == 'install') { if ($action == 'set' && $user->admin) { $resarray = activateModule($value); - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity); if (!empty($resarray['errors'])) { setEventMessages('', $resarray['errors'], 'errors'); } else { @@ -282,7 +282,7 @@ if ($action == 'set' && $user->admin) { exit; } elseif ($action == 'reset' && $user->admin && GETPOST('confirm') == 'yes') { $result = unActivateModule($value); - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity); if ($result) { setEventMessages($result, null, 'errors'); } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 79bfd9c9886..c44fafaf58f 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1673,7 +1673,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr } // Refresh value of MAIN_IHM_PARAMS_REV before forging the parameter line. if (GETPOST('dol_resetcache')) { - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", ((int) $conf->global->MAIN_IHM_PARAMS_REV) + 1, 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", getDolGlobalInt('MAIN_IHM_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity); } $themeparam = '?lang='.$langs->defaultlang.'&theme='.$conf->theme.(GETPOST('optioncss', 'aZ09') ? '&optioncss='.GETPOST('optioncss', 'aZ09', 1) : '').(empty($user->id) ? '' : ('&userid='.$user->id)).'&entity='.$conf->entity; From dcd751aa47d165e89de25c09ecc15b97ebc61ca3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Aug 2023 00:04:07 +0200 Subject: [PATCH 14/15] FIX fatal error with bad definition of dictionaries --- htdocs/admin/dict.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index ac2a8a14528..3c536d7e310 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1674,6 +1674,9 @@ if ($id > 0) { } if (in_array($value, array('label', 'libelle', 'libelle_facture')) && empty($tabcomplete[$tabname[$id]]['help'][$value])) { + if (!is_array($tabcomplete[$tabname[$id]]['help'])) { // protection when $tabcomplete[$tabname[$id]]['help'] is a an empty string, we must force it into an array + $tabcomplete[$tabname[$id]]['help'] = array(); + } $tabcomplete[$tabname[$id]]['help'][$value] = $langs->trans('LabelUsedByDefault'); } From d2a9fe70c61d658ac40b4f8fa874890d1cf7ae2b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Sep 2023 00:36:53 +0200 Subject: [PATCH 15/15] Fix phpcs --- htdocs/compta/paiement/card.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php index 004de242952..91045ae3370 100644 --- a/htdocs/compta/paiement/card.php +++ b/htdocs/compta/paiement/card.php @@ -523,9 +523,8 @@ if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) { } $params = array(); - if (! empty($title_button)) { - $params['attr'] = array('title' => $title_button); + $params['attr'] = array('title' => $title_button); } if ($user->socid == 0 && $action == '') {