43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
|
<?php
|
||
|
include dirname(__FILE__).'/../../config/config.inc.php';
|
||
|
|
||
|
|
||
|
if(($date = Tools::getValue('date'))
|
||
|
&& (Tools::getValue('token') === Tools::getAdminToken('AdminLaPosteSummary'.(int) Tab::getIdFromClassName('AdminLaPosteSummary').(int) Tools::getValue('id_employee')))) {
|
||
|
$carts = array();
|
||
|
foreach(Db::getInstance()->ExecuteS('
|
||
|
SELECT DISTINCT o.`id_cart`
|
||
|
FROM `'._DB_PREFIX_.'lapostews2` w, `'._DB_PREFIX_.'orders` o
|
||
|
WHERE w.`id_order` = o.`id_order`
|
||
|
AND w.`date_add` > "'.pSQL(date('Y-m-d 00:00:00', strtotime($date))).'"
|
||
|
AND w.`date_add` <= "'.pSQL(date('Y-m-d 23:59:59', strtotime($date))).'"
|
||
|
') as $cart) {
|
||
|
$carts[] = (int) $cart['id_cart'];
|
||
|
}
|
||
|
|
||
|
$modes = array();
|
||
|
|
||
|
$dom = Db::getInstance()->getRow('
|
||
|
SELECT COUNT(o.*) AS `total`
|
||
|
FROM `'._DB_PREFIX_.'orders` o
|
||
|
WHERE o.`id_cart` IN ('.implode(', ', $carts).'
|
||
|
AND o.`id_cart` NOT IN (
|
||
|
SELECT i.`id_cart`
|
||
|
FROM `'._DB_PREFIX_.'socolissimo_delivery_info` i
|
||
|
)
|
||
|
');
|
||
|
if($dom['total'] > 0) {
|
||
|
$modes[] = 'dom';
|
||
|
}
|
||
|
|
||
|
foreach(Db::getInstance()->ExecuteS('
|
||
|
SELECT DISTINCT `delivery_mode`
|
||
|
FROM `'._DB_PREFIX_.'socolissimo_delivery_info`
|
||
|
WHERE `id_cart` IN ('.implode(', ', $carts).')
|
||
|
') as $dm) {
|
||
|
$modes[] = strtolower($dm['delivery_mode']);
|
||
|
}
|
||
|
|
||
|
echo json_encode(array_unique($modes));
|
||
|
}
|