PageSourceSearch

https://www.axp-racing.com/modules/sldquickorder/views/js/front.js

js axp-racing.com collected 2026-10-07 02:47:05 UTC 32,149 bytes, 783 lines download raw bytes

1/**
2* NOTICE OF LICENSE
3*
4* This source file is subject to a commercial license from SOLEDIS
5* Use, copy, modification or distribution of this source file without written
6* license agreement from the SOLEDIS GROUP is strictly forbidden.
7*    ___  ___  _    ___ ___ ___ ___
8*   / __|/ _ \| |  | __|   \_ _/ __|
9*   \__ \ (_) | |__| _|| |) | |\__ \
10*   |___/\___/|____|___|___/___|___/
11*
12*  @author    SOLEDIS <[email protected]>
13*  @copyright 2024 SOLEDIS
14*  @license   All Rights Reserved
15*  @coder     Grégory Le Vaguerèse
16*/
17
18var sldqof_txt_delete = typeof(sldqof_txt_delete) != 'undefined' ?
19    sldqof_txt_delete : 'delete';
20var sldqof_txt_stock = typeof(sldqof_txt_stock) != 'undefined' ?
21    sldqof_txt_stock : 'In stock';
22var sldqof_txt_nostock = typeof(sldqof_txt_nostock) != 'undefined' ?
23    sldqof_txt_nostock : 'Out of stock';
24
25var sldqof_stock_type = typeof(sldqof_stock_type) != 'undefined' ?
26    sldqof_stock_type : 0;
27
28var sldqof_search_url = typeof(sldqof_search_url) != 'undefined' ?
29    sldqof_search_url : '/module/sldquickorder/quickorderform';
30var sldqof_cart_url = typeof(sldqof_cart_url) != 'undefined' ?
31    sldqof_cart_url : '/index.php?controller=cart';
32
33var sldqof_token = typeof(sldqof_token) != 'undefined' ?
34    sldqof_token : static_token;
35var sldqof_price_zero = typeof(sldqof_price_zero) != 'undefined' ?
36    sldqof_price_zero : '0,00 €';
37
38var sldqof_imgdir = typeof(sldqof_imgdir) != 'undefined' ?
39    sldqof_imgdir : '/img/';
40
41var sldqof_column_image = typeof(sldqof_column_image) != 'undefined' ?
42    parseInt(sldqof_column_image) : 1;
43var sldqof_column_name = typeof(sldqof_column_name) != 'undefined' ?
44    parseInt(sldqof_column_name) : 1;
45var sldqof_column_combination = typeof(sldqof_column_combination) != 'undefined' ?
46    parseInt(sldqof_column_combination) : 1;
47var sldqof_column_stock = typeof(sldqof_column_stock) != 'undefined' ?
48    parseInt(sldqof_column_stock) : 1;
49
50var sldqof_synchronous = typeof(sldqof_synchronous) != 'undefined' ?
51    parseInt(sldqof_synchronous) : 0;
52
53var sldqof_icons_type = typeof(sldqof_icons_type) != 'undefined' ?
54    parseInt(sldqof_icons_type) : 1;
55
56var sldglobal_currency = typeof(sldglobal_currency) != 'undefined' ?
57    sldglobal_currency : JSON.parse('{"iso_code":"EUR","sign":"€"');
58var sldglobal_language = typeof(sldglobal_language) != 'undefined' ?
59    sldglobal_language : JSON.parse('{"locale":"fr-FR"');
60
61var sldqof_adding_total;
62
63var sldqof_search_delay = 200;
64var sldqof_search_term = '';
65var sldqof_search_timer;
66var sldqof_search_products = [];
67
68var sldqof_quagga_started = false;
69
70function sldqof_setRealPrices(target)
71{
72  line = $(target).closest('tr').attr('id').split('_')[2];
73  quantity = $(target).val();
74  id_product = $(target).closest('tr').find('.id_product-input').val();
75  id_product_attribute = $(target).closest('tr').find('.combinations-input').val();
76  $.ajax({
77    type: 'POST',
78    url: sldqof_search_url,
79    async: true,
80    cache: false,
81    dataType : 'json',
82    data: {
83      ajax : 1,
84      action : 'price',
85      line : line,
86      id_product : id_product,
87      id_product_attribute : id_product_attribute,
88      quantity : quantity,
89    },
90    success: function(json)
91    {
92      if (json && json.success) {
93        $('#sldqof_tr_'+json['line']+' .product-price').attr('rel', json.price);
94        qty = parseInt($('#sldqof_tr_'+json['line']+' .quantity-input').val());
95        if (qty < json.quantity) {
96          $('#sldqof_tr_'+json['line']+' .quantity-input').val(json.quantity).focus();
97        }
98        sldqof_setPrices();
99      }
100    },
101    error: function (data)
102    {
103      sldqof_setPrices();
104    },
105    complete: function ()
106    {},
107  });
108}
109
110function sldqof_setPrices()
111{
112  order_total = 0;
113  $('#quickorderform-table tbody tr:not(.deleted)').each(function() {
114    quantity = parseInt($(this).find('.quantity-input').val());
115    quantity = quantity ? quantity : 1;
116    selected_combination = parseInt($(this).find('.combinations-input').val());
117    if (selected_combination) {
118      _image = $(this).find('.combinations-input option[value='+selected_combination+']').attr('img');
119      if (typeof _image != 'undefined') {
120        html = '<img src="'+_image+'" border="0" style="width:100%;height:auto;max-width:50px;" />';
121        $(this).find('.product-image').html(html);
122      }
123      reference = $(this).find('.combinations-input option[value='+selected_combination+']').attr('ref');
124      $(this).find('.reference-input').val(reference);
125      price = parseFloat($(this).find('.combinations-input option[value='+selected_combination+']').attr('rel'));
126      stock = parseFloat($(this).find('.combinations-input option[value='+selected_combination+']').attr('stock'));
127      $(this).find('.product-stock').attr('rel', stock).html(sldqof_displayStock(stock));
128    } else {
129      price = parseFloat($(this).find('.product-price').attr('rel'));
130    }
131    price = price ? price : 0;
132    total = price * quantity;
133    order_total += total;
134    $(this).find('.product-price').html(sldqof_formatPrice(price));
135    $(this).find('.product-total').html(sldqof_formatPrice(total));
136  });
137  $('#quickorderform-table .order-total').html(sldqof_formatPrice(order_total));
138}
139
140function sldqof_formatPrice(price)
141{
142  return new Intl.NumberFormat(
143    sldglobal_language.locale,
144    { style: 'currency', currency: sldglobal_currency.iso_code }
145  ).format(price);
146}
147function sldqof_setProduct(selected_line, product)
148{
149  is_selected = false;
150  if (product && product.combinations.length) {
151    for (k in product.combinations) {
152      if (typeof(product.combinations[k].selected) != 'undefined') {
153        is_selected = true;
154      }
155    }
156  }
157  $('.id_product-input').each(function () {
158    if (product && $(this).val() == product.id_product) {
159      if (!product.combinations.length || (is_selected && $(this).closest('tr').find('.combinations-input').val() == product.combinations[0].id_product_attribute)) {
160        qty = parseInt($(this).closest('tr').find('.quantity-input').val());
161        $(this).closest('tr').find('.quantity-input').val(qty + 1);
162        $('#sldqof_tr_'+selected_line+' input:not(.quantity-input)').val('');
163        sldqof_setPrices();
164        product = null;
165      }
166    }
167  });
168  if (product) {
169    $('#sldqof_tr_'+selected_line+' .reference-input').val(product.reference);
170    if (product.image) {
171      html = '<img src="'+product.image+'" border="0" style="width:100%;height:auto;max-width:50px;" />';
172      $('#sldqof_tr_'+selected_line+' .product-image').html(html);
173    }
174    $('#sldqof_tr_'+selected_line+' .id_product-input').val(product.id_product);
175    $('#sldqof_tr_'+selected_line+' .name-input').val(product.name);
176    $('#sldqof_tr_'+selected_line+' .product-price').attr('rel', product.price);
177    if (product.combinations.length) {
178      options = '';
179      for (k in product.combinations) {
180        combination = product.combinations[k];
181        selected = false;
182        if (typeof(combination.selected) != 'undefined') {
183          selected = true;
184          $('#sldqof_tr_'+selected_line+' .reference-input').val(combination.reference);
185        }
186        options += '<option value="'+combination.id_product_attribute+'" ref="'+combination.reference+'" rel="'+combination.price+'" img="'+combination.image+'" stock="'+combination.stock+'"'+(selected ? ' selected' : '')+'>'+combination.name+'</option>';
187      }
188      $('#sldqof_tr_'+selected_line+' .combinations-input')
189        .attr('readonly', false)
190        .attr('disabled', false)
191        .html(options);
192      $('#sldqof_tr_'+selected_line+' .product-stock')
193        .attr('rel', product.combinations[0].stock)
194        .html(sldqof_displayStock(product.combinations[0].stock));
195    } else {
196      $('#sldqof_tr_'+selected_line+' .combinations-input')
197        .attr('readonly', 'readonly')
198        .attr('disabled', 'disabled')
199        .html('<option value="0">--</option>');
200      $('#sldqof_tr_'+selected_line+' .product-stock')
201        .attr('rel', product.stock)
202        .html(sldqof_displayStock(product.stock));
203    }
204    setTimeout(function () {
205      sldqof_setRealPrices('#sldqof_tr_'+selected_line+' .quantity-input');
206      //$('#sldqof_tr_'+selected_line+' .quantity-input').focus();
207    }, 333);
208  } else {
209    $('#sldqof_tr_'+selected_line+' .product-image').html('');
210    $('#sldqof_tr_'+selected_line+' .id_product-input').val(0);
211    $('#sldqof_tr_'+selected_line+' .product-price').attr('rel', 0);
212    $('#sldqof_tr_'+selected_line+' .product-stock').attr('rel', 0).html('');
213    $('#sldqof_tr_'+selected_line+' .combinations-input')
214      .attr('readonly', 'readonly')
215      .attr('disabled', 'disabled')
216      .html('<option value="0">--</option>');
217  }
218  sldqof_setPrices();
219}
220
221function sldqof_searchProduct(selected_line, sldqof_search_term)
222{
223  if (sldqof_search_term.length > 2) {
224    html = '<img src="'+sldqof_imgdir+'admin/ajax-loader.gif" width="16" height="16" border="0" />';
225    $('#sldqof_tr_'+selected_line+' .product-image').html(html);
226    $.ajax({
227      type: 'POST',
228      url: sldqof_search_url,
229      async: true,
230      cache: false,
231      dataType : 'json',
232      data: {
233        ajax : 1,
234        action : 'search',
235        search : sldqof_search_term,
236        selected_line,
237      },
238      success: function(json) {
239        $('#slqof_choice_container').remove();
240        if (json.products.length) {
241          selected_line = json.selected_line;
242          sldqof_search_products = json.products;
243          $('#sldqof_tr_'+selected_line+' .product-image').html('');
244          if (json.products.length > 1) {
245            // plusieurs produits disponibles : choix !
246            html_list = '';
247            for (k in json.products) {
248              product = json.products[k];
249              html_list +=
250                '<a href="javascript:;" class="sldqof_list" rel="'+product.id_product+'">'+
251                  product.name+
252                  (product.reference && (product.reference).length > 1 ? ' ('+product.reference+')' : '')+
253                '</a>';
254            }
255            html = '<div id="slqof_choice_container"><div id="slqof_choice">'+html_list+'</div></div>';
256            if (!sldqof_column_name) {
257              $('#sldqof_tr_'+selected_line+' .product-reference').append(html);
258            } else {
259              $('#sldqof_tr_'+selected_line+' .product-name').append(html);
260            }
261            // Choix dans la liste
262            $('#quickorderform-table .sldqof_list').off().on('click', function() {
263              if (sldqof_search_products.length) {
264                selected_line = $(this).closest('tr').attr('id').split('_')[2];
265                id_product = $(this).attr('rel');
266                for (k in sldqof_search_products) {
267                  if (id_product == sldqof_search_products[k].id_product) {
268                    $('#slqof_choice_container').remove();
269                    $('#sldqof_tr_'+selected_line+' .product-image').html('');
270                    sldqof_setProduct(selected_line, sldqof_search_products[k]);
271                    if (sldqof_quagga_started) sldqof_quaggaClose(); // <= pour fermer quagga
272                  }
273                }
274              } else {
275                $('#slqof_choice_container').remove();
276              }
277            });
278          } else {
279            // Un seul produit disponible : remplissage de la ligne
280            sldqof_setProduct(selected_line, json.products[0]);
281            if (sldqof_quagga_started) sldqof_quaggaClose(); // <= pour fermer quagga
282          }
283        } else {
284          if ($(this).addClass('name-input')) {
285            $('#sldqof_tr_'+selected_line+' .reference-input').val('');
286          } else {
287            $('#sldqof_tr_'+selected_line+' .name-input').val('');
288          }
289          sldqof_setProduct(selected_line, null);
290        }
291      }
292    });
293  }
294}
295
296function sldqof_getScan(ean13)
297{
298  selected_line = 0;
299  $('#quickorderform-table tbody tr:not(.deleted)').each(function() {
300    id_product = parseInt($(this).find('.id_product-input').val());
301    id_product_attribute = parseInt($(this).find('.combinations-input').val());
302    qty = parseInt($(this).find('.quantity-input').val());
303    if (!id_product || !qty) {
304      selected_line = parseInt($(this).attr('id').split('_')[2]);
305      return false;
306    }
307  });
308  last_line = parseInt($('#quickorderform-table tbody tr:last-child').attr('id').split('_')[2]);
309  if (selected_line == last_line) {
310    sldqof_addFormLine();
311  }
312  sldqof_searchProduct(selected_line, ean13);
313  return true;
314}
315
316function sldqof_addFormLine()
317{
318  // ** Suppression de la gestion d'évènements **
319  $('#quickorderform-table tbody tr:last-child input').off();
320  $('#quickorderform-table .quantity-input').off();
321  $('#quickorderform-table .combinations-input').off();
322  $('#quickorderform-table .reference-input, #quickorderform-table .name-input').off();
323  $('#quickorderform-table input').off();
324  $('#quickorderform-table .delete').off();
325  
326  // Ajout d'une nouvelle ligne au formulaire
327  tr_number = $('#quickorderform-table tbody tr').length;
328  html_tr = '<tr id="sldqof_tr_'+tr_number+'">'+
329    '<input type="hidden" name="product-id_product" class="id_product-input" value="0" />'+
330    '<td class="product-reference"><input type="text" class="reference-input form-control" value="" /></td>'+
331    (sldqof_column_image ? '<td class="product-image"></td>' : '')+
332    (sldqof_column_name ? '<td class="product-name"><input type="text" class="name-input form-control" value="" /></td>' : '')+
333    '<td class="product-combinations"'+(sldqof_column_combination ? '' : ' style="display:none;"')+'><select readonly="readonly" disabled="disabled" class="combinations-input form-control"><option>--</option></select></td>'+
334    //'<td class="product-quantity center"><input type="text" class="quantity-input form-control qty" value="1" /></td>'+
335
336                '<td class="product-quantity center">'+
337                  '<div class="input-group bootstrap-touchspin">'+
338                    '<input type="text" class="quantity-input form-control qty" value="1" />'+
339                    '<span class="input-group-btn-vertical">'+
340                      '<button class="btn btn-touchspin js-touchspin bootstrap-touchspin-up" type="button"><i class="material-icons touchspin-up"></i></button>'+
341                      '<button class="btn btn-touchspin js-touchspin bootstrap-touchspin-down" type="button"><i class="material-icons touchspin-down"></i></button>'+
342                    '</span>'+
343                  '</div>'+
344                '</td>'+
345
346    (sldqof_column_stock ? '<td class="product-stock center" rel="0"></td>' : '')+
347    '<td class="product-price center" rel="0">'+sldqof_price_zero+'</td>'+
348    '<td class="product-total center" rel="0">'+sldqof_price_zero+'</td>'+
349    '<td><a class="delete" href="javascript:;">'+(sldqof_icons_type ? (sldqof_icons_type == 2 ? '<i class="fa fa-trash icon icon-trash"></i>' : '<i class="material-icons">delete</i>') : sldqof_txt_delete)+'</a></td>'+
350    '</tr>';
351  $('#quickorderform-table tbody').append(html_tr);
352
353  // ** Ajout de gestions d'évènements **
354  // Supression d'une ligne
355  $('#quickorderform-table .delete').on('click', function() {
356    $(this).closest('tr').addClass('deleted').hide();
357    sldqof_setPrices();
358    sldqof_addFormLine();
359  });
360  // Focus sur une case ?
361  $('#quickorderform-table input').on('focus', function() {
362    $(this).select();
363  });
364  // Besoin de faire une recherche ?
365  $('#quickorderform-table .reference-input, #quickorderform-table .name-input').on('keyup', function(e){
366    sldqof_search_term = $(this).val();
367    selected_line = $(this).closest('tr').attr('id').split('_')[2];
368    if (sldqof_search_term.length > 2) {
369      clearTimeout(sldqof_search_timer);
370      sldqof_search_timer = setTimeout(function() {
371        sldqof_searchProduct(selected_line, sldqof_search_term);
372      }, sldqof_search_delay);
373    } else if (!sldqof_search_term.length) {
374      if ($(this).hasClass('name-input')) {
375        $('#sldqof_tr_'+selected_line+' .reference-input').val('');
376      } else {
377        $('#sldqof_tr_'+selected_line+' .name-input').val('');
378      }
379      sldqof_setProduct(selected_line, null);
380    }
381  });
382  // Changement de déclinaison ?
383  $('#quickorderform-table .combinations-input').on('change', function() {
384    sldqof_setPrices();
385  });
386  // Modifcation d'une quantité ?
387  $('#quickorderform-table .quantity-input').on('keyup', function(e) {
388    //sldqof_setPrices();
389    sldqof_setRealPrices(e.target);
390  }).on('blur', function() {
391    quantity = parseInt($(this).val());
392    quantity = quantity ? quantity : 1;
393    /*
394    stock = parseInt($(this).closest('tr').find('.product-stock').attr('rel'));
395    stock = stock ? stock : 1;
396    if (stock < quantity) {
397      quantity = stock;
398    }
399    */
400    $(this).val(quantity);
401    sldqof_setPrices();
402  });
403  // Besoin d'ajouter une ligne au formulaire ?
404  $('#quickorderform-table tbody tr:last-child input').on('keyup', function(){
405    sldqof_addFormLine();
406  });
407}
408
409function sldqof_InitScanner(/*callback*/)
410{
411  $(document).on('keyup', function (event) {
412    var code = (event.keyCode ? event.keyCode : event.which);
413    if (typeof(scanner_spy) == 'undefined') { scanner_spy = []; }
414    if (typeof(scanner_timeout) == 'undefined') { scanner_timeout = null; }
415    if (code > 16 && code <= 22) { $(':focus').blur(); }
416    scanner_spy.push(code);
417    clearTimeout(scanner_timeout);
418    scanner_timeout = setTimeout(function () {
419      scanner_sentence = ''; is_scan = false;
420      for (k in scanner_spy) {
421        if (scanner_spy[k] > 16 && scanner_spy[k] <= 22) { is_scan = true; }
422        if (is_scan) { scanner_sentence += scanner_spy[k] >= 32 ? String.fromCharCode(scanner_spy[k]) : ''; }
423      }
424      if (scanner_sentence.length) {
425        sldqof_getScan(scanner_sentence);
426      }
427      scanner_spy = [];
428    }, 666);
429  });
430}
431
432function sldqof_AddToCart()
433{
434  $('#sldqof_loading').remove();
435  $('body').append('<div id="sldqof_loading"><div id="sldqof_loading_text"></div></div>');
436  $('#quickorderform-alerts').html('');
437  sldqof_adding_total = $('#quickorderform-table tbody tr:not(.deleted)').length;
438  if (sldqof_synchronous) {
439    if (sldqof_synchronous > 1) {
440      sldqof_AddToCartSpeed();
441    } else {
442      sldqof_AddToCartSlow();
443    }
444  } else {
445    sldqof_AddToCartFast();
446  }
447}
448
449function sldqof_AddToCartSlow()
450{
451  if ($('#quickorderform-table tbody tr:not(.deleted)').length) {
452    console.log($('#quickorderform-table tbody tr:not(.deleted)').length + ' products to process...');
453    _rest = $('#quickorderform-table tbody tr:not(.deleted)').length;
454    _percent = Math.ceil((sldqof_adding_total - _rest) / sldqof_adding_total * 100);
455    $('#sldqof_loading_text').html(_percent+'%');
456    $this = $('#quickorderform-table tbody tr:not(.deleted)').first();
457    id_product = parseInt($this.find('.id_product-input').val());
458    id_product_attribute = parseInt($this.find('.combinations-input').val());
459    qty = parseInt($this.find('.quantity-input').val());
460    $this.addClass('deleted');
461    if (id_product && qty) {
462      $.ajax({
463        type: 'POST',
464        url: sldqof_cart_url,
465        async: true,
466        cache: false,
467        dataType : 'json',
468        data: {
469          ajax : 1,
470          //action : 'update',
471          action : _percent >= 99 ? 'update' : 'updateQuickOrder',
472          token : sldqof_token,
473          add : 1,
474          id_product,
475          id_product_attribute,
476          qty,
477        },
478        success: function(json) {
479          if (json.success) {
480            prestashop.emit('updateCart', {reason:{}, resp:json});
481            $('#quickorderform-table tbody tr.deleted').each(function() {
482              id_product = parseInt($(this).find('.id_product-input').val());
483              id_product_attribute = parseInt($(this).find('.combinations-input').val());
484              qty = parseInt($(this).find('.quantity-input').val());
485              if (id_product == json.id_product && (json.id_product_attribute == 0 || id_product_attribute == json.id_product_attribute)/* && (qty == json.quantity || !json.quantity)*/) {
486                $(this).hide();
487                //sldqof_addFormLine();
488              }
489            });
490          } else {
491            if (json.hasError) {
492              if (json.errors.length) {
493                html = '<div class="alert alert-warning">'+json.errors.join('<br />')+'</div>';
494                $('#quickorderform-alerts').append(html);
495              }
496            } else if (json.products) { // PS 1.6
497              $('#quickorderform-table tbody tr.deleted').each(function() {
498                id_product = parseInt($(this).find('.id_product-input').val());
499                id_product_attribute = parseInt($(this).find('.combinations-input').val());
500                for(k in json.products) {
501                  product = json.products[k];
502                  if (id_product == product.id && id_product_attribute == product.idCombination) {
503                    $(this).hide();
504                    //sldqof_addFormLine();
505                  }
506                }
507              });
508            }
509          }
510          // ***
511          sldqof_AddToCartSlow();
512        }
513      });
514    } else {
515      sldqof_AddToCartSlow();
516    }
517  } else {
518    $('#quickorderform-table tbody tr.deleted:visible').removeClass('deleted');
519    sldqof_setPrices();
520    setTimeout(function () {
521      $('#sldqof_loading').remove();
522    }, 1000);
523    $('html').addClass('st-effect-right st-menu-open'); // si sidebar "panier"
524    $('.leo-fly-cart-mask').addClass('active'); $('.leo-fly-cart-slidebar').addClass('active'); // autre sidebar
525    if (typeof(ajaxCart) != 'undefined' && typeof(ajaxCart.refresh) != 'undefined') {
526      ajaxCart.refresh();
527    }
528  }
529}
530
531function sldqof_AddToCartFast()
532{
533  sldqof_adding_queue = $('#quickorderform-table tbody tr:not(.deleted)').length;
534  $('#quickorderform-table tbody tr:not(.deleted)').each(function() {
535    console.log($('#quickorderform-table tbody tr:not(.deleted)').length + ' products to process...');
536    id_product = parseInt($(this).find('.id_product-input').val());
537    id_product_attribute = parseInt($(this).find('.combinations-input').val());
538    qty = parseInt($(this).find('.quantity-input').val());
539    if (id_product && qty) {
540      $(this).addClass('deleted');
541      $.ajax({
542        type: 'POST',
543        url: sldqof_cart_url,
544        async: true,
545        cache: false,
546        dataType : 'json',
547        data: {
548          ajax : 1,
549          //action : 'update',
550          action : sldqof_adding_queue >= sldqof_adding_total ? 'update' : 'updateQuickOrder',
551          token : sldqof_token,
552          add : 1,
553          id_product,
554          id_product_attribute,
555          qty,
556          test:'updateQuickOrder_'+(new Date()).getTime(),
557        },
558        success: function(json) {
559          if (json.success) {
560            prestashop.emit('updateCart', {reason:{}, resp:json});
561            $('#quickorderform-table tbody tr.deleted').each(function() {
562              id_product = parseInt($(this).find('.id_product-input').val());
563              id_product_attribute = parseInt($(this).find('.combinations-input').val());
564              qty = parseInt($(this).find('.quantity-input').val());
565              if (id_product == json.id_product && (json.id_product_attribute == 0 || id_product_attribute == json.id_product_attribute)/* && (qty == json.quantity || !json.quantity)*/) {
566                $(this).hide();
567                //sldqof_addFormLine();
568              }
569            });
570          } else {
571            if (json.hasError) {
572              if (json.errors.length) {
573                html = '<div class="alert alert-warning">'+json.errors.join('<br />')+'</div>';
574                $('#quickorderform-alerts').append(html);
575              }
576            } else if (json.products) { // PS 1.6
577              $('#quickorderform-table tbody tr.deleted').each(function() {
578                id_product = parseInt($(this).find('.id_product-input').val());
579                id_product_attribute = parseInt($(this).find('.combinations-input').val());
580                for(k in json.products) {
581                  product = json.products[k];
582                  if (id_product == product.id && id_product_attribute == product.idCombination) {
583                    $(this).hide();
584                    //sldqof_addFormLine();
585                  }
586                }
587              });
588            }
589          }
590          sldqof_adding_queue--;
591          _percent = Math.ceil((sldqof_adding_total - sldqof_adding_queue) / sldqof_adding_total * 100);
592          $('#sldqof_loading_text').html(_percent+'%');
593          if (1 > sldqof_adding_queue) {
594            $('#quickorderform-table tbody tr.deleted:visible').removeClass('deleted');
595            sldqof_setPrices();
596            setTimeout(function () {
597              $('#sldqof_loading').remove();
598            }, 1000);
599            $('html').addClass('st-effect-right st-menu-open'); // si sidebar "panier"
600            $('.leo-fly-cart-mask').addClass('active'); $('.leo-fly-cart-slidebar').addClass('active'); // autre sidebar
601          }
602          if (typeof(ajaxCart) != 'undefined' && typeof(ajaxCart.refresh) != 'undefined') {
603            ajaxCart.refresh();
604          }
605        }
606      });
607    } else {
608      sldqof_adding_queue--;
609      _percent = Math.ceil((sldqof_adding_total - sldqof_adding_queue) / sldqof_adding_total * 100);
610      $('#sldqof_loading_text').html(_percent+'%');
611      if (1 > sldqof_adding_queue) {
612        $('#quickorderform-table tbody tr.deleted:visible').removeClass('deleted');
613        sldqof_setPrices();
614        setTimeout(function () {
615          $('#sldqof_loading').remove();
616        }, 1000);
617        $('html').addClass('st-effect-right st-menu-open'); // si sidebar "panier"
618        $('.leo-fly-cart-mask').addClass('active'); $('.leo-fly-cart-slidebar').addClass('active'); // autre sidebar
619      }
620    }
621  });
622}
623
624function sldqof_AddToCartSpeed()
625{
626  sldqof_adding_queue = $('#quickorderform-table tbody tr:not(.deleted)').length;
627  $('#quickorderform-table tbody tr:not(.deleted)').each(function() {
628    console.log($('#quickorderform-table tbody tr:not(.deleted)').length + ' products to process...');
629    id_product = parseInt($(this).find('.id_product-input').val());
630    id_product_attribute = parseInt($(this).find('.combinations-input').val());
631    qty = parseInt($(this).find('.quantity-input').val());
632    if (id_product && qty) {
633      $(this).addClass('deleted');
634      $.ajax({
635        type: 'POST',
636        url: sldqof_search_url,
637        async: true,
638        cache: false,
639        dataType : 'json',
640        data: {
641          ajax : 1,
642          action : 'cartFiling',
643          id_product : id_product,
644          id_product_attribute : id_product_attribute,
645          qty : qty,
646        },
647        success: function(json) {
648          if (json.success) {
649            prestashop.emit('updateCart', {reason:{}, resp:json});
650            $('#quickorderform-table tbody tr.deleted').each(function() {
651              id_product = parseInt($(this).find('.id_product-input').val());
652              id_product_attribute = parseInt($(this).find('.combinations-input').val());
653              qty = parseInt($(this).find('.quantity-input').val());
654              if (id_product == json.id_product && (json.id_product_attribute == 0 || id_product_attribute == json.id_product_attribute)/* && (qty == json.quantity || !json.quantity)*/) {
655                $(this).hide();
656                //sldqof_addFormLine();
657              }
658            });
659          } else {
660            if (json.hasError) {
661              if (json.errors.length) {
662                html = '<div class="alert alert-warning">'+json.errors.join('<br />')+'</div>';
663                $('#quickorderform-alerts').append(html);
664              }
665            } else if (json.products) { // PS 1.6
666              $('#quickorderform-table tbody tr.deleted').each(function() {
667                id_product = parseInt($(this).find('.id_product-input').val());
668                id_product_attribute = parseInt($(this).find('.combinations-input').val());
669                for(k in json.products) {
670                  product = json.products[k];
671                  if (id_product == product.id && id_product_attribute == product.idCombination) {
672                    $(this).hide();
673                    //sldqof_addFormLine();
674                  }
675                }
676              });
677            }
678          }
679          sldqof_adding_queue--;
680          _percent = Math.ceil((sldqof_adding_total - sldqof_adding_queue) / sldqof_adding_total * 100);
681          $('#sldqof_loading_text').html(_percent+'%');
682          if (1 > sldqof_adding_queue) {
683            $('#quickorderform-table tbody tr.deleted:visible').removeClass('deleted');
684            sldqof_setPrices();
685            setTimeout(function () {
686              $('#sldqof_loading').remove();
687            }, 1000);
688            $('html').addClass('st-effect-right st-menu-open'); // si sidebar "panier"
689            $('.leo-fly-cart-mask').addClass('active'); $('.leo-fly-cart-slidebar').addClass('active'); // autre sidebar
690          }
691          if (typeof(ajaxCart) != 'undefined' && typeof(ajaxCart.refresh) != 'undefined') {
692            ajaxCart.refresh();
693          }
694        }
695      });
696    } else {
697      sldqof_adding_queue--;
698      _percent = Math.ceil((sldqof_adding_total - sldqof_adding_queue) / sldqof_adding_total * 100);
699      $('#sldqof_loading_text').html(_percent+'%');
700      if (1 > sldqof_adding_queue) {
701        $('#quickorderform-table tbody tr.deleted:visible').removeClass('deleted');
702        sldqof_setPrices();
703        setTimeout(function () {
704          $('#sldqof_loading').remove();
705        }, 1000);
706        $('html').addClass('st-effect-right st-menu-open'); // si sidebar "panier"
707        $('.leo-fly-cart-mask').addClass('active'); $('.leo-fly-cart-slidebar').addClass('active'); // autre sidebar
708      }
709    }
710  });
711}
712
713function sldqof_displayStock(stock)
714{
715  switch (parseInt(sldqof_stock_type)) {
716    case 2:
717      return stock > 0 ?
718        '<img src="img/admin/enabled.gif" width="16" height="16" border="0" />' :
719        '<img src="img/admin/disabled.gif" width="16" height="16" border="0" />';
720    case 1:
721      return stock > 0 ? sldqof_txt_stock : sldqof_txt_nostock;
722    case 0:
723    default:
724      return stock;
725  }
726}
727
728function sldqof_quaggaStart() {
729    setTimeout(function () { $('#decoder_readers').val('ean').change(); }, 2000);
730    App.init();
731    sldqof_quagga_started = true;
732    $('#quickorderform-quagga-modal-background').show();
733    $('#decoder_readers').val('ean').change();
734}
735function sldqof_quaggaClose() {
736    Quagga.stop();
737    $('#quickorderform-quagga-modal-background').hide();
738    $('#container').hide();
739}
740function sldqof_quaggaOptions() {
741    if ($('#container').css('display') == 'block') {
742      $('#container').hide();
743    } else {
744      $('#container').show();
745    }
746}
747
748
749$(document).ready(function() {
750
751  if ($('#quickorderform').length) { // FrontController : quickorderform
752
753    // Ajouter au panier
754    $('#quickorderform-add-to-cart').on('click', function() {
755      sldqof_AddToCart();
756    });
757    // Ajout des premières lignes du formulaire
758    for (i = 0; i < 3; i++) {
759      sldqof_addFormLine();
760    }
761    sldqof_setPrices();
762    // Initialisation du Scanner
763    sldqof_InitScanner(/*'sldqof_getScan'*/);
764    // ***
765    $(window).blur(function() {
766      $('#quickorderform').css('opacity', .5);
767    });
768    $(window).focus(function() {
769      $('#quickorderform').css('opacity', 1);
770    });
771    // Autosélection du premier Input de Référence
772    $('#quickorderform-table tbody tr:first-child .reference-input').focus();
773
774    $('.product-quantity .js-touchspin').on('click', function (e) {
775      qty = $(this).closest('.product-quantity').find('.quantity-input').val();
776      if ($(this).is('.bootstrap-touchspin-up')) qty++; else if (qty > 0) qty--;
777      $(this).closest('.product-quantity').find('.quantity-input').val(qty);
778      sldqof_setRealPrices($(this).closest('.product-quantity').find('.quantity-input'));
779    });
780
781  }
782
783});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.