From 4b541c0e97f8dcf9d4f72167cf982a7594f8301c Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 12 Oct 2016 14:52:04 +0000 Subject: [PATCH] done #770 @1 --- inc/ws/Controlleur/class.ws.maintenance.php | 38 ++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index 99d28d3cc..e61bd1288 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -1025,7 +1025,43 @@ class wsMaintenance { } } - public static function syncMailchimp() { + public static function syncKadreoMailchimp() { + global $core; + + set_time_limit(0); + + + $u = array(); + + $r = $core->con->select('SELECT * FROM utilisateurs'); + while ($r->fetch()) { + $u[$r->utilisateur_id] = $r->row(); + } + + $r = $core->con->select("SELECT * FROM entreprises_ws WHERE revendeur='Kadreo' AND ws_grade<=4 AND ws_grade>0"); + while ($r->fetch()) { + $e[$r->entreprise_id] = array('COUNTRY' => $r->pays, 'CONTACT' => date('d/m/Y', $r->date_creation), 'COMPANY' => $r->nom); + } + + $batch = array(); + foreach ($u as $user) { + if (!isset($e[$user['entreprise']])) { + continue; + } + if (stristr($user['email'], 'extranet.cubedesigners.com')) { + continue; + } + + $batch[] = array_merge($e[$user['entreprise']], array('email' => $user['email'], 'LOCALE' => $user['lang'], 'FNAME' => $user['prenom'], 'LNAME' => $user['nom'])); + } + + $api = new CubeIT_Services_Mailchimp('2b255293f3595181dd7d079d29dc6b99-us14'); + $res = $api->batchSubscribe('8ff710b78e', $batch); + echo '
' . print_r($batch, true) . '
'; + } + + + public static function syncCubedesignersMailchimp() { global $core; set_time_limit(0); -- 2.39.5