executeS(' SELECT DISTINCT pmas.`id_sale` FROM `'._DB_PREFIX_.'philea_auto_sync` pmas LEFT JOIN `'._DB_PREFIX_.'philea_sync` pms 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(*) FROM `'._DB_PREFIX_.'philea_sync` WHERE `id_sale` = ' . (int) $id_sale . ' AND `status` = 3 ')){ continue; } // Db::getInstance()->execute(' // INSERT INTO `'._DB_PREFIX_.'philea_sync` // VALUES ( // DEFAULT, // '.(int) $id_sale.', // 3, // NOW() // ) // '); $sql = ' UPDATE `'._DB_PREFIX_.'philea_auto_sync` SET `last_sent` = NOW() WHERE `id_sale` = ' . (int) $id_sale . ' LIMIT 1'; Db::getInstance()->execute($sql); system('cd '.dirname(__FILE__).'/script && php send_commande.php '.(int) $id_sale); sleep(10); } }