update scan inventory error gestion
This commit is contained in:
parent
7512305b44
commit
325ad45bca
@ -265,4 +265,5 @@ ProductBarcodeDoesNotExist=Product with barcode does not exist
|
|||||||
WarehouseId=Warehouse ID
|
WarehouseId=Warehouse ID
|
||||||
WarehouseRef=Warehouse Ref
|
WarehouseRef=Warehouse Ref
|
||||||
SaveQtyFirst=Save the real inventoried quantities first, before asking creation of the stock movement.
|
SaveQtyFirst=Save the real inventoried quantities first, before asking creation of the stock movement.
|
||||||
InventoryStartedShort=Started
|
InventoryStartedShort=Started
|
||||||
|
ErrorOnElementsInventory=Scan was aborted due to following barcode or batch number on error
|
||||||
@ -60,18 +60,25 @@ $warehouseid = 0;
|
|||||||
$objectreturn = array();
|
$objectreturn = array();
|
||||||
|
|
||||||
if ($action == "existbarcode" && !empty($barcode)) {
|
if ($action == "existbarcode" && !empty($barcode)) {
|
||||||
$sql = "SELECT ps.fk_entrepot, ps.fk_product, p.barcode,ps.reel";
|
if (!empty($mode) && $mode == "lotserial") {
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid";
|
$sql = "SELECT ps.fk_entrepot, ps.fk_product, p.barcode, ps.reel, pb.batch";
|
||||||
$sql .= " WHERE p.barcode = '".$db->escape($barcode)."'";
|
$sql .= " FROM ".MAIN_DB_PREFIX."product_batch as pb";
|
||||||
|
$sql .= " JOIN ".MAIN_DB_PREFIX."product_stock as ps ON pb.fk_product_stock = ps.rowid JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid";
|
||||||
|
$sql .= " WHERE pb.batch = '".$db->escape($barcode)."'";
|
||||||
|
} else {
|
||||||
|
$sql = "SELECT ps.fk_entrepot, ps.fk_product, p.barcode,ps.reel";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."product_stock as ps JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid";
|
||||||
|
$sql .= " WHERE p.barcode = '".$db->escape($barcode)."'";
|
||||||
|
}
|
||||||
if (!empty($fk_entrepot)) {
|
if (!empty($fk_entrepot)) {
|
||||||
$sql .= "AND ps.fk_entrepot = '".$db->escape($fk_entrepot)."'";
|
$sql .= " AND ps.fk_entrepot = '".$db->escape($fk_entrepot)."'";
|
||||||
}
|
}
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$nbline = $db->num_rows($result);
|
$nbline = $db->num_rows($result);
|
||||||
for ($i=0; $i < $nbline; $i++) {
|
for ($i=0; $i < $nbline; $i++) {
|
||||||
$object = $db->fetch_object($result);
|
$object = $db->fetch_object($result);
|
||||||
if ($barcode == $object->barcode) {
|
if (($mode == "barcode" && $barcode == $object->barcode) || ($mode == "lotserial" && $barcode == $object->batch)) {
|
||||||
$warehouse->fetch(0, $product["Warehouse"]);
|
$warehouse->fetch(0, $product["Warehouse"]);
|
||||||
if (!empty($object->fk_entrepot) && $warehouse->id == $object->fk_entrepot) {
|
if (!empty($object->fk_entrepot) && $warehouse->id == $object->fk_entrepot) {
|
||||||
$warehousefound++;
|
$warehousefound++;
|
||||||
|
|||||||
@ -541,7 +541,10 @@ if ($object->id > 0) {
|
|||||||
if ($action == 'updatebyscaning') {
|
if ($action == 'updatebyscaning') {
|
||||||
if ($permissiontoadd) {
|
if ($permissiontoadd) {
|
||||||
print '<script>';
|
print '<script>';
|
||||||
print 'function barcodescannerjs(){
|
|
||||||
|
print '
|
||||||
|
var errortab = [];
|
||||||
|
function barcodescannerjs(){
|
||||||
console.log("We catch inputs in sacnner box");
|
console.log("We catch inputs in sacnner box");
|
||||||
var selectaddorreplace = $("select[name=selectaddorreplace]").val();
|
var selectaddorreplace = $("select[name=selectaddorreplace]").val();
|
||||||
var barcodemode = $("input[name=barcodemode]:checked").val();
|
var barcodemode = $("input[name=barcodemode]:checked").val();
|
||||||
@ -561,9 +564,9 @@ if ($object->id > 0) {
|
|||||||
productbatchcode = $("#"+id+"_batch").text();
|
productbatchcode = $("#"+id+"_batch").text();
|
||||||
if(barcodemode != "barcodeforproduct"){
|
if(barcodemode != "barcodeforproduct"){
|
||||||
tabproduct.forEach(product=>{
|
tabproduct.forEach(product=>{
|
||||||
if(product.Batch == productbatchcode){
|
if(product.Batch != "" && product.Batch == productbatchcode){
|
||||||
alert("'.$langs->trans('ErrorSameBatchNumber').': "+productbatchcode);
|
alert("'.$langs->transnoentities('ErrorSameBatchNumber').': "+productbatchcode);
|
||||||
throw"'.$langs->trans('ErrorSameBatchNumber').': "+productbatchcode;
|
throw"'.$langs->transnoentities('ErrorSameBatchNumber').': "+productbatchcode;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -590,32 +593,41 @@ if ($object->id > 0) {
|
|||||||
throw "'.$langs->trans('ErrorWrongBarcodemode').' \""+barcodemode+"\"";
|
throw "'.$langs->trans('ErrorWrongBarcodemode').' \""+barcodemode+"\"";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tabproduct.forEach(product => {
|
if (Object.keys(errortab).length < 1){
|
||||||
if(product.Qty!=0){
|
tabproduct.forEach(product => {
|
||||||
console.log("We change #"+product.Id+"_input to match input in scanner box");
|
if(product.Qty!=0){
|
||||||
if(product.hasOwnProperty("reelqty")){
|
console.log("We change #"+product.Id+"_input to match input in scanner box");
|
||||||
$.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\',
|
if(product.hasOwnProperty("reelqty")){
|
||||||
data: { "action":"addnewlineproduct","fk_entrepot":product.Warehouse,"batch":product.Batch,"fk_inventory":'.dol_escape_js($object->id).',"fk_product":product.fk_product,"reelqty":product.reelqty,"qty":product.Qty},
|
$.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\',
|
||||||
type: \'POST\',
|
data: { "action":"addnewlineproduct","fk_entrepot":product.Warehouse,"batch":product.Batch,"fk_inventory":'.dol_escape_js($object->id).',"fk_product":product.fk_product,"reelqty":product.reelqty,"qty":product.Qty},
|
||||||
async: false,
|
type: \'POST\',
|
||||||
success: function(response) {
|
async: false,
|
||||||
response = JSON.parse(response);
|
success: function(response) {
|
||||||
if(response.status == "success"){
|
response = JSON.parse(response);
|
||||||
console.log(response.message);
|
if(response.status == "success"){
|
||||||
}else{
|
console.log(response.message);
|
||||||
console.error(response.message);
|
}else{
|
||||||
}
|
console.error(response.message);
|
||||||
},
|
}
|
||||||
error : function(output) {
|
},
|
||||||
console.error("Error on barcodeserialforproduct function");
|
error : function(output) {
|
||||||
},
|
console.error("Error on barcodeserialforproduct function");
|
||||||
});
|
},
|
||||||
} else {
|
});
|
||||||
$("#"+product.Id+"_input").val(product.Qty);
|
} else {
|
||||||
|
$("#"+product.Id+"_input").val(product.Qty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
document.forms["formrecord"].submit();
|
||||||
document.forms["formrecord"].submit();
|
}else{
|
||||||
|
let stringerror = "";
|
||||||
|
errortab.forEach(element => {
|
||||||
|
stringerror += (element + ",")
|
||||||
|
});
|
||||||
|
stringerror = stringerror.slice(0, -1);
|
||||||
|
alert("'.$langs->trans("ErrorOnElementsInventory").' :\n" + stringerror);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -625,7 +637,7 @@ if ($object->id > 0) {
|
|||||||
newproductrow=0
|
newproductrow=0
|
||||||
tabproduct.forEach(product => {
|
tabproduct.forEach(product => {
|
||||||
$.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\',
|
$.ajax({ url: \''.DOL_URL_ROOT.'/product/inventory/ajax/searchfrombarcode.php\',
|
||||||
data: { "action":"existbarcode",'.(!empty($object->fk_warehouse)?'"fk_entrepot":'.$object->fk_warehouse.',':'').'"barcode":element,"product":product},
|
data: { "action":"existbarcode",'.(!empty($object->fk_warehouse)?'"fk_entrepot":'.$object->fk_warehouse.',':'').'"barcode":element,"product":product,"mode":mode},
|
||||||
type: \'POST\',
|
type: \'POST\',
|
||||||
async: false,
|
async: false,
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
@ -636,7 +648,10 @@ if ($object->id > 0) {
|
|||||||
newproductrow = response.object;
|
newproductrow = response.object;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
console.error(response.message);
|
if (!errortab.includes(element)){
|
||||||
|
errortab.push(element);
|
||||||
|
console.error(response.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error : function(output) {
|
error : function(output) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user