From 1c4a7a00cbcdc1bd8db5022f4321efc3124ef96d Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller Date: Tue, 30 Nov 2021 16:35:46 +0100 Subject: [PATCH] fix php8.0 warning --- htdocs/expedition/card.php | 1 + htdocs/expedition/index.php | 1 + htdocs/expedition/list.php | 2 +- htdocs/product/stats/card.php | 2 +- htdocs/product/stock/list.php | 9 ++++++--- htdocs/product/stock/massstockmove.php | 8 ++++++++ htdocs/product/stock/movement_list.php | 8 +++++++- htdocs/product/stock/productlot_list.php | 16 ++++++++++------ 8 files changed, 35 insertions(+), 12 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 64a080e8f6e..f077d9360de 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -81,6 +81,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'); $confirm = GETPOST('confirm', 'alpha'); diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index 49777518509..8a992e0c7ec 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; $hookmanager = new HookManager($db); +$socid = GETPOST('socid', 'int'); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $hookmanager->initHooks(array('sendingindex')); diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index ac5704511ef..f569501d440 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -253,7 +253,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."expedition 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']) && sis_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)"; } if ($sall || $search_product_category > 0) { diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index d2d9f289fd1..463297f043a 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -276,7 +276,7 @@ if ($result || !($id > 0)) { print '
'; // Generation of graphs - $dir = (!empty($conf->product->multidir_temp[$object->entity]) ? $conf->product->multidir_temp[$object->entity] : $conf->service->multidir_temp[$object->entity]); + $dir = (!empty($conf->product->multidir_temp[$conf->entity]) ? $conf->product->multidir_temp[$conf->entity] : $conf->service->multidir_temp[$conf->entity]); if ($object->id > 0) { // We are on statistics for a dedicated product if (!file_exists($dir.'/'.$object->id)) { if (dol_mkdir($dir.'/'.$object->id) < 0) { diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index bfd96716bb7..52c18c9cc97 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -78,7 +78,7 @@ if (!$sortorder) { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new Entrepot($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->inventory->dir_output.'/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('stocklist')); // Fetch optionals attributes and labels @@ -228,7 +228,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (!empty($conf->categorie->enabled)) { $sql .= Categorie::getFilterJoinQuery(Categorie::TYPE_WAREHOUSE, "t.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 (t.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON t.rowid = ps.fk_entrepot"; @@ -473,7 +473,7 @@ foreach ($object->fields as $key => $val) { } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { - print ''; + print ''; } print ''; } @@ -622,6 +622,9 @@ while ($i < min($num, $limit)) { } print ''; if (!$i) { + if (!isset($totalarray['nbfield'])) { + $totalarray['nbfield'] = 0; + } $totalarray['nbfield']++; } if (!empty($val['isameasure']) && $val['isameasure'] == 1) { diff --git a/htdocs/product/stock/massstockmove.php b/htdocs/product/stock/massstockmove.php index d7bd8bee9b4..781f2037dba 100644 --- a/htdocs/product/stock/massstockmove.php +++ b/htdocs/product/stock/massstockmove.php @@ -486,28 +486,36 @@ if (!empty($conf->global->MAIN_UPLOAD_DOC)) { $max = $conf->global->MAIN_UPLOAD_DOC; // In Kb $maxphp = @ini_get('upload_max_filesize'); // In unknown if (preg_match('/k$/i', $maxphp)) { + $maxphp = preg_replace('/k$/i', '', $maxphp); $maxphp = $maxphp * 1; } if (preg_match('/m$/i', $maxphp)) { + $maxphp = preg_replace('/m$/i', '', $maxphp); $maxphp = $maxphp * 1024; } if (preg_match('/g$/i', $maxphp)) { + $maxphp = preg_replace('/g$/i', '', $maxphp); $maxphp = $maxphp * 1024 * 1024; } if (preg_match('/t$/i', $maxphp)) { + $maxphp = preg_replace('/t$/i', '', $maxphp); $maxphp = $maxphp * 1024 * 1024 * 1024; } $maxphp2 = @ini_get('post_max_size'); // In unknown if (preg_match('/k$/i', $maxphp2)) { + $maxphp2 = preg_replace('/k$/i', '', $maxphp2); $maxphp2 = $maxphp2 * 1; } if (preg_match('/m$/i', $maxphp2)) { + $maxphp2 = preg_replace('/m$/i', '', $maxphp2); $maxphp2 = $maxphp2 * 1024; } if (preg_match('/g$/i', $maxphp2)) { + $maxphp2 = preg_replace('/g$/i', '', $maxphp2); $maxphp2 = $maxphp2 * 1024 * 1024; } if (preg_match('/t$/i', $maxphp2)) { + $maxphp2 = preg_replace('/t$/i', '', $maxphp2); $maxphp2 = $maxphp2 * 1024 * 1024 * 1024; } // Now $max and $maxphp and $maxphp2 are in Kb diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 7d261a73f7a..06d470b9b57 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -68,6 +68,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $result = restrictedArea($user, 'stock'); $idproduct = GETPOST('idproduct', 'int'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_date_startday = GETPOST('search_date_startday', 'int'); $search_date_startmonth = GETPOST('search_date_startmonth', 'int'); $search_date_startyear = GETPOST('search_date_startyear', 'int'); @@ -87,6 +88,8 @@ $search_batch = trim(GETPOST("search_batch")); $search_qty = trim(GETPOST("search_qty")); $search_type_mouvement = GETPOST('search_type_mouvement', 'int'); $search_fk_projet=GETPOST("search_fk_projet", 'int'); +$optioncss = GETPOST('optioncss', 'alpha'); +$type = GETPOST("type", "int"); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -498,7 +501,7 @@ $sql .= $hookmanager->resPrint; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql .= " ".MAIN_DB_PREFIX."product as p,"; $sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m"; -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 (m.rowid = ef.fk_object)"; } $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid"; @@ -1298,6 +1301,9 @@ while ($i < min($num, $limit)) { } print ''; if (!$i) { + if (!isset($totalarray['nbfield'])) { + $totalarray['nbfield'] = 0; + } $totalarray['nbfield']++; } diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 3c987cd1cfa..5e85daf06ba 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -37,6 +37,7 @@ $langs->loadLangs(array('stocks', 'productbatch', 'other', 'users')); // Get parameters $id = GETPOST('id', 'int'); $action = GETPOST('action', 'aZ09'); +$massaction = GETPOST('massaction', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'productlotlist'; // To manage different context of search @@ -64,7 +65,7 @@ $pagenext = $page + 1; // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array $object = new Productlot($db); $extrafields = new ExtraFields($db); -$diroutputmassaction = $conf->mymodule->dir_output.'/temp/massgeneration/'.$user->id; +$diroutputmassaction = $conf->productbatch->dir_output.'/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('product_lotlist')); // Fetch optionals attributes and labels @@ -215,7 +216,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { +if ( !empty($extrafields->attributes[$object->table_element]['label']) && ($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 (t.rowid = ef.fk_object)"; } if ($object->ismultientitymanaged == 1) { @@ -340,7 +341,7 @@ $arrayofmassactions = array( //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); -if ($permissiontodelete) { +if (!empty($permissiontodelete)) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { @@ -424,9 +425,9 @@ foreach ($object->fields as $key => $val) { if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); } elseif (strpos($val['type'], 'integer:') === 0) { - print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); + print $object->showInputField($val, $key, !empty($search[$key])?$search[$key]:0, '', '', 'search_', 'maxwidth150', 1); } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { - print ''; + print ''; } print ''; } @@ -477,7 +478,7 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { +if (!empty($extrafields->attributes[$object->table_element]['computed']) && is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { if (preg_match('/\$object/', $val)) { $needToFetchEachLine++; // There is at least one compute field that use $object @@ -535,6 +536,9 @@ while ($i < ($limit ? min($num, $limit) : $num)) { } print ''; if (!$i) { + if (!isset($totalarray['nbfield'])) { + $totalarray['nbfield'] = 0; + } $totalarray['nbfield']++; } if (!empty($val['isameasure']) && $val['isameasure'] == 1) {