24 if (!defined(
'NOREQUIRESOC')) {
 
   25   define(
'NOREQUIRESOC', 
'1');
 
   27 if (!defined(
'NOCSRFCHECK')) {
 
   28   define(
'NOCSRFCHECK', 1);
 
   30 if (!defined(
'NOTOKENRENEWAL')) {
 
   31   define(
'NOTOKENRENEWAL', 1);
 
   33 if (!defined(
'NOLOGIN')) {
 
   36 if (!defined(
'NOREQUIREMENU')) {
 
   37   define(
'NOREQUIREMENU', 1);
 
   39 if (!defined(
'NOREQUIREHTML')) {
 
   40   define(
'NOREQUIREHTML', 1);
 
   42 if (!defined(
'NOREQUIREAJAX')) {
 
   43   define(
'NOREQUIREAJAX', 
'1');
 
   46 session_cache_limiter(
'public');
 
   48 require_once 
'../../main.inc.php';
 
   53 if (empty($dolibarr_nocache)) {
 
   54   header(
'Cache-Control: max-age=10800, public, must-revalidate');
 
   56   header(
'Cache-Control: no-cache');
 
   68 function addDispatchLine(index, 
type, mode)
 
   70   mode = mode || 
'qtymissing' 
   72   console.log(
"fourn/js/lib_dispatch.js.php 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());    
 
   78   var qty = parseFloat($(
"#qty_"+(nbrTrs - 1)+
"_"+index).val());
 
   81   if (mode === 
'lessone')
 
   83     qtyDispatched = parseFloat($(
"#qty_dispatched_0_"+index).val()) + 1;
 
   87     qtyDispatched = parseFloat($(
"#qty_dispatched_0_"+index).val()) + qty;
 
   89     if (qtyDispatched == qtyOrdered && qtyDispatched > 1) {
 
   90       qtyDispatched = parseFloat($(
"#qty_dispatched_0_"+index).val()) + 1;
 
   94   console.log(
"qtyDispatched="+qtyDispatched+
" qtyOrdered="+qtyOrdered);
 
   96   if (qtyOrdered <= 1) {
 
   97     window.alert(
"Quantity can't be split");
 
   98   } 
else if (qtyDispatched < qtyOrdered) {
 
  100     $row.html($row.html().replace(/_0_/g,
"_"+nbrTrs+
"_"));
 
  105       $row.find(
'.hasDatepicker').each((i, dp) => {
 
  107           .removeClass(
'hasDatepicker');
 
  108         $(dp).next(
'img.ui-datepicker-trigger').remove();
 
  109         $(dp).datepicker($dpopt);
 
  114     $row.find(
"select[name='"+
'entrepot_'+nbrTrs+
'_'+index+
"']").select2();
 
  118     $row.find(
"input[name^='qty']").val(
'');
 
  120     $row.attr(
'name',
type+
'_'+nbrTrs+
'_'+index);
 
  122     $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"']:last").after($row);
 
  125     $(
"#s2id_entrepot_"+nbrTrs+
'_'+index).detach();     
 
  126     $(
".csswarehouse_"+nbrTrs+
"_"+index+
":first-child").parent(
"span.selection").parent(
".select2").detach();
 
  129     $(
"#qty_"+nbrTrs+
"_"+index).focus();
 
  130     $(
"#qty_dispatched_0_"+index).val(qtyDispatched);
 
  133     $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"'] .splitbutton").hide();
 
  134     $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"']:last .splitbutton").show();
 
  136     if (mode === 
'lessone')
 
  139       $(
"#qty_"+(nbrTrs-1)+
"_"+index).val(qty);
 
  141     $(
"#qty_"+nbrTrs+
"_"+index).val(qtyOrdered - qtyDispatched);
 
  143     $(
"#qty_"+(nbrTrs-1)+
"_"+index).data(
'qty', qty);
 
  144     $(
"#qty_"+(nbrTrs-1)+
"_"+index).data(
'type', 
type);
 
  145     $(
"#qty_"+(nbrTrs-1)+
"_"+index).data(
'index', index);
 
  147     $(
"#qty_"+(nbrTrs-1)+
"_"+index).change(this.onChangeDispatchLineQty);
 
  149     $(
"#lot_number_"+(nbrTrs)+
"_"+index).focus();
 
  163 function onChangeDispatchLineQty() {
 
  164   var index = $(
this).data(
'index'),
 
  165     type = $(
this).data(
'type'),
 
  166     qty = parseFloat($(
this).data(
'qty')),
 
  167     changedQty, nbrTrs, dispatchingQty, qtyOrdered, qtyDispatched;
 
  169   if (index >= 0 && 
type && qty >= 0) {
 
  170     nbrTrs = $(
"tr[name^='"+
type+
"_'][name$='_"+index+
"']").length;
 
  171     qtyChanged = parseFloat($(
this).val()) - qty; 
 
  172     qtyDispatching = parseFloat($(
"#qty_"+(nbrTrs-1)+
"_"+index).val()); 
 
  173     qtyOrdered = parseFloat($(
"#qty_ordered_0_"+index).val()); 
 
  174     qtyDispatched = parseFloat($(
"#qty_dispatched_0_"+index).val()); 
 
  176     console.log(
"onChangeDispatchLineQty qtyChanged: " + qtyChanged + 
" qtyDispatching: " + qtyDispatching + 
" qtyOrdered: " + qtyOrdered + 
" qtyDispatched: "+ qtyDispatched);
 
  178     if ((qtyChanged) <= (qtyOrdered - (qtyDispatched + qtyDispatching))) {
 
  179       $(
"#qty_dispatched_0_"+index).val(qtyDispatched + qtyChanged);
 
  181       $(
this).val($(
this).data(
'qty'));
 
  183     $(
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