NEW possibility to consume multiple batch
This commit is contained in:
parent
964656c728
commit
84d446cf73
@ -70,10 +70,12 @@ function addDispatchLine(index, type, mode)
|
|||||||
mode = mode || 'qtymissing'
|
mode = mode || 'qtymissing'
|
||||||
|
|
||||||
console.log("fourn/js/lib_dispatch.js.php Split line type="+type+" index="+index+" mode="+mode);
|
console.log("fourn/js/lib_dispatch.js.php Split line type="+type+" index="+index+" mode="+mode);
|
||||||
|
if(mode == 'qtymissingconsume') var inputId = 'qtytoconsume';
|
||||||
|
else var inputId = 'qtytoproduce';
|
||||||
var nbrTrs = $("tr[name^='"+type+"_"+index+"']").length; // position of line for batch
|
var nbrTrs = $("tr[name^='"+type+"_"+index+"']").length; // position of line for batch
|
||||||
var $row = $("tr[name='"+type+'_'+index+"_1']").clone(true); // clone last batch line to jQuery object
|
var $row = $("tr[name='"+type+'_'+index+"_1']").clone(true); // clone last batch line to jQuery object
|
||||||
var qtyOrdered = parseFloat($("#qty_ordered_"+index).val()); // Qty ordered is same for all rows
|
var qtyOrdered = parseFloat($("#qty_ordered_"+index).val()); // Qty ordered is same for all rows
|
||||||
var qty = parseFloat($("#qtytoproduce-"+index+"-"+nbrTrs).val());
|
var qty = parseFloat($("#"+inputId+"-"+index+"-"+nbrTrs).val());
|
||||||
var qtyDispatched;
|
var qtyDispatched;
|
||||||
|
|
||||||
if (mode === 'lessone')
|
if (mode === 'lessone')
|
||||||
@ -83,7 +85,7 @@ function addDispatchLine(index, type, mode)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
qtyDispatched = parseFloat($("#qty_dispatched_"+index).val()) + qty;
|
qtyDispatched = parseFloat($("#qty_dispatched_"+index).val()) + qty;
|
||||||
console.log(qty);
|
console.log($("#qty_dispatched_"+index).val());
|
||||||
// If user did not reduced the qty to dispatch on old line, we keep only 1 on old line and the rest on new line
|
// If user did not reduced the qty to dispatch on old line, we keep only 1 on old line and the rest on new line
|
||||||
if (qtyDispatched == qtyOrdered && qtyDispatched > 1) {
|
if (qtyDispatched == qtyOrdered && qtyDispatched > 1) {
|
||||||
qtyDispatched = parseFloat($("#qty_dispatched_"+index).val()) + 1;
|
qtyDispatched = parseFloat($("#qty_dispatched_"+index).val()) + 1;
|
||||||
|
|||||||
@ -811,6 +811,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
$alreadyconsumed += $line2['qty'];
|
$alreadyconsumed += $line2['qty'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$suffix = '_'.$line->id;
|
||||||
|
print '<!-- Line to dispatch '.$suffix.' -->'."\n";
|
||||||
|
// hidden fields for js function
|
||||||
|
print '<input id="qty_ordered'.$suffix.'" type="hidden" value="'.$line->qty.'">';
|
||||||
|
print '<input id="qty_dispatched'.$suffix.'" type="hidden" value="'.$alreadyconsumed.'">';
|
||||||
|
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
print '<td>'.$tmpproduct->getNomUrl(1);
|
print '<td>'.$tmpproduct->getNomUrl(1);
|
||||||
print '<br><span class="opacitymedium small">'.$tmpproduct->label.'</span>';
|
print '<br><span class="opacitymedium small">'.$tmpproduct->label.'</span>';
|
||||||
@ -914,13 +920,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) {
|
if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) {
|
||||||
$i = 1;
|
$i = 1;
|
||||||
print '<!-- Enter line to consume -->'."\n";
|
print '<!-- Enter line to consume -->'."\n";
|
||||||
print '<tr>';
|
print '<tr name="batch_'.$line->id.'_'.$i.'">';
|
||||||
print '<td><span class="opacitymedium">'.$langs->trans("ToConsume").'</span></td>';
|
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));
|
$preselected = (GETPOSTISSET('qty-'.$line->id.'-'.$i) ? GETPOST('qty-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyconsumed));
|
||||||
if ($action == 'consumeorproduce' && !GETPOSTISSET('qty-'.$line->id.'-'.$i)) {
|
if ($action == 'consumeorproduce' && !GETPOSTISSET('qty-'.$line->id.'-'.$i)) {
|
||||||
$preselected = 0;
|
$preselected = 0;
|
||||||
}
|
}
|
||||||
print '<td class="right"><input type="text" class="width50 right" name="qty-'.$line->id.'-'.$i.'" value="'.$preselected.'"></td>';
|
print '<td class="right"><input type="text" class="width50 right" id="qtytoconsume-'.$line->id.'-'.$i.'" name="qty-'.$line->id.'-'.$i.'" value="'.$preselected.'"></td>';
|
||||||
if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
|
if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) {
|
||||||
print '<td></td>';
|
print '<td></td>';
|
||||||
}
|
}
|
||||||
@ -945,6 +951,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
print '<input type="text" class="width50" name="batch-'.$line->id.'-'.$i.'" value="'.$preselected.'">';
|
print '<input type="text" class="width50" name="batch-'.$line->id.'-'.$i.'" value="'.$preselected.'">';
|
||||||
}
|
}
|
||||||
print '</td>';
|
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 '</td>';
|
||||||
}
|
}
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user