Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
BOM columns if "Stock management supports Services" is active.
  • Loading branch information
Humml87 committed Jul 17, 2024
1 parent 4aa5e45 commit 0c234e1
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 95 deletions.
74 changes: 40 additions & 34 deletions htdocs/bom/tpl/objectline_create.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,33 @@
print '</td>';
print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';

if ($filtertype != 1) {
if ($filtertype != 1) { // Product
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td class="linecoluseunit left">';
print '<span id="title_units">';
print $langs->trans('Unit');
print '</span></td>';
}
} else { // Service
print '<td class="linecolunit right">' . $form->textwithpicto($langs->trans('Unit'), '').'</td>';
}
if ($filtertype != 1 || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { // Product or stock support for Services is active
// Qty frozen
print '<td class="linecolqtyfrozen right">' . $form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")) . '</td>';

// Disable stock change
print '<td class="linecoldisablestockchange right">' . $form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')) . '</td>';

// Efficiency
print '<td class="linecollost right">' . $form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')) . '</td>';
} else {
print '<td class="linecolunit right">' . $form->textwithpicto($langs->trans('Unit'), '').'</td>';
print '<td class="linecolqtyfrozen right">' .$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")) . '</td>';
}

if (isModEnabled('workstation')) {
print '<td class="linecolworkstation right">' . $form->textwithpicto($langs->trans('Workstation'), '') . '</td>';
}
print '<td class="linecoltotalcost right">' . $form->textwithpicto($langs->trans('TotalCost'), '') . '</td>';
// Service and workstations are active
if ($filtertype == 1 && isModEnabled('workstation')) {
print '<td class="linecolworkstation right">' . $form->textwithpicto($langs->trans('Workstation'), '') . '</td>';
}
// Cost
print '<td class="linecoltotalcost right">' . $form->textwithpicto($langs->trans('TotalCost'), '') . '</td>';

print '<td class="linecoledit" colspan="' . $colspan . '">&nbsp;</td>';
print '</tr>';
Expand Down Expand Up @@ -154,55 +162,53 @@
print '<td class="bordertop nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="'.(GETPOSTISSET("qty") ? GETPOST("qty", 'alpha', 2) : 1).'">';
print '</td>';

if ($filtertype != 1) {
if ($filtertype != 1) { // Product
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
$coldisplay++;
print '<td class="nobottom linecoluseunit">';
print '</td>';
}

$coldisplay++;
print '<td class="bordertop nobottom linecolqtyfrozen right"><input type="checkbox" name="qty_frozen" id="qty_frozen" class="flat right" value="1"' . (GETPOST("qty_frozen", 'alpha') ? ' checked="checked"' : '') . '>';
print '</td>';


$coldisplay++;
print '<td class="bordertop nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"' . (GETPOST("disable_stock_change", 'alpha') ? ' checked="checked"' : '') . '">';
print '</td>';

$coldisplay++;
print '<td class="bordertop nobottom nowrap linecollost right">';
print '<input type="text" size="2" name="efficiency" id="efficiency" class="flat right" value="' . ((GETPOSTISSET("efficiency") && $action == 'addline') ? GETPOST("efficiency", 'alpha') : 1) . '">';
print '</td>';

$coldisplay++;
print '<td class="bordertop nobottom nowrap linecolcost right">';
print '&nbsp;';
print '</td>';
} else {
} else { // Service
$coldisplay++;
require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php';
$cUnit = new CUnits($this->db);
$fk_unit_default = $cUnit->getUnitFromCode('h', 'short_label', 'time');
print '<td class="bordertop nobottom nowrap linecolunit">';
print $formproduct->selectMeasuringUnits("fk_unit", "time", $fk_unit_default, 1);
print '</td>';

}
if ($filtertype != 1 || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { // Product or stock support for Services is active
// Qty frozen
$coldisplay++;
print '<td class="bordertop nobottom linecolqtyfrozen right"><input type="checkbox" name="qty_frozen" id="qty_frozen" class="flat right" value="1"' . (GETPOST("qty_frozen", 'alpha') ? ' checked="checked"' : '') . '>';
print '</td>';

// Disable stock change
$coldisplay++;
print '<td class="bordertop nobottom nowrap linecolworkstation">';
print $formproduct->selectWorkstations('', 'idworkstations', 1);
print '<td class="bordertop nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"' . (GETPOST("disable_stock_change", 'alpha') ? ' checked="checked"' : '') . '">';
print '</td>';

// Efficiency
$coldisplay++;
print '<td class="bordertop nobottom nowrap linecollost right">';
print '<input type="text" size="2" name="efficiency" id="efficiency" class="flat right" value="' . ((GETPOSTISSET("efficiency") && $action == 'addline') ? GETPOST("efficiency", 'alpha') : 1) . '">';
print '</td>';
}
// Service and workstations are active
if ($filtertype == 1 && isModEnabled('workstation')) {
$coldisplay++;
print '<td class="bordertop nobottom nowrap linecolcost right">';
print '&nbsp;';
print '<td class="bordertop nobottom nowrap linecolworkstation">';
print $formproduct->selectWorkstations('', 'idworkstations', 1);
print '</td>';
}

// Cost
$coldisplay++;
print '<td class="bordertop nobottom nowrap linecolcost right">';
print '&nbsp;';
print '</td>';


$coldisplay += $colspan;
print '<td class="bordertop nobottom linecoledit right valignmiddle" colspan="' . $colspan . '">';
print '<input type="submit" class="button button-add small" name="addline" id="addline" value="' . $langs->trans('Add') . '">';
Expand Down
37 changes: 18 additions & 19 deletions htdocs/bom/tpl/objectline_edit.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,48 +130,47 @@
}
print '</td>';

if ($filtertype != 1) {
if ($filtertype != 1) { // Product
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
$coldisplay++;
print '<td class="nobottom nowrap linecolunit">';
print $formproduct->selectMeasuringUnits("fk_unit", '', (($line->fk_unit) ? $line->fk_unit : ''), 0, 0);
print '</td>';
}

} else { // Service
$coldisplay++;
print '<td class="nobottom nowrap linecolunit">';
print $formproduct->selectMeasuringUnits("fk_unit", "time", ($line->fk_unit) ? $line->fk_unit : '', 0, 0);
print '</td>';
}
if ($filtertype != 1 || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { // Product or stock support for Services is active
// Qty frozen
$coldisplay++;
print '<td class="nobottom linecolqtyfrozen right"><input type="checkbox" name="qty_frozen" id="qty_frozen" class="flat right" value="1"' . (GETPOSTISSET("qty_frozen") ? (GETPOSTINT('qty_frozen') ? ' checked="checked"' : '') : ($line->qty_frozen ? ' checked="checked"' : '')) . '>';
print '</td>';

// Disable stock change
$coldisplay++;
print '<td class="nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"' . (GETPOSTISSET('disablestockchange') ? (GETPOSTINT("disable_stock_change") ? ' checked="checked"' : '') : ($line->disable_stock_change ? ' checked="checked"' : '')) . '">';
print '</td>';

// Efficiency
$coldisplay++;
print '<td class="nobottom nowrap linecollost right">';
print '<input type="text" size="2" name="efficiency" id="efficiency" class="flat right" value="' . $line->efficiency . '"></td>';
}

$coldisplay++;
print '<td class="nobottom nowrap linecolcostprice right">';
print '</td>';
} else {
$coldisplay++;
print '<td class="nobottom nowrap linecolunit">';
print $formproduct->selectMeasuringUnits("fk_unit", "time", ($line->fk_unit) ? $line->fk_unit : '', 0, 0);
print '</td>';

$coldisplay++;
print '<td class="nobottom linecolqtyfrozen right"><input type="checkbox" name="qty_frozen" id="qty_frozen" class="flat right" value="1"' . (GETPOSTISSET("qty_frozen") ? (GETPOST('qty_frozen', 'int') ? ' checked="checked"' : '') : ($line->qty_frozen ? ' checked="checked"' : '')) . '>';
print '</td>';

// Service and workstations are active
if ($filtertype == 1 && isModEnabled('workstation')) {
$coldisplay++;
print '<td class="nobottom nowrap linecolworkstation">';
print $formproduct->selectWorkstations($line->fk_default_workstation, 'idworkstations', 1);
print '</td>';

$coldisplay++;
print '<td class="nobottom nowrap linecolcostprice right">';
print '</td>';
}
// Cost
$coldisplay++;
print '<td class="nobottom nowrap linecolcostprice right">';
print '</td>';

$coldisplay += $colspan;
print '<td class="nobottom linecoledit center valignmiddle" colspan="'.$colspan.'">';
Expand Down
25 changes: 10 additions & 15 deletions htdocs/bom/tpl/objectline_title.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@
// Qty
print '<td class="linecolqty width100 right">'.$form->textwithpicto($langs->trans('Qty'), ($filtertype != 1) ? $langs->trans("QtyRequiredIfNoLoss") : '').'</td>';

if ($filtertype != 1) {
if ($filtertype != 1) { // Product
if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
print '<td class="linecoluseunit"></td>';
}

} else { // Service
print '<td class="linecolunit"></td>';
}
if ($filtertype != 1 || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { // Product or stock support for Services is active
// Qty frozen
print '<td class="linecolqtyfrozen right">' . $form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")) . '</td>';

Expand All @@ -84,26 +87,18 @@

// Efficiency
print '<td class="linecolefficiency right">' . $form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')) . '</td>';
}

// Cost
print '<td class="linecolcost right">'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).'</td>';
} else {
print '<td class="linecolunit"></td>';

// Qty frozen
print '<td class="linecolqtyfrozen right">' .$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")) . '</td>';

// Service and workstations are active
if ($filtertype == 1 && isModEnabled('workstation')) {
// Workstation
if (isModEnabled('workstation')) {
print '<td class="linecolworkstation">' . $form->textwithpicto($langs->trans('DefaultWorkstation'), '') . '</td>';
}

// Cost
print '<td class="linecolcost right">'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCostService")).'</td>';
}



// Cost
print '<td class="linecolcost right">'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).'</td>';

print '<td class="linecoledit" style="width: 10px"></td>'; // No width to allow autodim

Expand Down
53 changes: 26 additions & 27 deletions htdocs/bom/tpl/objectline_view.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '</td>';

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 '<td class="linecoluseunit nowrap">';
$label = measuringUnitString($line->fk_unit, '', '', 1);
Expand All @@ -148,21 +148,7 @@
}
print '</td>';
}

print '<td class="linecolqtyfrozen nowrap right">';
$coldisplay++;
echo $line->qty_frozen ? yn($line->qty_frozen) : '';
print '</td>';
print '<td class="linecoldisablestockchange nowrap right">';
$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 '</td>';

print '<td class="linecolefficiency nowrap right">';
$coldisplay++;
echo $line->efficiency;
print '</td>';
} else {
} else { // Service
// Unit // For services, units are always enabled
print '<td class="linecolunit nowrap">';
$coldisplay++;
Expand All @@ -175,25 +161,38 @@
}

print '</td>';

}
if ($filtertype != 1 || getDolGlobalString('STOCK_SUPPORTS_SERVICES')) { // Product or stock support for Services is active
// Qty frozen
print '<td class="linecolqtyfrozen nowrap right">';
$coldisplay++;
echo $line->qty_frozen ? yn($line->qty_frozen) : '';
print '</td>';

// Work station
if (isModEnabled('workstation')) {
$workstation = new Workstation($object->db);
$res = $workstation->fetch($line->fk_default_workstation);
// Disable stock change
print '<td class="linecoldisablestockchange nowrap right">';
$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 '</td>';

print '<td class="linecolworkstation nowrap">';
$coldisplay++;
if ($res > 0) {
echo $workstation->getNomUrl(1);
}
print '</td>';
// Efficiency
print '<td class="linecolefficiency nowrap right">';
$coldisplay++;
echo $line->efficiency;
print '</td>';
}

// Service and workstations are active
if ($filtertype == 1 && isModEnabled('workstation')) {
$workstation = new Workstation($object->db);
$res = $workstation->fetch($line->fk_default_workstation);

print '<td class="linecolworkstation nowrap">';
$coldisplay++;
if ($res > 0) {
echo $workstation->getNomUrl(1);
}
print '</td>';
}

// Cost
Expand Down

0 comments on commit 0c234e1

Please sign in to comment.