From 171ecaa81d966a11d990a424d317e0bbbe5c7a0a Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 1 Dec 2021 15:40:53 +0100 Subject: [PATCH 1/2] fix php8.0 warnings --- htdocs/reception/card.php | 1 + htdocs/reception/class/reception.class.php | 2 +- htdocs/reception/index.php | 1 + htdocs/reception/list.php | 3 ++- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 5b8727a3f0c..d9f8da644ea 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -85,6 +85,7 @@ if (empty($origin_id)) { } $ref = GETPOST('ref', 'alpha'); $line_id = GETPOST('lineid', 'int') ?GETPOST('lineid', 'int') : ''; +$facid = GETPOST('facid', 'int'); $action = GETPOST('action', 'alpha'); //Select mail models is same action as presend diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 954e7f192cd..8024bac4f36 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1120,7 +1120,7 @@ class Reception extends CommonObject $result = ''; $label = img_picto('', $this->picto).' '.$langs->trans("Reception").''; $label .= '
'.$langs->trans('Ref').': '.$this->ref; - $label .= '
'.$langs->trans('RefSupplier').': '.($this->ref_supplier ? $this->ref_supplier : $this->ref_client); + $label .= '
'.$langs->trans('RefSupplier').': '.($this->ref_supplier ? $this->ref_supplier : ''); $url = DOL_URL_ROOT.'/reception/card.php?id='.$this->id; diff --git a/htdocs/reception/index.php b/htdocs/reception/index.php index 580de4aca1a..ed5f3a715d2 100644 --- a/htdocs/reception/index.php +++ b/htdocs/reception/index.php @@ -39,6 +39,7 @@ $langs->loadLangs(array("orders", "receptions")); $reception = new Reception($db); // Security check +$socid = ''; if ($user->socid) { $socid = $user->socid; } diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index 5a6db5b53b1..00c59e47336 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -479,7 +479,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."reception as e"; -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 (e.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; @@ -878,6 +878,7 @@ print "\n"; $i = 0; $totalarray = array(); +$totalarray['nbfield'] = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); From ed7bfb333b882411d3f8c103bdf655f28dd187d0 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Wed, 1 Dec 2021 16:24:57 +0100 Subject: [PATCH 2/2] fix php8.0 errors --- htdocs/core/class/commonobject.class.php | 8 ++++---- htdocs/expedition/card.php | 18 +++++++++--------- htdocs/reception/card.php | 10 +++++----- htdocs/reception/stats/index.php | 3 ++- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9d1800af742..56537db2da9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4481,14 +4481,14 @@ abstract class CommonObject $qty = $line->qty ? $line->qty : 0; } - $weight = $line->weight ? $line->weight : 0; + $weight = !empty($line->weight) ? $line->weight : 0; ($weight == 0 && !empty($line->product->weight)) ? $weight = $line->product->weight : 0; - $volume = $line->volume ? $line->volume : 0; + $volume = !empty($line->volume) ? $line->volume : 0; ($volume == 0 && !empty($line->product->volume)) ? $volume = $line->product->volume : 0; - $weight_units = $line->weight_units; + $weight_units = !empty($line->weight_units) ? $line->weight_units : 0; ($weight_units == 0 && !empty($line->product->weight_units)) ? $weight_units = $line->product->weight_units : 0; - $volume_units = $line->volume_units; + $volume_units = !empty($line->volume_units) ? $line->volume_units : 0; ($volume_units == 0 && !empty($line->product->volume_units)) ? $volume_units = $line->product->volume_units : 0; $weightUnit = 0; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 64a080e8f6e..fe09a4c521d 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2103,7 +2103,7 @@ if ($action == 'create') { // Loop on each product to send/sent for ($i = 0; $i < $num_prod; $i++) { - $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => $editColspan, 'outputlangs' => $outputlangs); + $parameters = array('i' => $i, 'line' => $lines[$i], 'line_id' => $line_id, 'num' => $num_prod, 'alreadysent' => $alreadysent, 'editColspan' => !empty($editColspan) ? $editColspan : 0, 'outputlangs' => !empty($outputlangs) ? $outputlangs: ''); $reshook = $hookmanager->executeHooks('printObjectLine', $parameters, $object, $action); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -2143,10 +2143,10 @@ if ($action == 'create') { $product_static->weight_units = $lines[$i]->weight_units; $product_static->length = $lines[$i]->length; $product_static->length_units = $lines[$i]->length_units; - $product_static->width = $lines[$i]->width; - $product_static->width_units = $lines[$i]->width_units; - $product_static->height = $lines[$i]->height; - $product_static->height_units = $lines[$i]->height_units; + $product_static->width = !empty($lines[$i]->width) ? $lines[$i]->width : 0; + $product_static->width_units = !empty($lines[$i]->width_units) ? $lines[$i]->width_units : 0; + $product_static->height = !empty($lines[$i]->height) ? $lines[$i]->height : 0; + $product_static->height_units = !empty($lines[$i]->height_units) ? $lines[$i]->height_units : 0; $product_static->surface = $lines[$i]->surface; $product_static->surface_units = $lines[$i]->surface_units; $product_static->volume = $lines[$i]->volume; @@ -2156,7 +2156,7 @@ if ($action == 'create') { $text .= ' - '.$label; $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($lines[$i]->description)); print $form->textwithtooltip($text, $description, 3, '', '', $i); - print_date_range($lines[$i]->date_start, $lines[$i]->date_end); + print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start : '', !empty($lines[$i]->date_end) ? $lines[$i]->date_end : ''); if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { print (!empty($lines[$i]->description) && $lines[$i]->description != $lines[$i]->product) ? '
'.dol_htmlentitiesbr($lines[$i]->description) : ''; } @@ -2181,7 +2181,7 @@ if ($action == 'create') { } $unit_order = ''; - if ($conf->global->PRODUCT_USE_UNITS) { + if (!empty($conf->global->PRODUCT_USE_UNITS)) { $unit_order = measuringUnitString($lines[$i]->fk_unit); } @@ -2412,9 +2412,9 @@ if ($action == 'create') { // TODO Show all in same line by setting $display_type = 'line' if ($action == 'editline' && $line->id == $line_id) { - print $lines[$i]->showOptionals($extrafields, 'edit', array('colspan'=>$colspan), $indiceAsked, '', 0, 'card'); + print $lines[$i]->showOptionals($extrafields, 'edit', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); } else { - print $lines[$i]->showOptionals($extrafields, 'view', array('colspan'=>$colspan), $indiceAsked, '', 0, 'card'); + print $lines[$i]->showOptionals($extrafields, 'view', array('colspan'=>$colspan), !empty($indiceAsked) ? $indiceAsked : '', '', 0, 'card'); } } } diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index d9f8da644ea..c636cfb7b19 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1751,7 +1751,7 @@ if ($action == 'create') { // Loop on each product to send/sent for ($i = 0; $i < $num_prod; $i++) { - print ''; // id of order line + print ''; // id of order line print ''; // # @@ -1776,7 +1776,7 @@ if ($action == 'create') { $text .= ' - '.$label; $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($lines[$i]->product->description)); print $form->textwithtooltip($text, $description, 3, '', '', $i); - print_date_range($lines[$i]->date_start, $lines[$i]->date_end); + print_date_range(!empty($lines[$i]->date_start) ? $lines[$i]->date_start : 0, !empty($lines[$i]->date_end) ? $lines[$i]->date_end : 0); if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) { print (!empty($lines[$i]->product->description) && $lines[$i]->description != $lines[$i]->product->description) ? '
'.dol_htmlentitiesbr($lines[$i]->description) : ''; } @@ -1925,7 +1925,7 @@ if ($action == 'create') { // Weight print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { + if (!empty($lines[$i]->fk_product_type) && $lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { print $lines[$i]->product->weight * $lines[$i]->qty.' '.measuringUnitString(0, "weight", $lines[$i]->product->weight_units); } else { print ' '; @@ -1934,7 +1934,7 @@ if ($action == 'create') { // Volume print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { + if (!empty($lines[$i]->fk_product_type) && $lines[$i]->fk_product_type == Product::TYPE_PRODUCT) { print $lines[$i]->product->volume * $lines[$i]->qty.' '.measuringUnitString(0, "volume", $lines[$i]->product->volume_units); } else { print ' '; @@ -1965,7 +1965,7 @@ if ($action == 'create') { print ""; // Display lines extrafields - if (is_array($extralabelslines) && count($extralabelslines) > 0) { + if (!empty($extralabelslines) && is_array($extralabelslines) && count($extralabelslines) > 0) { $colspan = empty($conf->productbatch->enabled) ? 8 : 9; $line = new CommandeFournisseurDispatch($db); $line->id = $lines[$i]->id; diff --git a/htdocs/reception/stats/index.php b/htdocs/reception/stats/index.php index 8f20ed58065..865d0e95082 100644 --- a/htdocs/reception/stats/index.php +++ b/htdocs/reception/stats/index.php @@ -59,7 +59,7 @@ llxHeader(); print load_fiche_titre($langs->trans("StatisticsOfReceptions"), '', 'dollyrevert'); - +$dir = (!empty($conf->reception->multidir_temp[$conf->entity]) ? $conf->reception->multidir_temp[$conf->entity] : $conf->service->multidir_temp[$conf->entity]); dol_mkdir($dir); $stats = new ReceptionStats($db, $socid, '', ($userid > 0 ? $userid : 0)); @@ -78,6 +78,7 @@ if (empty($user->rights->societe->client->voir) || $user->socid) { $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); +$fileurlnb = ''; if (!$mesg) { $px1->SetData($data); $i = $startyear; $legend = array();