Merge branch 'ticket-14739-PackLogistic' into develop

This commit is contained in:
Michael RICOIS 2018-02-13 12:44:55 +01:00
commit 31047b7014

View File

@ -150,41 +150,42 @@ if(($id_order = (int) Tools::getValue('id_order'))
$products = array();
foreach($order->getProductsDetail() as $p) {
// --- Get quantity sent
$p['product_quantity_sent'] = 0;
// LaPoste
$p['product_quantity_sent'] += (int) Db::getInstance()->getValue('
SELECT IFNULL(SUM(`quantity`), 0)
FROM `'._DB_PREFIX_.'lapostews`
WHERE `id_order_detail` = '.(int) $p['id_order_detail'].'
');
WHERE `id_order_detail` = ' . (int) $p['id_order_detail']
);
// Exapaq
$p['product_quantity_sent'] += (int) Db::getInstance()->getValue('
SELECT IFNULL(SUM(`quantity`), 0)
FROM `'._DB_PREFIX_.'exapaqws`
WHERE `id_order_detail` = '.(int) $p['id_order_detail'].'
');
WHERE `id_order_detail` = ' . (int) $p['id_order_detail']
);
// MondialRelay
$p['product_quantity_sent'] += (int) Db::getInstance()->getValue('
SELECT IFNULL(SUM(`quantity`), 0)
FROM `'._DB_PREFIX_.'mondialrelay_parcel`
WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] . '
');
WHERE `id_order_detail` = ' . (int) $p['id_order_detail']
);
// Philea
$p['product_quantity_sent'] += (int) Db::getInstance()->getValue('
SELECT IFNULL(SUM(`quantity`), 0)
FROM `'._DB_PREFIX_.'philea_parcel`
WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] . '
');
WHERE `id_order_detail` = ' . (int) $p['id_order_detail']
);
// DropShipping
$p['product_quantity_sent'] += (int) Db::getInstance()->getValue('
SELECT IFNULL(SUM(`quantity`), 0)
FROM `'._DB_PREFIX_.'ant_dropshipping_parcel`
WHERE `id_order_detail` = ' . (int) $p['id_order_detail'] . '
');
WHERE `id_order_detail` = ' . (int) $p['id_order_detail']
);
// Image
$p['id_image'] = 0;
if((int) $p['product_attribute_id'] != 0) {
if ((int) $p['product_attribute_id'] != 0) {
$img = Db::getInstance()->getRow('
SELECT `id_image`
FROM `'._DB_PREFIX_.'product_attribute_image`
@ -194,7 +195,7 @@ if(($id_order = (int) Tools::getValue('id_order'))
$p['id_image'] = $img['id_image'];
}
if($p['id_image'] == 0) {
if ($p['id_image'] == 0) {
$img = Db::getInstance()->getRow('
SELECT `id_image`
FROM `'._DB_PREFIX_.'image`
@ -220,7 +221,7 @@ if(($id_order = (int) Tools::getValue('id_order'))
WHERE `id_product` = '.(int) $p['product_id'].' AND id_order = '.(int)$id_order
);
if(!isset($sales_carriers[(int) $p['id_sale']])) {
if (!isset($sales_carriers[(int) $p['id_sale']])) {
$sales_carriers[(int) $p['id_sale']] = array();
foreach(Db::getInstance()->ExecuteS('
SELECT `id_carrier`
@ -236,7 +237,7 @@ if(($id_order = (int) Tools::getValue('id_order'))
// --- Get Shipping Numbers
$shipping_numbers = array();
// Philea
foreach(Db::getInstance()->ExecuteS('
foreach (Db::getInstance()->ExecuteS('
SELECT l.`shipping_number`
FROM `'._DB_PREFIX_.'philea_parcel` l
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = l.`id_order_detail`)
@ -246,7 +247,7 @@ if(($id_order = (int) Tools::getValue('id_order'))
$shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"';
}
// LaPoste
foreach(Db::getInstance()->ExecuteS('
foreach (Db::getInstance()->ExecuteS('
SELECT l.`shipping_number`
FROM `'._DB_PREFIX_.'lapostews` l
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = l.`id_order_detail`)
@ -256,7 +257,7 @@ if(($id_order = (int) Tools::getValue('id_order'))
$shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"';
}
// Exapaq
foreach(Db::getInstance()->ExecuteS('
foreach (Db::getInstance()->ExecuteS('
SELECT e.`shipping_number`
FROM `'._DB_PREFIX_.'exapaqws` e
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = e.`id_order_detail`)
@ -266,7 +267,7 @@ if(($id_order = (int) Tools::getValue('id_order'))
$shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"';
}
// MondialRelay
foreach(Db::getInstance()->ExecuteS('
foreach (Db::getInstance()->ExecuteS('
SELECT l.`shipping_number`
FROM `'._DB_PREFIX_.'mondialrelay_parcel` l
LEFT JOIN `'._DB_PREFIX_.'order_detail` d ON (d.`id_order_detail` = l.`id_order_detail`)
@ -275,20 +276,22 @@ if(($id_order = (int) Tools::getValue('id_order'))
') as $row) {
$shipping_numbers[] = '"'.pSQL($row['shipping_number']).'"';
}
if(((int) $p['product_quantity_sent'] === 0) && Db::getInstance()->getRow('
SELECT h.`id_sale`
FROM `'._DB_PREFIX_.'shipping_history` h
WHERE h.`id_sale` = '.((int) $p['id_sale'] === 999999? 0: (int) $p['id_sale']).'
AND h.`id_order` = '.(int) $order->id.'
'.(count($shipping_numbers) > 0? 'AND h.`shipping_number` NOT IN ('.implode(', ', $shipping_numbers).')': '').'
')) {
$p['product_quantity_sent'] = $p['product_quantity'] - ( $p['product_quantity_return'] > 0 ?
$p['product_quantity_return']: $p['product_quantity_refunded'] );
if ((int)$p['product_quantity_sent'] === 0) {
if (Db::getInstance()->getRow('
SELECT h.`id_sale`
FROM `'._DB_PREFIX_.'shipping_history` h
WHERE h.`id_sale` = '.((int) $p['id_sale'] === 999999? 0: (int) $p['id_sale']).'
AND h.`id_order` = '.(int) $order->id.'
'.(count($shipping_numbers) > 0 ? 'AND h.`shipping_number` NOT IN ('.implode(', ', $shipping_numbers).')' : '').'
')) {
$p['product_quantity_sent'] = $p['product_quantity'] - (
$p['product_quantity_return'] > 0 ? $p['product_quantity_return'] : $p['product_quantity_refunded']
);
}
}
/* Pack */
if(Pack::isPack($p['product_id'])){
if (Pack::isPack($p['product_id'])){
$p['items_pack'] = Pack::getCompleteSimplePack((int) $p['product_id']);
}
@ -477,7 +480,7 @@ if(($id_order = (int) Tools::getValue('id_order'))
<td style="font-size:16px;"><strong>'.str_replace(' - ','<br>',$products[$key]['product_name']).'</strong></td>
<td class="right">'.($products[$key]['product_reference']? $products[$key]['product_reference'].'<br />': '').($products[$key]['product_ean13']? $products[$key]['product_ean13']: '').($products[$key]['location']?'<br /><span class="location">'.$products[$key]['location'].'</span>': '').'</td>
<td class="right" style="display: none;">'.($products[$key]['product_supplier_reference']? $products[$key]['product_supplier_reference']: '').'</td>
<td class="center"><span style="font-size:18px;opacity:0.4">'.$products[$key]['product_quantity'].' / '.($products[$key]['product_quantity_refunded'] > 0? $products[$key]['product_quantity_refunded']: $products[$key]['product_quantity_return']).' / '.$products[$key]['product_quantity_sent'].'</span></td>
<td class="center"><span style="font-size:18px;opacity:0.4">'.$products[$key]['product_quantity'].' / '.($products[$key]['product_quantity_refunded'] > 0 ? $products[$key]['product_quantity_refunded']: $products[$key]['product_quantity_return']).' / '.$products[$key]['product_quantity_sent'].'</span></td>
<td style="font-size:18px;" class=" center toship'.($products[$key]['product_quantity'] - $products[$key]['product_quantity_return'] - $products[$key]['product_quantity_sent'] == 0? ' bg-danger': '').'"><strong>'.max(in_array($products[$key]['product_id'], $locked_products)? '0': ($products[$key]['product_quantity'] - ($products[$key]['product_quantity_refunded'] > 0? $products[$key]['product_quantity_refunded']: $products[$key]['product_quantity_return']) - $products[$key]['product_quantity_sent']), 0).'</strong></td>
<td class="center"><input type="checkbox" name="product_ids[]" value="'.$products[$key]['product_id'].'" '.($products[$key]['is_pending']>0?'checked disabled':'').'/></td>
<td class="shipped text-center">';