modification to reprint label with multi products
This commit is contained in:
parent
9e2007dfe8
commit
064072bfb8
@ -225,19 +225,17 @@ class AdminLogistics extends AdminTab {
|
||||
Tools::redirectLink('http://'.$_SERVER['SERVER_NAME'].'/adm/index.php?tab=AdminLogistics&token='.Tools::getAdminTokenLite('AdminLogistics').'&id_order='.(int) Tools::getValue('id_order').'&mode='.Tools::getValue('mode', '').'#'.Tools::getValue('mode', ''));
|
||||
}
|
||||
|
||||
if( Tools::isSubmit('submitReprintShip')
|
||||
if( (Tools::isSubmit('submitReprintShip') || Tools::isSubmit('submitReprintShip2'))
|
||||
&& ((int) $cookie->profile == 1 || (int) $cookie->profile == 9 || (int) $cookie->profile == 7)
|
||||
&& (
|
||||
($id_order = Tools::getValue('id_order'))
|
||||
&& ($id_order_detail = Tools::getValue('id_order_detail'))
|
||||
&& ($quantity = Tools::getValue('quantity'))
|
||||
&& ($products = Tools::getValue('products'))
|
||||
&& ($weight = Tools::getValue('weight'))
|
||||
&& ($parcel_carrier = Tools::getValue('carrier'))
|
||||
)
|
||||
) {
|
||||
$order = new Order((int) $id_order);
|
||||
if(Validate::isLoadedObject($order)) {
|
||||
$products = array((int)$id_order_detail => (int)$quantity);
|
||||
$parcel_carrier == 'laposte'? $weight = 0.24: TRUE;
|
||||
$result = $logistics_carriers[$parcel_carrier]->registerParcel($order, $products, $weight);
|
||||
if($result[0] != '') {
|
||||
@ -262,17 +260,21 @@ class AdminLogistics extends AdminTab {
|
||||
&& $_SERVER['REMOTE_ADDR'] != '37.160.139.229'
|
||||
&& substr($_SERVER['REMOTE_ADDR'], 0, 2) != '37') {
|
||||
|
||||
$logistics_carriers[$parcel_carrier]->logParcel($result[1], $products);
|
||||
|
||||
$p = Db::getInstance()->getRow('
|
||||
$products_names = array();
|
||||
foreach(Db::getInstance()->ExecuteS('
|
||||
SELECT `id_order_detail`, `product_name`
|
||||
FROM `'._DB_PREFIX_.'order_detail`
|
||||
WHERE `id_order_detail` ='.(int) $id_order_detail.'
|
||||
');
|
||||
WHERE `id_order_detail` IN ('.implode(', ', array_keys($products)).')
|
||||
') as $p) {
|
||||
$products_names[(int) $p['id_order_detail']] = $p['product_name'];
|
||||
}
|
||||
|
||||
$products_sent = '';
|
||||
if($quantity > 0) {
|
||||
$products_sent .= '<br />'."\r\n".$quantity.' x '.(isset($p['product_name'])? $p['product_name']: '--');
|
||||
$logistics_carriers[$parcel_carrier]->logParcel($result[1], $products);
|
||||
|
||||
foreach($products as $k => $v) {
|
||||
if($v > 0) {
|
||||
$products_sent .= '<br />'."\r\n".$v.' x '.(isset($products_names[$k])? $products_names[$k]: '--');
|
||||
}
|
||||
}
|
||||
|
||||
$logistics_carriers[$parcel_carrier]->addOrderHistory($result[1], $order, $products_sent);
|
||||
@ -744,15 +746,54 @@ class AdminLogistics extends AdminTab {
|
||||
<p> <label>'.$this->l('Product:').'</label> <span id="product-name"></span></p>\
|
||||
<p> <label>'.$this->l('Ref:').'</label> <span id="product-ref"></span></p>\
|
||||
<p> <label for="weight">'.$this->l('Weight:').'</label> <input type="text" value="\' + \'0\' + \'" name="weight" id="weight-reprint" /> kg </p>\
|
||||
<p> <label for="weight">'.$this->l('Quantity:').'</label> <input type="text" value="\' + \'1\' + \'" name="quantity" id="quantity-reprint" /></p>\
|
||||
<p> <label for="products">'.$this->l('Quantity:').'</label> <input type="text" value="\' + \'1\' + \'" name="products[]" id="quantity-reprint" /></p>\
|
||||
<input type="hidden" value="laposte" name="carrier" id="carrier-reprint" />\
|
||||
<input type="hidden" value="0" name="id_order" id="id_order-reprint" />\
|
||||
<input type="hidden" value="0" name="id_order_detail" id="id_order_detail-reprint" />\
|
||||
<p style="padding-left: 200px;"> <input id="button5" type="submit" class="button" name="submitReprintShip" value="'.addslashes($this->l('Register the parcel and print the label')).'"> </p>\
|
||||
</fieldset>\
|
||||
</form>\
|
||||
\
|
||||
</div>\';
|
||||
|
||||
content += \'\
|
||||
'.(((int) $cookie->profile == 1 || (int) $cookie->profile == 9 || (int) $cookie->profile == 7)?
|
||||
'<!--a id="reprint_label2" class="button" data-id_order="\' + loaded.order.id + \'">'.$this->l('Print another Label (multi products)').'</a-->': '').'\';
|
||||
|
||||
content += \'\
|
||||
<!--div id="form-reprint-labels">\
|
||||
<form id="form_reprint2" method="POST" action="'.str_replace(array('&mode=&mode=', '&mode=0&mode=0', '&mode=1&mode=1'), array('&mode=', '&mode=0', '&mode=1'), preg_replace('/\&id_order=[0-9]+/', '', $_SERVER['REQUEST_URI'])).'&mode=\' + window.location.hash.replace(\'#\', \'\') + \'&id_order=\' + loaded.order.id + window.location.hash + \'">\
|
||||
<fieldset>\
|
||||
<legend>'.$this->l('Print another Label - choose your products').'</legend>\
|
||||
<table class="logs">\
|
||||
<thead>\
|
||||
<tr>\
|
||||
<th>'.$this->l('Product').'</th>\
|
||||
<th>'.$this->l('Reference').'</th>\
|
||||
<th>'.$this->l('Quantity sent').'</th>\
|
||||
<th>'.$this->l('Carrier').'</th>\
|
||||
<th>'.$this->l('Quantity to send').'</th>\
|
||||
</tr>\
|
||||
</thead>\
|
||||
<tbody>\';
|
||||
for(var i=0; i < loaded.logs.length; i++) {
|
||||
content += \'<tr>\
|
||||
<td>\' + loaded.logs[i].product_name.replace(" - ", "<br />") + \'</td>\
|
||||
<td>\' + loaded.logs[i].product_reference + \'</td>\
|
||||
<td>\' + loaded.logs[i].quantity + \'</td>\
|
||||
<td>\' + carriers[loaded.logs[i].carrier] + \'</td>\
|
||||
<td><input name="products[\' + loaded.logs[i].id_order_detail + \']" type="text" value="0" autocomplete="off" /></td>\
|
||||
</tr>\';
|
||||
}
|
||||
content += \'\
|
||||
</tbody></table>\
|
||||
<p> <label for="weight">'.$this->l('Weight:').'</label> <input type="text" value="\' + \'0\' + \'" name="weight" id="weight-reprint2" /> kg </p>\
|
||||
<input type="hidden" value="laposte" name="carrier" id="carrier-reprint2" />\
|
||||
<input type="hidden" value="0" name="id_order" id="id_order-reprint2" />\
|
||||
<p style="padding-left: 200px;"> <input id="button6" type="submit" class="button" name="submitReprintShip2" value="'.addslashes($this->l('Register the parcel and print the label')).'"> </p>\
|
||||
</fieldset>\
|
||||
</form>\
|
||||
\
|
||||
</div-->\';
|
||||
}
|
||||
|
||||
';
|
||||
@ -794,14 +835,24 @@ class AdminLogistics extends AdminTab {
|
||||
$(".reprint").each(function(){
|
||||
$(this).click(function(e){
|
||||
e.preventDefault();
|
||||
|
||||
$("span#product-name").text($(this).data("product"));
|
||||
$("span#product-ref").text($(this).data("ref"));
|
||||
$("#carrier-reprint").val($(this).data("carrier"));
|
||||
$("#id_order-reprint").val($(this).data("id_order"));
|
||||
$("#id_order_detail-reprint").val($(this).data("id_order_detail"));
|
||||
$("#quantity-reprint").attr("name","products["+$(this).data("id_order_detail")+"]");
|
||||
|
||||
/*$("#form-reprint-labels").hide();*/
|
||||
$("#form-reprint-label").show();
|
||||
});
|
||||
});
|
||||
|
||||
$("#reprint_label2").click(function(e){
|
||||
e.preventDefault();
|
||||
$("#id_order-reprint2").val($(this).data("id_order"));
|
||||
$("#form-reprint-label").hide();
|
||||
$("#form-reprint-labels").show();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -140,12 +140,18 @@ table.logs a.reprint {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#form-reprint-label{
|
||||
#form-reprint-label, #form-reprint-labels{
|
||||
display: none;
|
||||
overflow: auto;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
#reprint_label2{
|
||||
display: inline-block;
|
||||
margin: 20px 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.infos {
|
||||
line-height: 1.5em;
|
||||
margin-bottom: 20px;
|
||||
|
Loading…
Reference in New Issue
Block a user