From 69fcb0939f49c0625df951535da787c4cc2dec34 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 18 Aug 2022 12:12:58 +0200 Subject: [PATCH 1/9] =?UTF-8?q?Affichage=20du=20split=20all=20(num=C3=A9ro?= =?UTF-8?q?s=20de=20s=C3=A9rie=20uniques)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/mrp/mo_production.php | 41 +++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 6584c80cc37..28075a5c463 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -772,6 +772,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($permissiontodelete) { print ''; } + + // Split + print ''; + + // SplitAll + print ''; + print ''; if ($action == 'addconsumeline') { @@ -855,7 +862,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; - print ''; + print ''; // Product print ''.$tmpproduct->getNomUrl(1); print '
'.$tmpproduct->label.''; @@ -935,6 +942,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; } + + // Split + print ''; + + // Split All + print ''; + print ''; // Show detailed of already consumed with js code to collapse @@ -1052,7 +1066,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $formproduct->selectLotDataList('batch-'.$line->id.'-'.$i, 0, $line->fk_product, '', ''); $type = 'batch'; + print ''; print ' '.img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).', \''.dol_escape_js($type).'\', \'qtymissingconsume\')"'); + print ''; + print ''; + if (($action == 'consumeorproduce' || $action == 'consumeandproduceall') && $tmpproduct->status_batch == 2) print img_picto($langs->trans('SplitAllQuantity'), 'split.png', 'class="splitbutton splitallbutton field-error-icon" data-max-qty="1" onClick="addDispatchLine('.$line->id.', \'batch\', \'allmissingconsume\')"'); + print ''; } print ''; } @@ -1130,6 +1149,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; if ($collapse || in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { print $langs->trans("Batch"); + + // Split + print ''; + + // Split All + print ''; } print ''; print ''; @@ -1161,6 +1186,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($permissiontodelete) { print ''; } + + print ''; } @@ -1293,6 +1320,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } print ''; print ''; + + // Split + print ''; + + // Split All + print ''; } print ''; } @@ -1346,7 +1379,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; if ($tmpproduct->status_batch) { $type = 'batch'; + print ''; print img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.$line->id.', \''.$type.'\', \'qtymissing\')"'); + print ''; + + print ''; + if (($action == 'consumeorproduce' || $action == 'consumeandproduceall') && $tmpproduct->status_batch == 2) print img_picto($langs->trans('SplitAllQuantity'), 'split.png', 'class="splitbutton splitallbutton field-error-icon" onClick="addDispatchLine('.$line->id.', \'batch\', \'alltoproduce\')"'); // + print ''; } print ''; } From 7bd6f0338eda3d48351d8eaca6634811859338f1 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 18 Aug 2022 12:17:16 +0200 Subject: [PATCH 2/9] =?UTF-8?q?Ajout=20de=20la=20quantit=C3=A9=20maximum?= =?UTF-8?q?=20par=20produit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/mrp/mo_production.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 28075a5c463..83c512c050f 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -1014,6 +1014,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { $i = 1; print ''."\n"; + $maxQty = 1; + print ''; print ''; // Ref print ''.$langs->trans("ToConsume").''; @@ -1332,6 +1334,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (in_array($action, array('consumeorproduce', 'consumeandproduceall'))) { print ''."\n"; + $maxQty = 1; + print ''; print ''; print ''.$langs->trans("ToProduce").''; $preselected = (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i) ? GETPOST('qtytoproduce-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyproduced)); From 3e9a053b607c679b3081863227ce6ff99072befc Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 18 Aug 2022 13:31:51 +0200 Subject: [PATCH 3/9] =?UTF-8?q?FIX=20data=20quantit=C3=A9s=20sur=20tr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/mrp/mo_production.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 83c512c050f..3e2fb1da657 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -1016,7 +1016,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''."\n"; $maxQty = 1; print ''; - print ''; // Ref print ''.$langs->trans("ToConsume").''; $preselected = (GETPOSTISSET('qty-'.$line->id.'-'.$i) ? GETPOST('qty-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyconsumed)); @@ -1336,7 +1335,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''."\n"; $maxQty = 1; print ''; - print ''; print ''.$langs->trans("ToProduce").''; $preselected = (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i) ? GETPOST('qtytoproduce-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyproduced)); if ($action == 'consumeorproduce' && !GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) { From c0c540f4cb10c7fda931ef0a92dff79a56e10dab Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 18 Aug 2022 17:39:52 +0200 Subject: [PATCH 4/9] Traitement du splitall --- htdocs/mrp/js/lib_dispatch.js.php | 77 ++++++++++++++++++++++++++----- htdocs/mrp/mo_production.php | 2 +- 2 files changed, 66 insertions(+), 13 deletions(-) diff --git a/htdocs/mrp/js/lib_dispatch.js.php b/htdocs/mrp/js/lib_dispatch.js.php index e8ca84d7a4e..ac2b9bacf15 100644 --- a/htdocs/mrp/js/lib_dispatch.js.php +++ b/htdocs/mrp/js/lib_dispatch.js.php @@ -70,7 +70,7 @@ 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') { + if(mode == 'qtymissingconsume' || mode == 'allmissingconsume') { var inputId = 'qtytoconsume'; var warehouseId = 'idwarehouse'; } @@ -94,12 +94,56 @@ function addDispatchLine(index, type, mode) 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; - mode = 'lessone'; + qtyDispatched = parseFloat($("#qty_dispatched_" + index).val()) + 1; + if (mode != 'allmissingconsume' || mode != 'alltoproduce') mode = 'lessone'; + + } + if(mode == 'allmissingconsume' || mode == 'alltoproduce') { + var qtymax = parseFloat($($row).data('max-qty')); } } - console.log("qtyDispatched="+qtyDispatched+" qtyOrdered="+qtyOrdered); + if(mode == 'allmissingconsume' || mode == 'alltoproduce') { + var count = 0; + var qtyalreadyused = 0; + + while (count < qty) { + //If remaining qty needed is inferior to qtymax, qtymax = remaining qty needed + if ((qtyalreadyused + qtymax) > qtyOrdered) qtymax = qtyOrdered - qtyalreadyused; + + //If first line, we replace value, not add line + if(count === 0){ + $("#"+inputId+"-"+index+"-"+nbrTrs).val(qtymax); + } else { + addDispatchTR(qtyOrdered, qtyDispatched, index, nbrTrs, warehouseId, inputId, type, qtymax, mode, $row); + nbrTrs++; + } + + qtyalreadyused = qtyalreadyused + qtymax; + count++; + $row = $("tr[name='" + type + '_' + index + "_1']").clone(true); + } + } + else addDispatchTR(qtyOrdered, qtyDispatched, index, nbrTrs, warehouseId, inputId, type, qty, mode, $row) + +} + +/** + * addDispatchTR + * Adds new table row for dispatching to multiple stock locations or multiple lot/serial + * + * @param qtyOrdered double + * @param qtyDispatched double + * @param index int + * @param nbrTrs int + * @param warehouseId int + * @param inputId int + * @param type string + * @param qty double + * @param mode string + * @param $row object + */ +function addDispatchTR(qtyOrdered, qtyDispatched, index, nbrTrs, warehouseId, inputId, type, qty, mode, $row) { if (qtyOrdered <= 1) { window.alert("Quantity can't be split"); } else if (qtyDispatched >= qtyOrdered) { @@ -128,24 +172,27 @@ function addDispatchLine(index, type, mode) /* Suffix of lines are: index _ trs.length */ $("#"+inputId+"-"+index+"-"+(nbrTrs+1)).focus(); if ($("#"+inputId+"-"+index+"-"+(nbrTrs)).val() == 0) { - $("#"+inputId+"-"+index+"-"+(nbrTrs)).val(1); + if(mode == 'allmissingconsume' || mode == 'alltoproduce') $("#"+inputId+"-"+index+"-"+(nbrTrs)).val(qty); + else $("#"+inputId+"-"+index+"-"+(nbrTrs)).val(1); } var totalonallines = 0; for (let i = 1; i <= nbrTrs; i++) { console.log(i+" = "+parseFloat($("#"+inputId+"-"+index+"-"+i).val())); totalonallines = totalonallines + parseFloat($("#"+inputId+"-"+index+"-"+i).val()); } - console.log("totalonallines="+totalonallines); - if (totalonallines == qtyOrdered && qtyOrdered > 1) { - var prevouslineqty = $("#"+inputId+"-"+index+"-"+nbrTrs).val(); - $("#"+inputId+"-"+index+"-"+(nbrTrs)).val(1); - $("#"+inputId+"-"+index+"-"+(nbrTrs+1)).val(prevouslineqty - 1); + + if(mode != 'allmissingconsume' && mode != 'alltoproduce') { + if (totalonallines == qtyOrdered && qtyOrdered > 1) { + var prevouslineqty = $("#" + inputId + "-" + index + "-" + nbrTrs).val(); + $("#" + inputId + "-" + index + "-" + (nbrTrs)).val(1); + $("#" + inputId + "-" + index + "-" + (nbrTrs + 1)).val(prevouslineqty - 1); + } } $("#qty_dispatched_"+index).val(qtyDispatched); //hide all buttons then show only the last one - $("tr[name^='"+type+"_'][name$='_"+index+"'] .splitbutton").hide(); - $("tr[name^='"+type+"_'][name$='_"+index+"']:last .splitbutton").show(); + $("tr[name^='"+type+"_"+index+"_'] .splitbutton").hide(); + $("tr[name^='"+type+"_"+index+"_']:last .splitbutton").show(); if (mode === 'lessone') { @@ -156,6 +203,12 @@ function addDispatchLine(index, type, mode) $("#"+inputId+"-"+index+(nbrTrs)).data('qty', qty); $("#"+inputId+"-"+index+(nbrTrs)).data('type', type); $("#"+inputId+"-"+index+(nbrTrs)).data('index', index); + if(mode == 'allmissingconsume' || mode == 'alltoproduce') { + let currentQtyDispatched = qtyDispatched+qty; + console.log( $row.find("input[id^='"+inputId+"']")); + if((currentQtyDispatched+qty) > qtyOrdered) $row.find("input[id^='"+inputId+"']").val(qtyOrdered - currentQtyDispatched); + $row.find("input[id^='"+inputId+"']").val(qty); + } } } diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index 3e2fb1da657..d70578b1a81 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -1071,7 +1071,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ' '.img_picto($langs->trans('AddStockLocationLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine('.((int) $line->id).', \''.dol_escape_js($type).'\', \'qtymissingconsume\')"'); print ''; print ''; - if (($action == 'consumeorproduce' || $action == 'consumeandproduceall') && $tmpproduct->status_batch == 2) print img_picto($langs->trans('SplitAllQuantity'), 'split.png', 'class="splitbutton splitallbutton field-error-icon" data-max-qty="1" onClick="addDispatchLine('.$line->id.', \'batch\', \'allmissingconsume\')"'); + if (($action == 'consumeorproduce' || $action == 'consumeandproduceall')) print img_picto($langs->trans('SplitAllQuantity'), 'split.png', 'class="splitbutton splitallbutton field-error-icon" data-max-qty="1" onClick="addDispatchLine('.$line->id.', \'batch\', \'allmissingconsume\')"'); print ''; } print ''; From 17af973da3550977f226c32c2dc9cf915fb6365c Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 18 Aug 2022 18:50:05 +0200 Subject: [PATCH 5/9] FIX erreur --- htdocs/mrp/js/lib_dispatch.js.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/mrp/js/lib_dispatch.js.php b/htdocs/mrp/js/lib_dispatch.js.php index ac2b9bacf15..18e7d073fac 100644 --- a/htdocs/mrp/js/lib_dispatch.js.php +++ b/htdocs/mrp/js/lib_dispatch.js.php @@ -95,14 +95,15 @@ function addDispatchLine(index, type, mode) // 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; - if (mode != 'allmissingconsume' || mode != 'alltoproduce') mode = 'lessone'; } if(mode == 'allmissingconsume' || mode == 'alltoproduce') { var qtymax = parseFloat($($row).data('max-qty')); + if(qtymax === 'undefined') qtymax = 1; } } + if(mode == 'allmissingconsume' || mode == 'alltoproduce') { var count = 0; var qtyalreadyused = 0; @@ -110,7 +111,6 @@ function addDispatchLine(index, type, mode) while (count < qty) { //If remaining qty needed is inferior to qtymax, qtymax = remaining qty needed if ((qtyalreadyused + qtymax) > qtyOrdered) qtymax = qtyOrdered - qtyalreadyused; - //If first line, we replace value, not add line if(count === 0){ $("#"+inputId+"-"+index+"-"+nbrTrs).val(qtymax); From 453eeb1f4a0ea7a751a56243ecc8d29ddc667b46 Mon Sep 17 00:00:00 2001 From: Florian Charlaix Date: Fri, 19 Aug 2022 09:28:07 +0200 Subject: [PATCH 6/9] CLOSE #21780 Add pid field to Cronjob class and store PID on job execution Add the new pid column to the Cronjob class internal value and functions Store the current PID on job execution during run_jobs --- htdocs/cron/class/cronjob.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index a84fa3109df..200cf8a369f 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -137,6 +137,11 @@ class Cronjob extends CommonObject */ public $processing; + /** + * @var int The job current PID + */ + public $pid; + /** * @var int ID */ @@ -422,6 +427,7 @@ class Cronjob extends CommonObject $sql .= " t.frequency,"; $sql .= " t.status,"; $sql .= " t.processing,"; + $sql .= " t.pid,"; $sql .= " t.fk_user_author,"; $sql .= " t.fk_user_mod,"; $sql .= " t.note as note_private,"; @@ -470,6 +476,7 @@ class Cronjob extends CommonObject $this->frequency = $obj->frequency; $this->status = $obj->status; $this->processing = $obj->processing; + $this->pid = $obj->pid; $this->fk_user_author = $obj->fk_user_author; $this->fk_user_mod = $obj->fk_user_mod; $this->note_private = $obj->note_private; @@ -530,6 +537,7 @@ class Cronjob extends CommonObject $sql .= " t.frequency,"; $sql .= " t.status,"; $sql .= " t.processing,"; + $sql .= " t.pid,"; $sql .= " t.fk_user_author,"; $sql .= " t.fk_user_mod,"; $sql .= " t.note as note_private,"; @@ -606,6 +614,7 @@ class Cronjob extends CommonObject $line->frequency = $obj->frequency; $line->status = $obj->status; $line->processing = $obj->processing; + $line->pid = $obj->pid; $line->fk_user_author = $obj->fk_user_author; $line->fk_user_mod = $obj->fk_user_mod; $line->note_private = $obj->note_private; @@ -708,6 +717,10 @@ class Cronjob extends CommonObject $this->processing = 0; } + if (empty($this->pid)) { + $this->pid = NULL; + } + // Check parameters // Put here code to add a control on parameters values if (dol_strlen($this->datenextrun) == 0) { @@ -773,6 +786,7 @@ class Cronjob extends CommonObject $sql .= " frequency=".(isset($this->frequency) ? $this->frequency : "null").","; $sql .= " status=".(isset($this->status) ? $this->status : "null").","; $sql .= " processing=".((isset($this->processing) && $this->processing > 0) ? $this->processing : "0").","; + $sql .= " pid=".(isset($this->pid) ? $this->pid : "null").","; $sql .= " fk_user_mod=".$user->id.","; $sql .= " note=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; $sql .= " nbrun=".((isset($this->nbrun) && $this->nbrun > 0) ? $this->nbrun : "null").","; @@ -925,6 +939,7 @@ class Cronjob extends CommonObject $this->frequency = ''; $this->status = 0; $this->processing = 0; + $this->pid = NULL; $this->fk_user_author = 0; $this->fk_user_mod = 0; $this->note_private = ''; @@ -1125,6 +1140,7 @@ class Cronjob extends CommonObject $this->lastoutput = ''; $this->lastresult = ''; $this->processing = 1; // To know job was started + $this->pid = dol_getmypid(); $this->nbrun = $this->nbrun + 1; $result = $this->update($user); // This include begin/commit if ($result < 0) { @@ -1316,6 +1332,7 @@ class Cronjob extends CommonObject $this->datelastresult = dol_now(); $this->processing = 0; + $this->pid = NULL; $result = $this->update($user); // This include begin/commit if ($result < 0) { dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); From b1b10a5d3fc44f22b092e20882afea389f2607b5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 19 Aug 2022 07:35:20 +0000 Subject: [PATCH 7/9] Fixing style errors. --- htdocs/cron/class/cronjob.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 200cf8a369f..714622e8014 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -718,7 +718,7 @@ class Cronjob extends CommonObject } if (empty($this->pid)) { - $this->pid = NULL; + $this->pid = null; } // Check parameters @@ -939,7 +939,7 @@ class Cronjob extends CommonObject $this->frequency = ''; $this->status = 0; $this->processing = 0; - $this->pid = NULL; + $this->pid = null; $this->fk_user_author = 0; $this->fk_user_mod = 0; $this->note_private = ''; @@ -1332,7 +1332,7 @@ class Cronjob extends CommonObject $this->datelastresult = dol_now(); $this->processing = 0; - $this->pid = NULL; + $this->pid = null; $result = $this->update($user); // This include begin/commit if ($result < 0) { dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); From 4a6b85496344964d48e1a892dc30e78c04f28547 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 19 Aug 2022 11:29:56 +0200 Subject: [PATCH 8/9] FIX mode de calcul splitall --- htdocs/mrp/js/lib_dispatch.js.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/htdocs/mrp/js/lib_dispatch.js.php b/htdocs/mrp/js/lib_dispatch.js.php index 18e7d073fac..8470716ce8f 100644 --- a/htdocs/mrp/js/lib_dispatch.js.php +++ b/htdocs/mrp/js/lib_dispatch.js.php @@ -107,22 +107,30 @@ function addDispatchLine(index, type, mode) if(mode == 'allmissingconsume' || mode == 'alltoproduce') { var count = 0; var qtyalreadyused = 0; + var error = 0; - while (count < qty) { - //If remaining qty needed is inferior to qtymax, qtymax = remaining qty needed - if ((qtyalreadyused + qtymax) > qtyOrdered) qtymax = qtyOrdered - qtyalreadyused; + while (qtyalreadyused < qty) { + //If remaining qty needed is inferior to qty asked, qtymax = qty asked - qty already used + if ((qtyalreadyused + qtymax) > qty) qtymax = qty - qtyalreadyused; //If first line, we replace value, not add line if(count === 0){ $("#"+inputId+"-"+index+"-"+nbrTrs).val(qtymax); } else { - addDispatchTR(qtyOrdered, qtyDispatched, index, nbrTrs, warehouseId, inputId, type, qtymax, mode, $row); + var res = addDispatchTR(qtyOrdered, qtyDispatched, index, nbrTrs, warehouseId, inputId, type, qtymax, mode, $row); + if(res === -1){ + error = 1; + break; + } nbrTrs++; } - qtyalreadyused = qtyalreadyused + qtymax; count++; $row = $("tr[name='" + type + '_' + index + "_1']").clone(true); } + + if(error === 0) { + addDispatchTR(qtyOrdered, qtyDispatched, index, nbrTrs, warehouseId, inputId, type, '', mode, $row); + } } else addDispatchTR(qtyOrdered, qtyDispatched, index, nbrTrs, warehouseId, inputId, type, qty, mode, $row) @@ -146,8 +154,10 @@ function addDispatchLine(index, type, mode) function addDispatchTR(qtyOrdered, qtyDispatched, index, nbrTrs, warehouseId, inputId, type, qty, mode, $row) { if (qtyOrdered <= 1) { window.alert("Quantity can't be split"); + return -1; } else if (qtyDispatched >= qtyOrdered) { window.alert("No remain qty to dispatch"); + return -1; } else if (qtyDispatched < qtyOrdered) { //replace tr suffix nbr var re1 = new RegExp('_'+index+'_1', 'g'); @@ -205,8 +215,6 @@ function addDispatchTR(qtyOrdered, qtyDispatched, index, nbrTrs, warehouseId, in $("#"+inputId+"-"+index+(nbrTrs)).data('index', index); if(mode == 'allmissingconsume' || mode == 'alltoproduce') { let currentQtyDispatched = qtyDispatched+qty; - console.log( $row.find("input[id^='"+inputId+"']")); - if((currentQtyDispatched+qty) > qtyOrdered) $row.find("input[id^='"+inputId+"']").val(qtyOrdered - currentQtyDispatched); $row.find("input[id^='"+inputId+"']").val(qty); } } From 0e09e437147470ec52c9678ae9aca026f984dce8 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 19 Aug 2022 14:44:25 +0200 Subject: [PATCH 9/9] Clean --- htdocs/mrp/mo_production.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index d70578b1a81..d6fc14b33ae 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -1187,8 +1187,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($permissiontodelete) { print ''; } - - print ''; }