get_count_tpl()){ $mailtpl_script="
".$mailtpl->get_sel('mailtpl_id',0)."
".(SESSrights & ADMINISTRATION_AUTH ? "".$msg['admin_mailtpl_title']."" : "")."
"; } else $mailtpl_script=""; $mailtpl_vars="
".mailtpl::get_selvars()."
"; $get_sel_img=""; $sel_img=mailtpl::get_sel_img(); if($sel_img)$get_sel_img="
".mailtpl::get_sel_img()."
"; $urlbase="./circ/caddie/"; if (!$idemprcaddie) die(); if($pmb_javascript_office_editor){ print $pmb_javascript_office_editor; print ""; } if ((!isset($f_message) || !$f_message) && !$pmb_javascript_office_editor) { $f_message=" "; } else $f_message=html_entity_decode(stripslashes($f_message), ENT_QUOTES, $charset); $f_objet_mail = (isset($f_objet_mail) ? stripslashes($f_objet_mail) : ''); print "
" ; switch ($sub) { case "redige" : echo "

$msg[empr_mailing_titre_form]

$mailtpl_script
$mailtpl_vars $get_sel_img ".mailtpl::get_attachments_form()."
"; if (!$pmb_javascript_office_editor) echo ""; echo "
"; if (!$pmb_javascript_office_editor) echo "
".htmlentities(stripslashes($f_objet_mail),ENT_QUOTES,$charset)."
"; break; case "envoi" : $pieces_jointes=array(); $files=array(); $error=false; if(is_array($_FILES['pieces_jointes_mailing']['tmp_name']) && count($_FILES['pieces_jointes_mailing']['tmp_name'])){ foreach ( $_FILES['pieces_jointes_mailing']['tmp_name'] as $key => $tmp_file ) { if(trim($_FILES['pieces_jointes_mailing']['name'][$key]) && $_FILES['pieces_jointes_mailing']['size'][$key]){ $to_file = $base_path.'/temp/'.basename($tmp_file); $from_file = $_FILES['pieces_jointes_mailing']['name'][$key]; if (!@move_uploaded_file($tmp_file,$to_file)) { /* Fail to copy %s, Contact your admin... */ $error=1; }else{ $pieces_jointes[]=array("nomfichier"=>$from_file,"contenu"=>file_get_contents($to_file)); $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); $mailing->associated_campaign = (isset($associated_campaign) ? $associated_campaign : 0); $mailing->associated_num_campaign = (isset($associated_num_campaign) ? $associated_num_campaign : 0); 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 = pmb_mysql_query($sql) or die ("Couldn't select compte reste mailing !"); $n_envoi_restant=pmb_mysql_num_rows($sql_result); }else{//Todo: gérer proprement les ereurs $n_envoi_restant=0; } if ($n_envoi_restant > 0) { $parametres=array(); $parametres['total']=$mailing->total; $parametres['sub']="envoi"; $parametres['total_envoyes']=$mailing->total_envoyes; $parametres['f_objet_mail']=htmlentities($f_objet_mail,ENT_QUOTES,$charset); $parametres['f_message']=htmlentities($f_message,ENT_QUOTES,$charset); $parametres['idemprcaddie']=$idemprcaddie; $parametres['files_post']=urlencode(serialize($files)); $parametres['count_files']=count($files); $parametres['associated_campaign']=$mailing->associated_campaign; $parametres['associated_num_campaign']=$mailing->associated_num_campaign; $msg['empr_mailing_recap_comptes_encours'] = str_replace("!!total_envoyes!!", $mailing->total_envoyes, $msg['empr_mailing_recap_comptes_encours']) ; $msg['empr_mailing_recap_comptes_encours'] = str_replace("!!total!!", $mailing->total, $msg['empr_mailing_recap_comptes_encours']) ; $msg['empr_mailing_recap_comptes_encours'] = str_replace("!!n_envoi_restant!!", $n_envoi_restant, $msg['empr_mailing_recap_comptes_encours']) ; $message_info="
". $msg['empr_mailing_recap_comptes_encours']."
"; print construit_formulaire_recharge (1000, "./mailing.php", "envoi_mailing", $parametres, $f_objet_mail, $message_info) ; } else { //On enlève les fichiers temps des pièces jointes if(count($files)){ foreach ( $files as $key => $val ) { @unlink($val["location"]); } } print "

".$msg['empr_mailing_titre_resultat']."

".$msg['empr_mailing_form_obj_mail']." ".htmlentities($f_objet_mail,ENT_QUOTES,$charset)."
".$msg['empr_mailing_resultat_envoi']." "; $msg['empr_mailing_recap_comptes'] = str_replace("!!total_envoyes!!", $mailing->total_envoyes, $msg['empr_mailing_recap_comptes']) ; $msg['empr_mailing_recap_comptes'] = str_replace("!!total!!", $mailing->total, $msg['empr_mailing_recap_comptes']) ; print $msg['empr_mailing_recap_comptes'] ; print "

".$msg['empr_mailing_raz_pointage']."
"; $sql = "select id_empr, empr_mail, empr_nom, empr_prenom from empr, empr_caddie_content where flag='2' and empr_caddie_id=$idemprcaddie and object_id=id_empr "; $sql_result = pmb_mysql_query($sql) ; if (pmb_mysql_num_rows($sql_result)) { print "
$msg[empr_mailing_liste_erreurs]
"; while ($obj_erreur=pmb_mysql_fetch_object($sql_result)) { print "
".$obj_erreur->empr_nom." ".$obj_erreur->empr_prenom." (".$obj_erreur->empr_mail.")
"; } } //Reset du pointage les mails non envoyés $mailing->reset_flag_not_sended(); } break; default: // include("$include_path/messages/help/$lang/mailing_empr.txt") ; break; } print "
"; // Fonction qui construit un formulaire qui relance function construit_formulaire_recharge ($time_out, $action, $name, $hidden_param, $texte_titre="",$texte_message="") { global $current_module, $msg; if (!is_array($hidden_param)) return ""; $formulaire="\n
"; $formulaire.="\n

$texte_titre

"; foreach ($hidden_param as $cle => $params) { $formulaire.="\n"; } // fin de liste $formulaire.=$texte_message; $formulaire.="\n
"; if ($time_out<0) $formulaire.="\n
"; $formulaire.="\n
"; switch ($time_out) { case 0: $formulaire.="\n"; break; case -1: break; default: $formulaire.="\n"; break; } return $formulaire; }