Better label of field

This commit is contained in:
Laurent Destailleur 2021-09-20 19:00:28 +02:00
parent 96ac0e4bb2
commit 82f66f8b0a
2 changed files with 30 additions and 10 deletions

View File

@ -397,6 +397,7 @@ ActionAvailableOnVariantProductOnly=Action only available on the variant of prod
ProductsPricePerCustomer=Product prices per customers
ProductSupplierExtraFields=Additional Attributes (Supplier Prices)
DeleteLinkedProduct=Delete the child product linked to the combination
AmountUsedToUpdateWAP=Amount to use to update the Weighted Average Price
PMPValue=Weighted average price
PMPValueShort=WAP
DefaultBOM=Default BOM

View File

@ -38,7 +38,7 @@ dol_include_once('/bom/class/bom.class.php');
dol_include_once('/mrp/lib/mrp_mo.lib.php');
// Load translation files required by the page
$langs->loadLangs(array("mrp", "stocks", "other", "productbatch"));
$langs->loadLangs(array("mrp", "stocks", "other", "product", "productbatch"));
// Get parameters
$id = GETPOST('id', 'int');
@ -691,6 +691,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$bom = new Bom($db);
$res = $bom->fetch($object->fk_bom);
if ($res > 0) {
$bom->calculateCosts();
$bomcost = $bom->unit_cost;
}
}
@ -818,6 +819,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
}
$bomcost = price2num($bomcost, 'MU');
$arrayoflines = $object->fetchLinesLinked('consumed', $line->id);
$alreadyconsumed = 0;
foreach ($arrayoflines as $line2) {
@ -1006,9 +1009,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td class="right">'.$langs->trans("Qty").'</td>';
if ($permissiontoupdatecost) {
if (empty($bomcost)) {
print '<td class="right">'.$langs->trans("PMPValue").'</td>';
print '<td class="right">'.$form->textwithpicto($langs->trans("UnitCost"), $langs->trans("AmountUsedToUpdateWAP")).'</td>';
} else {
print '<td class="right">'.$langs->trans("UnitCost").'</td>';
print '<td class="right">'.$form->textwithpicto($langs->trans("ManufacturingPrice"), $langs->trans("AmountUsedToUpdateWAP")).'</td>';
}
}
print '<td class="right">'.$langs->trans("QtyAlreadyProduced").'</td>';
@ -1073,10 +1076,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$tmpproduct = new Product($db);
$tmpproduct->fetch($line->fk_product);
if (empty($bomcost)) {
$bomcost = $tmpproduct->pmp;
}
$arrayoflines = $object->fetchLinesLinked('produced', $line->id);
$alreadyproduced = 0;
foreach ($arrayoflines as $line2) {
@ -1095,8 +1094,19 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</td>';
print '<td class="right">'.$line->qty.'</td>';
if ($permissiontoupdatecost) {
// Defined $manufacturingcost
$manufacturingcost = $bomcost;
if (empty($manufacturingcost)) {
$manufacturingcost = price2num($tmpproduct->cost_price, 'MU');
}
if (empty($manufacturingcost)) {
$manufacturingcost = price2num($tmpproduct->pmp, 'MU');
}
print '<td class="right nowraponall">';
print price($bomcost);
if ($manufacturingcost) {
print price($manufacturingcost);
}
print '</td>';
}
print '<td class="right nowraponall">';
@ -1188,11 +1198,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}
print '<td class="right"><input type="text" class="width50 right" id="qtytoproduce-'.$line->id.'-'.$i.'" name="qtytoproduce-'.$line->id.'-'.$i.'" value="'.$preselected.'"></td>';
if ($permissiontoupdatecost) {
// Defined $manufacturingcost
$manufacturingcost = $bomcost;
if (empty($manufacturingcost)) {
$manufacturingcost = price2num($tmpproduct->cost_price, 'MU');
}
if (empty($manufacturingcost)) {
$manufacturingcost = price2num($tmpproduct->pmp, 'MU');
}
if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
$preselected = (GETPOSTISSET('pricetoproduce-'.$line->id.'-'.$i) ? GETPOST('pricetoproduce-'.$line->id.'-'.$i) : price($bomcost));
$preselected = (GETPOSTISSET('pricetoproduce-'.$line->id.'-'.$i) ? GETPOST('pricetoproduce-'.$line->id.'-'.$i) : price($manufacturingcost));
print '<td class="right"><input type="text" class="width50 right" name="pricetoproduce-'.$line->id.'-'.$i.'" value="'.$preselected.'"></td>';
} else {
print '<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.'-'.$i.'" value="'.$bomcost.'"></td>';
print '<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.'-'.$i.'" value="'.$manufacturingcost.'"></td>';
}
}
print '<td></td>';