From 8d86f5472900db72615e92acddbdf28ad4848f66 Mon Sep 17 00:00:00 2001
From: Christian Humpel <78662388+Humml87@users.noreply.github.com>
Date: Wed, 17 Jul 2024 16:05:06 +0200
Subject: [PATCH] Fix #30187 (#30409)
BOM columns if "Stock management supports Services" is active.
---
htdocs/bom/tpl/objectline_create.tpl.php | 74 +++++++++++++-----------
htdocs/bom/tpl/objectline_edit.tpl.php | 37 ++++++------
htdocs/bom/tpl/objectline_title.tpl.php | 25 ++++----
htdocs/bom/tpl/objectline_view.tpl.php | 53 +++++++++--------
4 files changed, 94 insertions(+), 95 deletions(-)
diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php
index 011666eb6abee..a099d93305791 100644
--- a/htdocs/bom/tpl/objectline_create.tpl.php
+++ b/htdocs/bom/tpl/objectline_create.tpl.php
@@ -77,25 +77,33 @@
print '';
print '
'.$langs->trans('Qty').' ';
- if ($filtertype != 1) {
+ if ($filtertype != 1) { // Product
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '';
print '';
print $langs->trans('Unit');
print ' ';
}
+ } else { // Service
+ print '' . $form->textwithpicto($langs->trans('Unit'), '').' ';
+ }
+ if ($filtertype != 1 || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { // Product or stock support for Services is active
+ // Qty frozen
print '' . $form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")) . ' ';
+
+ // Disable stock change
print '' . $form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')) . ' ';
+
+ // Efficiency
print '' . $form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')) . ' ';
- } else {
- print '' . $form->textwithpicto($langs->trans('Unit'), '').' ';
- print '' .$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")) . ' ';
+ }
- if (isModEnabled('workstation')) {
- print '' . $form->textwithpicto($langs->trans('Workstation'), '') . ' ';
- }
- print '' . $form->textwithpicto($langs->trans('TotalCost'), '') . ' ';
+ // Service and workstations are active
+ if ($filtertype == 1 && isModEnabled('workstation')) {
+ print '' . $form->textwithpicto($langs->trans('Workstation'), '') . ' ';
}
+ // Cost
+ print '' . $form->textwithpicto($langs->trans('TotalCost'), '') . ' ';
print ' ';
print '';
@@ -154,32 +162,13 @@
print ' ';
print ' ';
-if ($filtertype != 1) {
+if ($filtertype != 1) { // Product
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
$coldisplay++;
print '';
print ' ';
}
-
- $coldisplay++;
- print ' ';
- print ' ';
-
-
- $coldisplay++;
- print ' ';
- print ' ';
-
- $coldisplay++;
- print '';
- print ' ';
- print ' ';
-
- $coldisplay++;
- print '';
- print ' ';
- print ' ';
-} else {
+} else { // Service
$coldisplay++;
require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
$cUnit = new CUnits($this->db);
@@ -187,22 +176,39 @@
print '';
print $formproduct->selectMeasuringUnits("fk_unit", "time", $fk_unit_default, 1);
print ' ';
-
+}
+if ($filtertype != 1 || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { // Product or stock support for Services is active
+ // Qty frozen
$coldisplay++;
print ' ';
print ' ';
+ // Disable stock change
$coldisplay++;
- print '';
- print $formproduct->selectWorkstations('', 'idworkstations', 1);
+ print ' ';
print ' ';
+ // Efficiency
+ $coldisplay++;
+ print '';
+ print ' ';
+ print ' ';
+}
+// Service and workstations are active
+if ($filtertype == 1 && isModEnabled('workstation')) {
$coldisplay++;
- print '';
- print ' ';
+ print ' ';
+ print $formproduct->selectWorkstations('', 'idworkstations', 1);
print ' ';
}
+// Cost
+$coldisplay++;
+print '';
+print ' ';
+print ' ';
+
+
$coldisplay += $colspan;
print '';
print ' ';
diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php
index 8394cb4c0ad4b..dbff055c049e4 100644
--- a/htdocs/bom/tpl/objectline_edit.tpl.php
+++ b/htdocs/bom/tpl/objectline_edit.tpl.php
@@ -130,48 +130,47 @@
}
print ' ';
-if ($filtertype != 1) {
+if ($filtertype != 1) { // Product
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
$coldisplay++;
print '';
print $formproduct->selectMeasuringUnits("fk_unit", '', (($line->fk_unit) ? $line->fk_unit : ''), 0, 0);
print ' ';
}
-
+} else { // Service
+ $coldisplay++;
+ print '';
+ print $formproduct->selectMeasuringUnits("fk_unit", "time", ($line->fk_unit) ? $line->fk_unit : '', 0, 0);
+ print ' ';
+}
+if ($filtertype != 1 || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { // Product or stock support for Services is active
+ // Qty frozen
$coldisplay++;
print ' qty_frozen ? ' checked="checked"' : '')) . '>';
print ' ';
+ // Disable stock change
$coldisplay++;
print ' disable_stock_change ? ' checked="checked"' : '')) . '">';
print ' ';
+ // Efficiency
$coldisplay++;
print '';
print ' ';
+}
- $coldisplay++;
- print '';
- print ' ';
-} else {
- $coldisplay++;
- print '';
- print $formproduct->selectMeasuringUnits("fk_unit", "time", ($line->fk_unit) ? $line->fk_unit : '', 0, 0);
- print ' ';
-
- $coldisplay++;
- print ' qty_frozen ? ' checked="checked"' : '')) . '>';
- print ' ';
-
+// Service and workstations are active
+if ($filtertype == 1 && isModEnabled('workstation')) {
$coldisplay++;
print '';
print $formproduct->selectWorkstations($line->fk_default_workstation, 'idworkstations', 1);
print ' ';
-
- $coldisplay++;
- print '';
- print ' ';
}
+// Cost
+$coldisplay++;
+print '';
+print ' ';
$coldisplay += $colspan;
print '';
diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php
index a357628eba0f1..70dd5e95a95ef 100644
--- a/htdocs/bom/tpl/objectline_title.tpl.php
+++ b/htdocs/bom/tpl/objectline_title.tpl.php
@@ -71,11 +71,14 @@
// Qty
print ' '.$form->textwithpicto($langs->trans('Qty'), ($filtertype != 1) ? $langs->trans("QtyRequiredIfNoLoss") : '').' ';
-if ($filtertype != 1) {
+if ($filtertype != 1) { // Product
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print ' ';
}
-
+} else { // Service
+ print ' ';
+}
+if ($filtertype != 1 || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { // Product or stock support for Services is active
// Qty frozen
print '' . $form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")) . ' ';
@@ -84,26 +87,18 @@
// Efficiency
print '' . $form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')) . ' ';
+}
- // Cost
- print ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).' ';
-} else {
- print ' ';
-
- // Qty frozen
- print '' .$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")) . ' ';
-
+// Service and workstations are active
+if ($filtertype == 1 && isModEnabled('workstation')) {
// Workstation
if (isModEnabled('workstation')) {
print '' . $form->textwithpicto($langs->trans('DefaultWorkstation'), '') . ' ';
}
-
- // Cost
- print ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCostService")).' ';
}
-
-
+// Cost
+print ''.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).' ';
print ' '; // No width to allow autodim
diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php
index 1eb5af994551a..310466465ab8f 100644
--- a/htdocs/bom/tpl/objectline_view.tpl.php
+++ b/htdocs/bom/tpl/objectline_view.tpl.php
@@ -139,7 +139,7 @@
echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formatting role of function price
print '';
-if ($filtertype != 1) {
+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);
@@ -148,21 +148,7 @@
}
print ' ';
}
-
- print '';
- $coldisplay++;
- echo $line->qty_frozen ? yn($line->qty_frozen) : '';
- print ' ';
- print '';
- $coldisplay++;
- echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formatting role of function price
- print ' ';
-
- print '';
- $coldisplay++;
- echo $line->efficiency;
- print ' ';
-} else {
+} else { // Service
// Unit // For services, units are always enabled
print '';
$coldisplay++;
@@ -175,25 +161,38 @@
}
print ' ';
-
+}
+if ($filtertype != 1 || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { // Product or stock support for Services is active
// Qty frozen
print '';
$coldisplay++;
echo $line->qty_frozen ? yn($line->qty_frozen) : '';
print ' ';
- // Work station
- if (isModEnabled('workstation')) {
- $workstation = new Workstation($object->db);
- $res = $workstation->fetch($line->fk_default_workstation);
+ // Disable stock change
+ print '';
+ $coldisplay++;
+ echo $line->disable_stock_change ? yn($line->disable_stock_change) : ''; // Yes, it is a quantity, not a price, but we just want the formatting role of function price
+ print ' ';
- print '';
- $coldisplay++;
- if ($res > 0) {
- echo $workstation->getNomUrl(1);
- }
- print ' ';
+ // Efficiency
+ print '';
+ $coldisplay++;
+ echo $line->efficiency;
+ print ' ';
+}
+
+// Service and workstations are active
+if ($filtertype == 1 && isModEnabled('workstation')) {
+ $workstation = new Workstation($object->db);
+ $res = $workstation->fetch($line->fk_default_workstation);
+
+ print '';
+ $coldisplay++;
+ if ($res > 0) {
+ echo $workstation->getNomUrl(1);
}
+ print ' ';
}
// Cost