Fix scanner in inventory. Fix button must not be clicable if disabled.
This commit is contained in:
parent
38a8f52e8b
commit
caf999aa1f
@ -88,7 +88,7 @@ class FormOther
|
|||||||
$stringaddbarcode = str_replace("tmphtml", $htmltoreplaceby, $stringaddbarcode);
|
$stringaddbarcode = str_replace("tmphtml", $htmltoreplaceby, $stringaddbarcode);
|
||||||
$out .= $stringaddbarcode.' <input type="text" name="barcodeproductqty" class="width50 right" value="1"><br>';
|
$out .= $stringaddbarcode.' <input type="text" name="barcodeproductqty" class="width50 right" value="1"><br>';
|
||||||
$out .= '<br>';
|
$out .= '<br>';
|
||||||
$out .= '<textarea type="text" name="barcodelist" class="centpercent" autofocus rows="'.ROWS_3.'" placeholder="'.dol_escape_htmltag($langs->trans("ScanOrTypeOrCopyPasteYouBarCode")).'"></textarea>';
|
$out .= '<textarea type="text" name="barcodelist" class="centpercent" autofocus rows="'.ROWS_3.'" placeholder="'.dol_escape_htmltag($langs->trans("ScanOrTypeOrCopyPasteYourBarCodes")).'"></textarea>';
|
||||||
|
|
||||||
/*print '<br>'.$langs->trans("or").'<br>';
|
/*print '<br>'.$langs->trans("or").'<br>';
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ class FormOther
|
|||||||
$out .= 'jQuery("#scantoolmessage").text("");';
|
$out .= 'jQuery("#scantoolmessage").text("");';
|
||||||
$out .= '});'."\n";
|
$out .= '});'."\n";
|
||||||
$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).'\'");
|
||||||
'.dol_escape_js($jstoexecuteonadd).'();
|
'.dol_escape_js($jstoexecuteonadd).'();
|
||||||
return false; /* We want to stay on the scan tool */
|
return false; /* We want to stay on the scan tool */
|
||||||
})';
|
})';
|
||||||
|
|||||||
@ -410,3 +410,4 @@ DefaultBOMDesc=The default BOM recommended to use to manufacture this product. T
|
|||||||
Rank=Rank
|
Rank=Rank
|
||||||
SwitchOnSaleStatus=Switch on sale status
|
SwitchOnSaleStatus=Switch on sale status
|
||||||
SwitchOnPurchaseStatus=Switch on purchase status
|
SwitchOnPurchaseStatus=Switch on purchase status
|
||||||
|
ScanOrTypeOrCopyPasteYourBarCodes=Scan or type or copy/paste your barcodes
|
||||||
@ -377,8 +377,9 @@ print '<script type="text/javascript">
|
|||||||
function disablebuttonmakemovementandclose() {
|
function disablebuttonmakemovementandclose() {
|
||||||
console.log("Disable button idbuttonmakemovementandclose until we save");
|
console.log("Disable button idbuttonmakemovementandclose until we save");
|
||||||
jQuery("#idbuttonmakemovementandclose").attr(\'disabled\',\'disabled\');
|
jQuery("#idbuttonmakemovementandclose").attr(\'disabled\',\'disabled\');
|
||||||
|
jQuery("#idbuttonmakemovementandclose").attr(\'onclick\', \'return false;\');
|
||||||
jQuery("#idbuttonmakemovementandclose").attr(\'title\',\''.dol_escape_js($langs->trans("SaveQtyFirst")).'\');
|
jQuery("#idbuttonmakemovementandclose").attr(\'title\',\''.dol_escape_js($langs->trans("SaveQtyFirst")).'\');
|
||||||
jQuery("#idbuttonmakemovementandclose").attr(\'class\',\'butActionRefused\');
|
jQuery("#idbuttonmakemovementandclose").attr(\'class\',\'butActionRefused classfortooltip\');
|
||||||
};
|
};
|
||||||
|
|
||||||
jQuery(document).ready(function() {
|
jQuery(document).ready(function() {
|
||||||
@ -546,7 +547,7 @@ if ($object->id > 0) {
|
|||||||
// Save
|
// Save
|
||||||
if ($object->status == $object::STATUS_VALIDATED) {
|
if ($object->status == $object::STATUS_VALIDATED) {
|
||||||
if ($permissiontoadd) {
|
if ($permissiontoadd) {
|
||||||
print '<a class="butAction" id="idbuttonmakemovementandclose" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=record&token='.newToken().'" title="'.dol_escape_htmltag($langs->trans("MakeMovementsAndClose")).'">'.$langs->trans("MakeMovementsAndClose").'</a>'."\n";
|
print '<a class="butAction classfortooltip" id="idbuttonmakemovementandclose" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=record&token='.newToken().'" title="'.dol_escape_htmltag($langs->trans("MakeMovementsAndClose")).'">'.$langs->trans("MakeMovementsAndClose").'</a>'."\n";
|
||||||
} else {
|
} else {
|
||||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('MakeMovementsAndClose').'</a>'."\n";
|
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('MakeMovementsAndClose').'</a>'."\n";
|
||||||
}
|
}
|
||||||
@ -610,6 +611,7 @@ if ($object->id > 0) {
|
|||||||
print '<script>';
|
print '<script>';
|
||||||
|
|
||||||
print '
|
print '
|
||||||
|
var duplicatedbatchcode = [];
|
||||||
var errortab1 = [];
|
var errortab1 = [];
|
||||||
var errortab2 = [];
|
var errortab2 = [];
|
||||||
var errortab3 = [];
|
var errortab3 = [];
|
||||||
@ -625,6 +627,7 @@ if ($object->id > 0) {
|
|||||||
var textarea = $("textarea[name=barcodelist]").val();
|
var textarea = $("textarea[name=barcodelist]").val();
|
||||||
var textarray = textarea.split(/[\s,;]+/);
|
var textarray = textarea.split(/[\s,;]+/);
|
||||||
var tabproduct = [];
|
var tabproduct = [];
|
||||||
|
duplicatedbatchcode = [];
|
||||||
errortab1 = [];
|
errortab1 = [];
|
||||||
errortab2 = [];
|
errortab2 = [];
|
||||||
errortab3 = [];
|
errortab3 = [];
|
||||||
@ -636,18 +639,20 @@ if ($object->id > 0) {
|
|||||||
if(textarray.some((element) => element != "")){
|
if(textarray.some((element) => element != "")){
|
||||||
$(".expectedqty").each(function(){
|
$(".expectedqty").each(function(){
|
||||||
id = this.id;
|
id = this.id;
|
||||||
console.log("Analyze line "+id+" in inventory");
|
console.log("Analyze the line "+id+" in inventory, barcodemode="+barcodemode);
|
||||||
warehouse = $("#"+id+"_warehouse").children().first().text();
|
warehouse = $("#"+id+"_warehouse").attr(\'data-ref\');
|
||||||
productbarcode = $("#"+id+"_product").children().first().attr("title");
|
//console.log(warehouse);
|
||||||
productbarcode = productbarcode.split("<br>");
|
productbarcode = $("#"+id+"_product").attr(\'data-barcode\');
|
||||||
productbarcode = productbarcode.filter(barcode => barcode.includes("'.$langs->trans('BarCode').'"))[0];
|
//console.log(productbarcode);
|
||||||
productbarcode = productbarcode.slice(productbarcode.indexOf("</b> ")+5);
|
productbatchcode = $("#"+id+"_batch").attr(\'data-batch\');
|
||||||
|
//console.log(productbatchcode);
|
||||||
|
|
||||||
productbatchcode = $("#"+id+"_batch").text();
|
|
||||||
if (barcodemode != "barcodeforproduct") {
|
if (barcodemode != "barcodeforproduct") {
|
||||||
tabproduct.forEach(product=>{
|
tabproduct.forEach(product=>{
|
||||||
|
console.log("product.Batch="+product.Batch+" productbatchcode="+productbatchcode);
|
||||||
if(product.Batch != "" && product.Batch == productbatchcode){
|
if(product.Batch != "" && product.Batch == productbatchcode){
|
||||||
errortab1.push(productbatchcode);
|
console.log("duplicate batch code found for batch code "+productbatchcode);
|
||||||
|
duplicatedbatchcode.push(productbatchcode);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -658,7 +663,9 @@ if ($object->id > 0) {
|
|||||||
tabproduct.push({\'Id\':id,\'Warehouse\':warehouse,\'Barcode\':productbarcode,\'Batch\':productbatchcode,\'Qty\':productinput,\'fetched\':false});
|
tabproduct.push({\'Id\':id,\'Warehouse\':warehouse,\'Barcode\':productbarcode,\'Batch\':productbatchcode,\'Qty\':productinput,\'fetched\':false});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("Loop on each record entered in the textarea");
|
||||||
textarray.forEach(function(element,index){
|
textarray.forEach(function(element,index){
|
||||||
|
console.log("Process record element="+element+" id="+id);
|
||||||
var verify_batch = false;
|
var verify_batch = false;
|
||||||
var verify_barcode = false;
|
var verify_barcode = false;
|
||||||
switch(barcodemode){
|
switch(barcodemode){
|
||||||
@ -673,15 +680,20 @@ if ($object->id > 0) {
|
|||||||
verify_batch = barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"lotserial");
|
verify_batch = barcodeserialforproduct(tabproduct,index,element,barcodeproductqty,selectaddorreplace,"lotserial");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
alert("'.$langs->trans("ErrorWrongBarcodemode").' \""+barcodemode+"\"");
|
alert(\''.dol_escape_js($langs->trans("ErrorWrongBarcodemode")).' "\'+barcodemode+\'"\');
|
||||||
throw "'.$langs->trans('ErrorWrongBarcodemode').' \""+barcodemode+"\"";
|
throw \''.dol_escape_js($langs->trans('ErrorWrongBarcodemode')).' "\'+barcodemode+\'"\';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verify_batch == false && verify_barcode == false) { /* If the 2 flags are false, error */
|
if (verify_batch == false && verify_barcode == false) { /* If the 2 flags are false, not found error */
|
||||||
errortab2.push(element);
|
errortab2.push(element);
|
||||||
}
|
} else if (verify_batch == true && verify_barcode == true) { /* If the 2 flags are true, error: we don t know which one to take */
|
||||||
if (verify_batch == true && verify_barcode == true) { /* If the 2 flags are true, error: we don t know which one to take */
|
|
||||||
errortab3.push(element);
|
errortab3.push(element);
|
||||||
|
} else if (verify_batch == true) {
|
||||||
|
console.log("element="+element);
|
||||||
|
console.log(duplicatedbatchcode);
|
||||||
|
if (duplicatedbatchcode.includes(element)) {
|
||||||
|
errortab1.push(element);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -715,41 +727,41 @@ if ($object->id > 0) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
jQuery("#scantoolmessage").text("'.$langs->trans("QtyWasAddedToTheScannedBarcode").'\n");
|
jQuery("#scantoolmessage").text("'.dol_escape_js($langs->transnoentities("QtyWasAddedToTheScannedBarcode")).'\n");
|
||||||
/* document.forms["formrecord"].submit(); */
|
/* document.forms["formrecord"].submit(); */
|
||||||
} else {
|
} else {
|
||||||
let stringerror = "";
|
let stringerror = "";
|
||||||
if (Object.keys(errortab1).length > 0) {
|
if (Object.keys(errortab1).length > 0) {
|
||||||
stringerror += "<br>'.$langs->transnoentities('ErrorSameBatchNumber').': ";
|
stringerror += "<br>'.dol_escape_js($langs->transnoentities('ErrorSameBatchNumber')).': ";
|
||||||
errortab1.forEach(element => {
|
errortab1.forEach(element => {
|
||||||
stringerror += (element + ", ")
|
stringerror += (element + ", ")
|
||||||
});
|
});
|
||||||
stringerror = stringerror.slice(0, -2); /* Remove last ", " */
|
stringerror = stringerror.slice(0, -2); /* Remove last ", " */
|
||||||
}
|
}
|
||||||
if (Object.keys(errortab2).length > 0) {
|
if (Object.keys(errortab2).length > 0) {
|
||||||
stringerror += "<br>'.$langs->transnoentities('ErrorCantFindCodeInInventory').': ";
|
stringerror += "<br>'.dol_escape_js($langs->transnoentities('ErrorCantFindCodeInInventory')).': ";
|
||||||
errortab2.forEach(element => {
|
errortab2.forEach(element => {
|
||||||
stringerror += (element + ", ")
|
stringerror += (element + ", ")
|
||||||
});
|
});
|
||||||
stringerror = stringerror.slice(0, -2); /* Remove last ", " */
|
stringerror = stringerror.slice(0, -2); /* Remove last ", " */
|
||||||
}
|
}
|
||||||
if (Object.keys(errortab3).length > 0) {
|
if (Object.keys(errortab3).length > 0) {
|
||||||
stringerror += "<br>'.$langs->transnoentities('ErrorCodeScannedIsBothProductAndSerial').': ";
|
stringerror += "<br>'.dol_escape_js($langs->transnoentities('ErrorCodeScannedIsBothProductAndSerial')).': ";
|
||||||
errortab3.forEach(element => {
|
errortab3.forEach(element => {
|
||||||
stringerror += (element + ", ")
|
stringerror += (element + ", ")
|
||||||
});
|
});
|
||||||
stringerror = stringerror.slice(0, -2); /* Remove last ", " */
|
stringerror = stringerror.slice(0, -2); /* Remove last ", " */
|
||||||
}
|
}
|
||||||
if (Object.keys(errortab4).length > 0) {
|
if (Object.keys(errortab4).length > 0) {
|
||||||
stringerror += "<br>'.$langs->transnoentities('ErrorBarcodeNotFoundForProductWarehouse').': ";
|
stringerror += "<br>'.dol_escape_js($langs->transnoentities('ErrorBarcodeNotFoundForProductWarehouse')).': ";
|
||||||
errortab4.forEach(element => {
|
errortab4.forEach(element => {
|
||||||
stringerror += (element + ", ")
|
stringerror += (element + ", ")
|
||||||
});
|
});
|
||||||
stringerror = stringerror.slice(0, -2); /* Remove last ", " */
|
stringerror = stringerror.slice(0, -2); /* Remove last ", " */
|
||||||
}
|
}
|
||||||
|
|
||||||
jQuery("#scantoolmessage").text("'.$langs->trans("ErrorOnElementsInventory").'\n" + stringerror);
|
jQuery("#scantoolmessage").html(\''.dol_escape_js($langs->transnoentities("ErrorOnElementsInventory")).'\' + stringerror);
|
||||||
//alert("'.$langs->trans("ErrorOnElementsInventory").' :\n" + stringerror);
|
//alert("'.dol_escape_js($langs->trans("ErrorOnElementsInventory")).' :\n" + stringerror);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -827,6 +839,7 @@ if ($object->id > 0) {
|
|||||||
print 'jQuery(document).ready(function() {
|
print 'jQuery(document).ready(function() {
|
||||||
$("#clearqty").on("click", function() {
|
$("#clearqty").on("click", function() {
|
||||||
console.log("Clear all values");
|
console.log("Clear all values");
|
||||||
|
disablebuttonmakemovementandclose();
|
||||||
jQuery(".realqty").val("");
|
jQuery(".realqty").val("");
|
||||||
return false; /* disable submit */
|
return false; /* disable submit */
|
||||||
});
|
});
|
||||||
@ -945,16 +958,16 @@ if ($object->id > 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td id="id_'.$obj->rowid.'_warehouse">';
|
print '<td id="id_'.$obj->rowid.'_warehouse" data-ref="'.dol_escape_htmltag($warehouse_static->ref).'">';
|
||||||
print $warehouse_static->getNomUrl(1);
|
print $warehouse_static->getNomUrl(1);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td id="id_'.$obj->rowid.'_product">';
|
print '<td id="id_'.$obj->rowid.'_product" data-ref="'.dol_escape_htmltag($product_static->ref).'" data-barcode="'.dol_escape_htmltag($product_static->barcode).'">';
|
||||||
print $product_static->getNomUrl(1).' - '.$product_static->label;
|
print $product_static->getNomUrl(1).' - '.$product_static->label;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
if (!empty($conf->productbatch->enabled)) {
|
if (!empty($conf->productbatch->enabled)) {
|
||||||
print '<td id="id_'.$obj->rowid.'_batch">';
|
print '<td id="id_'.$obj->rowid.'_batch" data-batch="'.dol_escape_htmltag($obj->batch).'">';
|
||||||
print $obj->batch;
|
print dol_escape_htmltag($obj->batch);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user