_init_parameter_value('list_order', 'empr_nom, empr_prenom'); parent::_init_default_parameters(); } protected function get_mail_object() { return $this->get_parameter_value('objet'); } protected function get_query_list_order_all() { return " ORDER BY ".$this->get_parameter_value('list_order'); } protected function get_query_list_all() { global $pmb_lecteurs_localises, $empr_location_id, $deflt2docs_location; global $empr_statut_edit, $empr_categ_filter, $empr_codestat_filter; global $restricts; // restriction localisation le cas échéant if ($pmb_lecteurs_localises) { if ($empr_location_id=="") $empr_location_id = $deflt2docs_location ; if ($empr_location_id!=0) $restrict_localisation = " AND empr_location='$empr_location_id' "; else $restrict_localisation = ""; } // filtré par un statut sélectionné $restrict_statut=""; if ($empr_statut_edit) { if ($empr_statut_edit!=0) $restrict_statut = " AND empr_statut='$empr_statut_edit' "; } $restrict_categ = ''; if($empr_categ_filter) { $restrict_categ = " AND empr_categ= '".$empr_categ_filter."' "; } $restrict_codestat = ''; if($empr_codestat_filter) { $restrict_codestat = " AND empr_codestat= '".$empr_codestat_filter."' "; } $requete = "SELECT empr.id_empr FROM empr, empr_statut "; $restrict_empr = " WHERE 1 "; $restrict_requete = $restrict_empr.$restrict_localisation.$restrict_statut.$restrict_categ.$restrict_codestat." and ".$restricts; $requete .= $restrict_requete; $requete.=" and empr_mail!=''"; $requete .= " and empr_statut=idstatut "; $requete .= $this->get_query_list_order_all(); return $requete; } protected function get_mail_content($id_empr=0, $id_groupe=0) { $mail_content = ''; if($this->get_parameter_value('madame_monsieur')) { $mail_content .= $this->get_parameter_value('madame_monsieur')."\r\n\r\n"; } $mail_content .= $this->get_parameter_value('texte')."\r\n"; if($this->get_parameter_value('fdp')) { $mail_content .= $this->get_parameter_value('fdp')."\r\n\r\n"; } $mail_content .= $this->get_mail_bloc_adresse(); return $mail_content; } public function send_mail($id_empr=0, $id_groupe=0) { global $msg, $charset; global $action; global $biblio_name, $biblio_email, $PMBuseremailbcc; $headers = "Content-type: text/plain; charset=".$charset."\n"; if ($action=="print_all") { $requete = $this->get_query_list_all(); $res = @pmb_mysql_query($requete); while(($empr=pmb_mysql_fetch_object($res))) { $coords = $this->get_empr_coords($empr->id_empr); $mail_content = $this->get_mail_content($empr->id_empr); $mail_content = str_replace("!!date_fin_adhesion!!", $coords->aff_date_expiration, $mail_content); //remplacement nom et prenom $mail_content=str_replace("!!empr_name!!", $coords->empr_nom,$mail_content); $mail_content=str_replace("!!empr_first_name!!", $coords->empr_prenom,$mail_content); if($coords->empr_mail) { $res_envoi=mailpmb($coords->empr_prenom." ".$coords->empr_nom, $coords->empr_mail, $this->get_mail_object(),$mail_content, $biblio_name, $biblio_email,$headers, "", $PMBuseremailbcc,1); if ($res_envoi) echo "

".sprintf($msg["mail_retard_succeed"],$coords->empr_mail)."


".$msg["mail_retard_close"]."

".nl2br($mail_content); else echo "

".sprintf($msg["mail_retard_failed"],$coords->empr_mail)."


".$msg["mail_retard_close"].""; } else { echo "

".sprintf($msg["mail_retard_unknown_mail"],$coords->empr_prenom." ".$coords->empr_nom)."


".$msg["mail_retard_close"].""; } } } else { $coords = $this->get_empr_coords($id_empr); $mail_content = $this->get_mail_content($id_empr, $id_groupe); $mail_content = str_replace("!!date_fin_adhesion!!", $coords->aff_date_expiration, $mail_content); //remplacement nom et prenom $mail_content=str_replace("!!empr_name!!", $coords->empr_nom,$mail_content); $mail_content=str_replace("!!empr_first_name!!", $coords->empr_prenom,$mail_content); if($coords->empr_mail) { $res_envoi=mailpmb($coords->empr_prenom." ".$coords->empr_nom, $coords->empr_mail, $this->get_mail_object(),$mail_content, $biblio_name, $biblio_email,$headers, "", $PMBuseremailbcc,1); if ($res_envoi) echo "

".sprintf($msg["mail_retard_succeed"],$coords->empr_mail)."


".$msg["mail_retard_close"]."

".nl2br($mail_content); else echo "

".sprintf($msg["mail_retard_failed"],$coords->empr_mail)."


".$msg["mail_retard_close"].""; } else { echo "

".sprintf($msg["mail_retard_unknown_mail"],$coords->empr_prenom." ".$coords->empr_nom)."


".$msg["mail_retard_close"].""; } } } }