privilegedemarque/modules/antadismarketing/reallocation.php
Serveur preprod f0c0c48223 first push
2016-04-14 16:14:31 +02:00

34 lines
1.1 KiB
PHP

<?php
/**
* Permet de réaffecter des clients au tracking lorsqu'ils viennent d'une landing hebergée à l'ext
*/
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/antadismarketing.php');
$tracking_name = Configuration::get('CONF_TRACKING_ADLEAD');
$tracking = AntTracking::getTrackingInfo($tracking_name);
if(Validate::isLoadedObject($tracking)) {
$customers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT c.`id_customer`
FROM '. _DB_PREFIX_ .'customer c
LEFT JOIN '. _DB_PREFIX_ .'referralprogram rp ON (rp.`id_customer` = c.`id_customer` AND rp.`id_sponsor` = ' . (int)Configuration::get('CONF_TRACKING_ADLEAD_SPONSOR') . ')
WHERE c.`date_add` >= DATE_SUB(NOW(), INTERVAL 3 DAY)
AND rp.`id_customer` IS NOT NULL
AND rp.`id_customer` NOT IN (
SELECT amtu.`id_customer`
FROM '. _DB_PREFIX_ .'ant_marketing_tracking_users amtu
WHERE 1
-- WHERE amtu.`id_tracking` = '.(int)$tracking->id_tracking.'
)
');
//echo "<pre>";var_dump($customers);echo "</pre>";
foreach ($customers as $customer) {
$tracking->addSubscribe((int)$customer['id_customer']);
}
}
exit;