Skip to content
Snippets Groups Projects
Commit d4bd5ba8 authored by Thomas Negre's avatar Thomas Negre
Browse files

Manage DLC/DLUOs

parent 0388585d
No related branches found
No related tags found
2 merge requests!2Preprod -> master,!1Preprod manage lots
......@@ -25,4 +25,8 @@ ShippingScannerProductNotFoundOnExpedition2 = n'a pas été trouvé
ShippingScannerDispatchLinesDontHaveWarehouse = Sur certaines lignes, l'enterpôt n'est pas configuré. Veuillez le configurer.
ShippingScannerDispatchLinesLastLineNegative = La dernière ligne a une quantité négative. N'avez-vous pas scanné trop de produits ?
\ No newline at end of file
ShippingScannerDispatchLinesLastLineNegative = La dernière ligne a une quantité négative. N'avez-vous pas scanné trop de produits ?
ShippingScannerDlcMandatory = Une DLC n'est pas renseignée sur ce produit. Elle est obligatoire
ShippingScannerDuoMandatory = Une DMD/DLUO n'est pas renseignée sur ce produit. Elle est obligatoire
ShippingScannerDlcAndDluoMandatory = Une DLC ou DMD/DLUO n'est pas renseignée sur ce produit. Elles sont obligatoires.
\ No newline at end of file
......@@ -1007,6 +1007,7 @@ if ($id > 0 || !empty($ref)) {
// For serial number (batch status = 2) and lot (batch status = 1)
$canSearchSerial = (in_array($tmpproduct->status_batch, [1,2]) && $splitAsciiCode > 0);
$dlc_dluo_mandatory = !empty($tmpproduct->sell_or_eat_by_mandatory);
if ($canSearchSerial === true) {
$serialInput = dol_escape_js('lot_number' . $suffix);
......@@ -1034,6 +1035,32 @@ if ($id > 0 || !empty($ref)) {
jQuery("input[name=\"dispatch\"]").focus();
}
function checkDlcDluo(element) {
';
if ($dlc_dluo_mandatory) {
switch($tmpproduct->sell_or_eat_by_mandatory) {
case Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY:
$checkDlcDluoCond = 'Boolean(element.parent().parent().find("input[id^=dlc_]).val())';
$alert_msg = 'ShippingScannerDlcMandatory';
break;
case Product::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY:
$checkDlcDluoCond = 'Boolean(element.parent().parent().find("input[id^=dluo_]).val())';
$alert_msg = 'ShippingScannerDuoMandatory';
break;
case Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT:
$checkDlcDluoCond = 'Boolean(element.parent().parent().find("input[id^=dlc_]).val()) && Boolean(element.parent().parent().find("input[id^=dluo_]).val())';
$alert_msg = 'ShippingScannerDlcAndDluoMandatory';
break;
}
$jsLine .= '
if (! '.$checkDlcDluoCond.') {
alert("'.$langs->transnoentities($alert_msg).'")
}
';
} // else empty function
$jsLine .= '
}
jQuery("#' . $serialInput . '").keypress(function(event){
var splitAsciiCode = "' . dol_escape_js($splitAsciiCode) . '";
var i = ' . dol_escape_js($i) . ';
......@@ -1043,11 +1070,11 @@ if ($id > 0 || !empty($ref)) {
if (event.which == splitAsciiCode) {
if (jQuery("#qty_"+(qtyToDispatch-1)+"_"+i).length <= 0) { // max input lines to dispatch not reached
let searchInput = $("#' . $serialInput . '").val()
';
if ($tmpproduct->status_batch == 1) {
$jsLine .= '
// if we find a line with same lot number, increment qty
let searchInput = $("#' . $serialInput . '").val()
let same_lot_number = $("#' . $serialInput . '").parent().parent().parent().find("input[id^=\'lot_number_\']").filter((n, elt) => { return elt.value === searchInput })
if (same_lot_number.length > 1) { // There is already a line
......@@ -1060,6 +1087,7 @@ if ($id > 0 || !empty($ref)) {
let cur_qty = cur_qty_input.val();
cur_qty_input.val(cur_qty-1)
if (cur_qty-1 <= 0) {
checkDlcDluo(same_lot_number)
endReception()
}
......@@ -1073,16 +1101,19 @@ if ($id > 0 || !empty($ref)) {
let cur_qty_input = $(event.target).parent().parent().find("input[id^=qty_]");
let cur_qty = cur_qty_input.val();
if (cur_qty-1 <= 0) {
checkDlcDluo(searchInput)
endReception()
} else {
cur_qty_input.val(1)
addDispatchLine(i, type);
checkDlcDluo(searchInput)
}
}
';
} elseif ($tmpproduct->status_batch == 2) {
$jsLine .= '
addDispatchLine(i, type);
checkDlcDluo(searchInput)
';
}
$jsLine .= '
......@@ -1091,6 +1122,7 @@ if ($id > 0 || !empty($ref)) {
if (serialInputNext.length > 0) { // found a next serial input
serialInputNext.focus();
} else { // no next serial input : so go to create button
checkDlcDluo(searchInput)
endReception()
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment