bebeboutik/modules/stats_logistic/cron.php
Srv Bebeboutik 6c0978166c add modules
2016-01-04 12:49:26 +01:00

33 lines
841 B
PHP
Executable File

<?php
require_once '../../config/config.inc.php';
$date = date('Y-m-d');
if (!empty($argv[1])) {
$date = $argv[1];
} elseif (!empty($_GET['date'])) {
$date = $_GET['date'];
}
Configuration::updateValue('MAJ_STAT_LOGISTIC', date('Y-m-d H:i:s'));
$query = '
INSERT INTO `'._DB_PREFIX_.'stats_logistic`
SELECT
NULL AS `id`,
`id_employee` AS `id_employee`,
`date_add` AS `date`,
COUNT(`id_order_detail`) AS `nb_product`,
SUM(`quantity`) AS `quantity`,
COUNT(DISTINCT `shipping_number`) AS `nb_package`
FROM `'._DB_PREFIX_.'lapostews`
WHERE DATE(`date_add`) = "'.pSQL($date).'"
GROUP BY `id_employee` , DATE(`date_add`)
ON DUPLICATE KEY UPDATE
`nb_product` = VALUES(`nb_product`),
`quantity` = VALUES(`quantity`),
`nb_package` = VALUES(`nb_package`)
';
Db::getInstance()->execute($query);