2017-06-21 14:44:10 +02:00

25 lines
892 B
PHP

<?php
if(isset($_SERVER['REMOTE_ADDR'])) exit;
$_SERVER['SERVER_PORT'] = 80;
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
include(dirname(__FILE__).'/../../config/config.inc.php');
include dirname(__FILE__).'/../../init.php';
// Cleaning returns of 3 month and still in state 2
$order_returns = Db::getInstance()->ExecuteS('
SELECT r.`id_order_return`
FROM '._DB_PREFIX_.'order_return r
WHERE r.state = 2
AND r.date_upd < DATE_SUB(NOW(), INTERVAL 3 MONTH)'
);
$id_to_update = array();
foreach ($order_returns as $return) {
$id_to_update[] = (int)$return['id_order_return'];
Db::getInstance()->execute('INSERT INTO '._DB_PREFIX_.'order_return_history VALUES (DEFAULT,1,'.(int)$return['id_order_return'].',6,NOW())');
}
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'order_return SET state = 6 WHERE id_order_return IN ('.implode(',', $id_to_update).')');
exit;