This commit is contained in:
Laurent Destailleur 2022-08-10 04:07:18 +02:00
parent 2dd1ef22fa
commit 427541beaa
3 changed files with 41 additions and 33 deletions

View File

@ -101,7 +101,7 @@ class Mo extends CommonObject
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",),
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>5, 'notnull'=>1, 'default'=>'1', 'index'=>1),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1', 'noteditable'=>1),
'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:t.status=1', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>'$conf->bom->enabled', 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM", 'css'=>'minwidth100 maxwidth300', 'csslist'=>'nowraponall'),
'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:t.status=1', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>'$conf->bom->enabled', 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM", 'css'=>'minwidth100 maxwidth300', 'csslist'=>'nowraponall', 'picto'=>'bom'),
'mrptype' => array('type'=>'integer', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>34, 'notnull'=>1, 'default'=>'0', 'arrayofkeyval'=>array(0=>'Manufacturing', 1=>'Disassemble'), 'css'=>'minwidth150', 'csslist'=>'minwidth150 center'),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:0', 'label'=>'Product', 'enabled'=>'$conf->product->enabled', 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce", 'css'=>'maxwidth300', 'csslist'=>'tdoverflowmax100', 'picto'=>'product'),
'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'comment'=>"Qty to produce", 'css'=>'width75', 'default'=>1, 'isameasure'=>1),
@ -1375,13 +1375,13 @@ class Mo extends CommonObject
print '<tr class="liste_titre">';
// Product or sub-bom
print '<td class="linecoldescription">'.$langs->trans('Description');
print '<td class="linecoldescription">'.$langs->trans('Ref');
if (!empty($conf->global->BOM_SUB_BOM)) {
print ' &nbsp; <a id="show_all" href="#">'.img_picto('', 'folder-open', 'class="paddingright"').$langs->trans("ExpandAll").'</a>&nbsp;&nbsp;';
print '<a id="hide_all" href="#">'.img_picto('', 'folder', 'class="paddingright"').$langs->trans("UndoExpandAll").'</a>&nbsp;';
}
print '</td>';
print '<td>'.$langs->trans('Ref').'</td>';
// Qty
print '<td class="right">'.$langs->trans('Qty');
if ($this->bom->bomtype == 0) {
print ' <span class="opacitymedium">('.$langs->trans("ForAQuantityOf", $this->bom->qty).')</span>';
@ -1395,7 +1395,7 @@ class Mo extends CommonObject
print '<td class="center">'.$langs->trans('DisableStockChange').'</td>';
print '<td class="center">'.$langs->trans('MoChildGenerate').'</td>';
//print '<td class="center">'.$form->showCheckAddButtons('checkforselect', 1).'</td>';
// print '<td class="center"></td>';
//print '<td class="center"></td>';
print '</tr>';
$i = 0;

View File

@ -708,7 +708,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<div class="clearboth"></div>';
$url = $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addconsumeline&token='.newToken();
$permissiontoaddaconsumeline = $object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED && $action != 'consumeorproduce' && $action != 'consumeandproduceall';
$permissiontoaddaconsumeline = $object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED;
$parameters = array('morecss'=>'reposition');
$newcardbutton = '';
@ -996,6 +996,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$i = 1;
print '<!-- Enter line to consume -->'."\n";
print '<tr name="batch_'.$line->id.'_'.$i.'">';
// Ref
print '<td><span class="opacitymedium">'.$langs->trans("ToConsume").'</span></td>';
$preselected = (GETPOSTISSET('qty-'.$line->id.'-'.$i) ? GETPOST('qty-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyconsumed));
if ($action == 'consumeorproduce' && !GETPOSTISSET('qty-'.$line->id.'-'.$i)) {
@ -1044,12 +1045,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : '');
print '<input type="text" class="width50" name="batch-'.$line->id.'-'.$i.'" value="'.$preselected.'" list="batch-'.$line->id.'-'.$i.'">';
print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 0, $line->fk_product, '', '');
}
print '</td>';
print '<td>';
if ($tmpproduct->status_batch) {
$type = 'batch';
print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.$line->id.', \''.$type.'\', \'qtymissingconsume\')"');
print ' '.img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).', \''.dol_escape_js($type).'\', \'qtymissingconsume\')"');
}
print '</td>';
}
@ -1094,10 +1092,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$newcardbutton = '';
$url = $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=addproduceline&token='.newToken();
$permissiontoaddaproductline = $object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED && $action != 'consumeorproduce' && $action != 'consumeandproduceall';
$permissiontoaddaproductline = $object->status != $object::STATUS_PRODUCED && $object->status != $object::STATUS_CANCELED;
$parameters = array('morecss'=>'reposition');
if ($nblinetoproduce == 0 || $object->mrptype == 1) {
$newcardbutton = dolGetButtonTitle($langs->trans('AddNewProduceLines'), '', 'fa fa-plus-circle size15x', $url, '', $permissiontoaddaproductline, $parameters);
if ($action != 'consumeorproduce' && $action != 'consumeandproduceall') {
if ($nblinetoproduce == 0 || $object->mrptype == 1) {
$newcardbutton = dolGetButtonTitle($langs->trans('AddNewProduceLines'), '', 'fa fa-plus-circle size15x', $url, '', $permissiontoaddaproductline, $parameters);
}
}
print load_fiche_titre($langs->trans('Production'), $newcardbutton, '', 0, '', '');
@ -1196,12 +1196,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
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');
$manufacturingcost = 0;
if ($object->mrptype == 0) { // If MO is a "Manufacture" type (and not "Disassemble"
$manufacturingcost = $bomcost;
if (empty($manufacturingcost)) {
$manufacturingcost = price2num($tmpproduct->cost_price, 'MU');
}
if (empty($manufacturingcost)) {
$manufacturingcost = price2num($tmpproduct->pmp, 'MU');
}
}
print '<td class="right nowraponall">';
@ -1300,19 +1303,22 @@ 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');
$manufacturingcost = 0;
if ($object->mrptype == 0) { // If MO is a "Manufacture" type (and not "Disassemble"
$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($manufacturingcost));
$preselected = (GETPOSTISSET('pricetoproduce-'.$line->id.'-'.$i) ? GETPOST('pricetoproduce-'.$line->id.'-'.$i) : ($manufacturingcost ? 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="'.$manufacturingcost.'"></td>';
print '<td><input type="hidden" class="width50 right" name="pricetoproduce-'.$line->id.'-'.$i.'" value="'.($manufacturingcost ? $manufacturingcost : '').'"></td>';
}
}
print '<td></td>';

View File

@ -44,6 +44,7 @@ $res = $tmpbom->fetch($line->fk_bom_child);
<!-- BEGIN PHP TEMPLATE originproductline.tpl.php -->
<?php
print '<tr class="oddeven'.(empty($this->tpl['strike']) ? '' : ' strikefordisabled').'">';
// Ref or label
print '<td>';
if ($res) {
print $tmpproduct->getNomUrl(1);
@ -58,7 +59,7 @@ if ($res) {
print $this->tpl['label'];
}
print '</td>';
//print '<td>'.$this->tpl['label'].'</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>';
print '<td class="center">'.(empty($this->tpl['stock']) ? 0 : price2num($this->tpl['stock'], 'MS'));
if ($this->tpl['seuil_stock_alerte'] != '' && ($this->tpl['stock'] < $this->tpl['seuil_stock_alerte'])) {
@ -78,18 +79,19 @@ $selected = 1;
if (!empty($selectedLines) && !in_array($this->tpl['id'], $selectedLines)) {
$selected = 0;
}
print '<td class="center">';
//print '<input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected?' checked="checked"':'').'>';
print '</td>';
if ($tmpbom->id) {
if ($tmpbom->id > 0) {
print '<td class="center">';
print '<input type="checkbox" name="bomlineid[]" value="' . $line->id . '">';
print '</td>';
} else {
print '<td class="center">&nbsp;</td>';
print '<td class="center"></td>';
}
//print '<td class="center">';
//print '<input id="cb'.$this->tpl['id'].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$this->tpl['id'].'"'.($selected?' checked="checked"':'').'>';
//print '</td>';
print '</tr>'."\n";
// Select of all the sub-BOM lines