2017-01-11 15:53:24 +01:00

42 lines
1.3 KiB
PHP
Executable File

<?php
include dirname(__FILE__).'/../../../../config/config.inc.php';
if(($date = Tools::getValue('date'))
&& (Tools::getValue('token') === Tools::getAdminToken('AdminMondialRelaySummary'.(int) Tab::getIdFromClassName('AdminMondialRelaySummary').(int) Tools::getValue('id_employee')))) {
$carts = array();
foreach(Db::getInstance()->ExecuteS('
SELECT DISTINCT o.`id_cart`
FROM `'._DB_PREFIX_.'mondialrelay_parcel` w, `'._DB_PREFIX_.'order_detail` d, `'._DB_PREFIX_.'orders` o
WHERE w.`id_order_detail` = d.`id_order_detail`
AND d.`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_.'mr_selected` i
)
');
if($dom['total'] > 0) {
$modes[] = 'dom';
}
foreach(Db::getInstance()->ExecuteS('
SELECT DISTINCT `dlv_mode`
FROM `'._DB_PREFIX_.'mr_method`
') as $dm) {
$modes[] = strtolower($dm['dlv_mode']);
}
echo json_encode(array_unique($modes));
}