Barcode scanner tool update
This commit is contained in:
parent
b309af0ab8
commit
dd9eb28230
@ -92,10 +92,6 @@ class FormOther
|
|||||||
$out .= '<input type="submit" class="button marginleftonly marginrightonly" name="cancel" value="'.$langs->trans("Cancel").'">';
|
$out .= '<input type="submit" class="button marginleftonly marginrightonly" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||||
$out .= '<br>';
|
$out .= '<br>';
|
||||||
|
|
||||||
$out .= '<span class="opacitymedium">'.$langs->trans("FeatureNotYetAvailable").'</span>';
|
|
||||||
|
|
||||||
// TODO Add call of javascript $jstoexecuteonadd so each scan will add qty into the inventory page + an ajax save.
|
|
||||||
|
|
||||||
$out .= '<script>';
|
$out .= '<script>';
|
||||||
$out .= '$("#exec'.dol_escape_js($jstoexecuteonadd).'").click(function(){
|
$out .= '$("#exec'.dol_escape_js($jstoexecuteonadd).'").click(function(){
|
||||||
console.log("We call js to execute '.dol_escape_js($jstoexecuteonadd).'");
|
console.log("We call js to execute '.dol_escape_js($jstoexecuteonadd).'");
|
||||||
|
|||||||
@ -258,3 +258,6 @@ CollapseBatchDetailHelp=You can set batch detail default display in stocks modul
|
|||||||
FieldCannotBeNegative=Field "%s" cannot be negative
|
FieldCannotBeNegative=Field "%s" cannot be negative
|
||||||
ErrorWrongBarcodemode=Unknown Barcode mode
|
ErrorWrongBarcodemode=Unknown Barcode mode
|
||||||
ProductDoesNotExist=Product does not exist
|
ProductDoesNotExist=Product does not exist
|
||||||
|
ErrorSameBatchNumber=Same batch number found in inventory list
|
||||||
|
ProductBatchDoesNotExist=Product with batch/serial does not exist
|
||||||
|
ProductBarcodeDoesNotExist=Product with barcode does not exist
|
||||||
|
|||||||
@ -537,68 +537,120 @@ if ($object->id > 0) {
|
|||||||
|
|
||||||
// Popup for mass barcode scanning
|
// Popup for mass barcode scanning
|
||||||
if ($action == 'updatebyscaning') {
|
if ($action == 'updatebyscaning') {
|
||||||
print '<script>';
|
if ($permissiontoadd) {
|
||||||
print 'function barcodescannerjs(){
|
print '<script>';
|
||||||
var barcodemode = $("input[name=barcodemode]:checked").val();
|
print 'function barcodescannerjs(){
|
||||||
var barcodeproductqty = $("input[name=barcodeproductqty]").val();
|
console.log("We catch inputs in sacnner box");
|
||||||
var textarea = $("textarea[name=barcodelist]").val();
|
var barcodemode = $("input[name=barcodemode]:checked").val();
|
||||||
var textarray = textarea.split("\n");
|
var barcodeproductqty = $("input[name=barcodeproductqty]").val();
|
||||||
if(textarray[0] != ""){
|
var textarea = $("textarea[name=barcodelist]").val();
|
||||||
var tabproduct = [];
|
var textarray = textarea.split("\n");
|
||||||
$(".expectedqty").each(function(){
|
if(textarray[0] != ""){
|
||||||
id = this.id;
|
var tabproduct = [];
|
||||||
warehouse = $("#"+id+"_warehouse")[0].firstChild.lastChild.data;
|
$(".expectedqty").each(function(){
|
||||||
|
id = this.id;
|
||||||
|
warehouse = $("#"+id+"_warehouse")[0].firstChild.lastChild.data;
|
||||||
|
|
||||||
productbarcode = $("#"+id+"_product")[0].firstChild.title;
|
productbarcode = $("#"+id+"_product")[0].firstChild.title;
|
||||||
productbarcode = productbarcode.split("<br>");
|
productbarcode = productbarcode.split("<br>");
|
||||||
productbarcode = productbarcode.filter(barcode => barcode.includes("'.$langs->trans('BarCode').'"))[0];
|
productbarcode = productbarcode.filter(barcode => barcode.includes("'.$langs->trans('BarCode').'"))[0];
|
||||||
productbarcode = productbarcode.slice(productbarcode.indexOf("</b> ")+5);
|
productbarcode = productbarcode.slice(productbarcode.indexOf("</b> ")+5);
|
||||||
|
|
||||||
productbatchcode = $("#"+id+"_batch")[0].firstChild;
|
productbatchcode = $("#"+id+"_batch")[0].firstChild;
|
||||||
if(productbatchcode != null){
|
if(productbatchcode != null){
|
||||||
productbatchcode = productbatchcode.data;
|
productbatchcode = productbatchcode.data;
|
||||||
}
|
}
|
||||||
|
if(barcodemode != "barcodeforproduct"){
|
||||||
tabproduct.push({\'Id\':id,\'Warehouse\':warehouse,\'Barecode\':productbarcode,\'Batch\':productbatchcode,\'Qty\':0});
|
tabproduct.forEach(product=>{
|
||||||
})
|
if(product.Batch == productbatchcode){
|
||||||
switch(barcodemode){
|
alert("'.$langs->trans('ErrorSameBatchNumber').': "+productbatchcode);
|
||||||
case "barcodeforautodetect":
|
throw"'.$langs->trans('ErrorSameBatchNumber').': "+productbatchcode;
|
||||||
break;
|
|
||||||
case "barcodeforproduct":
|
|
||||||
textarray.forEach(function(element,index){
|
|
||||||
console.log("Product "+(index+=1)+": "+element);
|
|
||||||
BarCodeDoesNotExist=0;
|
|
||||||
tabproduct.forEach(product => {
|
|
||||||
if(product.Barecode == element){
|
|
||||||
product.Qty+=1;
|
|
||||||
}else{
|
|
||||||
BarCodeDoesNotExist+=1;
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if(BarCodeDoesNotExist >= tabproduct.length){
|
}
|
||||||
alert("'.$langs->trans('ProductDoesNotExist').': "+element);
|
tabproduct.push({\'Id\':id,\'Warehouse\':warehouse,\'Barcode\':productbarcode,\'Batch\':productbatchcode,\'Qty\':0});
|
||||||
}
|
})
|
||||||
})
|
switch(barcodemode){
|
||||||
break;
|
case "barcodeforautodetect":
|
||||||
case "barcodeforlotserial":
|
textarray.forEach(function(element,index){
|
||||||
break;
|
console.log("Product autodetect "+(index+=1)+": "+element);
|
||||||
default:
|
BatchCodeDoesNotExist=0;
|
||||||
alert("'.$langs->trans("ErrorWrongBarcodemode").' \""+barcodemode+"\"");
|
tabproduct.forEach(product => {
|
||||||
}
|
if(product.Batch == element || product.Barcode == element){
|
||||||
tabproduct.forEach(product => {
|
product.Qty+=1;
|
||||||
if(product.Qty!=0){
|
}else{
|
||||||
$("#"+product.Id+"_input")[0].value = product.Qty*barcodeproductqty;
|
BatchCodeDoesNotExist+=1;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(BatchCodeDoesNotExist >= tabproduct.length){
|
||||||
|
alert("'.$langs->trans('ProductDoesNotExist').': "+element);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
case "barcodeforproduct":
|
||||||
|
textarray.forEach(function(element,index){
|
||||||
|
console.log("Product "+(index+=1)+": "+element);
|
||||||
|
BarCodeDoesNotExist=0;
|
||||||
|
tabproduct.forEach(product => {
|
||||||
|
if(product.Barcode == element){
|
||||||
|
product.Qty+=1;
|
||||||
|
}else{
|
||||||
|
BarCodeDoesNotExist+=1;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(BarCodeDoesNotExist >= tabproduct.length){
|
||||||
|
alert("'.$langs->trans('ProductBarcodeDoesNotExist').': "+element);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
case "barcodeforlotserial":
|
||||||
|
textarray.forEach(function(element,index){
|
||||||
|
console.log("Product batch/serial "+(index+=1)+": "+element);
|
||||||
|
BatchCodeDoesNotExist=0;
|
||||||
|
tabproduct.forEach(product => {
|
||||||
|
if(product.Batch == element){
|
||||||
|
product.Qty+=1;
|
||||||
|
}else{
|
||||||
|
BatchCodeDoesNotExist+=1;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if(BatchCodeDoesNotExist >= tabproduct.length){
|
||||||
|
alert("'.$langs->trans('ProductBatchDoesNotExist').': "+element);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
alert("'.$langs->trans("ErrorWrongBarcodemode").' \""+barcodemode+"\"");
|
||||||
|
throw"'.$langs->trans('ErrorWrongBarcodemode').' \""+barcodemode+"\"";
|
||||||
}
|
}
|
||||||
})
|
tabproduct.forEach(product => {
|
||||||
document.forms["formrecord"].submit();
|
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;
|
||||||
print '</script>';
|
}
|
||||||
|
})
|
||||||
|
document.forms["formrecord"].submit();
|
||||||
|
}
|
||||||
|
}';
|
||||||
|
print '</script>';
|
||||||
|
}
|
||||||
include DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
include DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||||
$formother = new FormOther($db);
|
$formother = new FormOther($db);
|
||||||
print $formother->getHTMLScannerForm();
|
print $formother->getHTMLScannerForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Call method to undo changes in real qty
|
||||||
|
print '<script>';
|
||||||
|
print 'jQuery(document).ready(function() {
|
||||||
|
$(".undochangesqty").on("click",function undochangesqty(){
|
||||||
|
id = this.id;
|
||||||
|
id = id.split("_")[1];
|
||||||
|
tmpvalue = $("#id_"+id+"_input_tmp").val()
|
||||||
|
$("#id_"+id+"_input")[0].value = tmpvalue;
|
||||||
|
document.forms["formrecord"].submit();
|
||||||
|
});
|
||||||
|
});';
|
||||||
|
print '</script>';
|
||||||
|
|
||||||
print '<div class="fichecenter">';
|
print '<div class="fichecenter">';
|
||||||
//print '<div class="fichehalfleft">';
|
//print '<div class="fichehalfleft">';
|
||||||
@ -722,9 +774,10 @@ if ($object->id > 0) {
|
|||||||
print '<input type="text" class="maxwidth75 right realqty" name="id_'.$obj->rowid.'" id="id_'.$obj->rowid.'_input" value="'.$qty_view.'">';
|
print '<input type="text" class="maxwidth75 right realqty" name="id_'.$obj->rowid.'" id="id_'.$obj->rowid.'_input" value="'.$qty_view.'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td class="right">';
|
print '<td class="right">';
|
||||||
|
print '<a id="undochangesqty_'.$obj->rowid.'" href="#" class="undochangesqty"><span class="fas fa-undo pictoundo" ></span></a>  ';
|
||||||
print '<a class="reposition" href="'.DOL_URL_ROOT.'/product/inventory/inventory.php?id='.$object->id.'&lineid='.$obj->rowid.'&action=deleteline&token='.newToken().'">'.img_delete().'</a>';
|
print '<a class="reposition" href="'.DOL_URL_ROOT.'/product/inventory/inventory.php?id='.$object->id.'&lineid='.$obj->rowid.'&action=deleteline&token='.newToken().'">'.img_delete().'</a>';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
$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 '<input type="hidden" class="maxwidth75 right realqty" name="id_'.$obj->rowid.'_input_tmp" id="id_'.$obj->rowid.'_input_tmp" value="'.$qty_tmp.'">';
|
print '<input type="hidden" class="maxwidth75 right realqty" name="id_'.$obj->rowid.'_input_tmp" id="id_'.$obj->rowid.'_input_tmp" value="'.$qty_tmp.'">';
|
||||||
} else {
|
} else {
|
||||||
print $obj->qty_view;
|
print $obj->qty_view;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user