43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
ini_set('memory_limit', '4096M');
|
|
ini_set('max_execution_time', 0);
|
|
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
|
include('www/config/config.inc.php');
|
|
|
|
$categories = array();
|
|
foreach(Db::getInstance()->ExecuteS('
|
|
SELECT `id_category`
|
|
FROM `'._DB_PREFIX_.'category`
|
|
WHERE `active` = 1
|
|
') as $c) {
|
|
$categories[] = $c['id_category'];
|
|
}
|
|
|
|
foreach(Db::getInstance()->ExecuteS('
|
|
SELECT `id_discount`
|
|
FROM `'._DB_PREFIX_.'discount`
|
|
WHERE `date_from` <= NOW()
|
|
AND `date_to` > NOW()
|
|
AND `quantity` > 0
|
|
AND `active` = 1
|
|
') as $voucher) {
|
|
$voucher_categories = array();
|
|
foreach(Db::getInstance()->ExecuteS('
|
|
SELECT `id_category`
|
|
FROM `'._DB_PREFIX_.'discount_category`
|
|
WHERE `id_discount` = '.(int) $voucher['id_discount'].'
|
|
') as $vc) {
|
|
$voucher_categories[] = $vc['id_category'];
|
|
}
|
|
|
|
$diff = array_diff($categories, $voucher_categories);
|
|
$query = array();
|
|
foreach($diff as $d) {
|
|
$query[] = '('.$d.', '.(int) $voucher['id_discount'].')';
|
|
}
|
|
Db::getInstance()->Execute('
|
|
INSERT INTO `'._DB_PREFIX_.'discount_category`
|
|
VALUES '.implode(', ', $query).'
|
|
');
|
|
}
|