function sendMailingCaddie($id_caddie_empr, $id_tpl)
 {
     $id_caddie_empr += 0;
     if (!$id_caddie_empr) {
         throw new Exception("Missing parameter: id_caddie_empr");
     }
     $id_tpl += 0;
     if (!$id_tpl) {
         throw new Exception("Missing parameter: id_tpl");
     }
     $result = array();
     if (SESSrights & CIRCULATION_AUTH) {
         if ($id_caddie_empr && $id_tpl) {
             $mailtpl = new mailtpl($id_tpl);
             $objet_mail = $mailtpl->info['objet'];
             $message = $mailtpl->info['tpl'];
             $mailing = new mailing_empr($id_caddie_empr);
             $mailing->send($objet_mail, $message);
             $result["name"] = $mailtpl->info['name'];
             $result["object_mail"] = $objet_mail;
             $result["nb_mail"] = $mailing->total;
             $result["nb_mail_sended"] = $mailing->total_envoyes;
             $result["nb_mail_failed"] = $mailing->envoi_KO;
         }
     }
     return $result;
 }
Esempio n. 2
0
                 $files[] = array("name" => $from_file, "location" => $to_file);
             }
         } elseif (trim($_FILES['pieces_jointes_mailing']['name'][$key])) {
             $error = 2;
         }
     }
 } elseif ($count_files) {
     $files = unserialize(urldecode($files_post));
     foreach ($files as $key => $val) {
         if ($tmp = @file_get_contents($val["location"])) {
             $pieces_jointes[] = array("nomfichier" => $val["name"], "contenu" => $tmp);
         }
     }
 }
 if (!$error) {
     $mailing = new mailing_empr($idemprcaddie);
     if ($total_envoyes) {
         $mailing->total_envoyes = $total_envoyes;
     }
     if ($total) {
         $mailing->total = $total;
     }
     $mailing->send($f_objet_mail, $f_message, 20, $pieces_jointes);
     $sql = "select id_empr, empr_mail, empr_nom, empr_prenom from empr, empr_caddie_content where (flag='' or flag is null) and empr_caddie_id={$idemprcaddie} and object_id=id_empr";
     $sql_result = mysql_query($sql) or die("Couldn't select compte reste mailing !");
     $n_envoi_restant = mysql_num_rows($sql_result);
 } else {
     //Todo: gérer proprement les ereurs
     $n_envoi_restant = 0;
 }
 if ($n_envoi_restant > 0) {