24if (!defined(
'NOREQUIRESOC')) {
25 define(
'NOREQUIRESOC',
'1');
27if (!defined(
'NOCSRFCHECK')) {
28 define(
'NOCSRFCHECK', 1);
30if (!defined(
'NOTOKENRENEWAL')) {
31 define(
'NOTOKENRENEWAL', 1);
33if (!defined(
'NOLOGIN')) {
36if (!defined(
'NOREQUIREMENU')) {
37 define(
'NOREQUIREMENU', 1);
39if (!defined(
'NOREQUIREHTML')) {
40 define(
'NOREQUIREHTML', 1);
42if (!defined(
'NOREQUIREAJAX')) {
43 define(
'NOREQUIREAJAX',
'1');
46session_cache_limiter(
'public');
48require_once
'../../main.inc.php';
53if (empty($dolibarr_nocache)) {
54 header(
'Cache-Control: max-age=10800, public, must-revalidate');
56 header(
'Cache-Control: no-cache');
68function addDispatchLine(index,
type, mode) {
69 mode = mode ||
'qtymissing'
71 console.log(
"expedition/js/lib_dispatch.js.php addDispatchLine Split line type="+
type+
" index="+index+
" mode="+mode);
73 var $row0 = $(
"tr[name='"+
type+
'_0_'+index+
"']");
74 var $dpopt = $row0.find(
'.hasDatepicker').first().datepicker(
'option',
'all');
75 var $row = $row0.clone(
true);
76 var nbrTrs = $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"']").length;
77 var qtyOrdered = parseFloat($(
"#qty_ordered_0_"+index).val());
79 var qty = parseFloat($(
"#qty_"+(nbrTrs - 1)+
"_"+index).val());
84 console.log(
"expedition/js/lib_dispatch.js.php addDispatchLine Split line nbrTrs="+nbrTrs+
" qtyOrdered="+qtyOrdered+
" qty="+qty);
88 if (mode ===
'lessone') {
89 qtyDispatched = parseFloat($(
"#qty_dispatched_0_" + index).val()) + 1;
92 qtyDispatched = parseFloat($(
"#qty_dispatched_0_" + index).val()) + qty;
94 if (qtyDispatched == qtyOrdered && qtyDispatched > 1) {
95 qtyDispatched = parseFloat($(
"#qty_dispatched_0_" + index).val()) + 1;
99 console.log(
"expedition/js/lib_dispatch.js.php qtyDispatched=" + qtyDispatched +
" qtyOrdered=" + qtyOrdered+
" qty=" + qty);
102 window.alert(
"Remain quantity to dispatch is too low to be split");
104 var oldlineqty = qtyDispatched;
105 var newlineqty = qtyOrdered - qtyDispatched;
106 if (newlineqty <= 0) {
107 newlineqty = qty - 1;
109 $(
"#qty_"+(nbrTrs - 1)+
"_"+index).val(oldlineqty);
113 $row.html($row.html().replace(/_0_/g,
"_" + nbrTrs +
"_"));
118 $row.find(
'.hasDatepicker').each((i, dp) => {
120 .removeClass(
'hasDatepicker');
121 $(dp).next(
'img.ui-datepicker-trigger').remove();
122 $(dp).datepicker($dpopt);
127 $row.find(
"select[name='" +
'entrepot_' + nbrTrs +
'_' + index +
"']").select2();
131 $row.find(
"input[name^='qty']").val(
'');
133 $row.attr(
'name',
type +
'_' + nbrTrs +
'_' + index);
135 $(
"tr[name^='" +
type +
"_'][name$='_" + index +
"']:last").after($row);
138 $(
"#s2id_entrepot_" + nbrTrs +
'_' + index).detach();
139 $(
".csswarehouse_" + nbrTrs +
"_" + index +
":first-child").parent(
"span.selection").parent(
".select2").detach();
142 $(
"#qty_"+nbrTrs+
"_"+index).focus();
143 $(
"#qty_dispatched_0_"+index).val(oldlineqty);
146 $(
"tr[name^='" +
type +
"_'][name$='_" + index +
"'] .splitbutton").hide();
147 $(
"tr[name^='" +
type +
"_'][name$='_" + index +
"']:last .splitbutton").show();
149 $(
"#reset_" + (nbrTrs) +
"_" + index).click(
function (event) {
150 event.preventDefault();
151 id = $(
this).attr(
"id");
152 id =
id.split(
"reset_");
154 idlast = $(
"tr[name^='" +
type +
"_'][name$='_" + index +
"']:last .qtydispatchinput").attr(
"id");
155 if (idlast == $(
"#qty_" + idrow).attr(
"id")) {
156 console.log(
"expedition/js/lib_dispatch.js.php Remove trigger for tr name = " +
type +
"_" + idrow);
157 $(
'tr[name="' +
type +
'_' + idrow +
'"').remove();
158 $(
"tr[name^='" +
type +
"_'][name$='_" + index +
"']:last .splitbutton").show();
160 console.log(
"expedition/js/lib_dispatch.js.php Reset trigger for id = qty_" + idrow);
161 $(
"#qty_" + idrow).val(
"");
165 if (mode ===
'lessone')
168 $(
"#qty_"+(nbrTrs-1)+
"_"+index).val(qty);
170 $(
"#qty_"+nbrTrs+
"_"+index).val(newlineqty);
172 $(
"#qty_" + (nbrTrs - 1) +
"_" + index).data(
'qty', qty);
173 $(
"#qty_" + (nbrTrs - 1) +
"_" + index).data(
'type',
type);
174 $(
"#qty_" + (nbrTrs - 1) +
"_" + index).data(
'index', index);
178 $(
"#lot_number_" + (nbrTrs) +
"_" + index).focus();
180 $(
"tr[name^='" +
type +
"_'][name$='_" + index +
"']:last").data(
"remove",
"remove");
181 $(
"#lot_number_" + (nbrTrs) +
"_" + index).val(
"")
182 $(
"#idline_" + (nbrTrs) +
"_" + index).val(
"-1")
183 $(
"#qty_" + (nbrTrs) +
"_" + index).data(
'expected',
"0");
185 $(
"#lot_number_" + (nbrTrs) +
"_" + index).removeAttr(
"disabled");
198function onChangeDispatchLineQty(element) {
199 var
type = $(element).data(
'type'),
200 qty = parseFloat($(element).data(
'expected')),
201 changedQty, nbrTrs, dispatchingQty, qtyOrdered, qtyDispatched;
202 id = $(element).attr(
"id");
206 if (index >= 0 &&
type && qty >= 0) {
207 nbrTrs = $(
"tr[name^='" +
type +
"_'][name$='_" + index +
"']").length;
208 qtyChanged = parseFloat($(element).val()) - qty;
209 qtyDispatching = parseFloat($(element).val());
210 qtyOrdered = parseFloat($(
"#qty_ordered_0_" + index).val());
211 qtyDispatched = parseFloat($(
"#qty_dispatched_0_" + index).val());
213 console.log(
"onChangeDispatchLineQty qtyChanged: " + qtyChanged +
" qtyDispatching: " + qtyDispatching +
" qtyOrdered: " + qtyOrdered +
" qtyDispatched: " + qtyDispatched);
215 if ((qtyChanged) <= (qtyOrdered - (qtyDispatched + qtyDispatching))) {
216 $(
"#qty_dispatched_0_" + index).val(qtyDispatched + qtyChanged);
221 $(element).data(
'expected', $(element).val());
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type