diff --git a/dev/tools/phan/baseline.txt b/dev/tools/phan/baseline.txt index 0da0c9a12373b..dcfbfa73dda10 100644 --- a/dev/tools/phan/baseline.txt +++ b/dev/tools/phan/baseline.txt @@ -9,11 +9,11 @@ */ return [ // # Issue statistics: - // PhanTypeMismatchArgument : 2490+ occurrences + // PhanTypeMismatchArgument : 2450+ occurrences // PhanUndeclaredProperty : 530+ occurrences // PhanTypeMismatchArgumentNullable : 430+ occurrences // PhanUndeclaredGlobalVariable : 190+ occurrences - // PhanPluginUnknownArrayMethodReturnType : 180+ occurrences + // PhanPluginUnknownArrayMethodReturnType : 170+ occurrences // PhanPossiblyUndeclaredGlobalVariable : 160+ occurrences // PhanTypeMismatchProperty : 130+ occurrences // PhanTypeMismatchArgumentProbablyReal : 120+ occurrences @@ -27,8 +27,8 @@ return [ // PhanUndeclaredConstant : 15+ occurrences // PhanTypeComparisonFromArray : 10+ occurrences // PhanUndeclaredMethod : 10+ occurrences - // PhanPluginUnknownObjectMethodCall : 8 occurrences // PhanPluginSuspiciousParamPosition : 7 occurrences + // PhanPluginUnknownObjectMethodCall : 7 occurrences // PhanPluginDuplicateExpressionBinaryOp : 6 occurrences // PhanPluginEmptyStatementIf : 6 occurrences // PhanTypeArraySuspiciousNull : 6 occurrences @@ -123,7 +123,6 @@ return [ 'htdocs/admin/mails_templates.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'], 'htdocs/admin/mails_ticket.php' => ['PhanTypeMismatchArgumentNullable'], 'htdocs/admin/menus/index.php' => ['PhanTypeMismatchArgument'], - 'htdocs/admin/mrp.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/multicurrency.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/order.php' => ['PhanTypeMismatchArgument'], 'htdocs/admin/payment.php' => ['PhanTypeMismatchArgument'], @@ -466,7 +465,7 @@ return [ 'htdocs/core/modules/modSupplierProposal.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/core/modules/modTicket.class.php' => ['PhanTypeMismatchArgument'], 'htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php' => ['PhanTypeMismatchArgument'], - 'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], + 'htdocs/core/modules/mrp/doc/pdf_vinci.modules.php' => ['PhanUndeclaredProperty'], 'htdocs/core/modules/mrp/mod_mo_advanced.php' => ['PhanUndeclaredProperty'], 'htdocs/core/modules/oauth/github_oauthcallback.php' => ['PhanUndeclaredGlobalVariable'], 'htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php' => ['PhanTypeMismatchArgument'], @@ -608,20 +607,9 @@ return [ 'htdocs/loan/document.php' => ['PhanUndeclaredProperty'], 'htdocs/loan/note.php' => ['PhanUndeclaredProperty'], 'htdocs/loan/payment/payment.php' => ['PhanUndeclaredProperty'], - 'htdocs/mrp/ajax/ajax_bom.php' => ['PhanTypeMismatchArgument'], - 'htdocs/mrp/class/api_mos.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument'], - 'htdocs/mrp/class/mo.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchProperty'], - 'htdocs/mrp/class/moline.class.php' => ['PhanTypeMismatchArgument'], - 'htdocs/mrp/index.php' => ['PhanTypeMismatchArgument'], - 'htdocs/mrp/mo_agenda.php' => ['PhanTypeMismatchArgument'], - 'htdocs/mrp/mo_card.php' => ['PhanPossiblyUndeclaredGlobalVariable', 'PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanTypeMismatchArgumentProbablyReal'], - 'htdocs/mrp/mo_document.php' => ['PhanTypeMismatchArgument'], - 'htdocs/mrp/mo_list.php' => ['PhanTypeMismatchArgument'], - 'htdocs/mrp/mo_movements.php' => ['PhanPluginUnknownObjectMethodCall', 'PhanTypeMismatchArgument', 'PhanUndeclaredGlobalVariable'], - 'htdocs/mrp/mo_note.php' => ['PhanTypeMismatchArgument'], - 'htdocs/mrp/mo_production.php' => ['PhanTypeMismatchArgument'], - 'htdocs/mrp/tpl/linkedobjectblock.tpl.php' => ['PhanTypeMismatchArgument', 'PhanUndeclaredProperty'], - 'htdocs/mrp/tpl/originproductline.tpl.php' => ['PhanUndeclaredProperty'], + 'htdocs/mrp/class/mo.class.php' => ['PhanTypeMismatchProperty'], + 'htdocs/mrp/mo_movements.php' => ['PhanUndeclaredGlobalVariable'], + 'htdocs/mrp/tpl/linkedobjectblock.tpl.php' => ['PhanUndeclaredProperty'], 'htdocs/multicurrency/class/api_multicurrencies.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument'], 'htdocs/multicurrency/class/multicurrency.class.php' => ['PhanTypeExpectedObjectPropAccess', 'PhanTypeMismatchArgument'], 'htdocs/multicurrency/multicurrency_rate.php' => ['PhanTypeMismatchArgument'], diff --git a/htdocs/admin/mrp.php b/htdocs/admin/mrp.php index 0b343459e3d30..bc5a9c33f4dc5 100644 --- a/htdocs/admin/mrp.php +++ b/htdocs/admin/mrp.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 @@ -35,7 +35,6 @@ * @var Conf $conf * @var DoliDB $db * @var HookManager $hookmanager - * @var Societe $mysoc * @var Translate $langs * @var User $user */ @@ -263,13 +262,15 @@ $mrp = new Mo($db); $mrp->initAsSpecimen(); + $product = new Product($db); + $product->initAsSpecimen(); // Info $htmltooltip = ''; $htmltooltip .= ''.$langs->trans("Version").': '.$module->getVersion().'
'; $mrp->type = 0; - $nextval = $module->getNextValue($mysoc, $mrp); - if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $nextval = $module->getNextValue($product, $mrp); + if ((string) $nextval != $langs->trans("NotAvailable")) { $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { @@ -282,7 +283,7 @@ } print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); + print $form->textwithpicto('', $htmltooltip, 1, 'info'); print ''; print "\n"; @@ -417,7 +418,7 @@ print ''; - print $form->textwithpicto('', $htmltooltip, 1, 0); + print $form->textwithpicto('', $htmltooltip, 1, 'info'); print ''; // Preview diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index 8dcb13bcfb976..7a102ff96495f 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -543,7 +543,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Enough for 6 chars if ($this->getColumnStatus('qty')) { $qty = $bom->lines[$i]->qty; - $this->printStdColumnContent($pdf, $curY, 'qty', $qty); + $this->printStdColumnContent($pdf, $curY, 'qty', (string) $qty); $nexY = max($pdf->GetY(), $nexY); } @@ -551,7 +551,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Enough for 6 chars if ($this->getColumnStatus('qtytot')) { $qtytot = $object->qty * $bom->lines[$i]->qty; - $this->printStdColumnContent($pdf, $curY, 'qtytot', $qtytot); + $this->printStdColumnContent($pdf, $curY, 'qtytot', (string) $qtytot); $nexY = max($pdf->GetY(), $nexY); } @@ -1108,7 +1108,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', 'B', $default_font_size + 3); $pdf->SetXY($posx, $posy); $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell($w, 3, html_entity_decode($prodToMake->description), '', 'R', false, 1, '', '', true, 0, false, true, 51, 'T', true); + $pdf->MultiCell($w, 3, html_entity_decode($prodToMake->description), '', 'R', false, 1, null, null, true, 0, false, true, 51, 'T', true); $posy = $pdf->GetY() - 5; // dimensions diff --git a/htdocs/mrp/ajax/ajax_bom.php b/htdocs/mrp/ajax/ajax_bom.php index 5fc84d5e76e05..500018293af77 100644 --- a/htdocs/mrp/ajax/ajax_bom.php +++ b/htdocs/mrp/ajax/ajax_bom.php @@ -1,6 +1,7 @@ * 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 @@ -52,7 +53,7 @@ * @var User $user */ -$idbom = GETPOST('idbom', 'alpha'); +$idbom = GETPOSTINT('idbom'); //$action = GETPOST('action', 'aZ09'); $object = new BOM($db); diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index 7b267902f663d..df79b76fdb673 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -1,7 +1,7 @@ * Copyright (C) 2019 Maxime Kohlhaas - * 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 @@ -38,7 +38,7 @@ class Mos extends DolibarrApi { /** - * @var Mo $mo {@type Mo} + * @var Mo {@type Mo} */ public $mo; @@ -94,6 +94,8 @@ public function get($id) * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names * @return array Array of order objects + * @phan-return Mo[] + * @phpstan-return Mo[] * * @throws RestException */ @@ -175,6 +177,8 @@ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, * Create MO object * * @param array $request_data Request datas + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data * @return int ID of MO */ public function post($request_data = null) @@ -208,6 +212,8 @@ public function post($request_data = null) * * @param int $id Id of MO to update * @param array $request_data Datas + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data * @return Object Updated object */ public function put($id, $request_data = null) @@ -259,6 +265,8 @@ public function put($id, $request_data = null) * * @param int $id MO ID * @return array + * @phan-return array + * @phpstan-return array */ public function delete($id) { @@ -312,6 +320,8 @@ public function delete($id) * * @param int $id ID of state * @param array $request_data Request datas + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data * * @url POST {id}/produceandconsumeall * @@ -431,7 +441,7 @@ public function produceAndConsumeAll($id, $request_data = null) $error++; throw new RestException(500, $moline->error); } - $idstockmove = $stockmove->livraison(DolibarrApiAccess::$user, $value["objectid"], $value["fk_warehouse"], $qtytoprocess, 0, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + $idstockmove = $stockmove->livraison(DolibarrApiAccess::$user, $value["objectid"], $value["fk_warehouse"], $qtytoprocess, 0, $labelmovement, dol_now(), '', '', (string) $tmpproduct->status_batch, $id_product_batch, $codemovement); } else { $moline = new MoLine($this->db); $moline->fk_mo = $this->mo->id; @@ -450,7 +460,7 @@ public function produceAndConsumeAll($id, $request_data = null) $error++; throw new RestException(500, $moline->error); } - $idstockmove = $stockmove->reception(DolibarrApiAccess::$user, $value["objectid"], $value["fk_warehouse"], $qtytoprocess, 0, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + $idstockmove = $stockmove->reception(DolibarrApiAccess::$user, $value["objectid"], $value["fk_warehouse"], $qtytoprocess, 0, $labelmovement, '', '', (string) $tmpproduct->status_batch, dol_now(), $id_product_batch, $codemovement); } if ($idstockmove < 0) { $error++; @@ -519,9 +529,9 @@ public function produceAndConsumeAll($id, $request_data = null) $stockmove->origin_type = 'mo'; $stockmove->origin_id = $this->mo->id; if ($qtytoprocess >= 0) { - $idstockmove = $stockmove->livraison(DolibarrApiAccess::$user, $line->fk_product, $line->fk_warehouse, $qtytoprocess, 0, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + $idstockmove = $stockmove->livraison(DolibarrApiAccess::$user, $line->fk_product, $line->fk_warehouse, $qtytoprocess, 0, $labelmovement, dol_now(), '', '', (string) $tmpproduct->status_batch, $id_product_batch, $codemovement); } else { - $idstockmove = $stockmove->reception(DolibarrApiAccess::$user, $line->fk_product, $line->fk_warehouse, $qtytoprocess, 0, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + $idstockmove = $stockmove->reception(DolibarrApiAccess::$user, $line->fk_product, $line->fk_warehouse, $qtytoprocess, 0, $labelmovement, '', '', (string) $tmpproduct->status_batch, dol_now(), $id_product_batch, $codemovement); } if ($idstockmove < 0) { $error++; @@ -579,9 +589,9 @@ public function produceAndConsumeAll($id, $request_data = null) $stockmove->origin_type = 'mo'; $stockmove->origin_id = $this->mo->id; if ($qtytoprocess >= 0) { - $idstockmove = $stockmove->reception(DolibarrApiAccess::$user, $line->fk_product, $line->fk_warehouse, $qtytoprocess, 0, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + $idstockmove = $stockmove->reception(DolibarrApiAccess::$user, $line->fk_product, $line->fk_warehouse, $qtytoprocess, 0, $labelmovement, '', '', (string) $tmpproduct->status_batch, dol_now(), $id_product_batch, $codemovement); } else { - $idstockmove = $stockmove->livraison(DolibarrApiAccess::$user, $line->fk_product, $line->fk_warehouse, $qtytoprocess, 0, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + $idstockmove = $stockmove->livraison(DolibarrApiAccess::$user, $line->fk_product, $line->fk_warehouse, $qtytoprocess, 0, $labelmovement, dol_now(), '', '', (string) $tmpproduct->status_batch, $id_product_batch, $codemovement); } if ($idstockmove < 0) { $error++; @@ -688,6 +698,8 @@ public function produceAndConsumeAll($id, $request_data = null) * * @param int $id ID of state * @param array $request_data Request datas + * @phan-param ?array $request_data + * @phpstan-param ?array $request_data * * @url POST {id}/produceandconsume * @@ -803,15 +815,15 @@ public function produceAndConsume($id, $request_data = null) $stockmove->origin_id = $this->mo->id; if ($arrayname == "arraytoconsume") { if ($qtytoprocess >= 0) { - $idstockmove = $stockmove->livraison(DolibarrApiAccess::$user, $molinetoprocess->fk_product, $fk_warehousetoprocess, $qtytoprocess, 0, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + $idstockmove = $stockmove->livraison(DolibarrApiAccess::$user, $molinetoprocess->fk_product, $fk_warehousetoprocess, $qtytoprocess, 0, $labelmovement, dol_now(), '', '', (string) $tmpproduct->status_batch, $id_product_batch, $codemovement); } else { - $idstockmove = $stockmove->reception(DolibarrApiAccess::$user, $molinetoprocess->fk_product, $fk_warehousetoprocess, $qtytoprocess, 0, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + $idstockmove = $stockmove->reception(DolibarrApiAccess::$user, $molinetoprocess->fk_product, $fk_warehousetoprocess, $qtytoprocess, 0, $labelmovement, '', '', (string) $tmpproduct->status_batch, dol_now(), $id_product_batch, $codemovement); } } else { if ($qtytoprocess >= 0) { - $idstockmove = $stockmove->reception(DolibarrApiAccess::$user, $molinetoprocess->fk_product, $fk_warehousetoprocess, $qtytoprocess, $pricetoproduce, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + $idstockmove = $stockmove->reception(DolibarrApiAccess::$user, $molinetoprocess->fk_product, $fk_warehousetoprocess, $qtytoprocess, $pricetoproduce, $labelmovement, '', '', (string) $tmpproduct->status_batch, dol_now(), $id_product_batch, $codemovement); } else { - $idstockmove = $stockmove->livraison(DolibarrApiAccess::$user, $molinetoprocess->fk_product, $fk_warehousetoprocess, $qtytoprocess, 0, $labelmovement, dol_now(), '', '', $tmpproduct->status_batch, $id_product_batch, $codemovement); + $idstockmove = $stockmove->livraison(DolibarrApiAccess::$user, $molinetoprocess->fk_product, $fk_warehousetoprocess, $qtytoprocess, 0, $labelmovement, dol_now(), '', '', (string) $tmpproduct->status_batch, $id_product_batch, $codemovement); } } if ($idstockmove <= 0) { @@ -962,10 +974,10 @@ protected function _cleanObjectDatas($object) } /** - * Validate fields before create or update object + * Validate fields before creating or updating an object * - * @param array $data Array of data to validate - * @return array + * @param ?array $data Data to validate + * @return array * * @throws RestException */ diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index afbd022789f3e..86f72c71d2b5c 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -537,7 +537,7 @@ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = if ($key == 't.rowid') { $sqlwhere[] = $this->db->sanitize($key)." = ".((int) $value); } elseif (strpos($key, 'date') !== false) { - $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate($value)."'"; + $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate((int) $value)."'"; } else { $sqlwhere[] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'"; } @@ -768,7 +768,7 @@ public function createProduction(User $user, $notrigger = 0) } } - $resultline = $moline->create($user, false); // Never use triggers here + $resultline = $moline->create($user, 0); // Never use triggers here if ($resultline <= 0) { $error++; $this->error = $moline->error; @@ -808,7 +808,7 @@ public function createProduction(User $user, $notrigger = 0) $moline->fk_default_workstation = $line->fk_default_workstation; } - $resultline = $moline->create($user, false); // Never use triggers here + $resultline = $moline->create($user, 0); // Never use triggers here if ($resultline <= 0) { $error++; $this->error = $moline->error; @@ -1747,9 +1747,9 @@ public function printOriginLinesList($restrictlist = '', $selectedLines = array( // Qty print ''.$langs->trans('Qty'); if ($this->bom->bomtype == 0) { - print ' ('.$langs->trans("ForAQuantityOf", $this->bom->qty).')'; + print ' ('.$langs->trans("ForAQuantityOf", (string) $this->bom->qty).')'; } else { - print ' ('.$langs->trans("ForAQuantityToConsumeOf", $this->bom->qty).')'; + print ' ('.$langs->trans("ForAQuantityToConsumeOf", (string) $this->bom->qty).')'; } // Unit print ''.$langs->trans('Unit'); diff --git a/htdocs/mrp/class/moline.class.php b/htdocs/mrp/class/moline.class.php index fc157e805a3ef..a7758c292cdfd 100644 --- a/htdocs/mrp/class/moline.class.php +++ b/htdocs/mrp/class/moline.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2020 Lenin Rivas * Copyright (C) 2023-2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 William Mead * * This program is free software; you can redistribute it and/or modify @@ -301,7 +301,7 @@ public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = if ($key == 't.rowid') { $sqlwhere[] = $this->db->sanitize($key)." = ".((int) $value); } elseif (strpos($key, 'date') !== false) { - $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate($value)."'"; + $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate((int) $value)."'"; } else { $sqlwhere[] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'"; } diff --git a/htdocs/mrp/index.php b/htdocs/mrp/index.php index 2bc3b1432af42..eeaa7f8acf70a 100644 --- a/htdocs/mrp/index.php +++ b/htdocs/mrp/index.php @@ -6,6 +6,7 @@ * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2019-2024 Frédéric France * Copyright (C) 2024 Alexandre Spangaro + * 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 @@ -207,7 +208,7 @@ $staticbom->status = $obj->status; print ''; - print ''.$staticbom->getNomUrl(1, 32).''; + print ''.$staticbom->getNomUrl(1, '32').''; print ''.dol_print_date($db->jdate($obj->datem), 'dayhour').''; print ''.$staticbom->getLibStatut(3).''; print ''; @@ -263,7 +264,7 @@ $staticmo->status = $obj->status; print ''; - print ''.$staticmo->getNomUrl(1, 32).''; + print ''.$staticmo->getNomUrl(1, '32').''; print ''.dol_print_date($db->jdate($obj->datem), 'dayhour').''; print ''.$staticmo->getLibStatut(3).''; print ''; diff --git a/htdocs/mrp/mo_agenda.php b/htdocs/mrp/mo_agenda.php index bbff7b188f3aa..b657aa4b12478 100644 --- a/htdocs/mrp/mo_agenda.php +++ b/htdocs/mrp/mo_agenda.php @@ -2,7 +2,7 @@ /* Copyright (C) 2017 Laurent Destailleur * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Alexandre Spangaro - * 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 @@ -180,7 +180,7 @@ 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); diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 69c26b9f185d1..cd97ddf76bea5 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -1,7 +1,7 @@ * Copyright (C) 2024 Alexandre Spangaro - * 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 @@ -170,7 +170,7 @@ $objectbomchildline->fetch($id_bom_line); - $TMoLines = $moline->fetchAll('DESC', 'rowid', '1', '', array('origin_id' => $id_bom_line)); + $TMoLines = $moline->fetchAll('DESC', 'rowid', 1, 0, array('origin_id' => $id_bom_line)); foreach ($TMoLines as $tmpmoline) { $_POST['fk_bom'] = $objectbomchildline->fk_bom_child; @@ -188,7 +188,7 @@ exit; } elseif ($action == 'confirm_cancel' && $confirm == 'yes' && !empty($permissiontoadd)) { $also_cancel_consumed_and_produced_lines = (GETPOST('alsoCancelConsumedAndProducedLines', 'alpha') ? 1 : 0); - $result = $object->cancel($user, 0, $also_cancel_consumed_and_produced_lines); + $result = $object->cancel($user, 0, (bool) $also_cancel_consumed_and_produced_lines); if ($result > 0) { header("Location: " . dol_buildpath('/mrp/mo_card.php?id=' . $object->id, 1)); exit; @@ -198,7 +198,7 @@ } } elseif ($action == 'confirm_delete' && $confirm == 'yes' && !empty($permissiontodelete)) { $also_cancel_consumed_and_produced_lines = (GETPOST('alsoCancelConsumedAndProducedLines', 'alpha') ? 1 : 0); - $result = $object->delete($user, 0, $also_cancel_consumed_and_produced_lines); + $result = $object->delete($user, 0, (bool) $also_cancel_consumed_and_produced_lines); if ($result > 0) { header("Location: " . $backurlforlist); exit; @@ -342,9 +342,9 @@ llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-mrp page-card'); - // Part to create if ($action == 'create') { + $titlelist = null; if (GETPOSTINT('fk_bom') > 0) { $titlelist = $langs->trans("ToConsume"); if ($objectbom->bomtype == 1) { @@ -439,7 +439,7 @@ print $form->buttonsSaveCancel("Create"); if ($objectbom->id > 0) { - print load_fiche_titre($titlelist); + print load_fiche_titre((string) $titlelist); print ''."\n"; print '
'; @@ -642,7 +642,7 @@ 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); @@ -873,7 +873,7 @@ $htmltoenteralink = $tmparray['htmltoenteralink']; print $htmltoenteralink; - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, false); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, array()); print '
'; diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php index 9e5219d316fcd..b4e950d82e0eb 100644 --- a/htdocs/mrp/mo_document.php +++ b/htdocs/mrp/mo_document.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Alexandre Spangaro + * 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 @@ -156,7 +157,7 @@ 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); diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index ea434e1187e38..da3b60f503319 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2024 Alexandre Spangaro * 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 @@ -122,22 +123,22 @@ 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'] : '' ); } if ($key == 'fk_parent_line') { $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'] : '' ); } } @@ -270,7 +271,7 @@ } if ($key == 'status') { - $sql .= natural_search('t.status', $search[$key], 0); + $sql .= natural_search('t.status', (string) $search[$key], 0); continue; } @@ -445,8 +446,8 @@ print ''; $newcardbutton = ''; -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); -$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss' => 'reposition')); +$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss' => 'reposition')); $newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/mrp/mo_card.php?action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $permissiontoadd); @@ -545,7 +546,7 @@ 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 @@ -659,7 +660,7 @@ $selected = 1; } } - print $object->getKanbanView('', array('bom'=>($obj->fk_bom > 0 ? $bom : null), 'product'=>($obj->fk_product > 0 ? $product : null), 'selected' => $selected)); + print $object->getKanbanView('', array('bom' => ($obj->fk_bom > 0 ? $bom : null), 'product' => ($obj->fk_product > 0 ? $product : null), 'selected' => $selected)); if ($i == ($imaxinloop - 1)) { print '
'; print ''; @@ -708,7 +709,7 @@ 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') { @@ -719,9 +720,9 @@ print $moparent->getNomUrl(1); } } 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, ''); + print $object->showOutputField($val, $key, (string) $object->$key, ''); } print ''; if (!$i) { @@ -744,7 +745,7 @@ // 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; @@ -787,7 +788,7 @@ $db->free($resql); -$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); +$parameters = array('arrayfields' => $arrayfields, 'sql' => $sql); $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index 5120d8a3c98ea..fabcca4d0e1e6 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -3,7 +3,7 @@ * Copyright (C) 2022 Ferran Marcet * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Alexandre Spangaro - * 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 @@ -130,24 +130,24 @@ // Definition of fields for list $arrayfields = array( - 'm.rowid' => array('label' => "Ref", 'checked' => 1, 'position' => 1), - 'm.datem' => array('label' => "Date", 'checked' => 1, 'position' => 2), - 'p.ref' => array('label' => "ProductRef", 'checked' => 1, 'css' => 'maxwidth100', 'position' => 3), - 'p.label' => array('label' => "ProductLabel", 'checked' => 0, 'position' => 5), - 'm.batch' => array('label' => "BatchNumberShort", 'checked' => 1, 'position' => 8, 'enabled' => (isModEnabled('productbatch'))), - 'pl.eatby' => array('label' => "EatByDate", 'checked' => 0, 'position' => 9, 'enabled' => (isModEnabled('productbatch'))), - 'pl.sellby' => array('label' => "SellByDate", 'checked' => 0, 'position' => 10, 'enabled' => (isModEnabled('productbatch'))), - 'e.ref' => array('label' => "Warehouse", 'checked' => 1, 'position' => 100, 'enabled' => (!($id > 0))), // If we are on specific warehouse, we hide it - 'm.fk_user_author' => array('label' => "Author", 'checked' => 0, 'position' => 120), - 'm.inventorycode' => array('label' => "InventoryCodeShort", 'checked' => 1, 'position' => 130), - 'm.label' => array('label' => "MovementLabel", 'checked' => 1, 'position' => 140), - 'm.type_mouvement' => array('label' => "TypeMovement", 'checked' => 0, 'position' => 150), - 'origin' => array('label' => "Origin", 'checked' => 1, 'position' => 155), - 'm.fk_projet' => array('label' => 'Project', 'checked' => 0, 'position' => 180), - 'm.value' => array('label' => "Qty", 'checked' => 1, 'position' => 200), - 'm.price' => array('label' => "UnitPurchaseValue", 'checked' => 0, 'position' => 210) - //'m.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), - //'m.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500) + 'm.rowid' => array('label' => "Ref", 'checked' => '1', 'position' => 1), + 'm.datem' => array('label' => "Date", 'checked' => '1', 'position' => 2), + 'p.ref' => array('label' => "ProductRef", 'checked' => '1', 'css' => 'maxwidth100', 'position' => 3), + 'p.label' => array('label' => "ProductLabel", 'checked' => '0', 'position' => 5), + 'm.batch' => array('label' => "BatchNumberShort", 'checked' => '1', 'position' => 8, 'enabled' => (string) (int) (isModEnabled('productbatch'))), + 'pl.eatby' => array('label' => "EatByDate", 'checked' => '0', 'position' => 9, 'enabled' => (string) (int) (isModEnabled('productbatch'))), + 'pl.sellby' => array('label' => "SellByDate", 'checked' => '0', 'position' => 10, 'enabled' => (string) (int) (isModEnabled('productbatch'))), + 'e.ref' => array('label' => "Warehouse", 'checked' => '1', 'position' => 100, 'enabled' => (string) (int) (!($id > 0))), // If we are on specific warehouse, we hide it + 'm.fk_user_author' => array('label' => "Author", 'checked' => '0', 'position' => 120), + 'm.inventorycode' => array('label' => "InventoryCodeShort", 'checked' => '1', 'position' => 130), + 'm.label' => array('label' => "MovementLabel", 'checked' => '1', 'position' => 140), + 'm.type_mouvement' => array('label' => "TypeMovement", 'checked' => '0', 'position' => 150), + 'origin' => array('label' => "Origin", 'checked' => '1', 'position' => 155), + 'm.fk_projet' => array('label' => 'Project', 'checked' => '0', 'position' => 180), + 'm.value' => array('label' => "Qty", 'checked' => '1', 'position' => 200), + 'm.price' => array('label' => "UnitPurchaseValue", 'checked' => '0', 'position' => 210) + //'m.datec'=>array('label'=>"DateCreation", 'checked'=>'0', 'position'=>500), + //'m.tms'=>array('label'=>"DateModificationShort", 'checked'=>'0', 'position'=>500) ); if (getDolGlobalString('PRODUCT_DISABLE_SELLBY')) { unset($arrayfields['pl.sellby']); @@ -169,7 +169,7 @@ $permissiontoupdatecost = $user->hasRight('bom', 'write'); // User who can define cost must have knowledge of pricing if ($permissiontoupdatecost) { - $arrayfields['m.price']['enabled'] = 1; + $arrayfields['m.price']['enabled'] = '1'; } $arrayofselected = array(); @@ -360,7 +360,7 @@ 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); @@ -1016,7 +1016,7 @@ // fk_project print ''; if ($objp->fk_project != 0) { - print $movement->get_origin($objp->fk_project, 'project'); + print $objectlist->get_origin($objp->fk_project, 'project'); } print ''; } diff --git a/htdocs/mrp/mo_note.php b/htdocs/mrp/mo_note.php index 304457df2349c..c2ba92da2cae2 100644 --- a/htdocs/mrp/mo_note.php +++ b/htdocs/mrp/mo_note.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2017 Laurent Destailleur * Copyright (C) 2024 Frédéric France * Copyright (C) 2024 Alexandre Spangaro + * 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 @@ -133,7 +134,7 @@ 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); diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index bf68267ee2b15..53d383ba51aa5 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -3,7 +3,7 @@ * Copyright (C) 2023 Christian Humpel * Copyright (C) 2023 Vincent de Grandpré * Copyright (C) 2024 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify @@ -142,7 +142,7 @@ if ($action == 'confirm_cancel' && $confirm == 'yes' && !empty($permissiontoadd)) { $also_cancel_consumed_and_produced_lines = (GETPOST('alsoCancelConsumedAndProducedLines', 'alpha') ? 1 : 0); - $result = $object->cancel($user, 0, $also_cancel_consumed_and_produced_lines); + $result = $object->cancel($user, 0, (bool) $also_cancel_consumed_and_produced_lines); if ($result > 0) { header("Location: " . DOL_URL_ROOT.'/mrp/mo_card.php?id=' . $object->id); exit; @@ -152,7 +152,7 @@ } } elseif ($action == 'confirm_delete' && $confirm == 'yes' && !empty($permissiontodelete)) { $also_cancel_consumed_and_produced_lines = (GETPOST('alsoCancelConsumedAndProducedLines', 'alpha') ? 1 : 0); - $result = $object->delete($user, 0, $also_cancel_consumed_and_produced_lines); + $result = $object->delete($user, 0, (bool) $also_cancel_consumed_and_produced_lines); if ($result > 0) { header("Location: " . $backurlforlist); exit; @@ -244,7 +244,7 @@ $moline->array_options = $array_options; } - $resultline = $moline->create($user, false); // Never use triggers here + $resultline = $moline->create($user, 0); // Never use triggers here if ($resultline <= 0) { $error++; setEventMessages($moline->error, $moline->errors, 'errors'); @@ -297,9 +297,9 @@ $stockmove->context['mrp_role'] = 'toconsume'; if ($qtytoprocess >= 0) { - $idstockmove = $stockmove->livraison($user, $line->fk_product, GETPOST('idwarehouse-'.$line->id.'-'.$i), $qtytoprocess, 0, $labelmovement, dol_now(), '', '', GETPOST('batch-'.$line->id.'-'.$i), $id_product_batch, $codemovement); + $idstockmove = $stockmove->livraison($user, $line->fk_product, GETPOSTINT('idwarehouse-'.$line->id.'-'.$i), $qtytoprocess, 0, $labelmovement, dol_now(), '', '', GETPOST('batch-'.$line->id.'-'.$i), $id_product_batch, $codemovement); } else { - $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehouse-'.$line->id.'-'.$i), $qtytoprocess * -1, 0, $labelmovement, dol_now(), '', '', GETPOST('batch-'.$line->id.'-'.$i), $id_product_batch, $codemovement); + $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOSTINT('idwarehouse-'.$line->id.'-'.$i), $qtytoprocess * -1, 0, $labelmovement, dol_now(), '', '', GETPOST('batch-'.$line->id.'-'.$i), $id_product_batch, $codemovement); } if ($idstockmove < 0) { $error++; @@ -372,7 +372,7 @@ $stockmove->origin_id = $object->id; $stockmove->context['mrp_role'] = 'toproduce'; - $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i), $qtytoprocess, $pricetoprocess, $labelmovement, '', '', GETPOST('batchtoproduce-'.$line->id.'-'.$i), dol_now(), $id_product_batch, $codemovement); + $idstockmove = $stockmove->reception($user, $line->fk_product, GETPOSTINT('idwarehousetoproduce-'.$line->id.'-'.$i), $qtytoprocess, $pricetoprocess, $labelmovement, '', '', GETPOST('batchtoproduce-'.$line->id.'-'.$i), dol_now(), $id_product_batch, $codemovement); if ($idstockmove < 0) { $error++; setEventMessages($stockmove->error, $stockmove->errors, 'errors'); @@ -680,7 +680,7 @@ 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); @@ -986,7 +986,7 @@ // Extrafields Line if (is_object($objectline)) { $extrafields->fetch_name_optionals_label($object->table_element_line); - $temps = $objectline->showOptionals($extrafields, 'edit', array(), '', '', 1, 'line'); + $temps = $objectline->showOptionals($extrafields, 'edit', array(), '', '', '1', 'line'); if (!empty($temps)) { print ''; print $temps; @@ -1146,7 +1146,7 @@ // Extrafields Line if (!empty($extrafields)) { $line->fetch_optionals(); - $temps = $line->showOptionals($extrafields, 'edit', array(), '', '', 1, 'line'); + $temps = $line->showOptionals($extrafields, 'edit', array(), '', '', '1', 'line'); if (!empty($temps)) { $colspan = 10; print '
'; @@ -1307,7 +1307,7 @@ // Extrafields Line if (!empty($extrafields)) { $line->fetch_optionals(); - $temps = $line->showOptionals($extrafields, 'view', array(), '', '', 1, 'line'); + $temps = $line->showOptionals($extrafields, 'view', array(), '', '', '1', 'line'); if (!empty($temps)) { $colspan = 10; print '
'; diff --git a/htdocs/mrp/tpl/linkedobjectblock.tpl.php b/htdocs/mrp/tpl/linkedobjectblock.tpl.php index e4cfc5b84355d..3ba0e580b5b7b 100644 --- a/htdocs/mrp/tpl/linkedobjectblock.tpl.php +++ b/htdocs/mrp/tpl/linkedobjectblock.tpl.php @@ -3,7 +3,7 @@ * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2014 Marcos García * Copyright (C) 2013-2020 Charlene BENKE - * 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 @@ -60,7 +60,7 @@ echo ''; echo '' . $langs->trans("ManufacturingOrder"); if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { - print ' '; echo '' . $objectlink->getNomUrl(1) . ''; diff --git a/htdocs/mrp/tpl/originproductline.tpl.php b/htdocs/mrp/tpl/originproductline.tpl.php index 7b6a043608057..9b61917fe86ab 100644 --- a/htdocs/mrp/tpl/originproductline.tpl.php +++ b/htdocs/mrp/tpl/originproductline.tpl.php @@ -1,7 +1,7 @@ * Copyright (C) 2017 Charlie Benke - * 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 @@ -22,10 +22,14 @@ * @var CommonObject $this * @var Conf $conf * @var Form $form - * @var MoLine $line + * @var BOMLine $line * @var Translate $langs */ +' +@phan-var-force BOMLine $line +'; + // Protection to avoid direct call of template if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; @@ -54,8 +58,8 @@ } $tmpbom = new BOM($db); $res = 0; -if ($line->fk_bom_child > 0) { - $res = $tmpbom->fetch($line->fk_bom_child); +if ((int) $line->fk_bom_child > 0) { + $res = $tmpbom->fetch((int) $line->fk_bom_child); } ?> diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 5794ace75d374..1c96b0284e34d 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -208,15 +208,15 @@ public function __construct($db) * @param int $price Unit price HT of product, used to calculate average weighted price (AWP or PMP in french). If 0, average weighted price is not changed. * @param string $label Label of stock movement * @param string $inventorycode Inventory code - * @param integer|string $datem Force date of movement - * @param integer|string $eatby eat-by date. Will be used if lot does not exists yet and will be created. - * @param integer|string $sellby sell-by date. Will be used if lot does not exists yet and will be created. + * @param int|string $datem Force date of movement + * @param int|string $eatby eat-by date. Will be used if lot does not exists yet and will be created. + * @param int|string $sellby sell-by date. Will be used if lot does not exists yet and will be created. * @param string $batch batch number * @param boolean $skip_batch If set to true, stock movement is done without impacting batch record * @param int $id_product_batch Id product_batch (when skip_batch is false and we already know which record of product_batch to use) - * @param int $disablestockchangeforsubproduct Disable stock change for sub-products of kit (useful only if product is a subproduct) - * @param int $donotcleanemptylines Do not clean lines in stock table with qty=0 (because we want to have this done by the caller) - * @param boolean $force_update_batch Allows to add batch stock movement even if $product doesn't use batch anymore + * @param int<0,1> $disablestockchangeforsubproduct Disable stock change for sub-products of kit (useful only if product is a subproduct) + * @param int<0,1> $donotcleanemptylines Do not clean lines in stock table with qty=0 (because we want to have this done by the caller) + * @param bool $force_update_batch Allows to add batch stock movement even if $product doesn't use batch anymore * @return int Return integer <0 if KO, 0 if fk_product is null or product id does not exists, >0 if OK */ public function _create($user, $fk_product, $entrepot_id, $qty, $type, $price = 0, $label = '', $inventorycode = '', $datem = '', $eatby = '', $sellby = '', $batch = '', $skip_batch = false, $id_product_batch = 0, $disablestockchangeforsubproduct = 0, $donotcleanemptylines = 0, $force_update_batch = false)