Merge branch 'develop' of gitlab.antadis.net:dev-antadis/bebeboutik into develop

This commit is contained in:
root 2017-06-02 11:15:25 +02:00
commit d0b2205675
2 changed files with 23 additions and 57 deletions

View File

@ -596,7 +596,7 @@ class AdminAntReturnprocess extends AdminTab
} elseif($render === 'route_error') {
HelperFormBootstrap::displayErrors($this->l('Route not found'));
} elseif($render !== FALSE) {
//$this->printLabel($render); // comment in dev
$this->printLabel($render); // comment in dev
if($_SERVER['REMOTE_ADDR'] != '109.190.53.175'
&& $_SERVER['REMOTE_ADDR'] != '78.226.56.137'
@ -623,8 +623,28 @@ class AdminAntReturnprocess extends AdminTab
}
$logistics_carriers[$parcel_carrier]->addOrderHistory($result[1], $order, $products_sent);
HelperFormBootstrap::displaySuccess('Etiquette envoyée à l\'imprimante');
$id_order_return = (int)(Tools::getValue('id_order_return')))
$orderReturn = new OrderReturn($id_order_return);
$orderReturn->state = 5; // return is ended
if ($orderReturn->save())
{
$orderReturnState = new OrderReturnState($orderReturn->state);
Db::getInstance()->ExecuteS('
INSERT INTO `'._DB_PREFIX_.'order_return_history`
VALUES (
DEFAULT,
'.(int) $cookie->id_employee.',
'.(int) $orderReturn->id.',
'.(int) $orderReturn->state.',
NOW()
)
');
}
}
HelperFormBootstrap::displaySuccess('Etiquette envoyée à l\'imprimante');
} else {
HelperFormBootstrap::displayErrors($this->l('An error happened during the label rendering'));
}

View File

@ -763,61 +763,7 @@ class LaposteCarrier {
$history = new OrderHistory();
$history->id_order = (int) $order->id;
$fully_sent = TRUE;
$products_sent = array();
$to_send = array();
$shipping_numbers = array();
foreach(Db::getInstance()->ExecuteS('
SELECT d.`id_order_detail`, IF(
(d.`product_quantity` - IF(
d.`product_quantity_return` > 0, d.`product_quantity_return`, d.`product_quantity_refunded`
) - IFNULL(SUM(s.`quantity`), 0)) > 0, 1, 0
) AS `remain`, s.`shipping_number`
FROM `'._DB_PREFIX_.'order_detail` d
LEFT OUTER JOIN `'._DB_PREFIX_.'lapostews` s
ON s.`id_order_detail` = d.`id_order_detail`
WHERE d.`id_order` = '.(int) $order->id.'
GROUP BY d.`id_order_detail`
') as $quantity_remain) {
if($quantity_remain['shipping_number']) {
$shipping_numbers[] = pSQL($quantity_remain['shipping_number']);
}
if((int) $quantity_remain['remain'] > 0) {
$fully_sent = FALSE;
$to_send[] = (int) $quantity_remain['id_order_detail'];
}
}
$_to_send = array();
foreach($to_send as $p) {
$id_sale = (int) Db::getInstance()->getValue('
SELECT `id_sale`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_product` = (
SELECT `product_id`
FROM `'._DB_PREFIX_.'order_detail`
WHERE `id_order` = '.(int) $order->id.'
AND `id_order_detail` = '.(int) $p.'
)
');
if(!Db::getInstance()->getValue('
SELECT `id_order`
FROM `'._DB_PREFIX_.'shipping_history`
WHERE `id_order` = '.(int) $order->id.'
AND `id_sale` = '.(int) $id_sale.'
AND `shipping_number` NOT IN ("'.implode('", "', $shipping_numbers).'")
')) {
$_to_send[] = $p;
}
}
if(count($_to_send) === 0) {
$fully_sent = TRUE;
}
$history->changeIdOrderState(($fully_sent? Configuration::get('PS_OS_SHIPPING'): 17), (int) $order->id);
$history->changeIdOrderState(Configuration::get('PS_OS_SHIPPING'), (int) $order->id);
$history->id_employee = (int) $cookie->id_employee;
$history->addWithemail(TRUE, $templateVars);