get_evaluated_parameter($parameter_name); if(!empty($parameter_value)) { return $parameter_value; } } $parameter_name = static::get_parameter_prefix().'_1'.$name; $parameter_value = $this->get_evaluated_parameter($parameter_name); if($parameter_value) { return $parameter_value; } else { return parent::get_parameter_value($name); } } protected function _init_parameter_value($name, $value) { if(isset(static::$niveau_relance)) { $parameter_name = static::get_parameter_prefix().'_'.static::$niveau_relance.$name; global $$parameter_name; if(empty(${$parameter_name}) && ${$parameter_name} != "0") { ${$parameter_name} = $value; } } else { parent::_init_parameter_value($name, $value); } } protected function _init_default_parameters() { $this->_init_parameter_value('list_order', 'pret_date'); parent::_init_default_parameters(); } protected function get_mail_object() { return $this->get_parameter_value('objet'); } protected function get_query_list_order() { if (!empty($this->get_parameter_value('list_order'))) { return "order by ".$this->get_parameter_value('list_order'); } return ''; } protected function get_query_list($id_empr) { return $this->get_query_list_base()." where pret_idempr='".$id_empr."' and pret_retour < curdate() ".$this->get_query_list_order(); } protected function get_expl_list($id_empr) { global $niveau; $expl_list = array(); if($niveau!=3) { $rqt = $this->get_query_list($id_empr); $req = pmb_mysql_query($rqt); while ($data = pmb_mysql_fetch_array($req)) { $expl_list[] = $data; } } else { $expl_list['r3'] = array(); $requete="select expl_cb from exemplaires, pret where pret_idempr=$id_empr and pret_idexpl=expl_id and niveau_relance=3"; $res_recouvre=pmb_mysql_query($requete); while ($rrc=pmb_mysql_fetch_object($res_recouvre)) { $expl_list['r3'][]=$rrc->expl_cb; } $rqt = $this->get_query_list($id_empr); $req = pmb_mysql_query($rqt); $expl_list['r'] = array(); while ($data = pmb_mysql_fetch_object($req)) { // Pas répéter les retard si déjà en niveau 3 if(isset($expl_list['r3'])){ if(in_array($data->expl_cb,$expl_list['r3'])===false){ $expl_list['r'][] = $data->expl_cb; } } } } return $expl_list; } protected function get_mail_content($id_empr=0, $id_groupe=0) { global $niveau; $mail_content = ''; if($this->get_parameter_value('madame_monsieur')) { $mail_content .= $this->get_parameter_value('madame_monsieur')."\r\n\r\n"; } if($this->get_parameter_value('before_list')) { $mail_content .= $this->get_parameter_value('before_list')."\r\n\r\n"; } //Récupération des exemplaires $expl_list = $this->get_expl_list($id_empr); if($niveau!=3) { foreach ($expl_list as $data) { $mail_content .= $this->get_mail_expl_content($data['expl_cb']); } } else { $liste_r = $expl_list['r']; $liste_r3 = $expl_list['r3']; if(is_array($liste_r) && count($liste_r)) { // Il y a des retard simple: on affiche d'abord les retards simples foreach($liste_r as $cb_expl) { $mail_content .= $this->get_mail_expl_content($cb_expl); } if($this->get_parameter_value('before_recouvrement')) { $mail_content .= $this->get_parameter_value('before_recouvrement')."\r\n\r\n"; } // affiche retards niveau 3 if(isset($liste_r3)){ foreach($liste_r3 as $cb_expl) { $mail_content .= $this->get_mail_expl_content($cb_expl); } } } else { // il n'y a que des retards niveau 3 if(isset($liste_r3)){ foreach($liste_r3 as $cb_expl) { $mail_content .= $this->get_mail_expl_content($cb_expl); } } if($this->get_parameter_value('after_recouvrement')) { $mail_content .= $this->get_parameter_value('after_recouvrement')."\r\n\r\n"; } } } $mail_content .= "\r\n"; if($this->get_parameter_value('after_list')) { $mail_content .= $this->get_parameter_value('after_list')."\r\n\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; } protected function get_resp_coords($id_empr) { //Si mail de rappel affecté au responsable du groupe $requete="select id_groupe,resp_groupe from groupe,empr_groupe where id_groupe=groupe_id and empr_id=$id_empr and resp_groupe and mail_rappel limit 1"; $res=pmb_mysql_query($requete); /* Récupération du nom, prénom et mail du lecteur destinataire */ if(pmb_mysql_num_rows($res) > 0) { $requete="select id_empr, empr_mail, empr_nom, empr_prenom from empr where id_empr='".pmb_mysql_result($res, 0,1)."'"; $result=pmb_mysql_query($requete); $coords_dest=pmb_mysql_fetch_object($result); } else { $requete="select id_empr, empr_mail, empr_nom, empr_prenom from empr where id_empr=$id_empr"; $result=pmb_mysql_query($requete); $coords_dest=pmb_mysql_fetch_object($result); } return $coords_dest; } public function send_mail($id_empr=0, $id_groupe=0) { global $msg, $charset; global $biblio_name, $biblio_email, $PMBuseremailbcc; $coords_dest = $this->get_resp_coords($id_empr); $coords = $this->get_empr_coords($id_empr, $id_groupe); $headers = "Content-type: text/plain; charset=".$charset."\n"; $mail_content = $this->get_mail_content($id_empr, $id_groupe); //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_dest->empr_mail) { $res_envoi=mailpmb($coords_dest->empr_prenom." ".$coords_dest->empr_nom, $coords_dest->empr_mail, $this->get_mail_object()." : ".$coords->empr_prenom." ".mb_strtoupper($coords->empr_nom,$charset)." (".$coords->empr_cb.")",$mail_content, $biblio_name, $biblio_email,$headers, "", $PMBuseremailbcc,1); if ($res_envoi) echo "