]> _ Git - cubeextranet.git/commitdiff
done #770 @1
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 12 Oct 2016 14:52:04 +0000 (14:52 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Wed, 12 Oct 2016 14:52:04 +0000 (14:52 +0000)
inc/ws/Controlleur/class.ws.maintenance.php

index 99d28d3cceb48686b0aaa9032ef3d836ffd8a619..e61bd128879e3014bd37a656528d4ad5bc7e62fd 100644 (file)
@@ -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 '<pre>' . print_r($batch, true) . '</pre>';
+       }
+
+
+       public static function syncCubedesignersMailchimp() {
                global $core;
 
                set_time_limit(0);