Merge pull request #33012 from mdeweerd/phan/2025.2.10.stock-2

Qual: Fix phan (stock-2)
This commit is contained in:
Laurent Destailleur 2025-02-10 21:42:31 +01:00 committed by GitHub
commit 5051faa325
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 102 additions and 92 deletions

View File

@ -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'],

View File

@ -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

View File

@ -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")."<br>";
@ -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)?'<br>':'').$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')) {

View File

@ -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)) {

View File

@ -5,7 +5,7 @@
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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)

View File

@ -3,7 +3,7 @@
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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)

View File

@ -7,7 +7,7 @@
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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);

View File

@ -10,7 +10,7 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<tr><td class="">';
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 '</td><td>';
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, 0, $typeformat);
print '</td></tr>';
@ -667,7 +677,7 @@ if ($id > 0 || $ref) {
print '</td><td>';
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 '</td><td>';
print $form->editfieldval($text, 'cost_price', $object->cost_price, $object, $usercancreate, 'amount:6');
}
@ -746,12 +756,12 @@ if ($id > 0 || $ref) {
print '<table class="border tableforfield centpercent">';
// Stock alert threshold
print '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1), 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->hasRight('produit', 'creer')).'</td><td>';
print '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1), 'seuil_stock_alerte', (string) $object->seuil_stock_alerte, $object, $user->hasRight('produit', 'creer')).'</td><td>';
print $form->editfieldval("StockLimit", 'seuil_stock_alerte', $object->seuil_stock_alerte, $object, $user->hasRight('produit', 'creer'), 'string');
print '</td></tr>';
// Desired stock
print '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1), 'desiredstock', $object->desiredstock, $object, $user->hasRight('produit', 'creer'));
print '<tr><td>'.$form->editfieldkey($form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1), 'desiredstock', (string) $object->desiredstock, $object, $user->hasRight('produit', 'creer'));
print '</td><td>';
print $form->editfieldval("DesiredStock", 'desiredstock', $object->desiredstock, $object, $user->hasRight('produit', 'creer'), 'string');
print '</td></tr>';
@ -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);

View File

@ -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 '</div><div class="fichehalfright">';

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2018-2021 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<input type="text" class="flat maxwidth'.($val['type'] == 'integer' ? '50' : '75').'" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
}
@ -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 '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
if (preg_match('/tdoverflow/', $cssforfield) && !is_numeric($object->$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;

View File

@ -7,7 +7,7 @@
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2021 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2021 Antonin MARCHAL <antonin@letempledujeu.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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')) {

View File

@ -6,6 +6,7 @@
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<div class="divsearchfield">';
print $langs->trans('Period').' ('.$langs->trans("OrderDate").') - ';
print $langs->trans('Month').':<input class="flat" type="text" size="4" name="search_month" value="'.$search_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 '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"), 'searchclear.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';

View File

@ -6,6 +6,7 @@
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<div class="divsearchfield">';
print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - ';
print $langs->trans('Month').':<input class="flat" type="text" size="4" name="search_month" value="'.$search_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 '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"), 'searchclear.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';

View File

@ -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 '<div class="divsearchfield">';
print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - ';
print $langs->trans('Month').':<input class="flat" type="text" size="4" name="search_month" value="'.$search_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 '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"), 'searchclear.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';

View File

@ -6,6 +6,7 @@
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<div class="divsearchfield">';
print $langs->trans('Period').' ('.$langs->trans("DateCreation").') - ';
print $langs->trans('Month').':<input class="flat" type="text" size="4" name="search_month" value="'.$search_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 '<div style="vertical-align: middle; display: inline-block">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"), 'searchclear.png', '', 0, 1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';

View File

@ -5,7 +5,7 @@
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2016 ATM Consulting <support@atm-consulting.fr>
* Copyright (C) 2019-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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];

View File

@ -1,9 +1,8 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) ---Put here your own copyright and developer email---
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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,

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* 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 .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
}
$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);

View File

@ -5,6 +5,7 @@
* Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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);

View File

@ -1,8 +1,8 @@
<?php
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) ---Put here your own copyright and developer email---
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
*
* 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 '<input type="text" class="flat maxwidth'.($val['type'] == 'integer' ? '50' : '75').'" name="search_'.$key.'" value="'.dol_escape_htmltag(isset($search[$key]) ? $search[$key] : '').'">';
}
@ -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 '<td'.($cssforfield ? ' class="'.$cssforfield.(preg_match('/tdoverflow/', $cssforfield) ? ' classfortooltip' : '').'"' : '');
if (preg_match('/tdoverflow/', $cssforfield) && !in_array($val['type'], array('ip', 'url')) && !is_numeric($object->$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;