From b534fbae77bfe951fc36cf21cdc6aedf55a7aa14 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 28 Jun 2021 19:12:19 +0200 Subject: [PATCH 1/8] Fix warning php 8 in product ajax. --- htdocs/product/ajax/products.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index ac2e70e3287..77acafbbd55 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -235,7 +235,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) { // When used from jQuery, the search term is added as GET param "term". $searchkey = (($idprod && GETPOST($idprod, 'alpha')) ? GETPOST($idprod, 'alpha') : (GETPOST($htmlname, 'alpha') ? GETPOST($htmlname, 'alpha') : '')); - if (!is_object($form)) { + if (!isset($form) || !is_object($form)) { $form = new Form($db); } From 9b59f264fd873129fe50990415187a399cfb51a8 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Mon, 28 Jun 2021 20:00:10 +0200 Subject: [PATCH 2/8] Fix some php 8 warning --- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/tpl/object_discounts.tpl.php | 2 +- htdocs/core/tpl/objectline_create.tpl.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index b3ed477596c..33e2ed8b972 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7778,7 +7778,7 @@ class Form print ''; print ''; print ''; - print ''.(!empty($objp->ref_client) ? $objp->ref_client : $objp->ref_supplier).''; + print ''.(!empty($objp->ref_client) ? $objp->ref_client : (!empty($objp->ref_supplier) ? $objp->ref_supplier : '')).''; print ''; if ($possiblelink['label'] == 'LinkToContract') { $form = new Form($this->db); diff --git a/htdocs/core/tpl/object_discounts.tpl.php b/htdocs/core/tpl/object_discounts.tpl.php index e5bf1e1017c..4761e5857c2 100644 --- a/htdocs/core/tpl/object_discounts.tpl.php +++ b/htdocs/core/tpl/object_discounts.tpl.php @@ -53,7 +53,7 @@ if ($isNewObject) { // Is there is commercial discount or down payment available ? if ($absolute_discount > 0) { - if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut > $objclassname::STATUS_DRAFT || $object->type == $objclassname::TYPE_CREDIT_NOTE || $object->type == $objclassname::TYPE_DEPOSIT) { + if (!empty($cannotApplyDiscount) || !$isInvoice || $isNewObject || $object->statut > $objclassname::STATUS_DRAFT || $object->type == $objclassname::TYPE_CREDIT_NOTE || $object->type == $objclassname::TYPE_DEPOSIT) { $translationKey = !empty($discount_type) ? 'HasAbsoluteDiscountFromSupplier' : 'CompanyHasAbsoluteDiscount'; $text = $langs->trans($translationKey, price($absolute_discount), $langs->transnoentities("Currency".$conf->currency)).'.'; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index e181acd16e1..474b1a24957 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -128,7 +128,7 @@ if ($nolinesbefore) { trans('ReductionShort'); ?> situation_cycle_ref) { + if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) { print ''.$langs->trans('Progress').''; print ''; } @@ -416,7 +416,7 @@ if ($nolinesbefore) { ?> ">% situation_cycle_ref) { + if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) { $coldisplay++; print '%'; $coldisplay++; From b83f57da4897b22406602a4f06a96d93a322afe1 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Tue, 29 Jun 2021 16:26:48 +0200 Subject: [PATCH 3/8] Fix some proposal php 8 warning --- htdocs/comm/index.php | 2 ++ htdocs/comm/propal/class/propal.class.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 0a39e596ba3..9d0d9f1befc 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -65,6 +65,8 @@ $socid = GETPOST("socid", 'int'); if ($user->socid > 0) { $action = ''; $id = $user->socid; +} else { + $id = 0; } restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6c670c82364..940e0156c7e 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -2535,12 +2535,12 @@ class Propal extends CommonObject $resql = $this->db->query($sql); if ($resql) { // Status self::STATUS_REFUSED by default - $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->model_pdf; + $modelpdf = !empty($conf->global->PROPALE_ADDON_PDF_ODT_CLOSED) ? $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED : $this->model_pdf; $trigger_name = 'PROPAL_CLOSE_REFUSED'; if ($status == self::STATUS_SIGNED) { // Status self::STATUS_SIGNED $trigger_name = 'PROPAL_CLOSE_SIGNED'; - $modelpdf = $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL:$this->model_pdf; + $modelpdf = !empty($conf->global->PROPALE_ADDON_PDF_ODT_TOBILL) ? $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL : $this->model_pdf; // The connected company is classified as a client $soc=new Societe($this->db); From b8f5dc74d70bcb831a1690712562d2b6ba243fa6 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Tue, 29 Jun 2021 16:30:36 +0200 Subject: [PATCH 4/8] Some order php 8 warning --- htdocs/commande/class/commande.class.php | 2 +- htdocs/commande/tpl/linkedobjectblock.tpl.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 2805f4556d3..f601606be33 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1368,7 +1368,7 @@ class Commande extends CommonOrder } // Possibility to add external linked objects with hooks $this->linked_objects[$this->origin] = $this->origin_id; - if (is_array($object->other_linked_objects) && !empty($object->other_linked_objects)) { + if (isset($object->other_linked_objects) && is_array($object->other_linked_objects) && !empty($object->other_linked_objects)) { $this->linked_objects = array_merge($this->linked_objects, $object->other_linked_objects); } diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 428589aa844..a0641c4c493 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -47,7 +47,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) { } echo ''; echo ''.$langs->trans("CustomerOrder"); - if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { + if (!empty($showImportButton) && !empty($conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES)) { print ' '; From e4f61d430f9dc55aa8a630cf70c5cf11d0133547 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Tue, 29 Jun 2021 16:33:24 +0200 Subject: [PATCH 5/8] Invoice php 8 issue and warnings. Seems if ("" < 0) is true in php 8 --- htdocs/compta/facture/card.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 585cabc1be4..6ec837fe1d1 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -112,7 +112,12 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object if ($id > 0 || !empty($ref)) { if ($action != 'add') { - $ret = $object->fetch($id, $ref, '', '', $conf->global->INVOICE_USE_SITUATION); + if (empty($conf->global->INVOICE_USE_SITUATION)) { + $fetch_situation = false; + } else { + $fetch_situation = true; + } + $ret = $object->fetch($id, $ref, '', '', $fetch_situation); } } @@ -607,7 +612,7 @@ if (empty($reshook)) { } // Check for mandatory fields in invoice - $array_to_check = array('REF_CUSTOMER'=>'RefCustomer'); + $array_to_check = array('REF_CLIENT'=>'RefCustomer'); foreach ($array_to_check as $key => $val) { $keymin = strtolower($key); $vallabel = $object->$keymin; @@ -2362,21 +2367,22 @@ if (empty($reshook)) { $line = new FactureLigne($db); $line->fetch(GETPOST('lineid', 'int')); $percent = $line->get_prev_progress($object->id); + $progress = floatval(GETPOST('progress', 'int')); if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->situation_cycle_ref > 0) { // in case of situation credit note - if (GETPOST('progress') >= 0) { + if ($progress >= 0) { $mesg = $langs->trans("CantBeNullOrPositive"); setEventMessages($mesg, null, 'warnings'); $error++; $result = -1; - } elseif (GETPOST('progress') < $line->situation_percent) { // TODO : use a modified $line->get_prev_progress($object->id) result + } elseif ($progress < $line->situation_percent) { // TODO : use a modified $line->get_prev_progress($object->id) result $mesg = $langs->trans("CantBeLessThanMinPercent"); setEventMessages($mesg, null, 'warnings'); $error++; $result = -1; } - } elseif (GETPOST('progress') < $percent) { + } elseif ($progress < $percent) { $mesg = '
'.$langs->trans("CantBeLessThanMinPercent").'
'; setEventMessages($mesg, null, 'warnings'); $error++; From 051bb3f3ef8d7f31706f81457a6435af235581f6 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Tue, 29 Jun 2021 16:37:07 +0200 Subject: [PATCH 6/8] Fix some core php8 warnings. Fixing php 8 warnings seems also to solve some situations like a paiment condition removed from dictionary can not be selected. --- htdocs/core/class/html.form.class.php | 7 ++++++- htdocs/core/tpl/ajaxrow.tpl.php | 1 - htdocs/core/tpl/objectline_title.tpl.php | 2 +- htdocs/core/tpl/objectline_view.tpl.php | 4 ++-- htdocs/langs/en_US/errors.lang | 1 + 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 33e2ed8b972..0b1504d229a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5085,7 +5085,12 @@ class Form } else { if ($selected) { $this->load_cache_conditions_paiements(); - print $this->cache_conditions_paiements[$selected]['label']; + if (isset($this->cache_conditions_paiements[$selected])) { + print $this->cache_conditions_paiements[$selected]['label']; + } else { + $langs->load('errors'); + print $langs->trans('ErrorNotInDictionaryPaymentConditions'); + } } else { print " "; } diff --git a/htdocs/core/tpl/ajaxrow.tpl.php b/htdocs/core/tpl/ajaxrow.tpl.php index 6d6df3a5408..88c643c641d 100644 --- a/htdocs/core/tpl/ajaxrow.tpl.php +++ b/htdocs/core/tpl/ajaxrow.tpl.php @@ -79,7 +79,6 @@ $(document).ready(function(){ function() { console.log("tableDND end of ajax call"); if (reloadpage == 1) { - //console.log(''); global->PRODUCT_USE_UNITS)) { print ''.$langs->trans('ReductionShort').''; // Fields for situation invoice -if ($this->situation_cycle_ref) { +if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) { print ''.$langs->trans('Progress').''; print ''.$form->textwithpicto($langs->trans('TotalHT100Short'), $langs->trans('UnitPriceXQtyLessDiscount')).''; } diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 8e9d72d40b4..3b4bb3cfdcb 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -132,7 +132,7 @@ if (($line->info_bits & 2) == 2) { } } } else { - $format = $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE ? 'dayhour' : 'day'; + $format = (isset($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) && $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 'dayhour' : 'day'; if ($line->fk_product > 0) { print $form->textwithtooltip($text, $description, 3, '', '', $i, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : '')); @@ -288,7 +288,7 @@ if (!empty($line->remise_percent) && $line->special_code != 3) { } // Fields for situation invoices -if ($this->situation_cycle_ref) { +if (isset($this->situation_cycle_ref) && $this->situation_cycle_ref) { include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $coldisplay++; print ''.$line->situation_percent.'%'; diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index c4e8a1d7226..3ed7441afa5 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -301,3 +301,4 @@ ErrorActionCommPropertyUserowneridNotDefined=User's owner is required ErrorActionCommBadType=Selected event type (id: %n, code: %s) do not exist in Event Type dictionary CheckVersionFail=Version check fail ErrorWrongFileName=Name of the file cannot have __SOMETHING__ in it +ErrorNotInDictionaryPaymentConditions=Not in Payment Terms Dictionary, please modify. From 56787bc292074f4f576b1386f1c3073a246c8971 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Jun 2021 19:14:03 +0200 Subject: [PATCH 7/8] Update card.php --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 265f515233f..1f6a03ca351 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2367,7 +2367,7 @@ if (empty($reshook)) { $line = new FactureLigne($db); $line->fetch(GETPOST('lineid', 'int')); $percent = $line->get_prev_progress($object->id); - $progress = floatval(GETPOST('progress', 'int')); + $progress = price2num(GETPOST('progress', 'alpha')); if ($object->type == Facture::TYPE_CREDIT_NOTE && $object->situation_cycle_ref > 0) { // in case of situation credit note From 2860e12b6558c1bb5dfd39a1e9072b530ad70ffb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Jun 2021 19:16:29 +0200 Subject: [PATCH 8/8] Update objectline_view.tpl.php --- htdocs/core/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 3b4bb3cfdcb..c0339c28fc4 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -132,7 +132,7 @@ if (($line->info_bits & 2) == 2) { } } } else { - $format = (isset($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) && $conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 'dayhour' : 'day'; + $format = (!empty($conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE) ? 'dayhour' : 'day'); if ($line->fk_product > 0) { print $form->textwithtooltip($text, $description, 3, '', '', $i, 0, (!empty($line->fk_parent_line) ?img_picto('', 'rightarrow') : ''));