From b309af0ab8745a77cafb4f92196e32ad4a80ab1b Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 19 Jul 2021 13:43:48 +0200 Subject: [PATCH 1/3] First push new scan quanty inventory --- htdocs/core/class/html.formother.class.php | 17 ++++-- htdocs/langs/en_US/stocks.lang | 4 +- htdocs/product/inventory/inventory.php | 69 ++++++++++++++++++++-- 3 files changed, 79 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 991e3cb37cc..93aee37987f 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -63,7 +63,7 @@ class FormOther * @param string $jstoexecuteonadd Name of javascript function to call * @return string HTML component */ - public function getHTMLScannerForm($jstoexecuteonadd = 'barcodscannerjs') + public function getHTMLScannerForm($jstoexecuteonadd = 'barcodescannerjs') { global $langs; @@ -73,9 +73,9 @@ class FormOther $out .= '
'; $out .= '
Barcode scanner tool...

'; - $out .= ' Autodetect if we scan a product barcode or a lot/serial barcode
'; - $out .= ' Scan a product barcode
'; - $out .= ' Scan a product lot or serial number
'; + $out .= ' Autodetect if we scan a product barcode or a lot/serial barcode
'; + $out .= ' Scan a product barcode
'; + $out .= ' Scan a product lot or serial number
'; $out .= $langs->trans("QtyToAddAfterBarcodeScan").'
'; $out .= ''; @@ -88,7 +88,7 @@ class FormOther */ $out .= '
'; $out .= '
'; - $out .= ''; + $out .= ''; $out .= ''; $out .= '
'; @@ -96,6 +96,13 @@ class FormOther // TODO Add call of javascript $jstoexecuteonadd so each scan will add qty into the inventory page + an ajax save. + $out .= ''; + $out .= '
'; $out .= '
'; diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index efa5257498c..2f6bbafca4c 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -255,4 +255,6 @@ MakeMovementsAndClose=Generate movements and close AutofillWithExpected=Fill real quantity with expected quantity ShowAllBatchByDefault=By default, show batch details on product "stock" tab CollapseBatchDetailHelp=You can set batch detail default display in stocks module configuration -FieldCannotBeNegative=Field "%s" cannot be negative \ No newline at end of file +FieldCannotBeNegative=Field "%s" cannot be negative +ErrorWrongBarcodemode=Unknown Barcode mode +ProductDoesNotExist=Product does not exist diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 85cd0932f46..ffdd26c6803 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -449,7 +449,7 @@ if ($object->id > 0) { print dol_get_fiche_end(); - print '
'; + print ''; print ''; print ''; print ''; @@ -537,6 +537,63 @@ if ($object->id > 0) { // Popup for mass barcode scanning if ($action == 'updatebyscaning') { + print ''; include DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $formother = new FormOther($db); print $formother->getHTMLScannerForm(); @@ -639,15 +696,15 @@ if ($object->id > 0) { } print ''; - print ''; + print ''; print $warehouse_static->getNomUrl(1); print ''; - print ''; + print ''; print $product_static->getNomUrl(1); print ''; if ($conf->productbatch->enabled) { - print ''; + print ''; print $obj->batch; print ''; } @@ -667,6 +724,8 @@ if ($object->id > 0) { print ''; print ''.img_delete().''; print ''; + $qty_tmp = GETPOST("id_".$obj->rowid."_input_tmp") && price2num(GETPOST("id_".$obj->rowid."_input_tmp", 'MS')) >= 0 ? GETPOST("id_".$obj->rowid."_input_tmp") : $qty_view; + print ''; } else { print $obj->qty_view; $totalfound += $obj->qty_view; @@ -685,7 +744,7 @@ if ($object->id > 0) { print ''; if ($object->status == $object::STATUS_VALIDATED) { - print '
'; + print '
'; } print ''; From dd9eb282303e97948d2716faafb36dce9418d9fa Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 20 Jul 2021 14:43:36 +0200 Subject: [PATCH 2/3] Barcode scanner tool update --- htdocs/core/class/html.formother.class.php | 4 - htdocs/langs/en_US/stocks.lang | 3 + htdocs/product/inventory/inventory.php | 159 ++++++++++++++------- 3 files changed, 109 insertions(+), 57 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 93aee37987f..5f00ed6877b 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -92,10 +92,6 @@ class FormOther $out .= ''; $out .= '
'; - $out .= ''.$langs->trans("FeatureNotYetAvailable").''; - - // TODO Add call of javascript $jstoexecuteonadd so each scan will add qty into the inventory page + an ajax save. - $out .= ''; + tabproduct.forEach(product => { + if(product.Qty!=0){ + console.log("We change #"+product.Id+"_input to match input in scanner box"); + $("#"+product.Id+"_input")[0].value = product.Qty*barcodeproductqty; + } + }) + document.forms["formrecord"].submit(); + } + }'; + print ''; + } include DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $formother = new FormOther($db); print $formother->getHTMLScannerForm(); } + //Call method to undo changes in real qty + print ''; print '
'; //print '
'; @@ -722,9 +774,10 @@ if ($object->id > 0) { print ''; print ''; print ''; + print '  '; print ''.img_delete().''; print ''; - $qty_tmp = GETPOST("id_".$obj->rowid."_input_tmp") && price2num(GETPOST("id_".$obj->rowid."_input_tmp", 'MS')) >= 0 ? GETPOST("id_".$obj->rowid."_input_tmp") : $qty_view; + $qty_tmp = price2num(GETPOST("id_".$obj->rowid."_input_tmp", 'MS')) >= 0 ? GETPOST("id_".$obj->rowid."_input_tmp") : $qty_view; print ''; } else { print $obj->qty_view; From 60f0eeaea2e6a7e0c52f0a87ea463b2b197feb7e Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 20 Jul 2021 15:06:33 +0200 Subject: [PATCH 3/3] update inventory to be jquerry --- htdocs/product/inventory/inventory.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index a44e004f2e7..01968855836 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -549,17 +549,13 @@ if ($object->id > 0) { var tabproduct = []; $(".expectedqty").each(function(){ id = this.id; - warehouse = $("#"+id+"_warehouse")[0].firstChild.lastChild.data; - - productbarcode = $("#"+id+"_product")[0].firstChild.title; + warehouse = $("#"+id+"_warehouse").children().first().text(); + productbarcode = $("#"+id+"_product").children().first().attr("title"); productbarcode = productbarcode.split("
"); productbarcode = productbarcode.filter(barcode => barcode.includes("'.$langs->trans('BarCode').'"))[0]; productbarcode = productbarcode.slice(productbarcode.indexOf(" ")+5); - productbatchcode = $("#"+id+"_batch")[0].firstChild; - if(productbatchcode != null){ - productbatchcode = productbatchcode.data; - } + productbatchcode = $("#"+id+"_batch").text(); if(barcodemode != "barcodeforproduct"){ tabproduct.forEach(product=>{ if(product.Batch == productbatchcode){ @@ -626,7 +622,7 @@ if ($object->id > 0) { tabproduct.forEach(product => { if(product.Qty!=0){ console.log("We change #"+product.Id+"_input to match input in scanner box"); - $("#"+product.Id+"_input")[0].value = product.Qty*barcodeproductqty; + $("#"+product.Id+"_input").val(product.Qty*barcodeproductqty); } }) document.forms["formrecord"].submit();