diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index e4d6b885ce3..a12f0d94454 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,15 +9,15 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgument : 2050+ occurrences + // PhanTypeMismatchArgument : 2000+ occurrences // PhanUndeclaredProperty : 520+ occurrences - // PhanTypeMismatchArgumentNullable : 410+ occurrences + // PhanTypeMismatchArgumentNullable : 400+ occurrences // PhanUndeclaredGlobalVariable : 180+ occurrences // PhanPluginUnknownArrayMethodReturnType : 170+ occurrences // PhanTypeMismatchProperty : 130+ occurrences - // PhanPossiblyUndeclaredGlobalVariable : 120+ occurrences // PhanPluginUnknownArrayMethodParamType : 110+ occurrences // PhanTypeMismatchArgumentProbablyReal : 110+ occurrences + // PhanPossiblyUndeclaredGlobalVariable : 100+ occurrences // PhanRedefineFunction : 40+ occurrences // PhanTypeExpectedObjectPropAccess : 40+ occurrences // PhanTypeInvalidDimOffset : 25+ occurrences @@ -453,8 +453,7 @@ return [ 'htdocs/core/modules/propale/doc/pdf_cyan.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'], 'htdocs/core/modules/reception/doc/pdf_squille.modules.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredProperty'], 'htdocs/core/modules/societe/doc/doc_generic_odt.modules.php' => ['PhanTypeMismatchArgumentNullable'], - 'htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], - 'htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php' => ['PhanTypeMismatchArgumentNullable'], + 'htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php' => ['PhanUndeclaredProperty'], 'htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php' => ['PhanUndeclaredProperty'], 'htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php' => ['PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchProperty'], 'htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php' => ['PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchDimFetch', 'PhanTypeMismatchProperty', 'PhanUndeclaredProperty'], @@ -604,19 +603,13 @@ return [ 'htdocs/product/stock/list.php' => ['PhanUndeclaredProperty'], 'htdocs/product/stock/movement_card.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], 'htdocs/product/stock/movement_list.php' => ['PhanPluginUndeclaredVariableIsset', 'PhanUndeclaredGlobalVariable', 'PhanUndeclaredProperty'], - 'htdocs/product/stock/product.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/product/stock/productlot_card.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], - 'htdocs/product/stock/productlot_list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/product/stock/replenish.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/product/stock/stats/commande_fournisseur.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], - 'htdocs/product/stock/stats/expedition.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], - 'htdocs/product/stock/stats/mo.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], - 'htdocs/product/stock/stats/reception.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], - 'htdocs/product/stock/stockatdate.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgumentNullable'], - 'htdocs/product/stock/stocktransfer/class/stocktransferline.class.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], - 'htdocs/product/stock/stocktransfer/stocktransfer_card.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredGlobalVariable'], - 'htdocs/product/stock/stocktransfer/stocktransfer_contact.php' => ['PhanTypeMismatchArgument'], - 'htdocs/product/stock/stocktransfer/stocktransfer_list.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'], + 'htdocs/product/stock/productlot_card.php' => ['PhanUndeclaredProperty'], + 'htdocs/product/stock/stats/commande_fournisseur.php' => ['PhanUndeclaredProperty'], + 'htdocs/product/stock/stats/expedition.php' => ['PhanUndeclaredProperty'], + 'htdocs/product/stock/stats/mo.php' => ['PhanUndeclaredProperty'], + 'htdocs/product/stock/stats/reception.php' => ['PhanUndeclaredProperty'], + 'htdocs/product/stock/stocktransfer/class/stocktransferline.class.php' => ['PhanUndeclaredProperty'], + 'htdocs/product/stock/stocktransfer/stocktransfer_card.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/product/stock/tpl/stockcorrection.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/product/stock/tpl/stocktransfer.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/projet/activity/perday.php' => ['PhanTypeMismatchArgument'], diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ac2eb622bd2..537a0be605b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2659,7 +2659,7 @@ class Form * * @param int $selected Preselected products * @param string $htmlname Name of HTML select field (must be unique in page). - * @param int|string $filtertype Filter on product type (''=nofilter, 0=product, 1=service) + * @param int|'' $filtertype Filter on product type (''=nofilter, 0=product, 1=service) * @param int $limit Limit on number of returned lines * @param int $price_level Level of price to show * @param int<-1,1> $status Sell status: -1=No filter on sell status, 0=Products not on sell, 1=Products on sell diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php index 4413d742a92..77b6299e775 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php @@ -401,7 +401,7 @@ class pdf_eagle extends ModelePDFStockTransfer if (!empty($object->tracking_url)) { if ($object->shipping_method_id > 0) { // Get code using getLabelFromKey - $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); + $code = $outputlangs->getLabelFromKey($this->db, (string) $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); $label = ''; if ($object->tracking_url != $object->tracking_number) { $label .= $outputlangs->trans("LinkToTrackYourPackage")."
"; @@ -636,7 +636,7 @@ class pdf_eagle extends ModelePDFStockTransfer // Qty $pdf->SetXY($this->posxqty, $curY); - $pdf->writeHTMLCell($this->posxwarehousesource - $this->posxqty + 2, 3, $this->posxqty - 1, $curY, $object->lines[$i]->qty, 0, 0, false, true, 'C'); + $pdf->writeHTMLCell($this->posxwarehousesource - $this->posxqty + 2, 3, $this->posxqty - 1, $curY, (string) $object->lines[$i]->qty, 0, 0, false, true, 'C'); //$pdf->MultiCell(($this->posxwarehousesource - $this->posxqty), 3, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt,'','C'); // Warehouse source @@ -847,7 +847,7 @@ class pdf_eagle extends ModelePDFStockTransfer if (!getDolGlobalString('STOCKTRANSFER_PDF_HIDE_ORDERED')) { $pdf->SetXY($this->posxqty, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($this->posxwarehousesource - $this->posxqty, $tab2_hl, $totalQty, 0, 'C', true); + $pdf->MultiCell($this->posxwarehousesource - $this->posxqty, $tab2_hl, (string) $totalQty, 0, 'C', true); } if (getDolGlobalString('STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT')) { diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php index 9856be325d4..1b63623c86b 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php @@ -365,7 +365,7 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer } // Displays notes - $notetoshow = empty($object->note_public) ? '' : $object->note_public; + $notetoshow = empty($object->note_public) ? '' : (string) $object->note_public; if (getDolGlobalString('MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE')) { // Get first sale rep if (is_object($object->thirdparty)) { diff --git a/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php b/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php index 0bc819da50b..fde24100654 100644 --- a/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php +++ b/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php @@ -5,7 +5,7 @@ * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -126,7 +126,7 @@ class mod_stocktransfer_advanced extends ModeleNumRefStockTransfer /** * Return next free value * - * @param StockTransfer $object Object we need next value for + * @param StockTransfer|StockTransferLine $object Object we need next value for * @return string|int<-1,0> Value if OK, 0 if KO */ public function getNextValue($object) diff --git a/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php b/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php index e2f2335cb82..46d77a2f7c7 100644 --- a/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php +++ b/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2024-2025 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -123,7 +123,7 @@ class mod_stocktransfer_standard extends ModeleNumRefStockTransfer /** * Return next free value * - * @param StockTransfer $object Object we need next value for + * @param StockTransfer|StockTransferLine $object Object we need next value for * @return string|int<-1,0> Value if OK, 0 if KO */ public function getNextValue($object) diff --git a/htdocs/core/modules/stocktransfer/modules_stocktransfer.php b/htdocs/core/modules/stocktransfer/modules_stocktransfer.php index a11976bb280..1aa2d3905d7 100644 --- a/htdocs/core/modules/stocktransfer/modules_stocktransfer.php +++ b/htdocs/core/modules/stocktransfer/modules_stocktransfer.php @@ -7,7 +7,7 @@ * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2014 Marcos García * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -86,7 +86,7 @@ abstract class ModeleNumRefStockTransfer extends CommonNumRefGenerator /** * Return next free value * - * @param StockTransfer $object Object we need next value for + * @param StockTransfer|StockTransferLine $object Object we need next value for * @return string|int<-1,0> Value if OK, 0 if KO */ abstract public function getNextValue($object); diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 6d66d54c92e..a3c19abd5d3 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -10,7 +10,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -305,10 +305,10 @@ if ($action == "correct_stock" && !$cancel && $usercanupdatestock) { $result = $object->correct_stock_batch( $user, GETPOSTINT("id_entrepot"), - $nbpiece, + (float) $nbpiece, GETPOSTINT("mouvement"), GETPOST("label", 'alphanohtml'), // label movement - $priceunit, + (float) $priceunit, $d_eatby, $d_sellby, $batchnumber, @@ -321,10 +321,10 @@ if ($action == "correct_stock" && !$cancel && $usercanupdatestock) { $result = $object->correct_stock( $user, GETPOSTINT("id_entrepot"), - $nbpiece, + (float) $nbpiece, GETPOSTINT("mouvement"), GETPOST("label", 'alphanohtml'), - $priceunit, + (float) $priceunit, GETPOST('inventorycode', 'alphanohtml'), $origin_element, $origin_id, @@ -375,11 +375,16 @@ if ($action == "transfert_stock" && !$cancel && $usercanupdatestock) { $action = 'transfert'; } } + $batch = ''; + $sellby = 0; + $eatby = 0; if (!$error) { if ($id) { $object = new Product($db); $result = $object->fetch($id); + $result1 = -1; + $result2 = -1; $db->begin(); @@ -397,6 +402,8 @@ if ($action == "transfert_stock" && !$cancel && $usercanupdatestock) { if ($object->hasbatch()) { $pdluo = new Productbatch($db); + $srcwarehouseid = 0; + if ($pdluoid > 0) { $result = $pdluo->fetch($pdluoid); if ($result) { @@ -422,7 +429,7 @@ if ($action == "transfert_stock" && !$cancel && $usercanupdatestock) { $result1 = $object->correct_stock_batch( $user, $srcwarehouseid, - $nbpiece, + (float) $nbpiece, 1, GETPOST("label", 'alphanohtml'), $pricesrc, @@ -440,13 +447,13 @@ if ($action == "transfert_stock" && !$cancel && $usercanupdatestock) { $result2 = $object->correct_stock_batch( $user, GETPOSTINT("id_entrepot_destination"), - $nbpiece, + (float) $nbpiece, 0, GETPOST("label", 'alphanohtml'), $pricedest, $eatby, $sellby, - $batch, + (string) $batch, GETPOST('inventorycode', 'alphanohtml') ); if ($result2 < 0) { @@ -459,7 +466,7 @@ if ($action == "transfert_stock" && !$cancel && $usercanupdatestock) { $result1 = $object->correct_stock( $user, GETPOSTINT("id_entrepot"), - $nbpiece, + (float) $nbpiece, 1, GETPOST("label", 'alphanohtml'), $pricesrc, @@ -474,7 +481,7 @@ if ($action == "transfert_stock" && !$cancel && $usercanupdatestock) { $result2 = $object->correct_stock( $user, GETPOSTINT("id_entrepot_destination"), - $nbpiece, + (float) $nbpiece, 0, GETPOST("label", 'alphanohtml'), $pricedest, @@ -543,10 +550,13 @@ if ($action == 'updateline' && GETPOST('save') == $langs->trans("Save") && $user $form = new Form($db); $formproduct = new FormProduct($db); +$formproject = null; if (isModEnabled('project')) { $formproject = new FormProjets($db); } + +$variants = false; if ($id > 0 || $ref) { $object = new Product($db); $result = $object->fetch($id, $ref); @@ -645,7 +655,7 @@ if ($id > 0 || $ref) { if (isModEnabled("product") && isModEnabled("service")) { $typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); print ''; - print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, 0, $typeformat) : $langs->trans('Type'); + print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', (string) $object->type, $object, 0, $typeformat) : $langs->trans('Type'); print ''; print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat); print ''; @@ -667,7 +677,7 @@ if ($id > 0 || $ref) { print ''; print $form->editfieldval($text, 'cost_price', '', $object, 0, 'amount:6'); } else { - print $form->editfieldkey($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); + print $form->editfieldkey($text, 'cost_price', (string) $object->cost_price, $object, (int) $usercancreate, 'amount:6'); print ''; print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6'); } @@ -746,12 +756,12 @@ if ($id > 0 || $ref) { print ''; // Stock alert threshold - print ''; // Desired stock - print ''; @@ -891,6 +901,7 @@ if ($id > 0 || $ref) { $sql = "SELECT max(m.datem) as datem"; $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; $sql .= " WHERE m.fk_product = ".((int) $object->id); + $lastmovementdate = 0; $resqlbis = $db->query($sql); if ($resqlbis) { $obj = $db->fetch_object($resqlbis); diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index a21f6041664..7ef691049c2 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -608,7 +608,7 @@ if ($action != 'presend') { $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed = $usercanread; // If you can read, you can build the PDF to read content $delallowed = $usercancreate; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('product_batch', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', 0, '', (empty($object->default_lang) ? '' : $object->default_lang), '', $object); + print $formfile->showdocuments('product_batch', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', '', '', (empty($object->default_lang) ? '' : $object->default_lang), '', $object); } print '
'; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index e6164d741d3..ca502f5cae7 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2016 Laurent Destailleur * Copyright (C) 2018-2021 Ferran Marcet * Copyright (C) 2019-2024 Frédéric France + * Copyright (C) 2025 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 @@ -122,11 +123,11 @@ foreach ($object->fields as $key => $val) { if (!empty($val['visible'])) { $visible = (int) dol_eval((string) $val['visible'], 1); $arrayfields['t.'.$key] = array( - 'label'=>$val['label'], - 'checked'=>(($visible < 0) ? 0 : 1), - 'enabled'=>(abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), - 'position'=>$val['position'], - 'help'=> isset($val['help']) ? $val['help'] : '' + 'label' => $val['label'], + 'checked' => (($visible < 0) ? 0 : 1), + 'enabled' => (abs($visible) != 3 && (bool) dol_eval($val['enabled'], 1)), + 'position' => $val['position'], + 'help' => isset($val['help']) ? $val['help'] : '' ); } } @@ -526,7 +527,7 @@ foreach ($object->fields as $key => $val) { } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2); + print $formadmin->select_language($search[$key], 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2); } else { print ''; } @@ -537,7 +538,7 @@ foreach ($object->fields as $key => $val) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters = array('arrayfields'=>$arrayfields); +$parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; /*if (!empty($arrayfields['anotherfield']['checked'])) { @@ -581,7 +582,7 @@ foreach ($object->fields as $key => $val) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); +$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column @@ -655,13 +656,13 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['t.'.$key]['checked'])) { print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; + print ' title="'.dol_escape_htmltag((string) $object->$key).'"'; } print '>'; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'rowid') { - print $object->showOutputField($val, $key, $object->id, ''); + print $object->showOutputField($val, $key, (string) $object->id, ''); } else { if ($key == 'batch') { print $object->getNomUrl(1); @@ -690,7 +691,7 @@ while ($i < $imaxinloop) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column @@ -731,7 +732,7 @@ if ($num == 0) { $db->free($resql); -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 1f0a72aeb43..b242e522acd 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -7,7 +7,7 @@ * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2021 Ferran Marcet * Copyright (C) 2021 Antonin MARCHAL - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -80,6 +80,7 @@ $fk_entrepot = GETPOSTINT('fk_entrepot'); // List all visible warehouses $resWar = $db->query("SELECT rowid FROM " . MAIN_DB_PREFIX . "entrepot WHERE entity IN (" . $db->sanitize(getEntity('stock')) . ")"); $listofqualifiedwarehousesid = ""; +$lastWarehouseID = 0; $count = 0; while ($tmpobj = $db->fetch_object($resWar)) { if (!empty($listofqualifiedwarehousesid)) { @@ -286,10 +287,10 @@ if ($action == 'order' && GETPOST('valid') && $user->hasRight('fournisseur', 'co 0, $line->type, 0, - false, - null, - null, 0, + null, + null, + array(), $line->fk_unit, $line->multicurrency_subprice ); @@ -855,7 +856,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) { exit; } - $prod->load_stock('warehouseopen, warehouseinternal'.(!$usevirtualstock ? ', novirtual' : ''), $draftchecked); + $prod->load_stock('warehouseopen, warehouseinternal'.(!$usevirtualstock ? ', novirtual' : ''), $draftchecked === 'checked' ? 1 : 0); // Multilangs if (getDolGlobalInt('MAIN_MULTILANGS')) { diff --git a/htdocs/product/stock/stats/commande_fournisseur.php b/htdocs/product/stock/stats/commande_fournisseur.php index ce07ee4a3de..8bf1ba453f3 100644 --- a/htdocs/product/stock/stats/commande_fournisseur.php +++ b/htdocs/product/stock/stats/commande_fournisseur.php @@ -6,6 +6,7 @@ * Copyright (C) 2014 Florian Henry * Copyright (C) 2023 Gauthier VERDOL * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 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 @@ -241,10 +242,10 @@ if ($id > 0 || !empty($ref)) { $sql .= " WHERE cf.entity IN (".getEntity('product').")"; $sql .= " AND cfdi.batch = '".($db->escape($object->batch))."'"; if (!empty($search_month)) { - $sql .= ' AND MONTH(cf.date_commande) IN ('.$db->sanitize($search_month).')'; + $sql .= ' AND MONTH(cf.date_commande) IN ('.$db->sanitize((string) $search_month).')'; } if (!empty($search_year)) { - $sql .= ' AND YEAR(cf.date_commande) IN ('.$db->sanitize($search_year).')'; + $sql .= ' AND YEAR(cf.date_commande) IN ('.$db->sanitize((string) $search_year).')'; } if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); @@ -300,7 +301,7 @@ if ($id > 0 || !empty($ref)) { print '
'; print $langs->trans('Period').' ('.$langs->trans("OrderDate").') - '; print $langs->trans('Month').': '; - print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Year').':'.$formother->selectyear($search_year ? (string) $search_year : '-1', 'search_year', 1, 20, 5); print '
'; print ''; print ''; diff --git a/htdocs/product/stock/stats/expedition.php b/htdocs/product/stock/stats/expedition.php index 98e95f94520..b7e8e77a5f1 100644 --- a/htdocs/product/stock/stats/expedition.php +++ b/htdocs/product/stock/stats/expedition.php @@ -6,6 +6,7 @@ * Copyright (C) 2014 Florian Henry * Copyright (C) 2023 Gauthier VERDOL * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 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 @@ -241,10 +242,10 @@ if ($id > 0 || !empty($ref)) { $sql .= " WHERE exp.entity IN (".getEntity('product').")"; $sql .= " AND db.batch = '".($db->escape($object->batch))."'"; if (!empty($search_month)) { - $sql .= ' AND MONTH(exp.date_creation) IN ('.$db->sanitize($search_month).')'; + $sql .= ' AND MONTH(exp.date_creation) IN ('.$db->sanitize((string) $search_month).')'; } if (!empty($search_year)) { - $sql .= ' AND YEAR(exp.date_creation) IN ('.$db->sanitize($search_year).')'; + $sql .= ' AND YEAR(exp.date_creation) IN ('.$db->sanitize((string) $search_year).')'; } if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); @@ -299,7 +300,7 @@ if ($id > 0 || !empty($ref)) { print '
'; print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; print $langs->trans('Month').': '; - print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Year').':'.$formother->selectyear($search_year ? (string) $search_year : '-1', 'search_year', 1, 20, 5); print '
'; print ''; print ''; diff --git a/htdocs/product/stock/stats/mo.php b/htdocs/product/stock/stats/mo.php index b1a3477871b..933de644b1f 100644 --- a/htdocs/product/stock/stats/mo.php +++ b/htdocs/product/stock/stats/mo.php @@ -188,10 +188,10 @@ if ($id > 0 || !empty($ref)) { $sql .= " AND c.entity IN (".getEntity('mo').")"; $sql .= " AND cd.batch = '".($db->escape($object->batch))."'"; if (!empty($search_month)) { - $sql .= ' AND MONTH(c.date_valid) IN ('.$db->sanitize($search_month).')'; + $sql .= ' AND MONTH(c.date_valid) IN ('.$db->sanitize((string) $search_month).')'; } if (!empty($search_year)) { - $sql .= ' AND YEAR(c.date_valid) IN ('.$db->sanitize($search_year).')'; + $sql .= ' AND YEAR(c.date_valid) IN ('.$db->sanitize((string) $search_year).')'; } if ($socid > 0) { $sql .= " AND s.rowid = ".((int) $socid); @@ -245,7 +245,7 @@ if ($id > 0 || !empty($ref)) { print '
'; print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; print $langs->trans('Month').': '; - print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Year').':'.$formother->selectyear($search_year ? (string) $search_year : '-1', 'search_year', 1, 20, 5); print '
'; print ''; print ''; diff --git a/htdocs/product/stock/stats/reception.php b/htdocs/product/stock/stats/reception.php index 00eae3cb6aa..bbd3c4f129f 100644 --- a/htdocs/product/stock/stats/reception.php +++ b/htdocs/product/stock/stats/reception.php @@ -6,6 +6,7 @@ * Copyright (C) 2014 Florian Henry * Copyright (C) 2023 Gauthier VERDOL * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 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 @@ -240,10 +241,10 @@ if ($id > 0 || !empty($ref)) { $sql .= " WHERE recep.entity IN (".getEntity('product').")"; $sql .= " AND d.batch = '".($db->escape($object->batch))."'"; if (!empty($search_month)) { - $sql .= ' AND MONTH(recep.date_creation) IN ('.$db->sanitize($search_month).')'; + $sql .= ' AND MONTH(recep.date_creation) IN ('.$db->sanitize((string) $search_month).')'; } if (!empty($search_year)) { - $sql .= ' AND YEAR(recep.date_creation) IN ('.$db->sanitize($search_year).')'; + $sql .= ' AND YEAR(recep.date_creation) IN ('.$db->sanitize((string) $search_year).')'; } if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); @@ -298,7 +299,7 @@ if ($id > 0 || !empty($ref)) { print '
'; print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - '; print $langs->trans('Month').': '; - print $langs->trans('Year').':'.$formother->selectyear($search_year ? $search_year : - 1, 'search_year', 1, 20, 5); + print $langs->trans('Year').':'.$formother->selectyear($search_year ? (string) $search_year : '-1', 'search_year', 1, 20, 5); print '
'; print ''; print ''; diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index 1ae34e47050..0c25b9bb8ba 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -5,7 +5,7 @@ * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2016 ATM Consulting * Copyright (C) 2019-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -612,6 +612,8 @@ while ($i < ($limit ? min($num, $limit) : $num)) { //} } + $nbofmovement = 0; + $virtualstock = 0; if ($mode == 'future') { $prod->load_stock('warehouseopen,warehouseinternal,nobatch', 0, $dateendofday); $stock = $prod->stock_theorique; // virtual stock at a date @@ -619,7 +621,6 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $virtualstock = $prod->stock_theorique; // virtual stock in infinite future } else { $stock = $currentstock; - $nbofmovement = 0; if (!empty($search_fk_warehouse)) { foreach ($search_fk_warehouse as $val) { $stock -= empty($movements_prod_warehouse[$objp->rowid][$val]) ? 0 : $movements_prod_warehouse[$objp->rowid][$val]; diff --git a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php index f4bc5fa55c7..a9b6de52bf7 100644 --- a/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php +++ b/htdocs/product/stock/stocktransfer/class/stocktransferline.class.php @@ -1,9 +1,8 @@ * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) ---Put here your own copyright and developer email--- * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 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 @@ -457,7 +456,7 @@ class StockTransferLine extends CommonObjectLine $user, $p->id, $fk_entrepot, - $op[$direction], + (float) $op[$direction], $direction, empty($direction) ? $this->pmp : 0, $label, @@ -484,7 +483,7 @@ class StockTransferLine extends CommonObjectLine $user, $p->id, $fk_entrepot, - $op[$direction], + (float) $op[$direction], $direction, empty($direction) ? $this->pmp : 0, $label, diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_card.php b/htdocs/product/stock/stocktransfer/stocktransfer_card.php index 5e17dbc626e..32edbcc2494 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_card.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_card.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -647,7 +647,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action != 'classify') { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; } - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); } else { if (!empty($object->fk_project)) { $proj = new Project($db); @@ -941,9 +941,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $filtertype = ''; } if (getDolGlobalInt('PRODUIT_LIMIT_SIZE') <= 0) { - $limit = ''; + $limit = 0; } else { - $limit = getDolGlobalString('PRODUIT_LIMIT_SIZE'); + $limit = getDolGlobalInt('PRODUIT_LIMIT_SIZE'); } $form->select_produits($fk_product, 'fk_product', $filtertype, $limit, 0, -1, 2, '', 0, array(), 0, 0, 0, 'minwidth200imp maxwidth300', 1); diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_contact.php b/htdocs/product/stock/stocktransfer/stocktransfer_contact.php index aab6d493cc7..dfae3f2f121 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_contact.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_contact.php @@ -5,6 +5,7 @@ * Copyright (C) 2011-2015 Philippe Grand * Copyright (C) 2021 Gauthier VERDOL * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 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 @@ -123,7 +124,7 @@ if ($action == 'addcontact' && $user->hasRight('stocktransfer', 'stocktransfer', } } elseif ($action == 'swapstatut' && $user->hasRight('stocktransfer', 'stocktransfer', 'write')) { // Toggle the status of a contact if ($object->id > 0) { - $result = $object->swapContactStatus(GETPOST('ligne')); + $result = $object->swapContactStatus(GETPOSTINT('ligne')); } } elseif ($action == 'deletecontact' && $user->hasRight('stocktransfer', 'stocktransfer', 'write')) { // Deletes a contact $result = $object->delete_contact($lineid); diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_list.php b/htdocs/product/stock/stocktransfer/stocktransfer_list.php index c108ba11a80..cef55ad167c 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_list.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_list.php @@ -1,8 +1,8 @@ * Copyright (C) 2021 Gauthier VERDOL - * Copyright (C) ---Put here your own copyright and developer email--- * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 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 @@ -523,7 +523,7 @@ foreach ($object->fields as $key => $val) { } elseif ($key == 'lang') { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; $formadmin = new FormAdmin($db); - print $formadmin->select_language($search[$key], 'search_lang', 0, null, 1, 0, 0, 'minwidth100imp maxwidth125', 2); + print $formadmin->select_language($search[$key], 'search_lang', 0, array(), 1, 0, 0, 'minwidth100imp maxwidth125', 2); } else { print ''; } @@ -534,7 +534,7 @@ foreach ($object->fields as $key => $val) { include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Fields from hook -$parameters = array('arrayfields'=>$arrayfields); +$parameters = array('arrayfields' => $arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column @@ -577,7 +577,7 @@ foreach ($object->fields as $key => $val) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray'=>&$totalarray); +$parameters = array('arrayfields' => $arrayfields, 'param' => $param, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column @@ -676,13 +676,13 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['t.'.$key]['checked'])) { print '$key)) { - print ' title="'.dol_escape_htmltag($object->$key).'"'; + print ' title="'.dol_escape_htmltag((string) $object->$key).'"'; } print '>'; if ($key == 'status') { print $object->getLibStatut(5); } elseif ($key == 'rowid') { - print $object->showOutputField($val, $key, $object->id, ''); + print $object->showOutputField($val, $key, (string) $object->id, ''); } else { print $object->showOutputField($val, $key, $object->$key, ''); } @@ -707,7 +707,7 @@ while ($i < $imaxinloop) { // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php'; // Fields from hook - $parameters = array('arrayfields'=>$arrayfields, 'object'=>$object, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray); + $parameters = array('arrayfields' => $arrayfields, 'object' => $object, 'obj' => $obj, 'i' => $i, 'totalarray' => &$totalarray); $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column @@ -749,7 +749,7 @@ if ($num == 0) { $db->free($resql); -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint;
'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1), 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->hasRight('produit', 'creer')).''; + print '
'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1), 'seuil_stock_alerte', (string) $object->seuil_stock_alerte, $object, $user->hasRight('produit', 'creer')).''; print $form->editfieldval("StockLimit", 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->hasRight('produit', 'creer'), 'string'); print '
'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1), 'desiredstock', $object->desiredstock, $object, $user->hasRight('produit', 'creer')); + print '
'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1), 'desiredstock', (string) $object->desiredstock, $object, $user->hasRight('produit', 'creer')); print ''; print $form->editfieldval("DesiredStock", 'desiredstock', $object->desiredstock, $object, $user->hasRight('produit', 'creer'), 'string'); print '