garancia/cron/cron_group_client.php
2016-10-10 15:24:25 +02:00

24 lines
804 B
PHP
Executable File

<?php
require('../config/config.inc.php');
if(Tools::getIsset('token')){
$token = Configuration::get('cron_group_client');
if(Tools::getValue('token') == $token){
$sql = 'SELECT id_customer, id_gender
FROM ps_customer c
WHERE id_customer NOT IN (SELECT id_customer FROM ps_customer_group WHERE id_group IN(5,6))';
$customers = Db::getInstance()->executeS($sql);
foreach($customers as $customer){
if($customer['id_gender'] == 1){
$insert = 'INSERT INTO ps_customer_group VALUES('. $customer['id_customer'].', 5)';
}else if($customer['id_gender'] == 2 || $customer['id_gender'] == 3 || $customer['id_gender'] == 0){
$insert = 'INSERT INTO ps_customer_group VALUES('. $customer['id_customer'].', 6)';
}
Db::getInstance()->execute($insert);
}
}else{
die();
}
}