fix from prod
This commit is contained in:
parent
76dee4cf4c
commit
a56d8c04e8
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
||||
require_once '../../config/config.inc.php';
|
||||
|
||||
$date = date('Y-m-d');
|
||||
@ -11,42 +12,99 @@ if (!empty($argv[1])) {
|
||||
|
||||
Configuration::updateValue('MAJ_STAT_LOGISTIC', date('Y-m-d H:i:s'));
|
||||
// laposte
|
||||
$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);
|
||||
// $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);
|
||||
//
|
||||
$parcels = array();
|
||||
|
||||
$lp = Db::getInstance()->executeS('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`)');
|
||||
|
||||
foreach($lp as $colis){
|
||||
if(!isset($parcels[$colis['id_employee']])){
|
||||
$parcels[$colis['id_employee']] = $colis;
|
||||
}
|
||||
}
|
||||
|
||||
// Mondial relay
|
||||
$query = '
|
||||
INSERT INTO `'._DB_PREFIX_.'stats_logistic`
|
||||
SELECT
|
||||
// $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_.'mondialrelay_parcel`
|
||||
// WHERE DATE(`date_add`) = "'.pSQL($date).'"
|
||||
// GROUP BY `id_employee` , DATE(`date_add`)
|
||||
// ON DUPLICATE KEY UPDATE
|
||||
// `nb_product` = `nb_product` + VALUES(`nb_product`),
|
||||
// `quantity` = `quantity` + VALUES(`quantity`),
|
||||
// `nb_package` = `nb_package` + VALUES(`nb_package`)
|
||||
// ';
|
||||
// Db::getInstance()->execute($query);
|
||||
//
|
||||
$mr = Db::getInstance()->executeS('SELECT
|
||||
NULL AS `id`,
|
||||
`id_employee` AS `id_employee`,
|
||||
`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_.'mondialrelay_parcel`
|
||||
WHERE DATE(`date_add`) = "'.pSQL($date).'"
|
||||
GROUP BY `id_employee` , DATE(`date_add`)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`nb_product` = `nb_product` + VALUES(`nb_product`),
|
||||
`quantity` = `quantity` + VALUES(`quantity`),
|
||||
`nb_package` = `nb_package` + VALUES(`nb_package`)
|
||||
';
|
||||
Db::getInstance()->execute($query);
|
||||
GROUP BY `id_employee` , DATE(`date_add`)');
|
||||
|
||||
foreach($mr as $colis){
|
||||
if(!isset($parcels[$colis['id_employee']])){
|
||||
$parcels[$colis['id_employee']] = $colis;
|
||||
} else {
|
||||
$parcels[$colis['id_employee']]['nb_product'] = $parcels[$colis['id_employee']]['nb_product'] + $colis['nb_product'];
|
||||
$parcels[$colis['id_employee']]['quantity'] = $parcels[$colis['id_employee']]['quantity'] + $colis['quantity'];
|
||||
$parcels[$colis['id_employee']]['nb_package'] = $parcels[$colis['id_employee']]['nb_package'] + $colis['nb_package'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($parcels as $key => $value) {
|
||||
Db::getInstance()->execute('
|
||||
INSERT INTO `'._DB_PREFIX_.'stats_logistic`
|
||||
VALUES(
|
||||
DEFAULT,
|
||||
'.(int)$value['id_employee'].',
|
||||
"'.$value['date'].'",
|
||||
'.(int)$value['nb_product'].',
|
||||
'.(int)$value['quantity'].',
|
||||
'.(int)$value['nb_package'].'
|
||||
)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`nb_product` = '.(int)$value['nb_product'].',
|
||||
`quantity` = '.(int)$value['quantity'].',
|
||||
`nb_package` ='.(int)$value['nb_package'].'
|
||||
');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user