From 2130f1395aab0a43fc15b478abdc0ba22359b023 Mon Sep 17 00:00:00 2001 From: MDW Date: Sat, 8 Feb 2025 18:30:42 +0100 Subject: [PATCH 1/2] Qual: Fix phan (product-part-1) implies fixing unit types --- htdocs/bom/tpl/objectline_view.tpl.php | 6 +- .../core/class/commondocgenerator.class.php | 22 ++--- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/class/html.formcompany.class.php | 18 ++-- htdocs/core/lib/functions.lib.php | 4 +- htdocs/core/lib/product.lib.php | 18 ++-- .../expedition/doc/pdf_espadon.modules.php | 2 +- .../modules/product/modules_product.class.php | 10 +- htdocs/expedition/card.php | 4 +- htdocs/expedition/class/expedition.class.php | 6 +- .../class/expeditionligne.class.php | 6 +- htdocs/expedition/list.php | 2 +- htdocs/mrp/mo_production.php | 8 +- htdocs/mrp/tpl/originproductline.tpl.php | 6 +- htdocs/product/admin/price_rules.php | 6 +- htdocs/product/admin/product.php | 4 +- htdocs/product/admin/product_tools.php | 11 ++- htdocs/product/ajax/products.php | 11 ++- .../product/actions_card_product.class.php | 12 +-- htdocs/product/card.php | 70 ++++++------- .../product/class/html.formproduct.class.php | 6 +- htdocs/product/class/product.class.php | 99 ++++++++++--------- htdocs/product/stock/massstockmove.php | 6 +- htdocs/reception/card.php | 6 +- 24 files changed, 178 insertions(+), 167 deletions(-) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index def20558866..1ce3201aa9c 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -6,7 +6,7 @@ * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2013 Florian Henry * Copyright (C) 2017 Juanjo Menent - * 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 @@ -153,7 +153,7 @@ print ''; if ($filtertype != 1) { // Product if (getDolGlobalInt('PRODUCT_USE_UNITS')) { // For product, unit is shown only if option PRODUCT_USE_UNITS is on print ''; - $label = measuringUnitString($line->fk_unit, '', '', 1); + $label = measuringUnitString((int) $line->fk_unit, '', null, 1); if ($label !== '') { print $langs->trans($label); } @@ -359,7 +359,7 @@ if ($resql) { $total_cost += $sub_bom->total_cost * $sub_bom_line->qty * (float) $line->qty; } elseif ($sub_bom_product->type == Product::TYPE_SERVICE && isModEnabled('workstation') && !empty($sub_bom_product->fk_default_workstation)) { //Convert qty to hour - $unit = measuringUnitString($sub_bom_line->fk_unit, '', '', 1); + $unit = measuringUnitString($sub_bom_line->fk_unit, '', null, 1); $qty = convertDurationtoHour($sub_bom_line->qty, $unit); $workstation = new Workstation($this->db); $res = $workstation->fetch($sub_bom_product->fk_default_workstation); diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 65f87ed9870..4bb9a8fbb08 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2016-2023 Charlene Benke * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2020 Josep Lluís Amador - * Copyright (C) 2024 MDW + * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Mélina Joum * Copyright (C) 2024 Nick Fragoulis * @@ -1055,7 +1055,7 @@ abstract class CommonDocGenerator $array_key.'_tracking_number' => $object->tracking_number, $array_key.'_tracking_url' => $object->tracking_url, $array_key.'_shipping_method' => $object->listmeths[0]['libelle'], - $array_key.'_weight' => $object->trueWeight.' '.measuringUnitString(0, 'weight', (string) $object->weight_units), + $array_key.'_weight' => $object->trueWeight.' '.measuringUnitString(0, 'weight', $object->weight_units), $array_key.'_width' => $object->trueWidth.' '.measuringUnitString(0, 'size', $object->width_units), $array_key.'_height' => $object->trueHeight.' '.measuringUnitString(0, 'size', $object->height_units), $array_key.'_depth' => $object->trueDepth.' '.measuringUnitString(0, 'size', $object->depth_units), @@ -1092,31 +1092,31 @@ abstract class CommonDocGenerator // Set trueVolume and volume_units not currently stored into database if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $object->trueVolume = $object->trueWidth * $object->trueHeight * $object->trueDepth; - $object->volume_units = $object->size_units * 3; + $object->trueVolume = $object->trueWidth * $object->trueHeight * $object->trueDepth; + $object->volume_units = $object->size_units * 3; } $array_shipment[$array_key.'_total_ordered'] = (string) $totalOrdered; $array_shipment[$array_key.'_total_toship'] = (string) $totalToShip; if ($object->trueWeight) { - $array_shipment[$array_key.'_total_weight'] = (empty($totalWeight)) ? '' : showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); + $array_shipment[$array_key.'_total_weight'] = (empty($totalWeight)) ? '' : showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); } elseif (!empty($totalWeight)) { - $array_shipment[$array_key.'_total_weight'] = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1); + $array_shipment[$array_key.'_total_weight'] = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1); } else { - $array_shipment[$array_key.'_total_weight'] = ""; + $array_shipment[$array_key.'_total_weight'] = ""; } if (!empty($object->trueVolume)) { if ($object->volume_units < 50) { - $array_shipment[$array_key.'_total_volume'] = (empty($totalVolume)) ? '' : showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); + $array_shipment[$array_key.'_total_volume'] = (empty($totalVolume)) ? '' : showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); } else { - $array_shipment[$array_key.'_total_volume'] = (empty($totalVolume)) ? '' : price($object->trueVolume, 0, $outputlangs, 0, 0).' '.measuringUnitString(0, "volume", $object->volume_units); + $array_shipment[$array_key.'_total_volume'] = (empty($totalVolume)) ? '' : price($object->trueVolume, 0, $outputlangs, 0, 0).' '.measuringUnitString(0, "volume", $object->volume_units); } } elseif (!empty($totalVolume)) { - $array_shipment[$array_key.'_total_volume'] = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1); + $array_shipment[$array_key.'_total_volume'] = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1); } else { - $array_shipment[$array_key.'_total_volume'] = ""; + $array_shipment[$array_key.'_total_volume'] = ""; } return $array_shipment; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 8772968c774..a1ce6a738aa 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -204,7 +204,7 @@ class Form * @param string $text Text of label (not used in this function) * @param string $htmlname Name of select field * @param string|int $value Value to show/edit - * @param CommonObject $object Object (that we want to show) + * @param CommonObject|ActionsCardProduct|ActionsCardService $object Object (that we want to show) * @param bool|int<0,1> $perm Permission to allow button to edit parameter * @param string $typeofdata Type of data ('string' by default, 'checkbox', 'email', 'phone', 'amount:99', 'numeric:99', * 'text' or 'textarea:rows:cols%', 'safehtmlstring', 'restricthtml', diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 948907ff469..800913719ee 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2017 Rui Strecht * Copyright (C) 2020 Open-Dsi * 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 @@ -249,9 +249,9 @@ class FormCompany extends Form * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). * Thus the links with the departments are done on a department independently of its name. * - * @param string $selected Code state preselected - * @param int $country_codeid 0=list for all countries, otherwise country code or country rowid to show - * @param string $htmlname Id of department + * @param string $selected Code state preselected + * @param int|string $country_codeid 0=list for all countries, otherwise country code or country rowid to show + * @param string $htmlname Id of department * @return void */ public function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id') @@ -267,11 +267,11 @@ class FormCompany extends Form * The key of the list is the code (there can be several entries for a given code but in this case, the country field differs). * Thus the links with the departments are done on a department independently of its name. * - * @param int $selected Code state preselected (must be state id) - * @param int $country_codeid Country code or id: 0=list for all countries, otherwise country code or country rowid to show - * @param string $htmlname Id of department. If '', we want only the string with