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);
74 var typeArr =
type.split(
'-');
75 if (typeArr.length > 0) {
78 var $row0 = $(
"tr[name='"+
type+
'_0_'+index+
"']");
79 var $dpopt = $row0.find(
'.hasDatepicker').first().datepicker(
'option',
'all');
80 var $row = $row0.clone(
true);
81 var nbrTrs = $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"']").length;
82 var qtyOrdered = parseFloat($(
"#qty_ordered_0_"+index).val());
84 var qty = parseFloat($(
"#qty"+lineId+
"_"+(nbrTrs - 1)+
"_"+index).val());
89 console.log(
"expedition/js/lib_dispatch.js.php addDispatchLine Split line="+lineId+
" nbrTrs="+nbrTrs+
" qtyOrdered="+qtyOrdered+
" qty="+qty);
93 if (mode ===
'lessone') {
94 qtyDispatched = parseFloat($(
"#qty_dispatched_0_" + index).val()) + 1;
97 qtyDispatched = parseFloat($(
"#qty_dispatched_0_" + index).val()) + qty;
99 if (qtyDispatched == qtyOrdered && qtyDispatched > 1) {
100 qtyDispatched = parseFloat($(
"#qty_dispatched_0_" + index).val()) + 1;
104 console.log(
"expedition/js/lib_dispatch.js.php qtyDispatched=" + qtyDispatched +
" qtyOrdered=" + qtyOrdered+
" qty=" + qty);
107 window.alert(
"Remain quantity to dispatch is too low to be split");
109 var oldlineqty = qtyDispatched;
110 var newlineqty = qtyOrdered - qtyDispatched;
111 if (newlineqty <= 0) {
112 newlineqty = qty - 1;
114 $(
"#qty"+lineId+
"_"+(nbrTrs - 1)+
"_"+index).val(oldlineqty);
118 $row.html($row.html().replace(/_0_/g,
"_" + nbrTrs +
"_"));
123 $row.find(
'.hasDatepicker').each((i, dp) => {
125 .removeClass(
'hasDatepicker');
126 $(dp).next(
'img.ui-datepicker-trigger').remove();
127 $(dp).datepicker($dpopt);
132 $row.find(
"select[name='"+
'entrepot'+lineId+
'_'+nbrTrs+
'_'+index+
"']").select2();
134 $row.find(
"select[name='"+
'lot_number'+lineId+
'_'+nbrTrs+
'_'+index+
"']").select2();
138 $row.find(
"input[name^='qty']").val(
'');
140 $row.attr(
'name',
type+
'_'+nbrTrs+
'_'+index);
142 $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"']:last").after($row);
145 $(
"#s2id_entrepot"+lineId+
"_"+nbrTrs+
'_'+index).detach();
146 $(
".csswarehouse"+lineId+
"_"+nbrTrs+
"_"+index +
":first-child").parent(
"span.selection").parent(
".select2").detach();
149 $(
"#s2id_lot_number"+lineId+
"_"+nbrTrs+
'_'+index).detach();
150 $(
".csslotnumber"+lineId+
"_"+nbrTrs+
"_"+index +
":first-child").parent(
"span.selection").parent(
".select2").detach();
153 $(
"#qty"+lineId+
"_"+nbrTrs+
"_"+index).focus();
154 $(
"#qty_dispatched_0_"+index).val(oldlineqty);
157 $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"'] .splitbutton").hide();
158 $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"']:last .splitbutton").show();
160 $(
"#reset"+lineId+
"_"+(nbrTrs)+
"_"+index).click(
function (event) {
161 event.preventDefault();
162 id = $(
this).attr(
"id");
163 id =
id.split(
"reset"+lineId+
"_");
165 idlast = $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"']:last .qtydispatchinput").attr(
"id");
166 if (idlast == $(
"#qty"+lineId+
"_"+idrow).attr(
"id")) {
167 console.log(
"expedition/js/lib_dispatch.js.php Remove trigger for tr name = "+
type+
"_"+idrow);
168 $(
'tr[name="'+
type+
'_'+idrow+
'"').remove();
169 $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"']:last .splitbutton").show();
171 console.log(
"expedition/js/lib_dispatch.js.php Reset trigger for id = qty_"+idrow);
172 $(
"#qty"+lineId+
"_"+idrow).val(
"");
176 if (mode ===
'lessone')
179 $(
"#qty"+lineId+
"_"+(nbrTrs-1)+
"_"+index).val(qty);
181 $(
"#qty"+lineId+
"_"+nbrTrs+
"_"+index).val(newlineqty);
183 $(
"#qty"+lineId+
"_" + (nbrTrs - 1) +
"_" + index).data(
'qty', qty);
184 $(
"#qty"+lineId+
"_" + (nbrTrs - 1) +
"_" + index).data(
'type',
type);
185 $(
"#qty"+lineId+
"_" + (nbrTrs - 1) +
"_" + index).data(
'index', index);
189 $(
"#lot_number"+lineId+
"_"+(nbrTrs)+
"_"+index).focus();
191 $(
"tr[name^='"+
type+
"_'][name$='_"+index +
"']:last").data(
"remove",
"remove");
192 $(
"#lot_number_"+(nbrTrs) +
"_"+index).val(
"")
193 $(
"#idline"+lineId+
"_"+(nbrTrs)+
"_"+index).val(
"-1")
194 $(
"#qty"+lineId+
"_"+(nbrTrs)+
"_"+index).data(
'expected',
"0");
196 $(
"#lot_number"+lineId+
"_"+(nbrTrs)+
"_"+index).removeAttr(
"disabled");
209function onChangeDispatchLineQty(element) {
210 var
type = $(element).data(
'type'),
211 qty = parseFloat($(element).data(
'expected')),
212 changedQty, nbrTrs, dispatchingQty, qtyOrdered, qtyDispatched;
213 id = $(element).attr(
"id");
217 if (index >= 0 &&
type && qty >= 0) {
218 nbrTrs = $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"']").length;
219 qtyChanged = parseFloat($(element).val()) - qty;
220 qtyDispatching = parseFloat($(element).val());
221 qtyOrdered = parseFloat($(
"#qty_ordered_0_"+index).val());
222 qtyDispatched = parseFloat($(
"#qty_dispatched_0_"+index).val());
224 console.log(
"onChangeDispatchLineQty qtyChanged: "+qtyChanged+
" qtyDispatching: "+qtyDispatching+
" qtyOrdered: "+qtyOrdered+
" qtyDispatched: "+qtyDispatched);
226 if ((qtyChanged) <= (qtyOrdered - (qtyDispatched + qtyDispatching))) {
227 $(
"#qty_dispatched_0_" + index).val(qtyDispatched + qtyChanged);
232 $(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|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...