From 453c71efc8ef998cccba7c0237d1943300d6973e Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 21 Oct 2024 01:06:24 +0200 Subject: [PATCH] Qual: Fix phan & phpstan notices # Qual: Fix phan & phpstan notices Fix multiple phan & phpstan notices --- dev/tools/phan/baseline.txt | 27 ++++----- htdocs/core/class/cproductnature.class.php | 6 +- htdocs/expedition/dispatch.php | 8 +-- htdocs/fourn/commande/dispatch.php | 42 +++++++++---- htdocs/hrm/index.php | 19 +++--- htdocs/mrp/mo_production.php | 6 +- htdocs/product/card.php | 12 ++-- .../product/class/html.formproduct.class.php | 59 +++++++++++-------- htdocs/product/stock/movement_card.php | 2 +- htdocs/product/stock/movement_list.php | 22 ++++++- htdocs/product/stock/stockatdate.php | 48 +++++++-------- htdocs/reception/dispatch.php | 8 +-- 12 files changed, 151 insertions(+), 108 deletions(-) diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index b180a5d9434e7..1a1590a7e8271 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -15,12 +15,12 @@ return [ // PhanTypeMismatchArgumentProbablyReal : 400+ occurrences // PhanUndeclaredGlobalVariable : 350+ occurrences // PhanPluginUnknownArrayMethodReturnType : 300+ occurrences - // PhanPluginUnknownArrayMethodParamType : 250+ occurrences + // PhanPluginUnknownArrayMethodParamType : 240+ occurrences // PhanPossiblyUndeclaredVariable : 200+ occurrences - // PhanTypeMismatchProperty : 170+ occurrences + // PhanTypeMismatchProperty : 160+ occurrences // PhanPluginUnknownArrayFunctionParamType : 95+ occurrences - // PhanTypeMismatchArgumentNullableInternal : 70+ occurrences // PhanPluginUndeclaredVariableIsset : 65+ occurrences + // PhanTypeMismatchArgumentNullableInternal : 65+ occurrences // PhanPluginUnknownArrayPropertyType : 55+ occurrences // PhanPluginUnknownArrayFunctionReturnType : 50+ occurrences // PhanRedefineFunction : 50+ occurrences @@ -40,11 +40,12 @@ return [ // PhanPluginBothLiteralsBinaryOp : 8 occurrences // PhanPluginSuspiciousParamPosition : 8 occurrences // PhanPluginDuplicateExpressionBinaryOp : 7 occurrences + // PhanPossiblyNullTypeMismatchProperty : 6 occurrences // PhanParamTooMany : 5 occurrences // PhanPluginDuplicateArrayKey : 4 occurrences // PhanEmptyFQSENInClasslike : 3 occurrences // PhanInvalidFQSENInClasslike : 3 occurrences - // PhanTypeExpectedObjectPropAccessButGotNull : 3 occurrences + // PhanTypeExpectedObjectPropAccessButGotNull : 2 occurrences // PhanAccessMethodProtected : 1 occurrence // PhanTypeConversionFromArray : 1 occurrence @@ -266,7 +267,6 @@ return [ 'htdocs/core/class/commonsocialnetworks.class.php' => ['PhanUndeclaredProperty'], 'htdocs/core/class/commonstickergenerator.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayPropertyType', 'PhanPluginUnknownPropertyType'], 'htdocs/core/class/conf.class.php' => ['PhanPluginUnknownPropertyType', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchProperty'], - 'htdocs/core/class/cproductnature.class.php' => ['PhanPluginUnknownArrayPropertyType'], 'htdocs/core/class/ctypent.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/core/class/ctyperesource.class.php' => ['PhanPluginUnknownPropertyType', 'PhanUndeclaredProperty'], 'htdocs/core/class/cunits.class.php' => ['PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'], @@ -503,7 +503,7 @@ return [ 'htdocs/expedition/class/expedition.class.php' => ['PhanUndeclaredProperty'], 'htdocs/expedition/class/expeditionlinebatch.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/expedition/contact.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/expedition/dispatch.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/expedition/dispatch.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/expedition/document.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/expedition/list.php' => ['PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], 'htdocs/expedition/note.php' => ['PhanPossiblyUndeclaredGlobalVariable'], @@ -536,7 +536,7 @@ return [ 'htdocs/fourn/class/paiementfourn.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType', 'PhanPossiblyNullTypeMismatchProperty', 'PhanPossiblyUndeclaredVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/fourn/commande/card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], 'htdocs/fourn/commande/contact.php' => ['PhanUndeclaredGlobalVariable'], - 'htdocs/fourn/commande/dispatch.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeExpectedObjectPropAccessButGotNull', 'PhanTypeMismatchArgumentNullableInternal', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable'], + 'htdocs/fourn/commande/dispatch.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/fourn/commande/document.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/fourn/commande/info.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/fourn/commande/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], @@ -568,7 +568,6 @@ return [ 'htdocs/hrm/compare.php' => ['PhanPluginUnknownArrayFunctionParamType', 'PhanPluginUnknownArrayFunctionReturnType'], 'htdocs/hrm/core/tpl/objectline_view.tpl.php' => ['PhanPluginEmptyStatementIf', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/hrm/evaluation_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/hrm/index.php' => ['PhanTypeMismatchArgumentProbablyReal'], 'htdocs/hrm/job_agenda.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/hrm/job_card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/hrm/job_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], @@ -634,9 +633,9 @@ return [ 'htdocs/product/admin/product.php' => ['PhanPluginEmptyStatementIf', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/ajax/products.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], 'htdocs/product/canvas/service/actions_card_service.class.php' => ['PhanPluginUnknownPropertyType', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/product/card.php' => ['PhanPossiblyNullTypeMismatchProperty', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable'], + 'htdocs/product/card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/product/class/api_products.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanUndeclaredProperty'], - 'htdocs/product/class/html.formproduct.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], + 'htdocs/product/class/html.formproduct.class.php' => ['PhanUndeclaredProperty'], 'htdocs/product/class/product.class.php' => ['PhanPluginUnknownArrayMethodParamType'], 'htdocs/product/class/productbatch.class.php' => ['PhanPluginEmptyStatementIf', 'PhanPluginUnknownPropertyType'], 'htdocs/product/class/productcustomerprice.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownPropertyType'], @@ -664,8 +663,8 @@ return [ 'htdocs/product/stock/class/productstockentrepot.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/product/stock/info.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/product/stock/list.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredProperty'], - 'htdocs/product/stock/movement_card.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/product/stock/movement_list.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchProperty', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], + 'htdocs/product/stock/movement_card.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], + 'htdocs/product/stock/movement_list.php' => ['PhanPluginBothLiteralsBinaryOp', 'PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/product/stock/product.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/product/stock/productlot_card.php' => ['PhanUndeclaredProperty'], 'htdocs/product/stock/productlot_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], @@ -674,7 +673,7 @@ return [ 'htdocs/product/stock/stats/expedition.php' => ['PhanUndeclaredProperty'], 'htdocs/product/stock/stats/mo.php' => ['PhanUndeclaredProperty'], 'htdocs/product/stock/stats/reception.php' => ['PhanUndeclaredProperty'], - 'htdocs/product/stock/stockatdate.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/product/stock/stockatdate.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/product/stock/stocktransfer/class/stocktransferline.class.php' => ['PhanUndeclaredProperty'], 'htdocs/product/stock/stocktransfer/stocktransfer_card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/product/stock/stocktransfer/stocktransfer_list.php' => ['PhanTypeMismatchArgumentProbablyReal'], @@ -745,7 +744,7 @@ return [ 'htdocs/reception/class/reception.class.php' => ['PhanUndeclaredProperty'], 'htdocs/reception/class/receptionstats.class.php' => ['PhanPluginUnknownPropertyType'], 'htdocs/reception/contact.php' => ['PhanPossiblyUndeclaredGlobalVariable'], - 'htdocs/reception/dispatch.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/reception/dispatch.php' => ['PhanPossiblyUndeclaredGlobalVariable'], 'htdocs/reception/list.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanPossiblyUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/reception/note.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/reception/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'], diff --git a/htdocs/core/class/cproductnature.class.php b/htdocs/core/class/cproductnature.class.php index 749b07b402905..69c7f80e6c54c 100644 --- a/htdocs/core/class/cproductnature.class.php +++ b/htdocs/core/class/cproductnature.class.php @@ -33,7 +33,7 @@ class CProductNature extends CommonDict { /** - * @var array record + * @var CProductNature[] record */ public $records = array(); @@ -156,9 +156,9 @@ public function fetch($id, $code = '') * @param string $sortfield Sort field * @param int $limit Limit * @param int $offset Offset - * @param string $filter Filter USF + * @param string|array $filter Filter USF * @param string $filtermode Filter mode (AND or OR) - * @return array|int int <0 if KO, array of pages if OK + * @return CProductNature[]|int<-1,-1> int <0 if KO, array of pages if OK */ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND') { diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index a34c5dddc83a3..83961579dd85e 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -903,9 +903,9 @@ // Warehouse print ''; if (count($listwarehouses) > 1) { - print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : $objd->fk_entrepot, "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : $objd->fk_entrepot, "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, array(), 'csswarehouse'.$suffix); } elseif (count($listwarehouses) == 1) { - print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : $objd->fk_entrepot, "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : $objd->fk_entrepot, "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, array(), 'csswarehouse'.$suffix); } else { $langs->load("errors"); print $langs->trans("ErrorNoWarehouseDefined"); @@ -1053,9 +1053,9 @@ // Warehouse print ''; if (count($listwarehouses) > 1) { - print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, array(), 'csswarehouse'.$suffix); } elseif (count($listwarehouses) == 1) { - print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, array(), 'csswarehouse'.$suffix); } else { $langs->load("errors"); print $langs->trans("ErrorNoWarehouseDefined"); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 3aeac6573503a..a9e7e84677927 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -225,6 +225,7 @@ } } +$saveprice = "savepriceIsNotSet"; if ($action == 'dispatch' && $permissiontoreceive) { $error = 0; $notrigger = 0; @@ -407,6 +408,13 @@ } } +$batch = ''; +$eatby = null; +$sellby = 0; +$qty = 0; +$price = '0'; +$entrepot = 0; + // Remove a dispatched line if ($action == 'confirm_deleteline' && $confirm == 'yes' && $permissiontoreceive) { $db->begin(); @@ -570,6 +578,7 @@ $langs->load("projects"); $morehtmlref .= '
'; if (0) { + $caneditproject = false; // For static analysis $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); if ($action != 'classify' && $caneditproject) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; @@ -639,6 +648,7 @@ print '
'; + $listwarehouses = array(); if ($object->statut == CommandeFournisseur::STATUS_ORDERSENT || $object->statut == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY @@ -729,6 +739,10 @@ //$sql .= " GROUP BY p.ref, p.label, p.tobatch, p.fk_default_warehouse, l.rowid, l.fk_product, l.subprice, l.remise_percent, l.ref"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product $sql .= " ORDER BY l.rang, p.ref, p.label"; + // Nb of predefined product lines to dispatch (already done or not) if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is off (default) + // or nb of line that remain to dispatch if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is on. + $nbproduct = 0; + $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); @@ -793,9 +807,7 @@ print "\n"; } - $nbfreeproduct = 0; // Nb of lins of free products/services - $nbproduct = 0; // Nb of predefined product lines to dispatch (already done or not) if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is off (default) - // or nb of line that remain to dispatch if SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED is on. + $nbfreeproduct = 0; // Nb of lines of free products/services $conf->cache['product'] = array(); @@ -998,7 +1010,7 @@ // Qty to dispatch print ''; - if ($remaintodispatch>0) { + if ($remaintodispatch > 0) { $btnLabel = $langs->trans("Fill").' : '.$remaintodispatch; print ''; } @@ -1038,9 +1050,9 @@ // Warehouse print ''; if (count($listwarehouses) > 1) { - print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, array(), 'csswarehouse'.$suffix); } elseif (count($listwarehouses) == 1) { - print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, array(), 'csswarehouse'.$suffix); } else { $langs->load("errors"); print $langs->trans("ErrorNoWarehouseDefined"); @@ -1228,7 +1240,7 @@ print ''.$langs->trans("Comment").''; // Status - if (getDolGlobalString('SUPPLIER_ORDER_USE_DISPATCH_STATUS') && empty($reception->rowid)) { + if (getDolGlobalString('SUPPLIER_ORDER_USE_DISPATCH_STATUS') && $reception !== null && empty($reception->rowid)) { print ''.$langs->trans("Status").''; } elseif (isModEnabled("reception")) { print ''; @@ -1239,6 +1251,9 @@ print "\n"; + + $reception = null; + while ($i < $num) { $objp = $db->fetch_object($resql); @@ -1253,6 +1268,7 @@ print ''; // Reception ref + $reception = null; if (isModEnabled("reception")) { print ''; if (!empty($objp->fk_reception)) { @@ -1316,14 +1332,14 @@ } print ''; print ''; - // Warehouse print ''; if ($action == 'editline' && $lineid == $objp->dispatchlineid) { + $warehouse_id = GETPOSTINT("fk_entrepot") ? GETPOSTINT("fk_entrepot") : ($objp->warehouse_id ? $objp->warehouse_id : ''); if (count($listwarehouses) > 1) { - print $formproduct->selectWarehouses(GETPOST("fk_entrepot") ? GETPOST("fk_entrepot") : ($objp->warehouse_id ? $objp->warehouse_id : ''), "fk_entrepot", '', 1, 0, $objp->fk_product, '', 1, 1, null, 'csswarehouse'); + print $formproduct->selectWarehouses($warehouse_id, "fk_entrepot", '', 1, 0, $objp->fk_product, '', 1, 1, array(), 'csswarehouse'); } elseif (count($listwarehouses) == 1) { - print $formproduct->selectWarehouses(GETPOST("fk_entrepot") ? GETPOST("fk_entrepot") : ($objp->warehouse_id ? $objp->warehouse_id : ''), "fk_entrepot", '', 0, 0, $objp->fk_product, '', 1, 1, null, 'csswarehouse'); + print $formproduct->selectWarehouses($warehouse_id, "fk_entrepot", '', 0, 0, $objp->fk_product, '', 1, 1, array(), 'csswarehouse'); } else { $langs->load("errors"); print $langs->trans("ErrorNoWarehouseDefined"); @@ -1339,7 +1355,7 @@ print ''.$objp->comment.''; // Status - if (getDolGlobalString('SUPPLIER_ORDER_USE_DISPATCH_STATUS') && empty($reception->rowid)) { + if (getDolGlobalString('SUPPLIER_ORDER_USE_DISPATCH_STATUS') && ($reception === null || empty($reception->rowid))) { print ''; $supplierorderdispatch->status = (empty($objp->status) ? 0 : $objp->status); // print $supplierorderdispatch->status; @@ -1377,7 +1393,7 @@ print ''; } elseif (isModEnabled("reception")) { print ''; - if (!empty($reception->id)) { + if ($reception !== null && !empty($reception->id)) { print $reception->getLibStatut(5); } print ''; @@ -1385,7 +1401,7 @@ // Action if ($action != 'editline' || $lineid != $objp->dispatchlineid) { - if (empty($reception->id) || ($reception->statut == Reception::STATUS_DRAFT)) { // only allow edit on draft reception + if (($reception === null) || empty($reception->id) || ($reception->statut == Reception::STATUS_DRAFT)) { // only allow edit on draft reception print ''; print 'dispatchlineid.'#line_'.$objp->dispatchlineid.'">'; print img_edit(); diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index cea74e3718a37..dc5273803e237 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -5,6 +5,7 @@ * Copyright (C) 2015-2016 Alexandre Spangaro * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2021-2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -55,7 +56,7 @@ // Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context $hookmanager = new HookManager($db); -$hookmanager->initHooks('hrmindex'); +$hookmanager->initHooks(array('hrmindex')); // Load translation files required by the page $langs->loadLangs(array('users', 'holiday', 'trips', 'boxes')); @@ -122,15 +123,15 @@ if (getDolGlobalString('MAIN_SEARCH_FORM_ON_HOME_AREAS')) { // This is useless due to the global search combo if (isModEnabled('holiday') && $user->hasRight('holiday', 'read')) { $langs->load("holiday"); - $listofsearchfields['search_holiday'] = array('text'=>'TitreRequestCP'); + $listofsearchfields['search_holiday'] = array('text' => 'TitreRequestCP'); } if (isModEnabled('deplacement') && $user->hasRight('deplacement', 'lire')) { $langs->load("trips"); - $listofsearchfields['search_deplacement'] = array('text'=>'ExpenseReport'); + $listofsearchfields['search_deplacement'] = array('text' => 'ExpenseReport'); } if (isModEnabled('expensereport') && $user->hasRight('expensereport', 'lire')) { $langs->load("trips"); - $listofsearchfields['search_expensereport'] = array('text'=>'ExpenseReport'); + $listofsearchfields['search_expensereport'] = array('text' => 'ExpenseReport'); } if (count($listofsearchfields)) { print '
'; @@ -217,10 +218,10 @@ $userstatic = new User($db); $listhalfday = array( - 'morning'=>$langs->trans("Morning"), - 'morningshort'=>$langs->trans("Morning"), - "afternoon"=>$langs->trans("Afternoon"), - "afternoonshort"=>$langs->trans("Afternoon") + 'morning' => $langs->trans("Morning"), + 'morningshort' => $langs->trans("Morning"), + "afternoon" => $langs->trans("Afternoon"), + "afternoonshort" => $langs->trans("Afternoon") ); $typeleaves = $holidaystatic->getTypes(1, -1); @@ -384,7 +385,7 @@ $staticrecruitmentcandidature = new RecruitmentCandidature($db); $staticrecruitmentjobposition = new RecruitmentJobPosition($db); $sql = "SELECT rc.rowid, rc.ref, rc.email, rc.lastname, rc.firstname, rc.date_creation, rc.tms, rc.status,"; - $sql.= " rp.rowid as jobid, rp.ref as jobref, rp.label"; + $sql .= " rp.rowid as jobid, rp.ref as jobref, rp.label"; $sql .= " FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature as rc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."recruitment_recruitmentjobposition as rp ON rc.fk_recruitmentjobposition = rp.rowid"; if (isModEnabled('societe') && !$user->hasRight('societe', 'client', 'voir') && !$socid) { diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index e6aaf448e6e94..685ff1d11172e 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -1389,7 +1389,7 @@ if ($tmpproduct->type == Product::TYPE_PRODUCT || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { if (empty($line->disable_stock_change)) { $preselected = (GETPOSTISSET('idwarehouse-'.$line->id.'-'.$i) ? GETPOST('idwarehouse-'.$line->id.'-'.$i) : ($tmpproduct->fk_default_warehouse > 0 ? $tmpproduct->fk_default_warehouse : 'ifone')); - print $formproduct->selectWarehouses($preselected, 'idwarehouse-'.$line->id.'-'.$i, '', 1, 0, $line->fk_product, '', 1, 0, null, 'maxwidth200 csswarehouse_'.$line->id.'_'.$i); + print $formproduct->selectWarehouses($preselected, 'idwarehouse-'.$line->id.'-'.$i, '', 1, 0, $line->fk_product, '', 1, 0, array(), 'maxwidth200 csswarehouse_'.$line->id.'_'.$i); } else { print ''.$langs->trans("DisableStockChange").''; } @@ -1409,7 +1409,7 @@ if ($tmpproduct->status_batch) { $preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : ''); print ''; - print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 0, $line->fk_product, '', ''); + print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 0, $line->fk_product, 0, array()); } print ''; } @@ -1808,7 +1808,7 @@ print ''; if ($tmpproduct->type == Product::TYPE_PRODUCT || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { $preselected = (GETPOSTISSET('idwarehousetoproduce-'.$line->id.'-'.$i) ? GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) : ($object->fk_warehouse > 0 ? $object->fk_warehouse : 'ifone')); - print $formproduct->selectWarehouses($preselected, 'idwarehousetoproduce-'.$line->id.'-'.$i, '', 1, 0, $line->fk_product, '', 1, 0, null, 'maxwidth200 csswarehouse_'.$line->id.'_'.$i); + print $formproduct->selectWarehouses($preselected, 'idwarehousetoproduce-'.$line->id.'-'.$i, '', 1, 0, $line->fk_product, '', 1, 0, array(), 'maxwidth200 csswarehouse_'.$line->id.'_'.$i); } else { print ''.$langs->trans("NoStockChangeOnServices").''; } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 9e0d1f0c9b677..c542254c03726 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -513,7 +513,7 @@ $units = GETPOSTINT('units'); $object->entity = $conf->entity; - $object->ref = $ref; + $object->ref = (string) $ref; $object->label = GETPOST('label', $label_security_check); $object->price_base_type = GETPOST('price_base_type', 'aZ09'); $object->mandatory_period = !empty(GETPOST("mandatoryperiod", 'alpha')) ? 1 : 0; @@ -753,7 +753,7 @@ $object->oldcopy = dol_clone($object, 1); if (!getDolGlobalString('PRODUCT_GENERATE_REF_AFTER_FORM')) { - $object->ref = $ref; + $object->ref = (string) $ref; } $object->label = GETPOST('label', $label_security_check); @@ -772,7 +772,7 @@ $object->qc_frequency = GETPOSTINT('qc_frequency'); $object->status = GETPOSTINT('statut'); $object->status_buy = GETPOSTINT('statut_buy'); - $object->status_batch = GETPOST('status_batch', 'aZ09'); + $object->status_batch = GETPOSTINT('status_batch'); $object->sell_or_eat_by_mandatory = GETPOSTINT('sell_or_eat_by_mandatory'); $object->batch_mask = GETPOST('batch_mask', 'alpha'); $object->fk_default_warehouse = GETPOSTINT('fk_default_warehouse'); @@ -1462,10 +1462,10 @@ if (isModEnabled('productbatch')) { print ''.$langs->trans("ManageLotSerial").''; $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch"), '2' => $langs->trans("ProductStatusOnSerial")); - print $form->selectarray('status_batch', $statutarray, GETPOST('status_batch')); + print $form->selectarray('status_batch', $statutarray, GETPOSTINT('status_batch')); print ''; // Product specific batch number management - $status_batch = GETPOST('status_batch'); + $status_batch = GETPOSTINT('status_batch'); if ($status_batch !== '0') { $langs->load("admin"); $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Batch"), $langs->transnoentities("Batch")); @@ -2029,7 +2029,7 @@ print ''.$langs->trans("ManageLotSerial").''; $statutarray = array('0' => $langs->trans("ProductStatusNotOnBatch"), '1' => $langs->trans("ProductStatusOnBatch"), '2' => $langs->trans("ProductStatusOnSerial")); - print $form->selectarray('status_batch', $statutarray, GETPOSTISSET('status_batch') ? GETPOST('status_batch') : $object->status_batch); + print $form->selectarray('status_batch', $statutarray, GETPOSTISSET('status_batch') ? GETPOSTINT('status_batch') : $object->status_batch); print ''; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 98051f76b423a..acc5665fbc389 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -42,8 +42,17 @@ class FormProduct public $error = ''; // Cache arrays + /** + * @var array + */ public $cache_warehouses = array(); + /** + * @var array> + */ public $cache_lot = array(); + /** + * @var array + */ public $cache_workstations = array(); @@ -69,7 +78,7 @@ public function __construct($db) * 'warehouseclosed' = select products from closed warehouses, * 'warehouseinternal' = select products from warehouses for internal correct/transfer only * @param boolean $sumStock sum total stock of a warehouse, default true - * @param array $exclude warehouses ids to exclude + * @param int[] $exclude warehouses ids to exclude * @param bool|int $stockMin [=false] Value of minimum stock to filter (only warehouse with stock > stockMin are loaded) or false not not filter by minimum stock * @param string $orderBy [='e.ref'] Order by * @return int Nb of loaded lines, 0 if already loaded, <0 if KO @@ -180,7 +189,7 @@ public function loadWarehouses($fk_product = 0, $batch = '', $status = '', $sumS * If fk_product is not 0, we do not use cache * * @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0. - * @param array $exclude warehouses ids to exclude + * @param int[] $exclude warehouses ids to exclude * @param string $orderBy [='e.ref'] Order by * @return int Nb of loaded lines, 0 if already loaded, <0 if KO * @throws Exception @@ -239,7 +248,7 @@ public function loadWorkstations($fk_product = 0, $exclude = array(), $orderBy = * 0 : Default behavior, display parents of warehouse * 1 : Display only current warehouse label only * 2 : Display last parent warehouse label - * @param array $tab warehouse data in $this->cache_warehouses line + * @param array{id:int,label:string,parent_id:int,description:string,stock:string,full_label:string} $tab warehouse data in $this->cache_warehouses line * @param string $final_label full label with all parents, separated by ' >> ' (completed on each call) * @return string full label with all parents, separated by ' >> ' */ @@ -268,25 +277,25 @@ private function get_parent_path($tab, $final_label = '') /** * Return list of warehouses * - * @param string|int|array $selected Id of preselected warehouse ('' or '-1' for no value, 'ifone' and 'ifonenodefault' = select value if one value otherwise no value, '-2' to use the default value from setup) + * @param ''|'-1'|'ifone'|'ifonenodefault'|'-2'|string|int|int[] $selected Id of preselected warehouse ('' or '-1' for no value, 'ifone' and 'ifonenodefault' = select value if one value otherwise no value, '-2' to use the default value from setup) * @param string $htmlname Name of html select html * @param string $filterstatus warehouse status filter, following comma separated filter options can be used * 'warehouseopen' = select products from open warehouses, * 'warehouseclosed' = select products from closed warehouses, * 'warehouseinternal' = select products from warehouses for internal correct/transfer only - * @param int $empty 1=Can be empty, 0 if not - * @param int $disabled 1=Select is disabled + * @param int<0,1> $empty 1=Can be empty, 0 if not + * @param int<0,1> $disabled 1=Select is disabled * @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0. * @param string $empty_label Empty label if needed (only if $empty=1) - * @param int $showstock 1=Show stock count - * @param int $forcecombo 1=Force combo iso ajax select2 - * @param array $events Events to add to select2 + * @param int<0,1> $showstock 1=Show stock count + * @param int<0,1> $forcecombo 1=Force combo iso ajax select2 + * @param array}> $events Events to add to select2 * @param string $morecss Add more css classes to HTML select - * @param array $exclude Warehouses ids to exclude + * @param int[] $exclude Warehouses ids to exclude * @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse * @param bool|int $stockMin [=false] Value of minimum stock to filter (only warehouse with stock > stockMin are loaded) or false not not filter by minimum stock * @param string $orderBy [='e.ref'] Order by - * @param int $multiselect 1=Allow multiselect + * @param int<0,1> $multiselect 1=Allow multiselect * @return string HTML select * * @throws Exception @@ -401,15 +410,15 @@ public function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $fil * * @param string|int $selected Id of preselected warehouse ('' or '-1' for no value, 'ifone' and 'ifonenodefault' = select value if one value otherwise no value, '-2' to use the default value from setup) * @param string $htmlname Name of html select html - * @param int $empty 1=Can be empty, 0 if not - * @param int $disabled 1=Select is disabled + * @param int<0,1> $empty 1=Can be empty, 0 if not + * @param int<0,1> $disabled 1=Select is disabled * @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0. * @param string $empty_label Empty label if needed (only if $empty=1) - * @param int $forcecombo 1=Force combo iso ajax select2 - * @param array $events Events to add to select2 - * @param string $morecss Add more css classes to HTML select - * @param array $exclude Warehouses ids to exclude - * @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse + * @param int<0,1> $forcecombo 1=Force combo iso ajax select2 + * @param array}> $events Events to add to select2 + * @param string $morecss Add more css classes to HTML select + * @param int[] $exclude Warehouses ids to exclude + * @param int<0,1> $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse * @param string $orderBy [='e.ref'] Order by * @return string HTML select * @@ -501,7 +510,7 @@ public function selectWorkstations($selected = '', $htmlname = 'idworkstations', * @param string $page Page * @param string|int $selected Id of warehouse * @param string $htmlname Name of select html field - * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. + * @param int<0,2> $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @return void */ public function formSelectWarehouses($page, $selected = '', $htmlname = 'warehouse_id', $addempty = 0) @@ -556,9 +565,9 @@ public function select_measuring_units($name = 'measuring_units', $measuring_sty * @param string $measuring_style Unit to show: weight, size, surface, volume, time * @param string $selected Preselected value * @param int|string $adddefault 1=Add empty unit called "Default", ''=Add empty value - * @param int $mode 1=Use short label as value, 0=Use rowid, 2=Use scale (power) + * @param int<0,2> $mode 1=Use short label as value, 0=Use rowid, 2=Use scale (power) * @param string $morecss More CSS - * @return string|-1 + * @return string|int<-1,-1> */ public function selectMeasuringUnits($name = 'measuring_units', $measuring_style = '', $selected = '0', $adddefault = 0, $mode = 0, $morecss = 'minwidth75 maxwidth125') { @@ -706,10 +715,10 @@ public function selectProductNature($name = 'finished', $selected = '', $mode = * @param int $disabled 1=Select is disabled * @param int $fk_product show lot numbers of product with id fk_product. All from objectLines if 0. * @param int $fk_entrepot filter lot numbers for warehouse with id fk_entrepot. All if 0. - * @param array $objectLines Only cache lot numbers for products in lines of object. If no lines only for fk_product. If no fk_product, all. + * @param CommonObjectLine[] $objectLines Only cache lot numbers for products in lines of object. If no lines only for fk_product. If no fk_product, all. * @param string $empty_label Empty label if needed (only if $empty=1) * @param int $forcecombo 1=Force combo iso ajax select2 - * @param array $events Events to add to select2 + * @param array}> $events Events to add to select2 * @param string $morecss Add more css classes to HTML select * * @return string HTML select @@ -794,7 +803,7 @@ public function selectLotStock($selected = '', $htmlname = 'batch_id', $filterst * @param int $empty 1=Can be empty, 0 if not * @param int $fk_product show lot numbers of product with id fk_product. All from objectLines if 0. * @param int $fk_entrepot filter lot numbers for warehouse with id fk_entrepot. All if 0. - * @param array $objectLines Only cache lot numbers for products in lines of object. If no lines only for fk_product. If no fk_product, all. + * @param CommonObjectLine[] $objectLines Only cache lot numbers for products in lines of object. If no lines only for fk_product. If no fk_product, all. * @return string HTML datalist */ public function selectLotDataList($htmlname = 'batch_id', $empty = 0, $fk_product = 0, $fk_entrepot = 0, $objectLines = array()) @@ -864,7 +873,7 @@ public function selectLotDataList($htmlname = 'batch_id', $empty = 0, $fk_produc /** * Load in cache array list of lot available in stock from a given list of products * - * @param array $productIdArray array of product id's from who to get lot numbers. A + * @param int[] $productIdArray array of product id's from who to get lot numbers. A * * @return int Nb of loaded lines, 0 if nothing loaded, <0 if KO */ diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index 4b9367c8d2e01..40cfb94546a71 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -837,7 +837,7 @@ if (!empty($arrayfields['e.ref']['checked'])) { print ''; //print ''; - print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); + print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'maxwidth200'); print ''; } if (!empty($arrayfields['m.fk_user_author']['checked'])) { diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index 312ff77436719..c876eab1a5695 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -325,7 +325,8 @@ } if ($action == 'update_extras' && $permissiontoadd) { - $tmpwarehouse->oldcopy = dol_clone($tmpwarehouse, 2); + $whClass = get_class($whClass); + $whClass::$oldcopy = dol_clone($tmpwarehouse, 2); // Fill array 'array_options' with data from update form $ret = $extrafields->setOptionalsFromPost(null, $tmpwarehouse, GETPOST('attribute', 'restricthtml')); @@ -344,6 +345,13 @@ } } +$batch = ''; +$eatby = null; +$sellby = 0; +$qty = 0; +$price = '0'; +$entrepot = 0; + // Correct stock if ($action == "correct_stock" && $permissiontoadd) { $product = new Product($db); @@ -505,6 +513,8 @@ $sellby = $d_sellby; } + $result1 = -1; + $result2 = -1; if (!$error) { // Remove stock $result1 = $product->correct_stock_batch( @@ -608,6 +618,8 @@ if ($resql) { $num = $db->num_rows($resql); $i = 0; + $hasSuccess = false; + $hasError = false; while ($i < $num) { $obj = $db->fetch_object($resql); $object->fetch($obj->rowid); @@ -638,6 +650,8 @@ $formproduct = new FormProduct($db); if (isModEnabled('project')) { $formproject = new FormProjets($db); +} else { + $formproject = null; } $productlot = new Productlot($db); $productstatic = new Product($db); @@ -838,7 +852,7 @@ $morehtmlref .= $langs->trans("LocationSummary").' : '.$warehouse->lieu; // Project - if (isModEnabled('project')) { + if (isModEnabled('project') && $formproject !== null) { $langs->load("projects"); $morehtmlref .= '
'.img_picto('', 'project').' '.$langs->trans('Project').' '; if ($usercancreate && 1 == 2) { @@ -922,6 +936,8 @@ $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; $sql .= " WHERE m.fk_entrepot = ".((int) $warehouse->id); $resqlbis = $db->query($sql); + + $lastmovementdate = 0; if ($resqlbis) { $objbis = $db->fetch_object($resqlbis); $lastmovementdate = $db->jdate($objbis->datem); @@ -1209,7 +1225,7 @@ if (!empty($arrayfields['e.ref']['checked'])) { print ''; //print ''; - print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, null, 'maxwidth200'); + print $formproduct->selectWarehouses($search_warehouse, 'search_warehouse', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'maxwidth200'); print ''; } if (!empty($arrayfields['m.fk_user_author']['checked'])) { diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index 900b1d475c2f4..b5510929e51e4 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -49,7 +49,7 @@ $type = GETPOSTINT('type'); $mode = GETPOST('mode', 'alpha'); -$ext=(GETPOSTISSET('output') && in_array(GETPOST('output'), array('csv'))) ? GETPOST('output') : ''; +$ext = (GETPOSTISSET('output') && in_array(GETPOST('output'), array('csv'))) ? GETPOST('output') : ''; $date = ''; $dateendofday = ''; @@ -250,8 +250,8 @@ $movements_prod_warehouse_nb[$fk_product][$fk_entrepot] = $nbofmovement; // Pour llx_product.stock - $movements_prod[$fk_product] = $stock + (array_key_exists($fk_product, $movements_prod)?$movements_prod[$fk_product]:0); - $movements_prod_nb[$fk_product] = $nbofmovement + (array_key_exists($fk_product, $movements_prod_nb)?$movements_prod_nb[$fk_product]:0); + $movements_prod[$fk_product] = $stock + (array_key_exists($fk_product, $movements_prod) ? $movements_prod[$fk_product] : 0); + $movements_prod_nb[$fk_product] = $nbofmovement + (array_key_exists($fk_product, $movements_prod_nb) ? $movements_prod_nb[$fk_product] : 0); $i++; } @@ -371,11 +371,11 @@ if ($ext == 'csv') { top_httphead("text/csv"); //header("Content-Type: text/csv"); - header("Content-Disposition: attachment; filename=stock".($date?'-'.date("Y-m-d", $date):'').".csv"); + header("Content-Disposition: attachment; filename=stock".($date ? '-'.date("Y-m-d", $date) : '').".csv"); // Lines of title print implode(";", ($mode == 'future') ? - array('"Product Reference"', '"Label"', '"Current Stock"', '"'.$stocklabel.'"', '"Virtual Stock"'): + array('"Product Reference"', '"Label"', '"Current Stock"', '"'.$stocklabel.'"', '"Virtual Stock"') : array('"Product Reference"', '"Label"', '"'.$stocklabel.'"', '"Estimated Stock Value"', '"Estimate Sell Value"', '"Movements"', '"Current Stock"'))."\r\n"; } else { llxHeader('', $title, $helpurl, '', 0, 0, '', '', '', 'mod-product page-stock_stockatdate'); @@ -421,7 +421,7 @@ print img_picto('', 'stock', 'class="pictofixedwidth"').$langs->trans("Warehouse").' :'; print ' '; $selected = ((GETPOSTISSET('search_fk_warehouse') || GETPOSTISSET('fk_warehouse')) ? $search_fk_warehouse : 'ifonenodefault'); - print $formproduct->selectWarehouses($selected, 'search_fk_warehouse', '', 1, 0, 0, $langs->trans('Warehouse'), 0, 0, null, 'minwidth200', null, 1, false, 'e.ref', 1); + print $formproduct->selectWarehouses($selected, 'search_fk_warehouse', '', 1, 0, 0, $langs->trans('Warehouse'), 0, 0, array(), 'minwidth200', array(), 1, false, 'e.ref', 1); } print ''; @@ -473,13 +473,13 @@ if ($num) { print '

'; print ''; print img_picto('', 'download', 'class="pictofixedwidth"'); print 'Download CSV'; @@ -508,7 +508,7 @@ print ''; } // Fields from hook - $parameters = array('param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $parameters = array('param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -545,7 +545,7 @@ } // Hook fields - $parameters = array('param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $parameters = array('param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -638,8 +638,8 @@ '"'.$objp->ref.'"', '"'.$objp->label.'"', '"'.price(price2num($stock, 'MS')).'"', - price2num($stock * $objp->pmp, 'MT')?'"'.price2num($stock * $objp->pmp, 'MT').'"':'', - !getDolGlobalString('PRODUIT_MULTIPRICES')?'"'.price2num($stock * $objp->price, 'MT').'"':'"'.$langs->trans("Variable").'('.$langs->trans("OptionMULTIPRICESIsOn").')"', + price2num($stock * $objp->pmp, 'MT') ? '"'.price2num($stock * $objp->pmp, 'MT').'"' : '', + !getDolGlobalString('PRODUIT_MULTIPRICES') ? '"'.price2num($stock * $objp->price, 'MT').'"' : '"'.$langs->trans("Variable").'('.$langs->trans("OptionMULTIPRICESIsOn").')"', "$nbofmovement", '"'.price2num($currentstock, 'MS').'"'))."\r\n"; $totalbuyingprice += $stock * $objp->pmp; @@ -737,7 +737,7 @@ $totalcurrentstock += $currentstock; // Fields from hook - $parameters = array('objp'=>$objp); + $parameters = array('objp' => $objp); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; @@ -750,9 +750,9 @@ $i++; } -$parameters = array('sql'=>$sql); +$parameters = array('sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook -if ($ext!='csv') { +if ($ext != 'csv') { print $hookmanager->resPrint; } @@ -761,22 +761,24 @@ $colspan++; } -if ($ext=='csv') { - print implode(";", - ($mode == 'future')?array( +if ($ext == 'csv') { + print implode( + ";", + ($mode == 'future') ? array( '"'.$langs->trans("Totalforthispage").'"', '', $productid > 0 ? price2num($totalcurrentstock, 'MS') : '', '', - price(price2num($totalvirtualstock, 'MS'))): + price(price2num($totalvirtualstock, 'MS'))) : array( '"'.$langs->trans("Totalforthispage").'"', '', '', '"'.price2num($totalbuyingprice, 'MT').'"', - !getDolGlobalString('PRODUIT_MULTIPRICES')?'"'.price2num($totalsellingprice, 'MT').'"':'', + !getDolGlobalString('PRODUIT_MULTIPRICES') ? '"'.price2num($totalsellingprice, 'MT').'"' : '', '', - $productid > 0 ? price2num($totalcurrentstock, 'MS') : '')); + $productid > 0 ? price2num($totalcurrentstock, 'MS') : '') + ); } else { if (empty($date) || !$dateIsValid) { print ''.$langs->trans("EnterADateCriteria").''; diff --git a/htdocs/reception/dispatch.php b/htdocs/reception/dispatch.php index e53b525be5584..0f152e82cfcd0 100644 --- a/htdocs/reception/dispatch.php +++ b/htdocs/reception/dispatch.php @@ -840,9 +840,9 @@ // Warehouse print ''; if (count($listwarehouses) > 1) { - print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : $objd->fk_entrepot, "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : $objd->fk_entrepot, "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, array(), 'csswarehouse'.$suffix); } elseif (count($listwarehouses) == 1) { - print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : $objd->fk_entrepot, "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : $objd->fk_entrepot, "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, array(), 'csswarehouse'.$suffix); } else { $langs->load("errors"); print $langs->trans("ErrorNoWarehouseDefined"); @@ -1013,9 +1013,9 @@ // Warehouse print ''; if (count($listwarehouses) > 1) { - print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 1, 0, $objp->fk_product, '', 1, 0, array(), 'csswarehouse'.$suffix); } elseif (count($listwarehouses) == 1) { - print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, null, 'csswarehouse'.$suffix); + print $formproduct->selectWarehouses(GETPOST("entrepot".$suffix) ? GETPOST("entrepot".$suffix) : ($objp->fk_default_warehouse ? $objp->fk_default_warehouse : ''), "entrepot".$suffix, '', 0, 0, $objp->fk_product, '', 1, 0, array(), 'csswarehouse'.$suffix); } else { $langs->load("errors"); print $langs->trans("ErrorNoWarehouseDefined");