id_bannette = $id+0;
$this->getData();
}
// ---------------------------------------------------------------
// getData() : récupération infos
// ---------------------------------------------------------------
public function getData() {
global $msg;
global $deflt_associated_campaign;
$this->p_perso=new parametres_perso("notices");
if (!$this->id_bannette) {
// pas d'identifiant. on retourne un tableau vide
$this->date_last_envoi=today();
$this->aff_date_last_envoi=formatdate($this->date_last_envoi);
$this->date_last_envoi_sql=today();
$this->associated_campaign = intval($deflt_associated_campaign);
} else {
$requete = "SELECT id_bannette, num_classement, nom_bannette,comment_gestion,comment_public,statut_not_account, associated_campaign, bannette_num_sender, ";
$requete .= "date_last_remplissage, date_format(date_last_remplissage, '".$msg["format_date_heure"]."') as aff_date_last_remplissage, ";
$requete .= "date_last_envoi,date_last_envoi as date_last_envoi_sql, date_format(date_last_envoi, '".$msg["format_date_heure"]."') as aff_date_last_envoi, ";
$requete .= "proprio_bannette,bannette_auto,periodicite,diffusion_email, nb_notices_diff, update_type, entete_mail, bannette_tpl_num, piedpage_mail, notice_display_type, notice_tpl, django_directory, num_panier, ";
$requete .= "limite_type, limite_nombre, typeexport, prefixe_fichier, param_export, group_type, group_pperso, display_notice_in_every_group, archive_number, ";
$requete .= "document_generate, document_notice_display_type, document_notice_tpl, document_django_directory, document_insert_docnum, document_group, document_add_summary, bannette_opac_accueil, bannette_aff_notice_number ";
$requete .= "FROM bannettes WHERE id_bannette='".$this->id_bannette."' " ;
$result = pmb_mysql_query($requete) or die ($requete." in bannette.class.php : ".pmb_mysql_error());
if(pmb_mysql_num_rows($result)) {
$temp = pmb_mysql_fetch_object($result);
$this->id_bannette = $temp->id_bannette ;
$this->num_classement = $temp->num_classement ;
$this->nom_bannette = $temp->nom_bannette ;
$this->comment_gestion = $temp->comment_gestion ;
$this->comment_public = $temp->comment_public ;
$this->bannette_tpl_num = $temp->bannette_tpl_num ;
$this->entete_mail = $temp->entete_mail ;
$this->piedpage_mail = $temp->piedpage_mail ;
$this->notice_display_type = $temp->notice_display_type ;
$this->notice_tpl = $temp->notice_tpl ;
$this->django_directory = $temp->django_directory;
$this->date_last_remplissage= $temp->date_last_remplissage ;
$this->date_last_envoi = $temp->date_last_envoi ;
$this->aff_date_last_remplissage = $temp->aff_date_last_remplissage ;
$this->aff_date_last_envoi = $temp->aff_date_last_envoi ;
$this->date_last_envoi_sql = $temp->date_last_envoi_sql;
$this->proprio_bannette = $temp->proprio_bannette ;
$this->bannette_auto = $temp->bannette_auto ;
$this->periodicite = $temp->periodicite ;
$this->diffusion_email = $temp->diffusion_email ;
$this->nb_notices_diff = $temp->nb_notices_diff;
$this->update_type = $temp->update_type ;
$this->num_panier = $temp->num_panier ;
$this->limite_type = $temp->limite_type ;
$this->limite_nombre = $temp->limite_nombre ;
$this->typeexport = $temp->typeexport ;
$this->prefixe_fichier = $temp->prefixe_fichier ;
$this->group_pperso = $temp->group_pperso ;
$this->group_type = $temp->group_type;
$this->display_notice_in_every_group=$temp->display_notice_in_every_group;
$this->statut_not_account = $temp->statut_not_account ;
$this->associated_campaign = $temp->associated_campaign ;
$this->num_sender = $temp->bannette_num_sender ;
$this->archive_number = $temp->archive_number ;
$this->document_generate = $temp->document_generate ;
$this->document_notice_display_type = $temp->document_notice_display_type;
$this->document_notice_tpl = $temp->document_notice_tpl;
$this->document_django_directory = $temp->document_django_directory;
$this->document_insert_docnum= $temp->document_insert_docnum ;
$this->document_group = $temp->document_group ;
$this->document_add_summary = $temp->document_add_summary ;
$this->bannette_opac_accueil= $temp->bannette_opac_accueil ;
$this->bannette_aff_notice_number= $temp->bannette_aff_notice_number;
$this->param_export = unserialize($temp->param_export) ;
$this->compte_elements();
$requete = "SELECt nom_classement FROM classements WHERE id_classement='".$this->num_classement."'" ;
$resultclass = pmb_mysql_query($requete) or die ($requete." in bannette.class.php : ".pmb_mysql_error());
if ($temp = pmb_mysql_fetch_object($resultclass)) $this->nom_classement = $temp->nom_classement ;
else $this->nom_classement = "" ;
$rqt = "select * from bannette_empr_groupes where empr_groupe_num_bannette = '".$this->id_bannette."'";
$res = pmb_mysql_query($rqt);
if(pmb_mysql_num_rows($res)){
while($row = pmb_mysql_fetch_object($res)){
$this->groupe_lecteurs[] = $row->empr_groupe_num_groupe;
}
}
$rqt = "select * from bannette_empr_categs where empr_categ_num_bannette = '".$this->id_bannette."'";
$res = pmb_mysql_query($rqt);
if(pmb_mysql_num_rows($res)){
while($row = pmb_mysql_fetch_object($res)){
$this->categorie_lecteurs[] = $row->empr_categ_num_categ;
}
}
}
}
$this->bannette_descriptors = new bannette_descriptors($this->id_bannette);
$this->bannette_equations = new bannette_equations($this->id_bannette);
}
public function gen_facette_selection(){
$facette = new bannette_facettes($this->id_bannette);
return $facette->gen_facette_selection();
}
protected function get_senders_selector() {
global $msg, $charset;
$selector = "";
return $selector;
}
protected function get_classement_content_form($type="pro") {
global $dsi_bannette_classement_content_form;
if ($type=="pro") {
$content_form = $dsi_bannette_classement_content_form;
$content_form = str_replace('!!num_classement!!', show_classement_utilise ('BAN', $this->num_classement, 0), $content_form);
} else {
$content_form = "";
}
return $content_form;
}
protected function get_common_content_form($type="pro") {
global $charset;
global $dsi_bannette_common_content_form, $dsi_bannette_form_selvars;
$content_form = $dsi_bannette_common_content_form;
$content_form = str_replace('!!nom_bannette!!', htmlentities($this->nom_bannette,ENT_QUOTES, $charset), $content_form);
$content_form = str_replace('!!classement!!', $this->get_classement_content_form($type), $content_form);
$content_form = str_replace('!!comment_gestion!!', htmlentities($this->comment_gestion,ENT_QUOTES, $charset), $content_form);
$content_form = str_replace('!!comment_public!!', htmlentities($this->comment_public,ENT_QUOTES, $charset), $content_form);
//ajout champs emprunteur
if ($type=="pro") {
$comment_public_info_empr = str_replace('!!selector_name!!', 'comment_public_selvars_id', $dsi_bannette_form_selvars);
$comment_public_info_empr = str_replace('!!dest_dom_node!!', 'comment_public', $comment_public_info_empr);
$content_form = str_replace('!!comment_public_info_empr!!', $comment_public_info_empr, $content_form);
} else {
$content_form = str_replace('!!comment_public_info_empr!!', '', $content_form);
}
$bannette_tpl_list=bannette_tpl::gen_tpl_select("bannette_tpl_num",$this->bannette_tpl_num);
$content_form = str_replace('!!bannette_tpl_list!!', $bannette_tpl_list, $content_form);
$content_form = str_replace('!!entete_mail!!', htmlentities($this->entete_mail,ENT_QUOTES, $charset), $content_form);
$content_form = str_replace('!!piedpage_mail!!', htmlentities($this->piedpage_mail,ENT_QUOTES, $charset), $content_form);
$info_empr = str_replace('!!selector_name!!', 'selvars_id', $dsi_bannette_form_selvars);
$info_empr = str_replace('!!dest_dom_node!!', 'entete_mail', $info_empr);
$content_form = str_replace('!!info_empr!!', $info_empr, $content_form);
return $content_form;
}
protected function get_entity_content_form($type="pro") {
global $msg;
global $dsi_bannette_entity_records_content_form;
global $dsi_bannette_entity_records_content_form_abo;
if ($type=="abo") {
$content_form = $dsi_bannette_entity_records_content_form_abo;
} else {
$content_form = $dsi_bannette_entity_records_content_form;
}
// $content_form = str_replace('!!notice_display_type_0!!', (!$this->notice_display_type ? "checked='checked'" : ""), $content_form);
$content_form = str_replace('!!notice_tpl!!', notice_tpl_gen::gen_tpl_select("notice_tpl",$this->notice_tpl), $content_form);
// $content_form = str_replace('!!notice_display_type_1!!', ($this->notice_display_type ? "checked='checked'" : ""), $content_form);
// $content_form = str_replace('!!django_directory!!', record_display::get_directories_options($this->django_directory), $content_form);
$liste_p_perso = $this->p_perso->gen_liste_field("group_pperso",$this->group_pperso,$msg["dsi_ban_form_regroupe_pperso_no"]);
$content_form = str_replace('!!pperso_group!!', $liste_p_perso, $content_form);
if ($type=="pro") {
if ($this->id_bannette_origine) { //On vient d'une duplication
$origine_bannette = new bannette($this->id_bannette_origine) ;
$content_form = str_replace('!!facette_group!!', $origine_bannette->gen_facette_selection(), $content_form);
} else {
$content_form = str_replace('!!facette_group!!', $this->gen_facette_selection(), $content_form);
}
$content_form = str_replace("!!display_notice_in_every_group!!", ($this->display_notice_in_every_group ? "checked='checked'" : ""), $content_form);
// group_type, group_pperso, group_facettes
if($this->group_type){
$content_form = str_replace('!!checked_group_facette!!', " checked='checked' ", $content_form);
$content_form = str_replace('!!checked_group_pperso!!', "", $content_form);
}else{
$content_form = str_replace('!!checked_group_facette!!', "", $content_form);
$content_form = str_replace('!!checked_group_pperso!!', " checked='checked' ", $content_form);
}
}
return $content_form;
}
protected function get_archive_content_form($type="pro") {
global $dsi_bannette_archive_content_form;
if ($type=="pro") {
$content_form = $dsi_bannette_archive_content_form;
$content_form = str_replace('!!archive_number!!', $this->archive_number, $content_form);
} else {
$content_form = "";
}
return $content_form;
}
protected function get_options_content_form($type="pro") {
global $msg, $charset;
global $nom_prenom_abo;
global $dsi_bannette_options_content_form;
$content_form = $dsi_bannette_options_content_form;
$content_form = str_replace('!!date_last_remplissage!!', htmlentities($this->aff_date_last_remplissage,ENT_QUOTES, $charset), $content_form);
$date_clic = "onClick=\"openPopUp('./select.php?what=calendrier&caller=saisie_bannette&date_caller=".substr(preg_replace('/-/', '', $this->date_last_envoi),0,8)."¶m1=form_date_last_envoi¶m2=form_aff_date_last_envoi&auto_submit=NO&date_anterieure=YES', 'calendar')\" ";
$date_last_envoi = "
date_last_envoi)))."' />
";
$content_form = str_replace('!!date_last_envoi!!', $date_last_envoi, $content_form);
$content_form = str_replace('!!archive!!', $this->get_archive_content_form($type), $content_form);
if ($type=="pro") {
$content_form = str_replace('!!proprio_bannette!!', htmlentities($msg['dsi_ban_no_proprio'],ENT_QUOTES, $charset), $content_form);
} else {
$content_form = str_replace('!!proprio_bannette!!', htmlentities($nom_prenom_abo,ENT_QUOTES, $charset), $content_form);
}
$content_form = str_replace('!!bannette_auto!!', ($this->bannette_auto ? "checked='checked'" : ""), $content_form);
$content_form = str_replace('!!periodicite!!', htmlentities($this->periodicite,ENT_QUOTES, $charset), $content_form);
$content_form = str_replace('!!diffusion_email!!', ($this->diffusion_email ? "checked='checked'" : ""), $content_form);
$content_form = str_replace('!!nb_notices_diff!!', htmlentities($this->nb_notices_diff,ENT_QUOTES, $charset), $content_form);
$content_form = str_replace('!!bannette_aff_notice_number!!', ($this->bannette_aff_notice_number ? " checked='checked' " : ""), $content_form);
// update_type: se baser sur la date de création ou la date de mise à jour des notices ?
$update_type = "";
$content_form = str_replace('!!update_type!!', $update_type, $content_form);
return $content_form;
}
protected function get_access_rights_content_form($type="pro") {
global $msg;
global $dsi_bannette_access_rights_content_form, $dsi_bannette_access_rights_content_form_abo;
if ($type=="pro") {
$content_form = $dsi_bannette_access_rights_content_form;
$requete = 'SELECT id_categ_empr, libelle, IF(empr_categ_num_categ IS NULL, 0,1) as inscription FROM empr_categ
left join bannette_empr_categs on (id_categ_empr=empr_categ_num_categ and empr_categ_num_bannette=' . $this->id_bannette . ' )
ORDER BY libelle';
$categ_lect_aff = gen_liste_multiple ($requete, "id_categ_empr", "libelle", "inscription", "categorie_lecteurs[]", '', 1, 0, $msg['dsi_ban_aucune_categ'], -1,$msg['dsi_all_empr_categ'], 5) ;
$content_form = str_replace('!!categorie_lecteurs!!', $categ_lect_aff, $content_form);
$requete = 'SELECT id_groupe, libelle_groupe, IF(empr_groupe_num_groupe IS NULL, 0,1) as inscription FROM groupe
left join bannette_empr_groupes on (id_groupe=empr_groupe_num_groupe and empr_groupe_num_bannette=' . $this->id_bannette . ' )
ORDER BY libelle_groupe';
$groupe_lect_aff = gen_liste_multiple ($requete, "id_groupe", "libelle_groupe", "inscription", "groupe_lecteurs[]", '', 1, 0, $msg['empr_form_aucungroupe'], 0,'', 5) ;
$content_form = str_replace('!!groupe_lecteurs!!', $groupe_lect_aff, $content_form);
$content_form = str_replace('!!bannette_opac_accueil_check!!', ($this->bannette_opac_accueil ? "checked='checked'" : ""), $content_form);
} else {
$content_form = $dsi_bannette_access_rights_content_form_abo;
$content_form = str_replace('!!categorie_lecteurs!!', "", $content_form);
$content_form = str_replace('!!groupe_lecteurs!!', "", $content_form);
}
return $content_form;
}
protected function get_export_content_form($type="pro") {
global $msg;
global $dsi_bannette_export_content_form;
$content_form = $dsi_bannette_export_content_form;
$exp = start_export::get_exports();
$liste_exports = "" ;
$content_form = str_replace('!!typeexport!!', $liste_exports, $content_form);
$content_form = str_replace('!!prefixe_fichier!!', $this->prefixe_fichier, $content_form);
if($this->param_export) {
$param=new export_param(EXP_DSI_CONTEXT, $this->param_export);
} else {
$param=new export_param(EXP_DEFAULT_GESTION);
}
$content_form = str_replace('!!display_liste_param!!', (!$this->typeexport ? 'display:none' : ''), $content_form);
$content_form = str_replace('!!form_param!!', $param->check_default_param(), $content_form);
return $content_form;
}
protected function get_document_content_form($type="pro") {
global $dsi_bannette_document_content_form;
$content_form = $dsi_bannette_document_content_form;
$content_form = str_replace('!!document_generate!!', ($this->document_generate ? "checked='checked'" : ""), $content_form);
// $content_form = str_replace('!!document_notice_display_type_0!!', (!$this->document_notice_display_type ? "checked='checked'" : ""), $content_form);
$content_form = str_replace('!!document_notice_tpl!!', notice_tpl_gen::gen_tpl_select("document_notice_tpl",$this->document_notice_tpl), $content_form);
// $content_form = str_replace('!!document_notice_display_type_1!!', ($this->document_notice_display_type ? "checked='checked'" : ""), $content_form);
// $content_form = str_replace('!!document_django_directory!!', record_display::get_directories_options($this->document_django_directory), $content_form);
$content_form = str_replace('!!document_insert_docnum!!', ($this->document_insert_docnum ? "checked='checked'" : ""), $content_form);
$content_form = str_replace('!!document_group!!', ($this->document_group ? "checked='checked'" : ""), $content_form);
$content_form = str_replace('!!document_add_summary!!', ($this->document_add_summary ? "checked='checked'" : ""), $content_form);
return $content_form;
}
// ---------------------------------------------------------------
// show_form : affichage du formulaire de saisie
// ---------------------------------------------------------------
public function show_form($type="pro") {
global $msg, $base_path, $current_module;
global $dsi_bannette_content_form;
global $dsi_bannette_content_form_abo;
global $dsi_bannette_notices_template;
global $form_cb, $id_classement, $id_empr;
global $page, $nbr_lignes, $nb_per_page;
if ($type=="abo") {
$content_form = $dsi_bannette_content_form_abo ;
} else {
$content_form = $dsi_bannette_content_form;
}
$content_form = str_replace('!!id_bannette!!', $this->id_bannette, $content_form);
$interface_form = new interface_dsi_form('saisie_bannette');
if(!$this->id_bannette){
$interface_form->set_label($msg['dsi_ban_form_creat']);
}else{
$interface_form->set_label($msg['dsi_ban_form_modif']);
}
if($this->id_bannette) {
$link_pagination = "";
if($page > 1) {
$link_pagination .= "&page=".$page."&nbr_lignes=".$nbr_lignes."&nb_per_page=".$nb_per_page;
}
$interface_form->set_url_base($base_path.'/'.$current_module.'.php?categ=bannettes&sub='.$type.'&id_classement='.$id_classement.'&form_cb='.$form_cb.$link_pagination);
$link_annul = "";
} else {
$interface_form->set_url_base($base_path.'/'.$current_module.'.php?categ=bannettes&sub='.$type);
$link_annul = "";
if ($this->id_bannette_origine) { //On vient d'une duplication
$origine_bannette = new bannette($this->id_bannette_origine) ;
$this->notice_tpl=$origine_bannette->notice_tpl;
} else {
$this->notice_tpl=$dsi_bannette_notices_template;
}
}
$content_form = str_replace('!!type!!', $type, $content_form);
$content_form = str_replace('!!id_empr!!', $id_empr, $content_form);
$content_form = str_replace('!!bannette_common_content_form!!', $this->get_common_content_form($type), $content_form);
$content_form = str_replace('!!bannette_entity_content_form!!', $this->get_entity_content_form($type), $content_form);
$content_form = str_replace('!!bannette_options_content_form!!', $this->get_options_content_form($type), $content_form);
$content_form = str_replace('!!bannette_access_rights_content_form!!', $this->get_access_rights_content_form($type), $content_form);
$content_form = str_replace('!!bannette_export_content_form!!', $this->get_export_content_form($type), $content_form);
if($type=="pro") {
$content_form = str_replace('!!bannette_document_content_form!!', $this->get_document_content_form($type), $content_form);
}
if ($this->statut_not_account) $content_form = str_replace('!!statut_not_account!!', "checked", $content_form);
else $content_form = str_replace('!!statut_not_account!!', "", $content_form);
if ($this->associated_campaign) $content_form = str_replace('!!associated_campaign!!', "checked", $content_form);
else $content_form = str_replace('!!associated_campaign!!', "", $content_form);
// choix de l'expéditeur
$content_form = str_replace('!!senders!!', $this->get_senders_selector(), $content_form);
$content_form = str_replace('!!desc_fields!!', $this->bannette_descriptors->get_form(), $content_form);
$content_form = str_replace('!!num_panier!!', caddie::get_cart_list_selector('NOTI', 'num_panier', $this->num_panier), $content_form);
$limite_type = "";
$content_form = str_replace('!!limite_type!!', $limite_type, $content_form);
$content_form = str_replace('!!limite_nombre!!', $this->limite_nombre, $content_form);
$interface_form->set_object_id($this->id_bannette)
->set_bannette_type($type)
->set_id_empr($id_empr)
->set_confirm_delete_msg($msg['confirm_suppr'])
->set_content_form($content_form)
->set_table_name('bannettes')
->set_field_focus('nom_bannette');
if($type=="pro") {
$interface_form->set_duplicable(true);
}
print $interface_form->get_display();
}
public function set_properties_from_form() {
global $num_classement, $nom_bannette, $comment_gestion, $comment_public;
global $entete_mail, $piedpage_mail, $notice_display_type, $notice_tpl, $django_directory;
global $id_empr;
global $bannette_auto, $periodicite, $diffusion_email, $statut_not_account, $associated_campaign, $num_sender, $nb_notices_diff;
global $categorie_lecteurs, $groupe_lecteurs;
global $update_type, $form_date_last_envoi, $num_panier;
global $limite_type, $limite_nombre, $typeexport, $prefixe_fichier;
global $group_pperso, $display_notice_in_every_group, $archive_number, $group_type;
global $document_generate, $document_notice_display_type, $document_notice_tpl, $document_django_directory, $document_insert_docnum, $document_group, $document_add_summary;
global $bannette_opac_accueil,$bannette_tpl_num, $bannette_aff_notice_number;
global $genere_lien, $mere, $fille, $notice_mere, $notice_fille, $art_link, $bull_link, $perio_link, $bulletinage, $notice_art, $notice_perio;
$this->num_classement = $num_classement+0;
$this->nom_bannette = stripslashes($nom_bannette);
$this->comment_gestion = stripslashes($comment_gestion);
$this->comment_public = stripslashes($comment_public);
$this->entete_mail = stripslashes($entete_mail);
$this->piedpage_mail = stripslashes($piedpage_mail);
$this->notice_display_type = intval($notice_display_type);
$this->notice_tpl = $notice_tpl+0;
$this->django_directory = stripslashes($django_directory);
$this->proprio_bannette = $id_empr+0;
$this->bannette_auto = $bannette_auto+0;
$this->periodicite = $periodicite+0;
$this->diffusion_email = $diffusion_email+0;
$this->statut_not_account = $statut_not_account+0;
$this->associated_campaign = $associated_campaign+0;
$this->num_sender = $num_sender+0;
$this->nb_notices_diff = $nb_notices_diff+0;
$this->categorie_lecteurs= $categorie_lecteurs;
$this->groupe_lecteurs= $groupe_lecteurs;
$this->update_type = stripslashes($update_type);
$this->date_last_envoi = $form_date_last_envoi;
$this->num_panier = $num_panier+0;
$this->limite_type = stripslashes($limite_type);
$this->limite_nombre = $limite_nombre+0;
$this->typeexport = stripslashes($typeexport);
$this->prefixe_fichier = stripslashes($prefixe_fichier);
$this->group_pperso = stripslashes($group_pperso);
$this->display_notice_in_every_group = $display_notice_in_every_group+0;
$this->archive_number = $archive_number+0;
$this->group_type = $group_type+0;
$this->document_generate = $document_generate+0;
$this->document_notice_display_type = intval($document_notice_display_type);
$this->document_notice_tpl = $document_notice_tpl+0;
$this->document_django_directory = stripslashes($document_django_directory);
$this->document_insert_docnum = $document_insert_docnum+0;
$this->document_group = $document_group+0;
$this->document_add_summary = $document_add_summary+0;
$this->bannette_opac_accueil= $bannette_opac_accueil+0;
$this->bannette_tpl_num = $bannette_tpl_num+0;
$this->bannette_aff_notice_number = $bannette_aff_notice_number+0;
$this->param_export=array("genere_lien" => $genere_lien+0,
"mere" => $mere+0,
"fille" => $fille+0,
"notice_mere" => $notice_mere+0,
"notice_fille" => $notice_fille+0,
"art_link" => $art_link+0,
"bull_link" => $bull_link+0,
"perio_link" => $perio_link+0,
"bulletinage" => $bulletinage+0,
"notice_art" => $notice_art+0,
"notice_perio" => $notice_perio+0);
}
// ---------------------------------------------------------------
// save
// ---------------------------------------------------------------
public function save() {
global $msg;
if ($this->id_bannette) {
// update
$req = "UPDATE bannettes set ";
$clause = " WHERE id_bannette='".$this->id_bannette."'";
} else {
$req = "insert into bannettes set date_last_remplissage=sysdate(), ";
$clause = "";
}
$req.="num_classement='".$this->num_classement."',";
$req.="nom_bannette='".addslashes($this->nom_bannette)."',";
$req.="comment_gestion='".addslashes($this->comment_gestion)."',";
$req.="comment_public='".addslashes($this->comment_public)."',";
$req.="bannette_tpl_num='".$this->bannette_tpl_num."',";
$req.="entete_mail='".addslashes($this->entete_mail)."',";
$req.="piedpage_mail='".addslashes($this->piedpage_mail)."',";
$req.="notice_display_type='".$this->notice_display_type."',";
$req.="notice_tpl='".$this->notice_tpl."',";
$req.="django_directory='".addslashes($this->django_directory)."',";
$req.="proprio_bannette='".$this->proprio_bannette."',";
$req.="bannette_auto='".$this->bannette_auto."',";
$req.="periodicite='".$this->periodicite."',";
$req.="diffusion_email='".$this->diffusion_email."',";
$req.="statut_not_account='".$this->statut_not_account."',";
$req.="associated_campaign='".$this->associated_campaign."',";
$req.="bannette_num_sender='".$this->num_sender."',";
$req.="nb_notices_diff='".$this->nb_notices_diff."',";
$req.="update_type='".$this->update_type."',";
$req.="num_panier='".$this->num_panier."',";
$req.="limite_type='".$this->limite_type."',";
$req.="limite_nombre='".$this->limite_nombre."',";
$req.="typeexport='".$this->typeexport."',";
$req.="prefixe_fichier='".$this->prefixe_fichier."',";
$req.="group_type='".$this->group_type."',";
$req.="group_pperso='".$this->group_pperso."',";
$req.="display_notice_in_every_group='".$this->display_notice_in_every_group."',";
$req.="archive_number='".$this->archive_number."',";
$req.="param_export='".addslashes(serialize($this->param_export))."',";
$req.="document_generate='".$this->document_generate."',";
$req.="document_notice_display_type='".$this->document_notice_display_type."',";
$req.="document_notice_tpl='".$this->document_notice_tpl."',";
$req.="document_django_directory='".addslashes($this->document_django_directory)."',";
$req.="document_insert_docnum='".$this->document_insert_docnum."',";
$req.="document_group='".$this->document_group."',";
$req.="document_add_summary='".$this->document_add_summary."',";
$req.="bannette_opac_accueil='".$this->bannette_opac_accueil."',";
$req.="bannette_aff_notice_number='".$this->bannette_aff_notice_number."',";
if (!$this->date_last_envoi) $req.="date_last_envoi=sysdate() ";
else $req.="date_last_envoi='".construitdateheuremysql($this->date_last_envoi)."' ";
$req.=$clause ;
$res = pmb_mysql_query($req);
if (!$this->id_bannette) $this->id_bannette = pmb_mysql_insert_id() ;
$del = "delete from bannette_empr_groupes where empr_groupe_num_bannette = '".$this->id_bannette."'";
pmb_mysql_query($del);
if (is_array($this->groupe_lecteurs) && !empty($this->groupe_lecteurs)) {
for($i=0 ; $igroupe_lecteurs) ; $i++){
$id_groupe=$this->groupe_lecteurs[$i]*1;
$rqt = "insert into bannette_empr_groupes set empr_groupe_num_bannette = '".$this->id_bannette."', empr_groupe_num_groupe = '".$id_groupe."' ";
pmb_mysql_query($rqt);
}
}
$del = "delete from bannette_empr_categs where empr_categ_num_bannette = '".$this->id_bannette."'";
pmb_mysql_query($del);
if (is_array($this->categorie_lecteurs) && !empty($this->categorie_lecteurs)) {
$this->categorie_lecteurs=$this->categorie_lecteurs;
if($this->categorie_lecteurs[0]==-1){
$this->categorie_lecteurs=array();
$rqt = "SELECT id_categ_empr FROM empr_categ";
$res=pmb_mysql_query($rqt);
if(pmb_mysql_num_rows($res)){
while($row = pmb_mysql_fetch_object($res)){
$this->categorie_lecteurs[] = $row->id_categ_empr;
}
}
}
for($i=0 ; $icategorie_lecteurs) ; $i++){
$id_categ=$this->categorie_lecteurs[$i]*1;
$rqt = "insert into bannette_empr_categs set empr_categ_num_bannette = '".$this->id_bannette."', empr_categ_num_categ = '".$id_categ."' ";
pmb_mysql_query($rqt);
}
}else{
$this->categorie_lecteurs=array();
}
$this->bannette_descriptors->set_properties_from_form();
$this->bannette_descriptors->save();
$facette = new bannette_facettes($this->id_bannette);
$facette->save();
}
// ---------------------------------------------------------------
// delete() : suppression
// ---------------------------------------------------------------
public function delete() {
global $msg;
$requete = "delete from bannette_abon WHERE num_bannette='$this->id_bannette'";
pmb_mysql_query($requete);
$requete = "delete from bannette_contenu WHERE num_bannette='$this->id_bannette'";
pmb_mysql_query($requete);
$requete = "delete from bannettes WHERE id_bannette='$this->id_bannette'";
pmb_mysql_query($requete);
bannette_descriptors::delete($this->id_bannette);
bannette_equations::delete($this->id_bannette);
$facette = new bannette_facettes($this->id_bannette);
$facette->delete();
$del = "delete from bannette_empr_groupes where empr_groupe_num_bannette = '".$this->id_bannette."'";
pmb_mysql_query($del);
$del = "delete from bannette_empr_categs where empr_categ_num_bannette = '".$this->id_bannette."'";
pmb_mysql_query($del);
}
protected function get_records_over_days() {
$query = "select num_notice from bannette_contenu WHERE num_bannette='$this->id_bannette' and ";
$query .= " date_add(date_ajout, INTERVAL ".$this->limite_nombre." DAY) >= sysdate() ";
$result = pmb_mysql_query($query);
$tab = array();
while ($row=pmb_mysql_fetch_object($result)) {
$tab[] = $row->num_notice ;
}
return $tab;
}
protected function get_records_limit() {
$tab = array();
// selection des ## dernières notices, celles qu'il faut absolument garder
$requete = "select num_notice from bannette_contenu, notices WHERE num_bannette='".$this->id_bannette."' and notice_id=num_notice order by date_ajout DESC, update_date DESC ";
$requete .= " limit $this->limite_nombre ";
$res = pmb_mysql_query($requete);
while ($obj=pmb_mysql_fetch_object($res)) {
$tab[]=$obj->num_notice ;
}
// selection des notices ajoutées depuis moins d'un jour
$requete = "select num_notice from bannette_contenu WHERE num_bannette='".$this->id_bannette."' and ";
$requete .= " date_add(date_ajout, INTERVAL 1 DAY)>=sysdate() ";
$res = pmb_mysql_query($requete);
while ($obj=pmb_mysql_fetch_object($res)) {
$tab[]=$obj->num_notice ;
}
return $tab;
}
// ---------------------------------------------------------------
// purger() : après remplissage, vider ce qui dépasse selon le type de cumul de la bannette
// ---------------------------------------------------------------
public function purger() {
global $gestion_acces_active,$gestion_acces_empr_notice;
//purge pour les bannettes privees des notices ne devant pas etre diffusees
if ($this->proprio_bannette && $gestion_acces_active==1 && $gestion_acces_empr_notice==1){
$ac = new acces();
$dom_2 = $ac->setDomain(2);
$acces_j = $dom_2->getJoin($this->proprio_bannette,'4=0','num_notice');
$q="delete from bannette_contenu using bannette_contenu $acces_j WHERE num_bannette='$this->id_bannette' ";
pmb_mysql_query($q);
}
$records = array();
switch ($this->limite_type) {
case "D":
$records = $this->get_records_over_days();
break;
case "I":
$records = $this->get_records_limit();
break;
}
if(count($records)) {
$notice_suppr=implode(",",$records);
if ($this->num_panier) {
$requete = "delete from caddie_content WHERE caddie_id='$this->num_panier' and object_id not in (".$notice_suppr.") ";
pmb_mysql_query($requete);
}
$requete = "delete from bannette_contenu WHERE num_bannette='$this->id_bannette' and num_notice not in (".$notice_suppr.") ";
pmb_mysql_query($requete);
}
$this->compte_elements() ;
}
// ---------------------------------------------------------------
// vider() : vider le contenu de la bannette
// ---------------------------------------------------------------
public function vider() {
$requete = "delete from bannette_contenu WHERE num_bannette='".$this->id_bannette."'";
pmb_mysql_query($requete);
$requete = "delete from caddie_content WHERE caddie_id='".$this->num_panier."'";
pmb_mysql_query($requete);
$this->compte_elements() ;
}
// ---------------------------------------------------------------
// remplir() : remplir la bannette à partir des équations
// ---------------------------------------------------------------
public function remplir() {
global $pmb_allow_term_troncat_search, $opac_allow_term_troncat_search, $pmb_search_exclude_fields, $opac_exclude_fields;
global $dsi_private_bannette_search_equation;
global $search;
//On doit prendre en compte les paramètres OPAC si bannette privée
$initial_pmb_allow_term_troncat_search = $pmb_allow_term_troncat_search;
$initial_pmb_search_exclude_fields = $pmb_search_exclude_fields;
if ($this->proprio_bannette!=0) {
$pmb_allow_term_troncat_search = $opac_allow_term_troncat_search;
$pmb_search_exclude_fields = $opac_exclude_fields;
}
// récupérer les équations associées à la bannette
$equations = $this->bannette_equations->get_equations() ;
$res_affichage = "
" ;
$colonne_update_create = $this->get_date_used();
$nb_equations = count($equations);
for ($i = 0; $i < $nb_equations; $i++) {
// pour chaque équation ajouter les notices trouvées au contenu de la bannette
$equ = new equation ($equations[$i]) ;
$search_class = new search() ;
$search = array();
$this->add_extended_search(0, $equ->requete);
if (!empty($dsi_private_bannette_search_equation) && $this->proprio_bannette) {
$default_equation = new equation($dsi_private_bannette_search_equation);
if ($default_equation->requete) {
$this->add_extended_search(1, $default_equation->requete);
}
}
$table = $search_class->make_search();
if($search_class->is_created_temporary_table($table)) {
if($this->statut_not_account)
$temp_requete = "insert ignore into bannette_contenu (num_bannette, num_notice) (select ".$this->id_bannette." , notices.notice_id from $table , notices where notices.$colonne_update_create>='".$this->date_last_envoi."' and $table.notice_id=notices.notice_id )" ;
else
$temp_requete = "insert ignore into bannette_contenu (num_bannette, num_notice) (select ".$this->id_bannette." , notices.notice_id from $table , notices, notice_statut where notices.$colonne_update_create>='".$this->date_last_envoi."' and $table.notice_id=notices.notice_id and statut=id_notice_statut and ((notice_visible_opac=1 and notice_visible_opac_abon=0) or (notice_visible_opac_abon=1 and notice_visible_opac=1))) " ;
@pmb_mysql_query($temp_requete);
$temp_requete = "drop table $table " ;
@pmb_mysql_query($temp_requete);
}
$res_affichage .= "
".$equ->human_query."
" ;
}
// remplissage du panier avec le contenu de la bannette
if ($this->num_panier) {
$temp_requete = "insert ignore into caddie_content (caddie_id, object_id) (select ".$this->num_panier.", num_notice from bannette_contenu where num_bannette=".$this->id_bannette.")" ;
pmb_mysql_query($temp_requete);
}
//Si nécessaire, on remet le paramètre d'origine
if ($this->proprio_bannette!=0) {
$pmb_allow_term_troncat_search = $initial_pmb_allow_term_troncat_search;
$pmb_search_exclude_fields = $initial_pmb_search_exclude_fields;
}
$res_affichage .= "
" ;
$this->compte_elements() ;
$temp_requete = "update bannettes set date_last_remplissage=sysdate() where id_bannette='".$this->id_bannette."' " ;
pmb_mysql_query($temp_requete);
$this->purger();
return $res_affichage ;
}
protected function get_date_used() {
if ($this->update_type == 'C') {
return "create_date";
}
return "update_date";
}
protected function add_extended_search($ind, $extended_search) {
global $search;
$search[$ind] = 's_11';
global ${'inter_'.$ind.'_s_11'};
global ${'op_'.$ind.'_s_11'};
global ${'field_'.$ind.'_s_11'};
if ($ind) {
${'inter_'.$ind.'_s_11'} = 'and';
}
${'op_'.$ind.'_s_11'} = 'EQ';
${'field_'.$ind.'_s_11'} = array($extended_search);
}
protected function get_css($directory) {
global $base_path;
global $opac_url_base;
$css = '';
$css_path= $base_path."/opac_css/styles/".$directory."/dsi";
if (is_dir($css_path)) {
if (($dh = opendir($css_path))) {
while (($css_file = readdir($dh)) !== false) {
if(filetype($css_path."/".$css_file) =='file') {
if( substr($css_file, -4) == ".css" ) {
$css.="\n";
}
}
}
closedir($dh);
}
}
return $css;
}
protected function get_css_style() {
global $opac_default_style;
// récupération des fichiers de style commun
$css = $this->get_css('common');
// récupération des fichiers de style personnalisé
$css .= $this->get_css($opac_default_style);
return $css;
}
protected function get_query_records() {
global $dsi_bannette_notices_order;
if (!$dsi_bannette_notices_order) $dsi_bannette_notices_order="index_serie, tnvol, index_sew";
$limitation = '';
if ($this->nb_notices_diff && $this->use_limit) $limitation = " LIMIT $this->nb_notices_diff " ;
$query = "select num_notice from bannette_contenu, notices where num_bannette='".$this->id_bannette."' and notice_id=num_notice order by $dsi_bannette_notices_order $limitation ";
return $query;
}
protected function get_data_structure() {
$data = array();
//Nb total sans limitation
$data['records']['length_total'] = $this->nb_notices;
$result = pmb_mysql_query($this->get_query_records());
$data['records']['length'] = pmb_mysql_num_rows($result);
if(pmb_mysql_num_rows($result)) {
$bannette_facette = $this->get_instance_bannette_facette();
if($this->get_notice_tpl()){
$bannette_facette->noti_tpl_document = notice_tpl_gen::get_instance($this->get_notice_tpl());
}
while (($row = pmb_mysql_fetch_object($result))) {
$data['records'][$row->num_notice]['render'] = $bannette_facette->build_notice($row->num_notice, $this->id_bannette);
}
}
if($this->add_summary()) {
$data['sommaires'] = $this->get_data_summary_structure();
} else {
$data['sommaires'] = array();
}
return $data;
}
public function get_display_bannette_tpl() {
$data=$this->get_data_structure(); //$this->data_document
$data['info']['header']=$this->get_display_header();
$data['info']['footer']=$this->get_display_footer();
$data['info']['opac_name']=$this->comment_public;
$data['info']['id']=$this->id_bannette;
$data['info']['name']=$this->nom_bannette;
$data['info']['date_diff']=formatdate(today());
$data['info']['equation']=$this->bannette_equations->get_text();
$data['info']['nb_abonnes']=$this->nb_abonnes;
$data['empr']['name']='!!empr_name!!';
$data['empr']['first_name']='!!empr_first_name!!';
$data['empr']['civ']='!!empr_sexe!!';
$data['empr']['cb']='!!empr_cb!!';
$data['empr']['login']='!!empr_login!!';
$data['empr']['mail']='!!empr_mail!!';
$data['empr']['name_and_adress']='!!empr_name_and_adress!!';
$data['empr']['all_information']='!!empr_all_information!!';
$data['empr']['connect']='!!empr_connect!!';
$data['empr']['statut_id']='!!empr_statut_id!!';
$data['empr']['statut_lib']='!!empr_statut_lib!!';
$data['empr']['categ_id']='!!empr_categ_id!!';
$data['empr']['categ_lib']='!!empr_categ_lib!!';
$data['empr']['codestat_id']='!!empr_codestat_id!!';
$data['empr']['codestat_lib']='!!empr_codestat_lib!!';
$data['empr']['langopac_code']='!!empr_langopac_code!!';
$data['empr']['langopac_lib']='!!empr_langopac_lib!!';
$data['loc']['name']='!!loc_name!!';
$data['loc']['adr1']='!!loc_adr1!!';
$data['loc']['adr2']='!!loc_adr2!!';
$data['loc']['cp']='!!loc_cp!!';
$data['loc']['town']='!!loc_town!!';
$data['loc']['phone']='!!loc_phone!!';
$data['loc']['email']='!!loc_email!!';
$data['loc']['website']='!!loc_website!!';
if($this->bannette_tpl_num){
$tpl_id = $this->bannette_tpl_num;
} else{
$tpl_id = $this->get_private_bannette_tpl();
}
return bannette_tpl::render($tpl_id,$data);
}
public function get_display_document() {
global $charset;
$this->set_records_globals();
$this->set_output_format('document');
$this->build_lists(0);
$document = "".$this->get_css_style()."";
if(($this->bannette_tpl_num) || (($this->proprio_bannette)&&($this->get_private_bannette_tpl()))){
$document .= $this->get_display_bannette_tpl();
} else {
$document .= $this->get_display_header();
if (count($this->list) && $this->group_type==1) {
$facette = $this->get_instance_bannette_facette();
$document .= $facette->build_document($this->list,$this->document_notice_tpl,$this->document_add_summary,1);
} else {
$this->add_list_group_in_list();
if($this->is_grouped()){
$document .= $this->get_display_summary();
} else {
if($this->list) {
$document .= $this->get_display_template();
}
}
}
$document .= $this->get_display_footer();
}
$document.= "";
return $document;
}
public function get_empr_mail($id_empr){
$requete = "select empr_mail, bannette_mail from empr, bannette_abon, bannettes ";
$requete .= "where num_bannette='".$this->id_bannette."' and num_empr=$id_empr and num_bannette=id_bannette and num_empr=id_empr";
$res = pmb_mysql_query($requete);
$emaildest="";
if($empr=pmb_mysql_fetch_object($res)) {
$emaildest = $empr->empr_mail;
if ($empr->bannette_mail && $emaildest){
$destinataires = explode(";",$emaildest);
foreach($destinataires as $mail){
if($mail == $empr->bannette_mail){
$emaildest=$empr->bannette_mail;
break;
}
}
}
}
return $emaildest;
}
protected function get_display_header() {
$header = $this->construit_liens_HTML();
return $header;
}
protected function add_list_group_in_list() {
global $dsi_bannette_notices_order;
if(count($this->list_group)) {
foreach($this->list_group as $list_notice) {
$req_list=array();
foreach($list_notice as $r) {
$req_list[]=$r->num_notice;
}
$query = "select notice_id as num_notice from notices where notice_id in(".implode(",",$req_list).") order by $dsi_bannette_notices_order ";
$result = pmb_mysql_query($query) ;
while ($row = pmb_mysql_fetch_object($result)) {
$this->list[] = $row->num_notice;
}
}
}
}
protected function get_display_content() {
$display = "";
$this->build_lists(1);
if (count($this->list) && $this->group_type==1) {
$facette = $this->get_instance_bannette_facette();
$display .= $facette->build_document($this->list,$this->notice_tpl,1,0);
} else {
$this->add_list_group_in_list();
// il faut trier les regroupements par ordre alphabétique
if($this->group_pperso) {
$display .= $this->get_display_summary();
} else {
if ($this->list) {
// DSI classique par mail...
$display .= $this->get_display_template();
}
}
}
return $display;
}
protected function get_display_footer() {
$footer = $this->piedpage_mail;
$footer = str_replace('!!equation!!', $this->bannette_equations->get_text(), $footer);
return $footer;
}
protected function get_display_mail() {
global $charset;
$this->set_records_globals();
$this->set_output_format('mail');
$this->build_lists(1);
$display = "".$this->get_css_style()."";
if(($this->bannette_tpl_num) || (($this->proprio_bannette)&&($this->get_private_bannette_tpl()))){
if($this->bannette_aff_notice_number){
$display .= "!!dsi_diff_n_notices!!";
}
if ($this->diffusion_email) {
$display .= $this->get_display_bannette_tpl();
}
} else {
$display .= $this->get_display_header();
if($this->bannette_aff_notice_number){
$display .= "!!dsi_diff_n_notices!!";
}
if ($this->diffusion_email) {
$display .= $this->get_display_content();
}
$display .= $this->get_display_footer();
}
$display .= "