liste_etat = $list_etat->table; } /* * Affichage du formulaire d'enregistrement */ function show_form(){ global $form_do_demande, $dbh, $charset; $date = formatdate(today()); $date_fin=date("Ymd",time()); //Selecteur des thèmes $req = "select * from demandes_theme order by libelle_theme"; $res = mysql_query($req,$dbh); $theme_selector = ""; //Selecteur des types $req = "select * from demandes_type order by libelle_type"; $res = mysql_query($req,$dbh); $type_selector = ""; $form_do_demande = str_replace('!!date_fin!!',$date_fin, $form_do_demande); $form_do_demande = str_replace('!!date_fin_btn!!',$date, $form_do_demande); $form_do_demande = str_replace('!!select_theme!!',$theme_selector, $form_do_demande); $form_do_demande = str_replace('!!select_type!!',$type_selector, $form_do_demande); print $form_do_demande; } /* * Enregistrement de la demande */ function save(){ global $titre, $sujet, $idtheme, $idtype, $date_fin, $id_empr, $dbh, $demandes_statut_notice, $pmb_type_audit; global $demandes_email_demandes; $index_wew = $titre; $index_sew = strip_empty_words($index_wew); $index_ncontenu = strip_empty_words($sujet); $req = "insert into notices set tit1='".$titre."', n_contenu='".$sujet."', statut ='".$demandes_statut_notice."', index_sew ='".$index_sew."', index_wew ='".$index_wew."', index_n_contenu = '".$index_ncontenu."', create_date = CURRENT_TIMESTAMP() "; mysql_query($req,$dbh); $id_notice = mysql_insert_id(); if ($pmb_type_audit) { $query = "INSERT INTO audit SET "; $query .= "type_obj='1', "; $query .= "object_id='$id_notice', "; $query .= "type_modif=1 "; $result = @mysql_query($query, $dbh); } $date=date("Ymd",time()); $req="insert into demandes set titre_demande='".$titre."', sujet_demande='".$sujet."', theme_demande='".$idtheme."', type_demande='".$idtype."', deadline_demande='".$date_fin."', date_demande='".$date."', date_prevue='".$date."', num_demandeur='".$id_empr."', num_notice='".$id_notice."', etat_demande=1 "; mysql_query($req,$dbh); if($demandes_email_demandes) $this->alert_mail_users_pmb($id_empr); } /* * Affichage de la liste des demandes */ function show_list($idetat=0){ global $id_empr, $form_liste_demande, $msg, $dbh, $base_path, $opac_url_base,$opac_permalink,$charset; $req="select id_demande, num_demandeur,theme_demande,type_demande,etat_demande, date_demande, if(date_prevue>deadline_demande,date_prevue, deadline_demande) as deadline, titre_demande, sujet_demande, progression, num_user_cloture, concat(empr_prenom,' ',empr_nom) as dmdeur, group_concat(distinct if(concat(prenom,' ',nom)!='',concat(prenom,' ',nom),username) separator '/ ' ) as user, group_concat(username separator '/ ' ) as login, num_notice from demandes join demandes_theme on theme_demande=id_theme join demandes_type on type_demande=id_type join empr on id_empr=num_demandeur left join demandes_users du on du.num_demande=id_demande left join users on userid=du.num_user where num_demandeur='".$id_empr."' "; if ($idetat) $req .= " and etat_demande='".$idetat."' "; $req .= " group by id_demande order by date_demande desc"; $res = mysql_query($req,$dbh); if(!$idetat){ $entete = "".$msg['demandes_etat'].""; $form_liste_demande = str_replace('!!entete_etat!!',$entete,$form_liste_demande); } else $form_liste_demande = str_replace('!!entete_etat!!','',$form_liste_demande); $form_liste_demande = str_replace('!!select_etat!!',$this->getStateSelector($idetat,true),$form_liste_demande); $liste = ""; if(mysql_num_rows($res)){ $parity=1; while(($dmde = mysql_fetch_object($res))){ if ($parity % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; } $parity += 1; $tr_javascript = "onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='".$pair_impair."'\" "; $action = "onclick=document.location='./empr.php?tab=request&lvl=list_dmde&sub=see_action&iddemande=$dmde->id_demande'"; $liste .= ""; $liste .= "".htmlentities($dmde->titre_demande,ENT_QUOTES,$charset).""; $liste .= (!$idetat ? "".htmlentities($this->liste_etat[$dmde->etat_demande],ENT_QUOTES,$charset)."" : ''); $req = "select notice_visible_opac as visible, notice_visible_opac_abon as visu_abo from notice_statut join notices on id_notice_statut=statut where notice_id='".$dmde->num_notice."'"; $res_vis = mysql_query($req,$dbh); $noti_display = mysql_fetch_object($res_vis); if($noti_display->visible || $noti_display->visu_abo){ $link_noti = ""; } else $link_noti = ""; $liste .=" ".htmlentities(formatdate($dmde->date_demande),ENT_QUOTES,$charset)." ".htmlentities(formatdate($dmde->deadline),ENT_QUOTES,$charset)." ".htmlentities($dmde->user,ENT_QUOTES,$charset)." progression."%\" title='".$dmde->progression."%' /> $link_noti "; $liste .= ""; } } else { $liste .= "".$msg['demandes_liste_vide'].""; } $form_liste_demande = str_replace('!!liste_dmde!!',$liste,$form_liste_demande); print $form_liste_demande; } /* * Selecteur d'etat */ function getStateSelector($idetat=0,$default=false){ global $charset, $msg; $selector = ""; return $selector; } /* * Alerter par mail les utilisateurs de la nouvelle demande */ function alert_mail_users_pmb($id_empr) { global $dbh; global $msg, $charset; global $opac_biblio_name, $opac_biblio_email ; global $opac_url_base ; global $titre, $sujet, $idtheme, $idtype, $date_fin; // paramétrage OPAC: choix du nom de la bibliothèque comme expéditeur $requete = "select location_libelle, email from empr, docs_location where empr_location=idlocation and id_empr='$id_empr' "; $res = mysql_query($requete, $dbh); $loc=mysql_fetch_object($res) ; $PMBusernom = $loc->location_libelle ; $PMBuserprenom = "" ; $PMBuseremail = $loc->email ; // libellé du thème de la demande $requete = "select libelle_theme from demandes_theme where id_theme='".$idtheme."'"; $res = mysql_query($requete, $dbh); $theme=mysql_fetch_object($res) ; $libelle_theme = $theme->libelle_theme; // libellé du type de la demande $requete = "select libelle_type from demandes_type where id_type='".$idtype."'"; $res = mysql_query($requete, $dbh); $typ=mysql_fetch_object($res) ; $libelle_type = $typ->libelle_type; $query = "select distinct empr_prenom, empr_nom, empr_cb, empr_mail, empr_tel1, empr_tel2, empr_ville, location_libelle, nom, prenom, user_email, date_format(sysdate(), '".$msg["format_date_heure"]."') as aff_quand from empr, docs_location, users where id_empr='$id_empr' and empr_location=idlocation and user_alert_demandesmail=1"; $result = @mysql_query($query, $dbh); $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=".$charset."\n"; while ($empr=@mysql_fetch_object($result)) { $output_final = "" ; $output_final .= "".$msg["mail_obj_demande_added"] ; $sujet = $msg["mail_obj_demande_added"] ; $output_final .= " ".$empr->aff_quand."
".$empr->empr_prenom." ".$empr->empr_nom."
".$empr->empr_mail." / ".$empr->empr_tel1." / ".$empr->empr_tel2.""; if ($empr->empr_cp || $empr->empr_ville) $output_final .= "
".$empr->empr_cp." ".$empr->empr_ville.""; $output_final .= "
".$msg[situation].": ".$empr->location_libelle."
"; $output_final .= $msg["mail_content_demande_theme"]." ".$libelle_theme."
"; $output_final .= $msg["mail_content_demande_type"]." ".$libelle_type."
"; $output_final .= $titre."

"; $output_final .= $sujet."

"; $output_final .= $msg["mail_content_demande_date_fin"]." ".formatdate($date_fin)."
"; $output_final .= "
"; $res_envoi=mailpmb($empr->nom." ".$empr->prenom, $empr->user_email,$sujet." ".$empr->aff_quand,$output_final,$opac_biblio_email, $opac_biblio_email, $headers, "", "", 1); } } } ?>