From 1f1e01aa88ee4a7bc72184cbeedf2f6585dedf04 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Fri, 22 Oct 2021 23:38:35 +0200 Subject: [PATCH] fix php 8 warning --- htdocs/comm/action/card.php | 2 +- htdocs/contact/list.php | 1 + htdocs/product/card.php | 7 ++-- htdocs/product/fournisseurs.php | 57 ++++++++++++++++++--------------- 4 files changed, 37 insertions(+), 30 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index e56a2e89fcf..f852d7e9938 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -2207,7 +2207,7 @@ if ($id > 0) { $delallowed = $user->rights->agenda->myactions->create; - print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $object->default_lang); + print $formfile->showdocuments('actions', $object->id, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 0, 0, '', '', '', $langs->getDefaultLang()); print '
'; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 71e888540b2..3808c651cae 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -1019,6 +1019,7 @@ print "\n"; $i = 0; $totalarray = array(); +$totalarray['nbfield'] = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index b4c951a953f..ce633975af8 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2175,8 +2175,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$langs->trans("ManageLotSerial").''; print $object->getLibStatut(0, 2); print ''; - if ((($object->status_batch == '1' && $conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') - || ($object->status_batch == '2' && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' && $conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS))) { + if ((($object->status_batch == '1' && !empty($conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS) && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') + || ($object->status_batch == '2' && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' && !empty($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS)))) { print ''.$langs->trans("ManageLotMask").''; print $object->batch_mask; print ''; @@ -2686,7 +2686,6 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete') { // Documents $objectref = dol_sanitizeFileName($object->ref); - $relativepath = $comref.'/'.$objectref.'.pdf'; if (!empty($conf->product->multidir_output[$object->entity])) { $filedir = $conf->product->multidir_output[$object->entity].'/'.$objectref; //Check repertories of current entities } else { @@ -2696,7 +2695,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete') { $genallowed = $usercanread; $delallowed = $usercancreate; - print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); + print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $langs->getDefaultLang(), '', $object); $somethingshown = $formfile->numoffiles; print '
'; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index a3ae38184e9..02e0211c01d 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -931,7 +931,7 @@ END; 'pfp.fk_availability'=>array('label'=>$langs->trans("Availability"), 'enabled' => !empty($conf->global->FOURN_PRODUCT_AVAILABILITY), 'checked'=>0, 'position'=>4), 'pfp.quantity'=>array('label'=>$langs->trans("QtyMin"), 'checked'=>1, 'position'=>5), 'pfp.unitprice'=>array('label'=>$langs->trans("UnitPriceHT"), 'checked'=>1, 'position'=>9), - 'pfp.multicurrency_unitprice'=>array('label'=>$langs->trans("UnitPriceHTCurrency"), 'enabled' => $conf->multicurrency->enabled, 'checked'=>0, 'position'=>10), + 'pfp.multicurrency_unitprice'=>array('label'=>$langs->trans("UnitPriceHTCurrency"), 'enabled' => (!empty($conf->multicurrency->enabled)), 'checked'=>0, 'position'=>10), 'pfp.delivery_time_days'=>array('label'=>$langs->trans("NbDaysToDelivery"), 'checked'=>1, 'position'=>13), 'pfp.supplier_reputation'=>array('label'=>$langs->trans("ReputationForThisProduct"), 'checked'=>1, 'position'=>14), 'pfp.fk_barcode_type'=>array('label'=>$langs->trans("BarcodeType"), 'enabled' => $conf->barcode->enabled, 'checked'=>0, 'position'=>15), @@ -942,14 +942,19 @@ END; // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label("product_fournisseur_price"); - $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; + if ($extrafields->attributes["product_fournisseur_price"] && array_key_exists('label', $extrafields->attributes["product_fournisseur_price"])) { + $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; - if (!empty($extralabels)) { - foreach ($extralabels as $key => $value) { - // Show field if not hidden - if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { - $extratitle = $langs->trans($value); - $arrayfields['ef.'.$key] = array('label'=>$extratitle, 'checked'=>0, 'position'=>(end($arrayfields)['position'] + 1), 'langfile'=>$extrafields->attributes["product_fournisseur_price"]['langfile'][$key], 'help'=>$extrafields->attributes["product_fournisseur_price"]['help'][$key]); + if (!empty($extralabels)) { + foreach ($extralabels as $key => $value) { + // Show field if not hidden + if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + $extratitle = $langs->trans($value); + $arrayfields['ef.' . $key] = array('label' => $extratitle, 'checked' => 0, + 'position' => (end($arrayfields)['position'] + 1), + 'langfile' => $extrafields->attributes["product_fournisseur_price"]['langfile'][$key], + 'help' => $extrafields->attributes["product_fournisseur_price"]['help'][$key]); + } } } } @@ -1023,29 +1028,31 @@ END; // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label("product_fournisseur_price"); - $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; + if ($extrafields->attributes["product_fournisseur_price"] && array_key_exists('label', $extrafields->attributes["product_fournisseur_price"])) { + $extralabels = $extrafields->attributes["product_fournisseur_price"]['label']; - if (!empty($extralabels)) { - foreach ($extralabels as $key => $value) { - // Show field if not hidden - if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { - if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) { - $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]); - } - if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) { - $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key])); - } else { - $extratitle = $langs->trans($value); - } - if (!empty($arrayfields['ef.'.$key]['checked'])) { - print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], 'ef.'.$key, '', $param, '', $sortfield, $sortorder, 'right '); + if (!empty($extralabels)) { + foreach ($extralabels as $key => $value) { + // Show field if not hidden + if (!empty($extrafields->attributes["product_fournisseur_price"]['list'][$key]) && $extrafields->attributes["product_fournisseur_price"]['list'][$key] != 3) { + if (!empty($extrafields->attributes["product_fournisseur_price"]['langfile'][$key])) { + $langs->load($extrafields->attributes["product_fournisseur_price"]['langfile'][$key]); + } + if (!empty($extrafields->attributes["product_fournisseur_price"]['help'][$key])) { + $extratitle = $form->textwithpicto($langs->trans($value), $langs->trans($extrafields->attributes["product_fournisseur_price"]['help'][$key])); + } else { + $extratitle = $langs->trans($value); + } + if (!empty($arrayfields['ef.' . $key]['checked'])) { + print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], 'ef.' . $key, '', $param, '', $sortfield, $sortorder, 'right '); + } } } } } if (is_object($hookmanager)) { - $parameters = array('id_fourn'=>$id_fourn, 'prod_id'=>$object->id); + $parameters = array('id_fourn'=>(!empty($id_fourn)?$id_fourn:''), 'prod_id'=>$object->id); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); @@ -1213,7 +1220,7 @@ END; } if (is_object($hookmanager)) { - $parameters = array('id_pfp'=>$productfourn->product_fourn_price_id, 'id_fourn'=>$id_fourn, 'prod_id'=>$object->id); + $parameters = array('id_pfp'=>$productfourn->product_fourn_price_id, 'id_fourn'=>(!empty($id_fourn)?$id_fourn:''), 'prod_id'=>$object->id); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); }