24 if (!defined(
'NOREQUIRESOC')) define(
'NOREQUIRESOC',
'1');
25 if (!defined(
'NOCSRFCHECK')) define(
'NOCSRFCHECK', 1);
26 if (!defined(
'NOTOKENRENEWAL')) define(
'NOTOKENRENEWAL', 1);
27 if (!defined(
'NOLOGIN')) define(
'NOLOGIN', 1);
28 if (!defined(
'NOREQUIREMENU')) define(
'NOREQUIREMENU', 1);
29 if (!defined(
'NOREQUIREHTML')) define(
'NOREQUIREHTML', 1);
30 if (!defined(
'NOREQUIREAJAX')) define(
'NOREQUIREAJAX',
'1');
32 session_cache_limiter(
'public');
34 require_once
'../../main.inc.php';
39 if (empty($dolibarr_nocache)) header(
'Cache-Control: max-age=10800, public, must-revalidate');
40 else header(
'Cache-Control: no-cache');
51 function addDispatchLine(index,
type, mode)
53 mode = mode ||
'qtymissing'
55 console.log(
"fourn/js/lib_dispatch.js.php Split line type="+
type+
" index="+index+
" mode="+mode);
56 var $row = $(
"tr[name='"+
type+
'_0_'+index+
"']").clone(
true);
57 var nbrTrs = $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"']").length;
58 var qtyOrdered = parseFloat($(
"#qty_ordered_0_"+index).val());
59 var qty = parseFloat($(
"#qty_"+(nbrTrs - 1)+
"_"+index).val());
62 if (mode ===
'lessone')
64 qtyDispatched = parseFloat($(
"#qty_dispatched_0_"+index).val()) + 1;
68 qtyDispatched = parseFloat($(
"#qty_dispatched_0_"+index).val()) + qty;
70 if (qtyDispatched == qtyOrdered && qtyDispatched > 1) {
71 qtyDispatched = parseFloat($(
"#qty_dispatched_0_"+index).val()) + 1;
75 console.log(
"qtyDispatched="+qtyDispatched+
" qtyOrdered="+qtyOrdered);
77 if (qtyOrdered <= 1) {
78 window.alert(
"Quantity can't be split");
80 if (qtyDispatched < qtyOrdered)
83 $row.html($row.html().replace(/_0_/g,
"_"+nbrTrs+
"_"));
85 $row.find(
"select[name='"+
'entrepot_'+nbrTrs+
'_'+index+
"']").select2();
89 $row.find(
"input[name^='qty']").val(
'');
91 $row.attr(
'name',
type+
'_'+nbrTrs+
'_'+index);
93 $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"']:last").after($row);
96 $(
"#s2id_entrepot_"+nbrTrs+
'_'+index).detach();
97 $(
".csswarehouse_"+nbrTrs+
"_"+index+
":first-child").parent(
"span.selection").parent(
".select2").detach();
100 $(
"#qty_"+nbrTrs+
"_"+index).focus();
101 $(
"#qty_dispatched_0_"+index).val(qtyDispatched);
104 $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"'] .splitbutton").hide();
105 $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"']:last .splitbutton").show();
107 if (mode ===
'lessone')
110 $(
"#qty_"+(nbrTrs-1)+
"_"+index).val(qty);
112 $(
"#qty_"+nbrTrs+
"_"+index).val(qtyOrdered - qtyDispatched);
114 $(
"#qty_"+(nbrTrs-1)+
"_"+index).data(
'qty', qty);
115 $(
"#qty_"+(nbrTrs-1)+
"_"+index).data(
'type',
type);
116 $(
"#qty_"+(nbrTrs-1)+
"_"+index).data(
'index', index);
118 $(
"#qty_"+(nbrTrs-1)+
"_"+index).change(this.onChangeDispatchLineQty);
120 $(
"#lot_number_"+(nbrTrs)+
"_"+index).focus();
134 function onChangeDispatchLineQty() {
135 var index = $(
this).data(
'index'),
136 type = $(
this).data(
'type'),
137 qty = parseFloat($(
this).data(
'qty')),
138 changedQty, nbrTrs, dispatchingQty, qtyOrdered, qtyDispatched;
140 if (index >= 0 &&
type && qty >= 0) {
141 nbrTrs = $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"']").length;
142 qtyChanged = parseFloat($(
this).val()) - qty;
143 qtyDispatching = parseFloat($(
"#qty_"+(nbrTrs-1)+
"_"+index).val());
144 qtyOrdered = parseFloat($(
"#qty_ordered_0_"+index).val());
145 qtyDispatched = parseFloat($(
"#qty_dispatched_0_"+index).val());
147 console.log(
"onChangeDispatchLineQty qtyChanged: " + qtyChanged +
" qtyDispatching: " + qtyDispatching +
" qtyOrdered: " + qtyOrdered +
" qtyDispatched: "+ qtyDispatched);
149 if ((qtyChanged) <= (qtyOrdered - (qtyDispatched + qtyDispatching))) {
150 $(
"#qty_dispatched_0_"+index).val(qtyDispatched + qtyChanged);
152 $(
this).val($(
this).data(
'qty'));
154 $(
this).data(
'qty', $(
this).val());
if(!defined('NOREQUIREMENU')) 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