2016-09-06 15:32:52 +02:00
|
|
|
<?php
|
|
|
|
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
|
|
|
include dirname(__FILE__).'/../../config/config.inc.php';
|
|
|
|
|
|
|
|
if(isset($_SERVER['REMOTE_ADDR'])) {
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
set_time_limit(600);
|
|
|
|
$auto_sync_sales = Db::getInstance()->executeS('
|
|
|
|
SELECT DISTINCT pmas.`id_sale`
|
2016-11-03 11:58:23 +01:00
|
|
|
FROM `'._DB_PREFIX_.'philea_auto_sync` pmas
|
|
|
|
LEFT JOIN `'._DB_PREFIX_.'philea_sync` pms
|
2016-09-06 15:32:52 +02:00
|
|
|
ON pms.`id_sale` = pmas.`id_sale`
|
|
|
|
LEFT JOIN `'._DB_PREFIX_.'privatesale` p
|
|
|
|
ON p.`id_sale` = pmas.`id_sale`
|
|
|
|
WHERE pms.`status` >= 2
|
|
|
|
AND pmas.active = 1
|
|
|
|
AND p.date_start <= NOW()
|
|
|
|
AND p.date_end >= DATE_SUB(NOW(), INTERVAL 1 HOUR)
|
|
|
|
');
|
|
|
|
if ($auto_sync_sales && count($auto_sync_sales))
|
|
|
|
{
|
|
|
|
foreach ($auto_sync_sales as $sale) {
|
|
|
|
$id_sale = (int) $sale['id_sale'];
|
|
|
|
|
|
|
|
if (Db::getInstance()->getValue('
|
|
|
|
SELECT COUNT(*)
|
2016-11-03 11:58:23 +01:00
|
|
|
FROM `'._DB_PREFIX_.'philea_sync`
|
2016-09-06 15:32:52 +02:00
|
|
|
WHERE `id_sale` = ' . (int) $id_sale . '
|
|
|
|
AND `status` = 3
|
|
|
|
')){
|
|
|
|
continue;
|
|
|
|
}
|
2016-11-03 17:20:09 +01:00
|
|
|
// Db::getInstance()->execute('
|
|
|
|
// INSERT INTO `'._DB_PREFIX_.'philea_sync`
|
|
|
|
// VALUES (
|
|
|
|
// DEFAULT,
|
|
|
|
// '.(int) $id_sale.',
|
|
|
|
// 3,
|
|
|
|
// NOW()
|
|
|
|
// )
|
|
|
|
// ');
|
2016-09-06 15:32:52 +02:00
|
|
|
$sql = '
|
2016-11-03 11:58:23 +01:00
|
|
|
UPDATE `'._DB_PREFIX_.'philea_auto_sync`
|
2016-09-06 15:32:52 +02:00
|
|
|
SET `last_sent` = NOW()
|
|
|
|
WHERE `id_sale` = ' . (int) $id_sale . '
|
|
|
|
LIMIT 1';
|
|
|
|
Db::getInstance()->execute($sql);
|
2016-11-03 11:58:23 +01:00
|
|
|
system('cd '.dirname(__FILE__).'/script && php send_commande.php '.(int) $id_sale);
|
|
|
|
sleep(10);
|
2016-09-06 15:32:52 +02:00
|
|
|
}
|
|
|
|
}
|