From 60cef82038d8e46db3eb91100accfd098037e043 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Tue, 30 Jan 2018 12:17:53 +0100 Subject: [PATCH] Get file from server --- modules/ant_logistic/AdminAntLogistic.php | 2 +- modules/ant_logistic/ajax.php | 2 +- modules/ant_logistic/script.js | 47 ++++++++++++++++++++--- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/modules/ant_logistic/AdminAntLogistic.php b/modules/ant_logistic/AdminAntLogistic.php index a08b61ff..c9d43e39 100644 --- a/modules/ant_logistic/AdminAntLogistic.php +++ b/modules/ant_logistic/AdminAntLogistic.php @@ -951,7 +951,7 @@ class AdminAntLogistic extends AdminTab '.$this->l('Produit').' '.$this->l('Référence').' - '.$this->l('Quantités').' + '.$this->l('Quantités').' '.$this->l('Quantité à envoyée').' '.$this->l('Att').' '.$this->l('Quantité envoyée').' diff --git a/modules/ant_logistic/ajax.php b/modules/ant_logistic/ajax.php index cbe3cced..223c9f9e 100644 --- a/modules/ant_logistic/ajax.php +++ b/modules/ant_logistic/ajax.php @@ -523,7 +523,7 @@ if(($id_order = (int) Tools::getValue('id_order')) if ($products[$key]['id_shipping'] != 2 || ($products[$key]['id_shipping'] == 2 && in_array((int)$profile, array(1,7))) ) { - $html_products.='+-'; + $html_products.='+-'; } $html_products.=' diff --git a/modules/ant_logistic/script.js b/modules/ant_logistic/script.js index a8c3a03a..7c003730 100644 --- a/modules/ant_logistic/script.js +++ b/modules/ant_logistic/script.js @@ -126,14 +126,18 @@ function qtyDown(el) { } input.val(Math.max(parseInt(input.val()) - 1, 0)); - if(parseInt(input.val()) > 0) { - $(input).trigger("change"); + if(input.parent().parent().hasClass('pack_item')){ + packQtyDown(input.attr('data-id_order_detail')); + } else { + if(parseInt(input.val()) > 0) { + $(input).trigger("change"); + } } changeCarrier(); } -function checkQuantityPack(el, id_item, id_order_detail, quantity, max){ +function checkQuantityPack(id_order_detail){ var add_quantity = true; var quantity_ok = {}; var pack_quantity = parseInt($('input[name="shipped['+id_order_detail+']"]').val()); @@ -144,10 +148,10 @@ function checkQuantityPack(el, id_item, id_order_detail, quantity, max){ item_pack_quantity = $('input[name="shipped['+id_order_detail+']"]').parent().parent().attr('data-pack_'+id_item); result = quantity / (item_pack_quantity*(pack_quantity+1)); - if(parseFloat(result)!=1){ - quantity_ok[id_item] = false; + if(parseFloat(result)>=1){ + quantity_ok[id_item] = parseInt(quantity / item_pack_quantity); } else { - quantity_ok[id_item] = true; + quantity_ok[id_item] = false; } }); @@ -165,6 +169,37 @@ function checkQuantityPack(el, id_item, id_order_detail, quantity, max){ } } +function packQtyDown(id_order_detail){ + var add_quantity = true; + var quantity_ok = {}; + var pack_quantity = parseInt($('input[name="shipped['+id_order_detail+']"]').val()); + $('.pack_'+id_order_detail+' input.input_quantity').each(function(){ + id_item = $(this).data('item'); + quantity = $(this).val(); + item_pack_quantity = $('input[name="shipped['+id_order_detail+']"]').parent().parent().attr('data-pack_'+id_item); + result = quantity / ((item_pack_quantity-1)*(pack_quantity)); + if(parseFloat(result)>=1){ + quantity_ok[id_item] = parseInt(quantity / item_pack_quantity); + } else { + quantity_ok[id_item] = 0; + } + }); + + var val_to_put = 0; + var i = 0; + $.each(quantity_ok, function( key, value ) { + if(i == 0){ + val_to_put = value; + } + if(value != false){ + val_to_put = Math.min(val_to_put,value); + } + i++; + }); + $('input[name="shipped['+id_order_detail+']"]').val(val_to_put); + $('input[name="shipped['+id_order_detail+']"]').trigger("change"); +} + function confirm(message, callback) { $('#confirm .message').html(message); $('#confirm').modal('toggle');