From 84d446cf73ec1e14432253ebd2ff3ebc7b5b2d57 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Fri, 21 Jan 2022 15:31:30 +0100 Subject: [PATCH] NEW possibility to consume multiple batch --- htdocs/mrp/js/lib_dispatch.js.php | 6 ++++-- htdocs/mrp/mo_production.php | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/htdocs/mrp/js/lib_dispatch.js.php b/htdocs/mrp/js/lib_dispatch.js.php index 8a5eef60211..aa29b38c5fb 100644 --- a/htdocs/mrp/js/lib_dispatch.js.php +++ b/htdocs/mrp/js/lib_dispatch.js.php @@ -70,10 +70,12 @@ function addDispatchLine(index, type, mode) mode = mode || 'qtymissing' 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 $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 qty = parseFloat($("#qtytoproduce-"+index+"-"+nbrTrs).val()); + var qty = parseFloat($("#"+inputId+"-"+index+"-"+nbrTrs).val()); var qtyDispatched; if (mode === 'lessone') @@ -83,7 +85,7 @@ function addDispatchLine(index, type, mode) else { 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 (qtyDispatched == qtyOrdered && qtyDispatched > 1) { qtyDispatched = parseFloat($("#qty_dispatched_"+index).val()) + 1; diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index ca9480eb1ae..fa5897bb5f0 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -811,6 +811,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $alreadyconsumed += $line2['qty']; } + $suffix = '_'.$line->id; + print ''."\n"; + // hidden fields for js function + print ''; + print ''; + print ''; print ''.$tmpproduct->getNomUrl(1); print '
'.$tmpproduct->label.''; @@ -914,13 +920,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { $i = 1; print ''."\n"; - print ''; + print ''; print ''.$langs->trans("ToConsume").''; $preselected = (GETPOSTISSET('qty-'.$line->id.'-'.$i) ? GETPOST('qty-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyconsumed)); if ($action == 'consumeorproduce' && !GETPOSTISSET('qty-'.$line->id.'-'.$i)) { $preselected = 0; } - print ''; + print ''; if ($permissiontoupdatecost && !empty($conf->global->MRP_SHOW_COST_FOR_CONSUMPTION)) { print ''; } @@ -945,6 +951,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; } print ''; + print ''; + if ($tmpproduct->status_batch) { + $type = 'batch'; + print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.$line->id.', \''.$type.'\', \'qtymissingconsume\')"'); + } + print ''; } print ''; }