From 688d217bed7e1b4498fcf611185f03f8bd45d7a1 Mon Sep 17 00:00:00 2001 From: Givriz Date: Wed, 1 Sep 2021 16:39:28 +0200 Subject: [PATCH 1/3] Compatibility phpv8 --- htdocs/comm/card.php | 2 +- htdocs/core/class/html.form.class.php | 3 ++- htdocs/core/tpl/object_discounts.tpl.php | 4 ++-- htdocs/fourn/card.php | 9 +++++---- htdocs/fourn/commande/card.php | 4 ++-- htdocs/societe/list.php | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 015e06df36a..dd71918031a 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -1370,7 +1370,7 @@ if ($object->id > 0) { print '
'.$langs->trans("AddOrder").'
'; } - if ($user->rights->contrat->creer && $object->status == 1) { + if (!empty($user->rights->contrat->creer) && $object->status == 1) { $langs->load("contracts"); print '
'.$langs->trans("AddContract").'
'; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 265255f6e0a..188ee8c33c8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -9298,7 +9298,8 @@ class Form $retstring = $withoutdiv ? '': '
'; foreach ($buttons as $button) { - $retstring .= ''; + $addclass = empty($button['addclass']) ? '' : $button['addclass']; + $retstring .= ''; } $retstring .= $withoutdiv ? '': '
'; diff --git a/htdocs/core/tpl/object_discounts.tpl.php b/htdocs/core/tpl/object_discounts.tpl.php index 4761e5857c2..e30cd8fe72a 100644 --- a/htdocs/core/tpl/object_discounts.tpl.php +++ b/htdocs/core/tpl/object_discounts.tpl.php @@ -78,7 +78,7 @@ if ($absolute_discount > 0) { } // Is there credit notes availables ? -if ($absolute_creditnote > 0) { +if (isset($absolute_creditnote) && $absolute_creditnote > 0) { // If validated, we show link "add credit note to payment" if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut != $objclassname::STATUS_VALIDATED || $object->type == $objclassname::TYPE_CREDIT_NOTE) { $translationKey = !empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote'; @@ -104,7 +104,7 @@ if ($absolute_creditnote > 0) { } } -if ($absolute_discount <= 0 && $absolute_creditnote <= 0) { +if (!empty($absolute_creditnote) && $absolute_discount <= 0 && $absolute_creditnote <= 0) { $translationKey = !empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount'; print '
'.$langs->trans($translationKey).'.'; diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 599242375d2..971e98012b8 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -73,7 +73,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); $hookmanager->initHooks(array('suppliercard', 'globalcard')); // Security check -$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0); +$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0); if ($object->id > 0) { if (!($object->fournisseur > 0) || empty($user->rights->fournisseur->lire)) { @@ -385,7 +385,7 @@ if ($object->id > 0) { $boxstat .= ''; $boxstat .= ''; } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index fff3aa11592..328d7e3741d 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -485,7 +485,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s2 ON s.parent = s2.rowid"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if (!empty($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 (s.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays)"; From 60e4e23870c5716806c4bfb7cf697549ae92e963 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 1 Sep 2021 17:33:18 +0200 Subject: [PATCH 2/3] Update object_discounts.tpl.php --- htdocs/core/tpl/object_discounts.tpl.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/object_discounts.tpl.php b/htdocs/core/tpl/object_discounts.tpl.php index e30cd8fe72a..2bac4fca588 100644 --- a/htdocs/core/tpl/object_discounts.tpl.php +++ b/htdocs/core/tpl/object_discounts.tpl.php @@ -30,6 +30,14 @@ $objclassname = get_class($object); $isInvoice = in_array($object->element, array('facture', 'invoice', 'facture_fourn', 'invoice_supplier')); $isNewObject = empty($object->id) && empty($object->rowid); +// Clean variables not defined +if (!isset($absolute_discount)) { + $absolute_discount = 0; +} +if (!isset($absolute_creditnote)) { + $absolute_creditnote = 0; +} + // Relative and absolute discounts $addrelativediscount = ''.$langs->trans("EditRelativeDiscount").''; $addabsolutediscount = ''.$langs->trans("EditGlobalDiscounts").''; @@ -78,7 +86,7 @@ if ($absolute_discount > 0) { } // Is there credit notes availables ? -if (isset($absolute_creditnote) && $absolute_creditnote > 0) { +if ($absolute_creditnote > 0) { // If validated, we show link "add credit note to payment" if ($cannotApplyDiscount || !$isInvoice || $isNewObject || $object->statut != $objclassname::STATUS_VALIDATED || $object->type == $objclassname::TYPE_CREDIT_NOTE) { $translationKey = !empty($discount_type) ? 'HasCreditNoteFromSupplier' : 'CompanyHasCreditNote'; @@ -104,7 +112,7 @@ if (isset($absolute_creditnote) && $absolute_creditnote > 0) { } } -if (!empty($absolute_creditnote) && $absolute_discount <= 0 && $absolute_creditnote <= 0) { +if ($absolute_discount <= 0 && $absolute_creditnote <= 0) { $translationKey = !empty($discount_type) ? 'HasNoAbsoluteDiscountFromSupplier' : 'CompanyHasNoAbsoluteDiscount'; print '
'.$langs->trans($translationKey).'.'; From 1457afb9b920e0c2b90e04b8c2971b084760deb5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 1 Sep 2021 15:35:23 +0000 Subject: [PATCH 3/3] Fixing style errors. --- htdocs/core/tpl/object_discounts.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/object_discounts.tpl.php b/htdocs/core/tpl/object_discounts.tpl.php index 2bac4fca588..df565aea6f9 100644 --- a/htdocs/core/tpl/object_discounts.tpl.php +++ b/htdocs/core/tpl/object_discounts.tpl.php @@ -37,7 +37,7 @@ if (!isset($absolute_discount)) { if (!isset($absolute_creditnote)) { $absolute_creditnote = 0; } - + // Relative and absolute discounts $addrelativediscount = ''.$langs->trans("EditRelativeDiscount").''; $addabsolutediscount = ''.$langs->trans("EditGlobalDiscounts").'';
'; - if ($conf->supplier_proposal->enabled) { + if (!empty($conf->supplier_proposal->enabled)) { // Box proposals $tmp = $object->getOutstandingProposals('supplier'); $outstandingOpened = $tmp['opened']; @@ -428,6 +428,7 @@ if ($object->id > 0) { } if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)) { + $warn = ''; $tmp = $object->getOutstandingBills('supplier'); $outstandingOpened = $tmp['opened']; $outstandingTotal = $tmp['total_ht']; @@ -584,7 +585,7 @@ if ($object->id > 0) { */ $proposalstatic = new SupplierProposal($db); - if ($user->rights->supplier_proposal->lire) { + if (!empty($user->rights->supplier_proposal->lire)) { $langs->loadLangs(array("supplier_proposal")); $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.total_tva, p.total_ttc"; @@ -831,7 +832,7 @@ if ($object->id > 0) { print ''; } - if ($conf->supplier_proposal->enabled && $user->rights->supplier_proposal->creer) { + if (!empty($conf->supplier_proposal->enabled) && !empty($user->rights->supplier_proposal->creer)) { $langs->load("supplier_proposal"); if ($object->status == 1) { print ''.$langs->trans("AddSupplierProposal").''; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 6f4a591e567..9c30f75fd0a 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1591,7 +1591,7 @@ if ($action == 'create') { print '
'; print ''; print ''; - print ''; + print ''; print ''; print ''; if ($backtopage) { @@ -1693,7 +1693,7 @@ if ($action == 'create') { $langs->load('projects'); print '
'.$langs->trans('Project').''; print img_picto('', 'project').$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500'); - print '   id).'">'; + print '   id).'">'; print '