Merge pull request #32992 from mdeweerd/phan/2025.2.8.product
Qual: Fix phan (product-part-1) implies fixing unit types
This commit is contained in:
commit
0691c18355
25 changed files with 179 additions and 176 deletions
|
|
@ -9,7 +9,7 @@
|
|||
*/
|
||||
return [
|
||||
// # Issue statistics:
|
||||
// PhanTypeMismatchArgument : 2300+ occurrences
|
||||
// PhanTypeMismatchArgument : 2230+ occurrences
|
||||
// PhanUndeclaredProperty : 530+ occurrences
|
||||
// PhanTypeMismatchArgumentNullable : 430+ occurrences
|
||||
// PhanUndeclaredGlobalVariable : 190+ occurrences
|
||||
|
|
@ -593,16 +593,8 @@ return [
|
|||
'htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php' => ['PhanUndeclaredProperty'],
|
||||
'htdocs/partnership/partnership_card.php' => ['PhanUndeclaredGlobalVariable'],
|
||||
'htdocs/partnership/partnership_list.php' => ['PhanUndeclaredProperty'],
|
||||
'htdocs/product/admin/price_rules.php' => ['PhanTypeMismatchArgument'],
|
||||
'htdocs/product/admin/product.php' => ['PhanPluginEmptyStatementIf', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/product/admin/product_tools.php' => ['PhanTypeMismatchArgument'],
|
||||
'htdocs/product/ajax/products.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentProbablyReal'],
|
||||
'htdocs/product/canvas/product/actions_card_product.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
|
||||
'htdocs/product/canvas/service/actions_card_service.class.php' => ['PhanTypeMismatchArgument'],
|
||||
'htdocs/product/card.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable', 'PhanUndeclaredGlobalVariable'],
|
||||
'htdocs/product/class/api_products.class.php' => ['PhanPluginUnknownArrayMethodParamType', 'PhanPluginUnknownArrayMethodReturnType', 'PhanTypeMismatchArgument', 'PhanUndeclaredProperty'],
|
||||
'htdocs/product/class/html.formproduct.class.php' => ['PhanUndeclaredProperty'],
|
||||
'htdocs/product/class/product.class.php' => ['PhanTypeMismatchArgument', 'PhanTypeMismatchArgumentNullable'],
|
||||
'htdocs/product/class/productcustomerprice.class.php' => ['PhanTypeMismatchArgument'],
|
||||
'htdocs/product/class/productfournisseurprice.class.php' => ['PhanUndeclaredMethod', 'PhanUndeclaredProperty'],
|
||||
'htdocs/product/composition/card.php' => ['PhanTypeMismatchArgument'],
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2017 Juanjo Menent <jmenent@2byte.es>
|
||||
* 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
|
||||
|
|
@ -153,7 +153,7 @@ print '</td>';
|
|||
if ($filtertype != 1) { // Product
|
||||
if (getDolGlobalInt('PRODUCT_USE_UNITS')) { // For product, unit is shown only if option PRODUCT_USE_UNITS is on
|
||||
print '<td class="linecoluseunit nowrap">';
|
||||
$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);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
* Copyright (C) 2016-2023 Charlene Benke <charlene@patas-monkey.com>
|
||||
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Mélina Joum <melina.joum@altairis.fr>
|
||||
* 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;
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
|
||||
* Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
|
||||
* 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
|
||||
|
|
@ -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 <option>
|
||||
* @param string $morecss Add more css
|
||||
* @return string String with HTML select
|
||||
* @param int $selected Code state preselected (must be state id)
|
||||
* @param int|string $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 <option>
|
||||
* @param string $morecss Add more css
|
||||
* @return string String with HTML select
|
||||
* @see select_country()
|
||||
*/
|
||||
public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id', $morecss = 'maxwidth200onsmartphone minwidth300')
|
||||
|
|
|
|||
|
|
@ -7104,7 +7104,7 @@ function price2num($amount, $rounding = '', $option = 0)
|
|||
* @param Translate $outputlangs Translate language object
|
||||
* @param int<-1,max> $round -1 = non rounding, x = number of decimal
|
||||
* @param string $forceunitoutput 'no' or numeric (-3, -6, ...) compared to $unit (In most case, this value is value defined into $conf->global->MAIN_WEIGHT_DEFAULT_UNIT)
|
||||
* @param int $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated.
|
||||
* @param int<0,1> $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated.
|
||||
* @return string String to show dimensions
|
||||
*/
|
||||
function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput = 'no', $use_short_label = 0)
|
||||
|
|
@ -7139,7 +7139,7 @@ function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round
|
|||
|
||||
$ret = price($dimension, 0, $outputlangs, 0, 0, $round);
|
||||
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition
|
||||
$ret .= ' '.measuringUnitString(0, $type, (string) $unit, $use_short_label, $outputlangs);
|
||||
$ret .= ' '.measuringUnitString(0, $type, $unit, $use_short_label, $outputlangs);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
|
||||
* Copyright (C) 2024 Jean-Rémi TAPONIER <jean-remi@netlogic.fr>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Mélina Joum <melina.joum@altairis.fr>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
|
|
@ -879,15 +879,15 @@ function show_stats_for_batch($batch, $socid)
|
|||
* Return translation label of a unit key.
|
||||
* Function kept for backward compatibility.
|
||||
*
|
||||
* @param string $unitscale Scale of unit: '0', '-3', '6', ...
|
||||
* @param ?int $unitscale Scale of unit: '0', '-3', '6', ...
|
||||
* @param string $measuring_style Style of unit: weight, volume,...
|
||||
* @param int $unitid ID of unit (rowid in llx_c_units table)
|
||||
* @param int $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated.
|
||||
* @param Translate $outputlangs Language object
|
||||
* @param int<0,1> $use_short_label 1=Use short label ('g' instead of 'gram'). Short labels are not translated.
|
||||
* @param ?Translate $outputlangs Language object
|
||||
* @return string Unit string
|
||||
* @see measuringUnitString() formproduct->selectMeasuringUnits()
|
||||
*/
|
||||
function measuring_units_string($unitscale = '', $measuring_style = '', $unitid = 0, $use_short_label = 0, $outputlangs = null)
|
||||
function measuring_units_string($unitscale = null, $measuring_style = '', $unitid = 0, $use_short_label = 0, $outputlangs = null)
|
||||
{
|
||||
return measuringUnitString($unitid, $measuring_style, $unitscale, $use_short_label, $outputlangs);
|
||||
}
|
||||
|
|
@ -897,13 +897,13 @@ function measuring_units_string($unitscale = '', $measuring_style = '', $unitid
|
|||
*
|
||||
* @param int $unitid ID of unit (rowid in llx_c_units table)
|
||||
* @param string $measuring_style Style of unit: 'weight', 'volume', ..., '' = 'net_measure' for option PRODUCT_ADD_NET_MEASURE
|
||||
* @param string $unitscale Scale of unit: '0', '-3', '6', ...
|
||||
* @param int $use_short_label 1=Use very short label ('g' instead of 'gram'), not translated. 2=Use translated short label.
|
||||
* @param Translate $outputlangs Language object
|
||||
* @param ?int $unitscale Scale of unit: '0', '-3', '6', ...
|
||||
* @param int<0,2> $use_short_label 1=Use very short label ('g' instead of 'gram'), not translated. 2=Use translated short label.
|
||||
* @param ?Translate $outputlangs Language object
|
||||
* @return string|-1 Unit string if OK, -1 if KO
|
||||
* @see formproduct->selectMeasuringUnits()
|
||||
*/
|
||||
function measuringUnitString($unitid, $measuring_style = '', $unitscale = '', $use_short_label = 0, $outputlangs = null)
|
||||
function measuringUnitString($unitid, $measuring_style = '', $unitscale = null, $use_short_label = 0, $outputlangs = null)
|
||||
{
|
||||
global $langs, $db;
|
||||
global $measuring_unit_cache;
|
||||
|
|
|
|||
|
|
@ -705,7 +705,7 @@ class pdf_espadon extends ModelePdfExpedition
|
|||
}
|
||||
|
||||
if ($this->getColumnStatus('unit_order')) {
|
||||
$this->printStdColumnContent($pdf, $curY, 'unit_order', measuringUnitString($object->lines[$i]->fk_unit));
|
||||
$this->printStdColumnContent($pdf, $curY, 'unit_order', measuringUnitString((int) $object->lines[$i]->fk_unit));
|
||||
$nexY = max($pdf->GetY(), $nexY);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* 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
|
||||
|
|
@ -81,7 +81,7 @@ abstract class ModeleProductCode extends CommonNumRefGenerator
|
|||
/**
|
||||
* Return next value available
|
||||
*
|
||||
* @param Product|string $objproduct Object product
|
||||
* @param Product|'' $objproduct Object product
|
||||
* @param int $type Type
|
||||
* @return string Value
|
||||
*/
|
||||
|
|
@ -124,8 +124,8 @@ abstract class ModeleProductCode extends CommonNumRefGenerator
|
|||
* Return description of module parameters
|
||||
*
|
||||
* @param Translate $langs Output language
|
||||
* @param Product $product Product object
|
||||
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
|
||||
* @param Product|'' $product Product object
|
||||
* @param int<-1,1> $type -1=Nothing, 0=Customer, 1=Supplier
|
||||
* @return string HTML translated description
|
||||
*/
|
||||
public function getToolTip($langs, $product, $type)
|
||||
|
|
@ -205,7 +205,7 @@ abstract class ModeleProductCode extends CommonNumRefGenerator
|
|||
* Return an example of result returned by getNextValue
|
||||
*
|
||||
* @param ?Translate $langs Object langs
|
||||
* @param Product|string $objproduct Object product
|
||||
* @param Product|'' $objproduct Object product
|
||||
* @param int<-1,2> $type Type of third party (1:customer, 2:supplier, -1:autodetect)
|
||||
* @return string Return string example
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2113,7 +2113,7 @@ if ($action == 'create') {
|
|||
print '</form>';
|
||||
} else {
|
||||
print $object->trueWeight;
|
||||
print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", (string) $object->weight_units) : '';
|
||||
print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : '';
|
||||
}
|
||||
|
||||
// Calculated
|
||||
|
|
@ -2175,7 +2175,7 @@ if ($action == 'create') {
|
|||
if ($volumeUnit < 50) {
|
||||
print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, getDolGlobalInt('MAIN_VOLUME_DEFAULT_ROUND', -1), getDolGlobalString('MAIN_VOLUME_DEFAULT_UNIT', 'no'));
|
||||
} else {
|
||||
print $calculatedVolume.' '.measuringUnitString(0, "volume", (string) $volumeUnit);
|
||||
print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit);
|
||||
}
|
||||
}
|
||||
if ($totalVolume > 0) {
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ class Expedition extends CommonObject
|
|||
*/
|
||||
public $trueWidth;
|
||||
/**
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
public $width_units;
|
||||
/**
|
||||
|
|
@ -157,7 +157,7 @@ class Expedition extends CommonObject
|
|||
*/
|
||||
public $trueHeight;
|
||||
/**
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
public $height_units;
|
||||
/**
|
||||
|
|
@ -165,7 +165,7 @@ class Expedition extends CommonObject
|
|||
*/
|
||||
public $trueDepth;
|
||||
/**
|
||||
* @var string
|
||||
* @var int
|
||||
*/
|
||||
public $depth_units;
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2020 Lenin Rivas <lenin@leninrivas.com>
|
||||
* 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
|
||||
|
|
@ -228,7 +228,7 @@ class ExpeditionLigne extends CommonObjectLine
|
|||
public $width;
|
||||
|
||||
/**
|
||||
* @var string|int
|
||||
* @var int
|
||||
*/
|
||||
public $width_units;
|
||||
|
||||
|
|
@ -238,7 +238,7 @@ class ExpeditionLigne extends CommonObjectLine
|
|||
public $height;
|
||||
|
||||
/**
|
||||
* @var string|int
|
||||
* @var int
|
||||
*/
|
||||
public $height_units;
|
||||
|
||||
|
|
|
|||
|
|
@ -1619,7 +1619,7 @@ while ($i < $imaxinloop) {
|
|||
print $form->textwithpicto('', $langs->trans('EstimatedWeight'), 1);
|
||||
} else {
|
||||
print $object->trueWeight;
|
||||
print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", (string) $object->weight_units) : '';
|
||||
print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : '';
|
||||
}
|
||||
print '</td>';
|
||||
if (!$i) {
|
||||
|
|
|
|||
|
|
@ -1039,7 +1039,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
}
|
||||
$qtyhourforline = 0;
|
||||
if ($line->fk_unit) {
|
||||
$unitforline = measuringUnitString($line->fk_unit, '', '', 1);
|
||||
$unitforline = measuringUnitString($line->fk_unit, '', null, 1);
|
||||
$qtyhourforline = convertDurationtoHour($line->qty, $unitforline);
|
||||
}
|
||||
|
||||
|
|
@ -1096,7 +1096,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
print '<td class="right nowraponall">';
|
||||
$useunit = (($tmpproduct->type == Product::TYPE_PRODUCT && getDolGlobalInt('PRODUCT_USE_UNITS')) || (($tmpproduct->type == Product::TYPE_SERVICE) && ($line->fk_unit)));
|
||||
if ($useunit) {
|
||||
print measuringUnitString($line->fk_unit, '', '', 2);
|
||||
print measuringUnitString($line->fk_unit, '', null, 2);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
|
|
@ -1186,7 +1186,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
print '<td class="right nowraponall">';
|
||||
$useunit = (($tmpproduct->type == Product::TYPE_PRODUCT && getDolGlobalInt('PRODUCT_USE_UNITS')) || (($tmpproduct->type == Product::TYPE_SERVICE) && ($line->fk_unit)));
|
||||
if ($useunit) {
|
||||
print measuringUnitString($line->fk_unit, '', '', 2);
|
||||
print measuringUnitString($line->fk_unit, '', null, 2);
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
|
|
@ -1671,7 +1671,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||
print '<td class="right">'.$line->qty.'</td>';
|
||||
// Unit
|
||||
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
|
||||
print '<td class="right">'.measuringUnitString($line->fk_unit, '', '', 1).'</td>';
|
||||
print '<td class="right">'.measuringUnitString($line->fk_unit, '', null, 1).'</td>';
|
||||
}
|
||||
// Cost price
|
||||
if ($permissiontoupdatecost) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2017 Charlie Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2024-2025 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
|
||||
|
|
@ -85,7 +85,7 @@ print '</td>';
|
|||
// Qty
|
||||
print '<td class="right">'.$this->tpl['qty'].(($this->tpl['efficiency'] > 0 && $this->tpl['efficiency'] < 1) ? ' / '.$form->textwithpicto($this->tpl['efficiency'], $langs->trans("ValueOfMeansLoss")).' = '.$qtytoconsumeforline : '').'</td>';
|
||||
// Unit
|
||||
print '<td class="right">'.measuringUnitString($this->tpl['fk_unit'], '', '', 1).'</td>';
|
||||
print '<td class="right">'.measuringUnitString($this->tpl['fk_unit'], '', null, 1).'</td>';
|
||||
// Stock
|
||||
print '<td class="center">';
|
||||
if ($tmpproduct->isStockManaged()) {
|
||||
|
|
@ -170,7 +170,7 @@ if ($resql) {
|
|||
}
|
||||
|
||||
// Unit
|
||||
print '<td class="linecolunit nowrap right" id="sub_bom_unit_'.$sub_bom_line->id.'">'.measuringUnitString($sub_bom_line->fk_unit, '', '', 1).'</td>';
|
||||
print '<td class="linecolunit nowrap right" id="sub_bom_unit_'.$sub_bom_line->id.'">'.measuringUnitString($sub_bom_line->fk_unit, '', null, 1).'</td>';
|
||||
|
||||
// Stock réel
|
||||
if ($sub_bom_product->stock_reel > 0) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com
|
||||
* 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
|
||||
|
|
@ -93,12 +93,12 @@ if ($action == 'update') {
|
|||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_pricerules (level, fk_level, var_percent, var_min_percent) VALUES (";
|
||||
$sql .= ((int) $i).", ".$db->escape($i_fk_level).", ".$i_var_percent.", ".$i_var_min_percent.")";
|
||||
$sql .= ((int) $i).", ".((int) $i_fk_level).", ".$i_var_percent.", ".$i_var_min_percent.")";
|
||||
|
||||
if (!$db->query($sql)) {
|
||||
//If we could not create, then we try updating
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product_pricerules";
|
||||
$sql .= " SET fk_level = ".$db->escape($i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent." WHERE level = ".((int) $i);
|
||||
$sql .= " SET fk_level = ".((int) $i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent." WHERE level = ".((int) $i);
|
||||
|
||||
if (!$db->query($sql)) {
|
||||
setEventMessages($langs->trans('ErrorSavingChanges'), null, 'errors');
|
||||
|
|
|
|||
|
|
@ -363,8 +363,8 @@ foreach ($dirproduct as $dirroot) {
|
|||
print "</td>\n";
|
||||
} else {
|
||||
$disabled = false;
|
||||
if (!(isModEnabled('multicompany') && ((is_object($mc) && !empty($mc->sharings['referent'])) && ($mc->sharings['referent'] == $conf->entity)))) {
|
||||
}
|
||||
// if (!(isModEnabled('multicompany') && ((is_object($mc) && !empty($mc->sharings['referent'])) && ($mc->sharings['referent'] == $conf->entity)))) {
|
||||
// }
|
||||
print '<td class="center">';
|
||||
if (!$disabled) {
|
||||
print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setcodeproduct&token='.newToken().'&value='.urlencode($file).'">';
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
/* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* 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
|
||||
|
|
@ -150,7 +151,7 @@ if ($action == 'convert') {
|
|||
$newlevel = $level;
|
||||
|
||||
//print "$objectstatic->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr<br>\n";
|
||||
$retm = $objectstatic->updatePrice($newprice, $price_base_type, $user, $newvatrateclean, $newminprice, $newlevel, $newnpr, 0, 0, $localtaxes_type, $newdefaultvatcode);
|
||||
$retm = $objectstatic->updatePrice((float) $newprice, $price_base_type, $user, (float) $newvatrateclean, $newminprice, $newlevel, $newnpr, 0, 0, $localtaxes_type, $newdefaultvatcode);
|
||||
if ($retm < 0) {
|
||||
$error++;
|
||||
break;
|
||||
|
|
@ -180,7 +181,7 @@ if ($action == 'convert') {
|
|||
$newlevel = 0;
|
||||
if (!empty($price_base_type) && !$updatelevel1) {
|
||||
//print "$objectstatic->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr<br>\n";
|
||||
$ret = $objectstatic->updatePrice($newprice, $price_base_type, $user, $newvatrateclean, $newminprice, $newlevel, $newnpr, 0, 0, $localtaxes_type, $newdefaultvatcode);
|
||||
$ret = $objectstatic->updatePrice((float) $newprice, $price_base_type, $user, (float) $newvatrateclean, $newminprice, $newlevel, $newnpr, 0, 0, $localtaxes_type, $newdefaultvatcode);
|
||||
}
|
||||
|
||||
if ($ret < 0 || $retm < 0) {
|
||||
|
|
@ -236,8 +237,8 @@ if ($action == 'convert') {
|
|||
//}
|
||||
//else
|
||||
//{
|
||||
$newprice = price2num($obj->price, 'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals)
|
||||
//$newminprice=$objectstatic2->fourn_price_min;
|
||||
$newprice = price2num($obj->price, 'MU'); // Second param must be MU (we want a unit price so 'MU'. If unit price was on 4 decimal, we must keep 4 decimals)
|
||||
//$newminprice=$objectstatic2->fourn_price_min;
|
||||
//}
|
||||
//if ($newminprice > $newprice) $newminprice=$newprice;
|
||||
$newvat = str_replace('*', '', $newvatrate);
|
||||
|
|
@ -254,7 +255,7 @@ if ($action == 'convert') {
|
|||
if (!empty($price_base_type) && !$updatelevel1) {
|
||||
//print "$objectstatic2->id $newprice, $price_base_type, $newvat, $newminprice, $newlevel, $newnpr<br>\n";
|
||||
$fourn->id = $obj->fk_soc;
|
||||
$ret = $objectstatic2->update_buyprice($obj->qty, $newprice, $user, $price_base_type, $fourn, $obj->fk_availability, $obj->ref_fourn, $newvat, '', $newpercent, 0, $newnpr, $newdeliverydelay, $newsupplierreputation, $localtaxes_type, $newdefaultvatcode);
|
||||
$ret = $objectstatic2->update_buyprice($obj->qty, (float) $newprice, $user, $price_base_type, $fourn, $obj->fk_availability, $obj->ref_fourn, (float) $newvat, '', $newpercent, 0, $newnpr, $newdeliverydelay, $newsupplierreputation, $localtaxes_type, $newdefaultvatcode);
|
||||
}
|
||||
|
||||
if ($ret < 0 || $retm < 0) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2020 Josep Lluís Amador <joseplluis@lliuretic.cat>
|
||||
* 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
|
||||
|
|
@ -68,7 +69,7 @@ $finished = GETPOSTINT('finished');
|
|||
$alsoproductwithnosupplierprice = GETPOSTINT('alsoproductwithnosupplierprice');
|
||||
$warehouseStatus = GETPOST('warehousestatus', 'alpha');
|
||||
$hidepriceinlabel = GETPOSTINT('hidepriceinlabel');
|
||||
$warehouseId = GETPOST('warehouseid', 'int');
|
||||
$warehouseId = GETPOSTINT('warehouseid');
|
||||
|
||||
// Security check
|
||||
restrictedArea($user, 'produit|service|commande|propal|facture', 0, 'product&product');
|
||||
|
|
@ -214,7 +215,7 @@ if ($action == 'fetch' && !empty($id)) {
|
|||
|
||||
$prodcustprice = new ProductCustomerPrice($db);
|
||||
|
||||
$filter = array('t.fk_product' => $object->id, 't.fk_soc' => $socid);
|
||||
$filter = array('t.fk_product' => (string) $object->id, 't.fk_soc' => (string) $socid);
|
||||
|
||||
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
|
|
@ -252,7 +253,7 @@ if ($action == 'fetch' && !empty($id)) {
|
|||
$tmpvatwithcode = get_default_tva($mysoc, $thirdparty_buyer, $id, 0);
|
||||
|
||||
if (!is_numeric($tmpvatwithcode) || $tmpvatwithcode != -1) {
|
||||
$reg =array();
|
||||
$reg = array();
|
||||
if (preg_match('/(.+)\s\((.+)\)/', $tmpvatwithcode, $reg)) {
|
||||
$outtva_tx = price2num($reg[1]);
|
||||
$outtva_tx_formated = price($outtva_tx);
|
||||
|
|
@ -286,7 +287,7 @@ if ($action == 'fetch' && !empty($id)) {
|
|||
'qty' => $outqty,
|
||||
'discount' => $outdiscount,
|
||||
'mandatory_period' => $mandatory_period,
|
||||
'array_options'=>$object->array_options
|
||||
'array_options' => $object->array_options
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -325,7 +326,7 @@ if ($action == 'fetch' && !empty($id)) {
|
|||
|
||||
$arrayresult = [];
|
||||
if (empty($mode) || $mode == 1) { // mode=1: customer
|
||||
$arrayresult = $form->select_produits_list("", $htmlname, $type, getDolGlobalInt('PRODUIT_LIMIT_SIZE', 1000), $price_level, $searchkey, $status, $finished, $outjson, $socid, '1', 0, '', $hidepriceinlabel, $warehouseStatus, $status_purchase, $warehouseId);
|
||||
$arrayresult = $form->select_produits_list(0, $htmlname, $type, getDolGlobalInt('PRODUIT_LIMIT_SIZE', 1000), $price_level, $searchkey, $status, $finished, $outjson, $socid, '1', 0, '', $hidepriceinlabel, $warehouseStatus, $status_purchase, $warehouseId);
|
||||
} elseif ($mode == 2) { // mode=2: supplier
|
||||
$arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, getDolGlobalInt('PRODUIT_LIMIT_SIZE', 1000), $alsoproductwithnosupplierprice);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/* Copyright (C) 2010-2018 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* 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
|
||||
|
|
@ -245,23 +245,23 @@ class ActionsCardProduct
|
|||
|
||||
// Finished
|
||||
$statutarray = array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial"));
|
||||
$this->tpl['finished'] = $form->selectarray('finished', $statutarray, $this->object->finished);
|
||||
$this->tpl['finished'] = $form->selectarray('finished', $statutarray, (int) $this->object->finished);
|
||||
|
||||
// Weight
|
||||
$this->tpl['weight'] = $this->object->weight;
|
||||
$this->tpl['weight_units'] = $formproduct->selectMeasuringUnits("weight_units", "weight", $this->object->weight_units, 0, 2);
|
||||
$this->tpl['weight_units'] = $formproduct->selectMeasuringUnits("weight_units", "weight", (string) $this->object->weight_units, 0, 2);
|
||||
|
||||
// Length
|
||||
$this->tpl['length'] = $this->object->length;
|
||||
$this->tpl['length_units'] = $formproduct->selectMeasuringUnits("length_units", "size", $this->object->length_units, 0, 2);
|
||||
$this->tpl['length_units'] = $formproduct->selectMeasuringUnits("length_units", "size", (string) $this->object->length_units, 0, 2);
|
||||
|
||||
// Surface
|
||||
$this->tpl['surface'] = $this->object->surface;
|
||||
$this->tpl['surface_units'] = $formproduct->selectMeasuringUnits("surface_units", "surface", $this->object->surface_units, 0, 2);
|
||||
$this->tpl['surface_units'] = $formproduct->selectMeasuringUnits("surface_units", "surface", (string) $this->object->surface_units, 0, 2);
|
||||
|
||||
// Volume
|
||||
$this->tpl['volume'] = $this->object->volume;
|
||||
$this->tpl['volume_units'] = $formproduct->selectMeasuringUnits("volume_units", "volume", $this->object->volume_units, 0, 2);
|
||||
$this->tpl['volume_units'] = $formproduct->selectMeasuringUnits("volume_units", "volume", (string) $this->object->volume_units, 0, 2);
|
||||
}
|
||||
|
||||
if ($action == 'view') {
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ $extrafields = new ExtraFields($db);
|
|||
$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$result = $object->fetch($id, $ref);
|
||||
$result = $object->fetch($id, (string) $ref);
|
||||
if ($result < 0) {
|
||||
dol_print_error($db, $object->error, $object->errors);
|
||||
}
|
||||
|
|
@ -634,7 +634,7 @@ if (empty($reshook)) {
|
|||
$object->desiredstock = GETPOST('desiredstock') ? GETPOST('desiredstock') : 0;
|
||||
$object->canvas = GETPOST('canvas');
|
||||
$object->net_measure = GETPOST('net_measure');
|
||||
$object->net_measure_units = GETPOST('net_measure_units'); // This is not the fk_unit but the power of unit
|
||||
$object->net_measure_units = GETPOST('net_measure_units') === '' ? null : GETPOSTINT('net_measure_units'); // This is not the fk_unit but the power of unit
|
||||
$object->weight = GETPOST('weight');
|
||||
$object->weight_units = GETPOST('weight_units'); // This is not the fk_unit but the power of unit
|
||||
$object->length = GETPOST('size');
|
||||
|
|
@ -812,7 +812,7 @@ if (empty($reshook)) {
|
|||
|
||||
$object->canvas = GETPOST('canvas');
|
||||
$object->net_measure = GETPOST('net_measure');
|
||||
$object->net_measure_units = GETPOST('net_measure_units'); // This is not the fk_unit but the power of unit
|
||||
$object->net_measure_units = GETPOST('net_measure_units') === '' ? null : GETPOSTINT('net_measure_units'); // This is not the fk_unit but the power of unit
|
||||
$object->weight = GETPOST('weight');
|
||||
$object->weight_units = GETPOST('weight_units'); // This is not the fk_unit but the power of unit
|
||||
$object->length = GETPOST('size');
|
||||
|
|
@ -1090,27 +1090,27 @@ if (empty($reshook)) {
|
|||
$commande = null;
|
||||
|
||||
// Get object and test permission
|
||||
if (GETPOST('propalid') > 0) {
|
||||
if (GETPOSTINT('propalid') > 0) {
|
||||
$propal = new Propal($db);
|
||||
$result = $propal->fetch(GETPOST('propalid'));
|
||||
$result = $propal->fetch(GETPOSTINT('propalid'));
|
||||
if ($result <= 0) {
|
||||
dol_print_error($db, $propal->error);
|
||||
exit;
|
||||
}
|
||||
$thirdpartyid = $propal->socid;
|
||||
$permissiontoaddline = $user->hasRight('propal', 'creer');
|
||||
} elseif (GETPOST('commandeid') > 0) {
|
||||
} elseif (GETPOSTINT('commandeid') > 0) {
|
||||
$commande = new Commande($db);
|
||||
$result = $commande->fetch(GETPOST('commandeid'));
|
||||
$result = $commande->fetch(GETPOSTINT('commandeid'));
|
||||
if ($result <= 0) {
|
||||
dol_print_error($db, $commande->error);
|
||||
exit;
|
||||
}
|
||||
$thirdpartyid = $commande->socid;
|
||||
$permissiontoaddline = $user->hasRight('commande', 'creer');
|
||||
} elseif (GETPOST('factureid') > 0) {
|
||||
} elseif (GETPOSTINT('factureid') > 0) {
|
||||
$facture = new Facture($db);
|
||||
$result = $facture->fetch(GETPOST('factureid'));
|
||||
$result = $facture->fetch(GETPOSTINT('factureid'));
|
||||
if ($result <= 0) {
|
||||
dol_print_error($db, $facture->error);
|
||||
exit;
|
||||
|
|
@ -1151,7 +1151,7 @@ if (empty($reshook)) {
|
|||
|
||||
$prodcustprice = new ProductCustomerPrice($db);
|
||||
|
||||
$filter = array('t.fk_product' => $object->id, 't.fk_soc' => $soc->id);
|
||||
$filter = array('t.fk_product' => (string) $object->id, 't.fk_soc' => (string) $soc->id);
|
||||
|
||||
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
|
|
@ -1165,7 +1165,7 @@ if (empty($reshook)) {
|
|||
}
|
||||
|
||||
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
|
||||
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
|
||||
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $object->tva_tx));
|
||||
|
||||
// On reevalue prix selon taux tva car taux tva transaction peut etre different
|
||||
// de ceux du produit par default (par example si pays different entre vendeur et acheteur).
|
||||
|
|
@ -1177,10 +1177,10 @@ if (empty($reshook)) {
|
|||
}
|
||||
}
|
||||
|
||||
if (GETPOST('propalid') > 0 && $permissiontoaddline && is_object($propal)) {
|
||||
if (GETPOSTINT('propalid') > 0 && $permissiontoaddline && is_object($propal)) {
|
||||
// Define cost price for margin calculation
|
||||
$buyprice = 0;
|
||||
if (($result = $propal->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) {
|
||||
if (($result = $propal->defineBuyPrice($pu_ht, (float) price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) {
|
||||
dol_syslog($langs->trans('FailedToGetCostPrice'));
|
||||
setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors');
|
||||
} else {
|
||||
|
|
@ -1190,12 +1190,12 @@ if (empty($reshook)) {
|
|||
$result = $propal->addline(
|
||||
$desc,
|
||||
$pu_ht,
|
||||
price2num(GETPOST('qty'), 'MS'),
|
||||
(float) price2num(GETPOST('qty'), 'MS'),
|
||||
$tva_tx,
|
||||
$localtax1_tx, // localtax1
|
||||
$localtax2_tx, // localtax2
|
||||
$object->id,
|
||||
price2num(GETPOST('remise_percent'), '', 2),
|
||||
(float) price2num(GETPOST('remise_percent'), '', 2),
|
||||
$price_base_type,
|
||||
$pu_ttc,
|
||||
0,
|
||||
|
|
@ -1220,7 +1220,7 @@ if (empty($reshook)) {
|
|||
} elseif (GETPOST('commandeid') > 0 && $permissiontoaddline && is_object($commande)) {
|
||||
// Define cost price for margin calculation
|
||||
$buyprice = 0;
|
||||
if (($result = $commande->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) {
|
||||
if (($result = $commande->defineBuyPrice($pu_ht, (float) price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) {
|
||||
dol_syslog($langs->trans('FailedToGetCostPrice'));
|
||||
setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors');
|
||||
} else {
|
||||
|
|
@ -1229,13 +1229,13 @@ if (empty($reshook)) {
|
|||
|
||||
$result = $commande->addline(
|
||||
$desc,
|
||||
$pu_ht,
|
||||
price2num(GETPOST('qty'), 'MS'),
|
||||
(float) $pu_ht,
|
||||
(float) price2num(GETPOST('qty'), 'MS'),
|
||||
$tva_tx,
|
||||
$localtax1_tx, // localtax1
|
||||
$localtax2_tx, // localtax2
|
||||
$object->id,
|
||||
price2num(GETPOST('remise_percent'), '', 2),
|
||||
(float) price2num(GETPOST('remise_percent'), '', 2),
|
||||
0,
|
||||
0,
|
||||
$price_base_type,
|
||||
|
|
@ -1262,7 +1262,7 @@ if (empty($reshook)) {
|
|||
} elseif (GETPOST('factureid') > 0 && $permissiontoaddline && is_object($facture)) {
|
||||
// Define cost price for margin calculation
|
||||
$buyprice = 0;
|
||||
if (($result = $facture->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) {
|
||||
if (($result = $facture->defineBuyPrice($pu_ht, (float) price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) {
|
||||
dol_syslog($langs->trans('FailedToGetCostPrice'));
|
||||
setEventMessages($langs->trans('FailedToGetCostPrice'), null, 'errors');
|
||||
} else {
|
||||
|
|
@ -1271,13 +1271,13 @@ if (empty($reshook)) {
|
|||
|
||||
$result = $facture->addline(
|
||||
$desc,
|
||||
$pu_ht,
|
||||
price2num(GETPOST('qty'), 'MS'),
|
||||
(float) $pu_ht,
|
||||
(float) price2num(GETPOST('qty'), 'MS'),
|
||||
$tva_tx,
|
||||
$localtax1_tx,
|
||||
$localtax2_tx,
|
||||
$object->id,
|
||||
price2num(GETPOST('remise_percent'), '', 2),
|
||||
(float) price2num(GETPOST('remise_percent'), '', 2),
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
|
|
@ -1666,7 +1666,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
|
|||
if (!getDolGlobalString('PRODUCT_DISABLE_NATURE')) {
|
||||
// Nature
|
||||
print '<tr><td>'.$form->textwithpicto($langs->trans("NatureOfProductShort"), $langs->trans("NatureOfProductDesc")).'</td><td>';
|
||||
print $formproduct->selectProductNature('finished', $object->finished);
|
||||
print $formproduct->selectProductNature('finished', (string) $object->finished);
|
||||
print '</td></tr>';
|
||||
}
|
||||
}
|
||||
|
|
@ -1845,7 +1845,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
|
|||
} else {
|
||||
$accountancy_code_sell = (GETPOSTISSET('accountancy_code_sell') ? GETPOST('accountancy_code_sell', 'alpha') : getDolGlobalString("ACCOUNTING_SERVICE_SOLD_ACCOUNT"));
|
||||
}
|
||||
print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, array(), 1, 1, 'minwidth150 maxwidth300', 1);
|
||||
print $formaccounting->select_account($accountancy_code_sell, 'accountancy_code_sell', 1, array(), 1, 1, 'minwidth150 maxwidth300', '1');
|
||||
print '</td></tr>';
|
||||
|
||||
// Accountancy_code_sell_intra
|
||||
|
|
@ -1857,7 +1857,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
|
|||
} else {
|
||||
$accountancy_code_sell_intra = (GETPOSTISSET('accountancy_code_sell_intra') ? GETPOST('accountancy_code_sell_intra', 'alpha') : getDolGlobalString("ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT"));
|
||||
}
|
||||
print $formaccounting->select_account($accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, array(), 1, 1, 'minwidth150 maxwidth300', 1);
|
||||
print $formaccounting->select_account($accountancy_code_sell_intra, 'accountancy_code_sell_intra', 1, array(), 1, 1, 'minwidth150 maxwidth300', '1');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
|
@ -1869,7 +1869,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
|
|||
} else {
|
||||
$accountancy_code_sell_export = (GETPOST('accountancy_code_sell_export') ? GETPOST('accountancy_code_sell_export', 'alpha') : getDolGlobalString("ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT"));
|
||||
}
|
||||
print $formaccounting->select_account($accountancy_code_sell_export, 'accountancy_code_sell_export', 1, array(), 1, 1, 'minwidth150 maxwidth300', 1);
|
||||
print $formaccounting->select_account($accountancy_code_sell_export, 'accountancy_code_sell_export', 1, array(), 1, 1, 'minwidth150 maxwidth300', '1');
|
||||
print '</td></tr>';
|
||||
|
||||
// Accountancy_code_buy
|
||||
|
|
@ -1880,7 +1880,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
|
|||
} else {
|
||||
$accountancy_code_buy = (GETPOST('accountancy_code_buy', 'alpha') ? (GETPOST('accountancy_code_buy', 'alpha')) : getDolGlobalString("ACCOUNTING_SERVICE_BUY_ACCOUNT"));
|
||||
}
|
||||
print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, array(), 1, 1, 'minwidth150 maxwidth300', 1);
|
||||
print $formaccounting->select_account($accountancy_code_buy, 'accountancy_code_buy', 1, array(), 1, 1, 'minwidth150 maxwidth300', '1');
|
||||
print '</td></tr>';
|
||||
|
||||
// Accountancy_code_buy_intra
|
||||
|
|
@ -1892,7 +1892,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
|
|||
} else {
|
||||
$accountancy_code_buy_intra = (GETPOSTISSET('accountancy_code_buy_intra') ? GETPOST('accountancy_code_buy_intra', 'alpha') : getDolGlobalString("ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT"));
|
||||
}
|
||||
print $formaccounting->select_account($accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, array(), 1, 1, 'minwidth150 maxwidth300', 1);
|
||||
print $formaccounting->select_account($accountancy_code_buy_intra, 'accountancy_code_buy_intra', 1, array(), 1, 1, 'minwidth150 maxwidth300', '1');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
|
@ -1904,7 +1904,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
|
|||
} else {
|
||||
$accountancy_code_buy_export = (GETPOST('accountancy_code_buy_export') ? GETPOST('accountancy_code_buy_export', 'alpha') : getDolGlobalString("ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT"));
|
||||
}
|
||||
print $formaccounting->select_account($accountancy_code_buy_export, 'accountancy_code_buy_export', 1, array(), 1, 1, 'minwidth150 maxwidth300', 1);
|
||||
print $formaccounting->select_account($accountancy_code_buy_export, 'accountancy_code_buy_export', 1, array(), 1, 1, 'minwidth150 maxwidth300', '1');
|
||||
print '</td></tr>';
|
||||
} else {// For external software
|
||||
if (!empty($accountancy_code_sell)) {
|
||||
|
|
@ -2360,7 +2360,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
|
|||
print '<tr><td>'.$langs->trans("CountryOrigin").'</td>';
|
||||
print '<td>';
|
||||
print img_picto('', 'globe-americas', 'class="paddingrightonly"');
|
||||
print $form->select_country(GETPOSTISSET('country_id') ? GETPOSTINT('country_id') : $object->country_id, 'country_id', '', 0, 'minwidth100 maxwidthonsmartphone');
|
||||
print $form->select_country((string) (GETPOSTISSET('country_id') ? GETPOSTINT('country_id') : $object->country_id), 'country_id', '', 0, 'minwidth100 maxwidthonsmartphone');
|
||||
if ($user->admin) {
|
||||
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||
}
|
||||
|
|
@ -2559,7 +2559,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
|
|||
if (isModEnabled("product") && isModEnabled("service")) {
|
||||
$typeformat = 'select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service");
|
||||
print '<tr><td class="titlefield">';
|
||||
print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans('Type');
|
||||
print (!getDolGlobalString('PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey("Type", 'fk_product_type', (string) $object->type, $object, (int) $usercancreate, $typeformat) : $langs->trans('Type');
|
||||
print '</td><td>';
|
||||
print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat);
|
||||
print '</td></tr>';
|
||||
|
|
@ -2605,7 +2605,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
|
|||
if ($action == 'editbarcode') {
|
||||
$tmpcode = GETPOSTISSET('barcode') ? GETPOST('barcode') : $object->barcode;
|
||||
if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
|
||||
$tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type);
|
||||
$tmpcode = $modBarCodeProduct->getNextValue($object, (string) $fk_barcode_type);
|
||||
}
|
||||
|
||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
|
||||
|
|
@ -2900,7 +2900,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio
|
|||
// Net Measure
|
||||
print '<tr><td class="titlefieldmiddle">'.$langs->trans("NetMeasure").'</td><td>';
|
||||
if ($object->net_measure != '') {
|
||||
print $object->net_measure." ".measuringUnitString($object->net_measure_units);
|
||||
print $object->net_measure." ".measuringUnitString((int) $object->net_measure_units);
|
||||
} else {
|
||||
print ' ';
|
||||
}
|
||||
|
|
@ -3212,7 +3212,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete') {
|
|||
$genallowed = $usercanread;
|
||||
$delallowed = $usercancreate;
|
||||
|
||||
print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $langs->getDefaultLang(), '', $object);
|
||||
print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, (int) $genallowed, (int) $delallowed, '', 0, 0, 0, 28, 0, '', '', '', $langs->getDefaultLang(), '', $object);
|
||||
$somethingshown = $formfile->numoffiles;
|
||||
|
||||
print '</div><div class="fichehalfright">';
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
/* Copyright (C) 2008-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2015-2017 Francis Appels <francis.appels@yahoo.com>
|
||||
* 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
|
||||
|
|
@ -292,7 +292,7 @@ class FormProduct
|
|||
* @param array<array{method:string,url:string,htmlname:string,params:array<string,string>}> $events Events to add to select2
|
||||
* @param string $morecss Add more css classes to HTML select
|
||||
* @param int[] $exclude Warehouses ids to exclude
|
||||
* @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse
|
||||
* @param int<0,1> $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse
|
||||
* @param bool|int $stockMin [=false] Value of minimum stock to filter (only warehouse with stock > stockMin are loaded) or false not not filter by minimum stock
|
||||
* @param string $orderBy [='e.ref'] Order by
|
||||
* @param int<0,1> $multiselect 1=Allow multiselect
|
||||
|
|
@ -307,7 +307,7 @@ class FormProduct
|
|||
dol_syslog(get_class($this)."::selectWarehouses " . (is_array($selected) ? 'selected is array' : $selected) . ", $htmlname, $filterstatus, $empty, $disabled, $fk_product, $empty_label, $showstock, $forcecombo, $morecss", LOG_DEBUG);
|
||||
|
||||
$out = '';
|
||||
if ((!getDolGlobalString('ENTREPOT_EXTRA_STATUS')) && ($filterstatus==="warehouseinternal")) {
|
||||
if ((!getDolGlobalString('ENTREPOT_EXTRA_STATUS')) && ($filterstatus === "warehouseinternal")) {
|
||||
$filterstatus = '';
|
||||
}
|
||||
if (!empty($fk_product) && $fk_product > 0) {
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ class Product extends CommonObject
|
|||
public $level;
|
||||
|
||||
/**
|
||||
* @var ?array<string,array{label:string,description:string,note?:string}> Array for multilangs
|
||||
* @var ?array<string,array{label:string,description:string,note?:string,other?:string}> Array for multilangs
|
||||
*/
|
||||
public $multilangs = array();
|
||||
|
||||
|
|
@ -509,7 +509,7 @@ class Product extends CommonObject
|
|||
public $weight;
|
||||
|
||||
/**
|
||||
* @var int|string
|
||||
* @var ?int
|
||||
*/
|
||||
public $weight_units; // scale -3, 0, 3, 6
|
||||
/**
|
||||
|
|
@ -517,7 +517,7 @@ class Product extends CommonObject
|
|||
*/
|
||||
public $length;
|
||||
/**
|
||||
* @var int|string
|
||||
* @var ?int
|
||||
*/
|
||||
public $length_units; // scale -3, 0, 3, 6
|
||||
/**
|
||||
|
|
@ -525,7 +525,7 @@ class Product extends CommonObject
|
|||
*/
|
||||
public $width;
|
||||
/**
|
||||
* @var int|string
|
||||
* @var ?int
|
||||
*/
|
||||
public $width_units; // scale -3, 0, 3, 6
|
||||
/**
|
||||
|
|
@ -533,7 +533,7 @@ class Product extends CommonObject
|
|||
*/
|
||||
public $height;
|
||||
/**
|
||||
* @var int|string|null
|
||||
* @var ?int
|
||||
*/
|
||||
public $height_units; // scale -3, 0, 3, 6
|
||||
/**
|
||||
|
|
@ -541,7 +541,7 @@ class Product extends CommonObject
|
|||
*/
|
||||
public $surface;
|
||||
/**
|
||||
* @var int|string|null
|
||||
* @var ?int
|
||||
*/
|
||||
public $surface_units; // scale -3, 0, 3, 6
|
||||
/**
|
||||
|
|
@ -549,7 +549,7 @@ class Product extends CommonObject
|
|||
*/
|
||||
public $volume;
|
||||
/**
|
||||
* @var int|string|null
|
||||
* @var ?int
|
||||
*/
|
||||
public $volume_units; // scale -3, 0, 3, 6
|
||||
|
||||
|
|
@ -558,7 +558,7 @@ class Product extends CommonObject
|
|||
*/
|
||||
public $net_measure;
|
||||
/**
|
||||
* @var ?string
|
||||
* @var ?int
|
||||
*/
|
||||
public $net_measure_units; // scale -3, 0, 3, 6
|
||||
|
||||
|
|
@ -1151,7 +1151,7 @@ class Product extends CommonObject
|
|||
$sql .= ", ".((empty($this->sell_or_eat_by_mandatory) || $this->sell_or_eat_by_mandatory < 0) ? 0 : ((int) $this->sell_or_eat_by_mandatory));
|
||||
$sql .= ", '".$this->db->escape($this->batch_mask)."'";
|
||||
$sql .= ", ".($this->fk_unit > 0 ? ((int) $this->fk_unit) : 'NULL');
|
||||
$sql .= ", '".$this->db->escape($this->mandatory_period)."'";
|
||||
$sql .= ", '".$this->db->escape((string) $this->mandatory_period)."'";
|
||||
$sql .= ")";
|
||||
|
||||
dol_syslog(get_class($this)."::Create", LOG_DEBUG);
|
||||
|
|
@ -1368,19 +1368,19 @@ class Product extends CommonObject
|
|||
$this->note_private = (isset($this->note_private) ? trim($this->note_private) : null);
|
||||
$this->note_public = (isset($this->note_public) ? trim($this->note_public) : null);
|
||||
$this->net_measure = price2num($this->net_measure);
|
||||
$this->net_measure_units = (is_null($this->net_measure_units) ? '' : trim((string) $this->net_measure_units));
|
||||
$this->net_measure_units = (!is_numeric($this->net_measure_units) ? null : (int) $this->net_measure_units);
|
||||
$this->weight = price2num($this->weight);
|
||||
$this->weight_units = (is_null($this->weight_units) ? '' : trim((string) $this->weight_units));
|
||||
$this->weight_units = (!is_numeric($this->weight_units) ? null : (int) $this->weight_units);
|
||||
$this->length = price2num($this->length);
|
||||
$this->length_units = (is_null($this->length_units) ? '' : trim((string) $this->length_units));
|
||||
$this->length_units = (!is_numeric($this->length_units) ? null : (int) $this->length_units);
|
||||
$this->width = price2num($this->width);
|
||||
$this->width_units = (is_null($this->width_units) ? '' : trim((string) $this->width_units));
|
||||
$this->width_units = (!is_numeric($this->width_units) ? null : (int) $this->width_units);
|
||||
$this->height = price2num($this->height);
|
||||
$this->height_units = (is_null($this->height_units) ? '' : trim((string) $this->height_units));
|
||||
$this->height_units = (!is_numeric($this->height_units) ? null : (int) $this->height_units);
|
||||
$this->surface = price2num($this->surface);
|
||||
$this->surface_units = (is_null($this->surface_units) ? '' : trim((string) $this->surface_units));
|
||||
$this->surface_units = (!is_numeric($this->surface_units) ? null : (int) $this->surface_units);
|
||||
$this->volume = price2num($this->volume);
|
||||
$this->volume_units = (is_null($this->volume_units) ? '' : trim((string) $this->volume_units));
|
||||
$this->volume_units = (!is_numeric($this->volume_units) ? null : (int) $this->volume_units);
|
||||
|
||||
// set unit not defined
|
||||
if (is_numeric($this->length_units)) {
|
||||
|
|
@ -1511,7 +1511,7 @@ class Product extends CommonObject
|
|||
$ObjLot->entity = $this->entity;
|
||||
$ObjLot->fk_user_creat = $user->id;
|
||||
$ObjLot->batch = $valueforundefinedlot;
|
||||
if ($ObjLot->create($user, true) < 0) {
|
||||
if ($ObjLot->create($user, 1) < 0) {
|
||||
$error++;
|
||||
$this->errors = $ObjLot->errors;
|
||||
}
|
||||
|
|
@ -1544,7 +1544,7 @@ class Product extends CommonObject
|
|||
$sql .= ", localtax2_type = ".($this->localtax2_type != '' ? "'".$this->db->escape($this->localtax2_type)."'" : "'0'");
|
||||
|
||||
$sql .= ", barcode = ".(empty($this->barcode) ? "null" : "'".$this->db->escape($this->barcode)."'");
|
||||
$sql .= ", fk_barcode_type = ".(empty($this->barcode_type) ? "null" : $this->db->escape($this->barcode_type));
|
||||
$sql .= ", fk_barcode_type = ".(empty($this->barcode_type) ? "null" : $this->db->escape((string) $this->barcode_type));
|
||||
|
||||
$sql .= ", tosell = ".(int) $this->status;
|
||||
$sql .= ", tobuy = ".(int) $this->status_buy;
|
||||
|
|
@ -1555,19 +1555,19 @@ class Product extends CommonObject
|
|||
$sql .= ", finished = ".((!isset($this->finished) || $this->finished < 0 || $this->finished === '') ? "null" : (int) $this->finished);
|
||||
$sql .= ", fk_default_bom = ".((!isset($this->fk_default_bom) || $this->fk_default_bom < 0 || $this->fk_default_bom == '') ? "null" : (int) $this->fk_default_bom);
|
||||
$sql .= ", net_measure = ".($this->net_measure != '' ? "'".$this->db->escape($this->net_measure)."'" : 'null');
|
||||
$sql .= ", net_measure_units = ".($this->net_measure_units != '' ? "'".$this->db->escape($this->net_measure_units)."'" : 'null');
|
||||
$sql .= ", net_measure_units = ".((string) $this->net_measure_units != '' ? ((int) $this->net_measure_units) : 'null');
|
||||
$sql .= ", weight = ".($this->weight != '' ? "'".$this->db->escape($this->weight)."'" : 'null');
|
||||
$sql .= ", weight_units = ".($this->weight_units != '' ? "'".$this->db->escape($this->weight_units)."'" : 'null');
|
||||
$sql .= ", weight_units = ".((string) $this->weight_units != '' ? ((int) $this->weight_units) : 'null');
|
||||
$sql .= ", length = ".($this->length != '' ? "'".$this->db->escape($this->length)."'" : 'null');
|
||||
$sql .= ", length_units = ".($this->length_units != '' ? "'".$this->db->escape($this->length_units)."'" : 'null');
|
||||
$sql .= ", length_units = ".((string) $this->length_units != '' ? ((int) $this->length_units) : 'null');
|
||||
$sql .= ", width= ".($this->width != '' ? "'".$this->db->escape($this->width)."'" : 'null');
|
||||
$sql .= ", width_units = ".($this->width_units != '' ? "'".$this->db->escape($this->width_units)."'" : 'null');
|
||||
$sql .= ", width_units = ".((string) $this->width_units != '' ? ((int) $this->width_units) : 'null');
|
||||
$sql .= ", height = ".($this->height != '' ? "'".$this->db->escape($this->height)."'" : 'null');
|
||||
$sql .= ", height_units = ".($this->height_units != '' ? "'".$this->db->escape($this->height_units)."'" : 'null');
|
||||
$sql .= ", height_units = ".((string) $this->height_units != '' ? ((int) $this->height_units) : 'null');
|
||||
$sql .= ", surface = ".($this->surface != '' ? "'".$this->db->escape($this->surface)."'" : 'null');
|
||||
$sql .= ", surface_units = ".($this->surface_units != '' ? "'".$this->db->escape($this->surface_units)."'" : 'null');
|
||||
$sql .= ", surface_units = ".((string) $this->surface_units != '' ? ((int) $this->surface_units) : 'null');
|
||||
$sql .= ", volume = ".($this->volume != '' ? "'".$this->db->escape($this->volume)."'" : 'null');
|
||||
$sql .= ", volume_units = ".($this->volume_units != '' ? "'".$this->db->escape($this->volume_units)."'" : 'null');
|
||||
$sql .= ", volume_units = ".((string) $this->volume_units != '' ? ((int) $this->volume_units) : 'null');
|
||||
$sql .= ", fk_default_warehouse = ".($this->fk_default_warehouse > 0 ? ((int) $this->fk_default_warehouse) : 'null');
|
||||
$sql .= ", fk_default_workstation = ".($this->fk_default_workstation > 0 ? ((int) $this->fk_default_workstation) : 'null');
|
||||
$sql .= ", seuil_stock_alerte = ".((isset($this->seuil_stock_alerte) && is_numeric($this->seuil_stock_alerte)) ? (float) $this->seuil_stock_alerte : 'null');
|
||||
|
|
@ -2346,7 +2346,7 @@ class Product extends CommonObject
|
|||
|
||||
$prodcustprice = new ProductCustomerPrice($this->db);
|
||||
|
||||
$filter = array('t.fk_product' => $this->id, 't.fk_soc' => $thirdparty_buyer->id);
|
||||
$filter = array('t.fk_product' => (string) $this->id, 't.fk_soc' => (string) $thirdparty_buyer->id);
|
||||
|
||||
// If a price per customer exist
|
||||
$pricebycustomerexist = false;
|
||||
|
|
@ -2409,7 +2409,7 @@ class Product extends CommonObject
|
|||
|
||||
$prodcustprice = new ProductCustomerPrice($this->db);
|
||||
|
||||
$filter = array('t.fk_product' => $this->id, 't.fk_soc' => $thirdparty_buyer->id);
|
||||
$filter = array('t.fk_product' => (string) $this->id, 't.fk_soc' => (string) $thirdparty_buyer->id);
|
||||
|
||||
$result = $prodcustprice->fetchAll('', '', 0, 0, $filter);
|
||||
if ($result) {
|
||||
|
|
@ -2783,7 +2783,7 @@ class Product extends CommonObject
|
|||
$sql .= " default_vat_code = ".($newdefaultvatcode ? "'".$this->db->escape($newdefaultvatcode)."'" : "null").",";
|
||||
$sql .= " price_label = ".(!empty($price_label) ? "'".$this->db->escape($price_label)."'" : "null").",";
|
||||
$sql .= " tva_tx = ".(float) price2num($newvat).",";
|
||||
$sql .= " recuperableonly = '".$this->db->escape($newnpr)."'";
|
||||
$sql .= " recuperableonly = '".$this->db->escape((string) $newnpr)."'";
|
||||
$sql .= " WHERE rowid = ".((int) $id);
|
||||
|
||||
dol_syslog(get_class($this)."::update_price", LOG_DEBUG);
|
||||
|
|
@ -3616,7 +3616,7 @@ class Product extends CommonObject
|
|||
if (getDolGlobalString('DECREASE_ONLY_UNINVOICEDPRODUCTS')) {
|
||||
// If option DECREASE_ONLY_UNINVOICEDPRODUCTS is on, we make a compensation but only if order not yet invoice.
|
||||
$adeduire = 0;
|
||||
$sql = "SELECT SUM(".$this->db->ifsql('f.type=2', -1, 1)." * fd.qty) as count FROM ".$this->db->prefix()."facturedet as fd ";
|
||||
$sql = "SELECT SUM(".$this->db->ifsql('f.type=2', '-1', '1')." * fd.qty) as count FROM ".$this->db->prefix()."facturedet as fd ";
|
||||
$sql .= " JOIN ".$this->db->prefix()."facture as f ON fd.fk_facture = f.rowid";
|
||||
$sql .= " JOIN ".$this->db->prefix()."element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))";
|
||||
$sql .= " JOIN ".$this->db->prefix()."commande as c ON el.fk_source = c.rowid";
|
||||
|
|
@ -3638,7 +3638,7 @@ class Product extends CommonObject
|
|||
|
||||
// For every order having invoice already validated we need to decrease stock cause it's in physical stock
|
||||
$adeduire = 0;
|
||||
$sql = "SELECT sum(".$this->db->ifsql('f.type=2', -1, 1)." * fd.qty) as count FROM ".MAIN_DB_PREFIX."facturedet as fd ";
|
||||
$sql = "SELECT sum(".$this->db->ifsql('f.type=2', '-1', '1')." * fd.qty) as count FROM ".MAIN_DB_PREFIX."facturedet as fd ";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."facture as f ON fd.fk_facture = f.rowid";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."element_element as el ON ((el.fk_target = f.rowid AND el.targettype = 'facture' AND sourcetype = 'commande') OR (el.fk_source = f.rowid AND el.targettype = 'commande' AND sourcetype = 'facture'))";
|
||||
$sql .= " JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid";
|
||||
|
|
@ -5342,7 +5342,7 @@ class Product extends CommonObject
|
|||
* @param int $multiply Because each sublevel must be multiplicated by parent nb
|
||||
* @param int $level Init level
|
||||
* @param int $id_parent Id parent
|
||||
* @param int $ignore_stock_load Ignore stock load
|
||||
* @param int<0,1> $ignore_stock_load Ignore stock load
|
||||
* @return void
|
||||
*/
|
||||
public function fetch_prod_arbo($prod, $compl_path = '', $multiply = 1, $level = 1, $id_parent = 0, $ignore_stock_load = 0)
|
||||
|
|
@ -5350,6 +5350,11 @@ class Product extends CommonObject
|
|||
// phpcs:enable
|
||||
$tmpproduct = null;
|
||||
|
||||
if ($multiply < 1) {
|
||||
dol_syslog(get_class($this).'::'.__FUNCTION__.' Product quantity rounded up to 1 from '.$multiply.'. May result in unexpected end quantity for product children of '.$id_parent, LOG_WARNING);
|
||||
$multiply = 1;
|
||||
}
|
||||
|
||||
//var_dump($prod);
|
||||
foreach ($prod as $id_product => $desc_pere) { // $id_product is 0 (first call starting with root top) or an id of a sub_product
|
||||
if (is_array($desc_pere)) { // If desc_pere is an array, this means it's a child
|
||||
|
|
@ -5359,10 +5364,6 @@ class Product extends CommonObject
|
|||
$label = (!empty($desc_pere[3]) ? $desc_pere[3] : '');
|
||||
$incdec = (!empty($desc_pere[4]) ? $desc_pere[4] : 0);
|
||||
|
||||
if ($multiply < 1) {
|
||||
$multiply = 1;
|
||||
}
|
||||
|
||||
//print "XXX We add id=".$id." - label=".$label." - nb=".$nb." - multiply=".$multiply." fullpath=".$compl_path.$label."\n";
|
||||
if (is_null($tmpproduct)) {
|
||||
$tmpproduct = new Product($this->db); // So we initialize tmpproduct only once for all loop.
|
||||
|
|
@ -5392,8 +5393,12 @@ class Product extends CommonObject
|
|||
|
||||
// Recursive call if there child has children of its own
|
||||
if (isset($desc_pere['childs']) && is_array($desc_pere['childs'])) {
|
||||
if (!is_int($desc_pere[1] * $multiply)) {
|
||||
dol_syslog(get_class($this).'::'.__FUNCTION__.' Source product quantity and multiplier may result in unexpected end quantity for '.$label.'/'.$multiply.' Child product:'.json_encode($desc_pere), LOG_WARNING);
|
||||
}
|
||||
|
||||
//print 'YYY We go down for '.$desc_pere[3]." -> \n";
|
||||
$this->fetch_prod_arbo($desc_pere['childs'], $compl_path.$desc_pere[3]." -> ", $desc_pere[1] * $multiply, $level + 1, $id, $ignore_stock_load);
|
||||
$this->fetch_prod_arbo($desc_pere['childs'], $compl_path.$desc_pere[3]." -> ", (int) ceil($desc_pere[1] * $multiply), $level + 1, $id, $ignore_stock_load);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5405,7 +5410,7 @@ class Product extends CommonObject
|
|||
* this->sousprods must have been loaded by this->get_sousproduits_arbo()
|
||||
*
|
||||
* @param int $multiply Because each sublevel must be multiplicated by parent nb
|
||||
* @param int $ignore_stock_load Ignore stock load
|
||||
* @param int<0,1> $ignore_stock_load Ignore stock load
|
||||
* @return array<int,array{id:int,id_parent:int,ref:string,nb:int,nb_total:int,stock:float,stock_alert:float,label:string,fullpath:string,type:int,desiredstick:float,level:int,incdec:int<0,1>,entity:CommonObject}> Array with tree
|
||||
*/
|
||||
public function get_arbo_each_prod($multiply = 1, $ignore_stock_load = 0)
|
||||
|
|
@ -5426,8 +5431,8 @@ class Product extends CommonObject
|
|||
/**
|
||||
* Count all parent and children products for current product (first level only)
|
||||
*
|
||||
* @param int $mode 0=Both parent and child, -1=Parents only, 1=Children only
|
||||
* @return int Nb of father + child
|
||||
* @param int<-1,1> $mode 0=Both parent and child, -1=Parents only, 1=Children only
|
||||
* @return int Nb of father + child
|
||||
* @see getFather(), get_sousproduits_arbo()
|
||||
*/
|
||||
public function hasFatherOrChild($mode = 0)
|
||||
|
|
@ -6075,6 +6080,8 @@ class Product extends CommonObject
|
|||
|
||||
include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
|
||||
|
||||
// Ensure $nbpiece is a number and positive
|
||||
$nbpiece = (float) $nbpiece;
|
||||
if ($nbpiece < 0) {
|
||||
if (!$movement) {
|
||||
$movement = 1;
|
||||
|
|
@ -6082,11 +6089,11 @@ class Product extends CommonObject
|
|||
$nbpiece = abs($nbpiece);
|
||||
}
|
||||
$op = array();
|
||||
$op[0] = "+".trim((string) $nbpiece);
|
||||
$op[1] = "-".trim((string) $nbpiece);
|
||||
$op[0] = $nbpiece;
|
||||
$op[1] = -$nbpiece;
|
||||
|
||||
$movementstock = new MouvementStock($this->db);
|
||||
$movementstock->setOrigin($origin_element, $origin_id); // Set ->origin_type and ->origin_id
|
||||
$movementstock->setOrigin($origin_element, (int) $origin_id); // Set ->origin_type and ->origin_id
|
||||
$result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', '', '', '', false, 0, $disablestockchangeforsubproduct);
|
||||
|
||||
if ($result >= 0) {
|
||||
|
|
@ -6138,6 +6145,8 @@ class Product extends CommonObject
|
|||
|
||||
include_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
|
||||
|
||||
// Ensure $nbpiece is a number and positive
|
||||
$nbpiece = (float) $nbpiece;
|
||||
if ($nbpiece < 0) {
|
||||
if (!$movement) {
|
||||
$movement = 1;
|
||||
|
|
@ -6146,11 +6155,11 @@ class Product extends CommonObject
|
|||
}
|
||||
|
||||
$op = array();
|
||||
$op[0] = "+".trim((string) $nbpiece);
|
||||
$op[1] = "-".trim((string) $nbpiece);
|
||||
$op[0] = $nbpiece;
|
||||
$op[1] = -$nbpiece;
|
||||
|
||||
$movementstock = new MouvementStock($this->db);
|
||||
$movementstock->setOrigin($origin_element, $origin_id); // Set ->origin_type and ->fk_origin
|
||||
$movementstock->setOrigin($origin_element, (int) $origin_id); // Set ->origin_type and ->fk_origin
|
||||
$result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode, '', $dlc, $dluo, $lot, false, 0, $disablestockchangeforsubproduct, 0, $force_update_batch);
|
||||
|
||||
if ($result >= 0) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/* Copyright (C) 2013-2022 Laurent Destaileur <ely@users.sourceforge.net>
|
||||
* Copyright (C) 2014 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* 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
|
||||
|
|
@ -686,11 +686,11 @@ print '</tr>';
|
|||
print '<tr class="oddeven">';
|
||||
// From warehouse
|
||||
print '<td class="nowraponall">';
|
||||
print img_picto($langs->trans("WarehouseSource"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses($id_sw, 'id_sw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200');
|
||||
print img_picto($langs->trans("WarehouseSource"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses(is_null($id_sw) ? '' : $id_sw, 'id_sw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200');
|
||||
print '</td>';
|
||||
// To warehouse
|
||||
print '<td class="nowraponall">';
|
||||
print img_picto($langs->trans("WarehouseTarget"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses($id_tw, 'id_tw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200');
|
||||
print img_picto($langs->trans("WarehouseTarget"), 'stock', 'class="paddingright"').$formproduct->selectWarehouses(is_null($id_sw) ? '' : $id_tw, 'id_tw', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200');
|
||||
print '</td>';
|
||||
// Product
|
||||
print '<td class="nowraponall">';
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2016 Yasser Carreón <yacasia@gmail.com>
|
||||
* Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@atm-consulting.fr>
|
||||
* 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
|
||||
|
|
@ -999,7 +999,7 @@ if ($action == 'create') {
|
|||
/**
|
||||
* @var array<string,int> $suffix2numAsked map HTTP query parameter suffixes (like '1_0') to line indices so that
|
||||
* extrafields from HTTP query can be assigned to the correct dispatch line
|
||||
*/
|
||||
*/
|
||||
$suffix2numAsked = array();
|
||||
$dispatchLines = array();
|
||||
|
||||
|
|
@ -1648,7 +1648,7 @@ if ($action == 'create') {
|
|||
if ($volumeUnit < 50) {
|
||||
print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, getDolGlobalInt('MAIN_VOLUME_DEFAULT_ROUND', -1), getDolGlobalString("MAIN_VOLUME_DEFAULT_UNIT", 'no'));
|
||||
} else {
|
||||
print $calculatedVolume.' '.measuringUnitString(0, "volume", (string) $volumeUnit);
|
||||
print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit);
|
||||
}
|
||||
}
|
||||
if ($totalVolume > 0) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue