fetch_data($id_note,$id_action); } function fetch_data($id_note=0,$id_action=0){ global $dbh; if($this->id_note && !$id_note){ $id_note=$this->id_note; }elseif(!$this->id_note && $id_note){ $this->id_note=$id_note; } if($this->num_action && !$id_action){ $id_action=$this->num_action; }elseif(!$this->num_action && $id_action){ $this->num_action=$id_action; } if($this->id_note){ $req = "select id_note, prive, rapport,contenu,date_note, sujet_action, id_demande, titre_demande, notes_num_user, notes_type_user, num_action, num_note_parent, notes_read_gestion, notes_read_opac from demandes_notes join demandes_actions on num_action=id_action join demandes on num_demande=id_demande where id_note='".$this->id_note."'"; $res = pmb_mysql_query($req,$dbh); if(pmb_mysql_num_rows($res)){ $obj = pmb_mysql_fetch_object($res); $this->date_note = $obj->date_note; $this->contenu = $obj->contenu; $this->rapport = $obj->rapport; $this->prive = $obj->prive; $this->num_note_parent = $obj->num_note_parent; $this->num_action = $obj->num_action; $this->libelle_action = $obj->sujet_action; $this->libelle_demande = $obj->titre_demande; $this->num_demande = $obj->id_demande; $this->notes_num_user = $obj->notes_num_user; $this->notes_type_user = $obj->notes_type_user; $this->notes_read_gestion = $obj->notes_read_gestion; $this->notes_read_opac = $obj->notes_read_opac; } else { $this->date_note = '0000-00-00 00:00:00'; $this->contenu = ''; $this->rapport = 0; $this->prive = 0; $this->num_note_parent = 0; $this->num_action = 0; $this->notes_num_user = 0; $this->notes_type_user = 0; $this->notes_read_gestion = 0; $this->notes_read_opac = 0; } } else { $this->date_note = '0000-00-00 00:00:00'; $this->contenu = ''; $this->rapport = 0; $this->prive = 0; $this->num_note_parent = 0; $this->notes_num_user = 0; $this->notes_type_user = 0; $this->notes_read_gestion = 0; $this->notes_read_opac = 0; } if($this->num_action){ $req = "select sujet_action, titre_demande, id_demande from demandes_actions join demandes on num_demande=id_demande where id_action='".$this->num_action."' "; $res = pmb_mysql_query($req,$dbh); $obj = pmb_mysql_fetch_object($res); $this->libelle_action = $obj->sujet_action; $this->libelle_demande = $obj->titre_demande; $this->num_demande = $obj->id_demande; } if($this->notes_num_user){ $this->createur_note = $this->getCreateur($this->notes_num_user,$this->notes_type_user); } } /* * Formulaire d'ajout/modification */ function show_modif_form($reply=false){ global $form_modif_note, $msg, $charset, $demandes_include_note; $act_cancel = "document.location='./demandes.php?categ=action&act=see&idaction=$this->num_action#fin'"; $form_modif_note = str_replace('!!cancel_action!!',$act_cancel,$form_modif_note); $form_modif_note = str_replace('!!iduser!!',$this->notes_num_user,$form_modif_note); $form_modif_note = str_replace('!!typeuser!!',$this->notes_type_user,$form_modif_note); if($this->id_note && !$reply){ $title = (strlen($this->contenu)>30 ? substr($this->contenu,0,30).'...' : $this->contenu); $form_modif_note = str_replace('!!form_title!!',$msg['demandes_note_modif'].' : '.$title,$form_modif_note); $form_modif_note = str_replace('!!contenu!!',htmlentities($this->contenu,ENT_QUOTES,$charset),$form_modif_note); if($this->rapport){ $form_modif_note = str_replace('!!ck_rapport!!','checked',$form_modif_note); }else{ $form_modif_note = str_replace('!!ck_rapport!!','',$form_modif_note); } if($this->prive){ $form_modif_note = str_replace('!!ck_prive!!','checked',$form_modif_note); }else{ $form_modif_note = str_replace('!!ck_prive!!','',$form_modif_note); } if($this->notes_read_opac){ $form_modif_note = str_replace('!!ck_vue!!','',$form_modif_note); }else{ $form_modif_note = str_replace('!!ck_vue!!','checked',$form_modif_note); } $form_modif_note = str_replace('!!date_note_btn!!',formatdate($this->date_note),$form_modif_note); $form_modif_note = str_replace('!!date_note!!',$this->date_note,$form_modif_note); $form_modif_note = str_replace('!!idnote!!',$this->id_note,$form_modif_note); $form_modif_note = str_replace('!!idaction!!',$this->num_action,$form_modif_note); $btn_suppr = "id_note && $reply){ $nots = new demandes_notes($this->id_note); $title = (strlen($nots->contenu)>30 ? substr($nots->contenu,0,30).'...' : $nots->contenu); $form_modif_note = str_replace('!!form_title!!',$msg['demandes_note_reply'].' : '.$title,$form_modif_note); $form_modif_note = str_replace('!!contenu!!','',$form_modif_note); if($demandes_include_note) $form_modif_note = str_replace('!!ck_rapport!!','checked',$form_modif_note); else $form_modif_note = str_replace('!!ck_rapport!!','',$form_modif_note); $form_modif_note = str_replace('!!ck_prive!!','',$form_modif_note); $date = formatdate(today()); $date_note=date("Ymd",time()); $form_modif_note = str_replace('!!date_note_btn!!',$date,$form_modif_note); $form_modif_note = str_replace('!!date_note!!',$date_note,$form_modif_note); $form_modif_note = str_replace('!!idnote!!','',$form_modif_note); $form_modif_note = str_replace('!!idaction!!',$this->num_action,$form_modif_note); } else { $form_modif_note = str_replace('!!form_title!!',$msg['demandes_note_creation'],$form_modif_note); $form_modif_note = str_replace('!!ck_prive!!','',$form_modif_note); if($demandes_include_note) $form_modif_note = str_replace('!!ck_rapport!!','checked',$form_modif_note); else $form_modif_note = str_replace('!!ck_rapport!!','',$form_modif_note); $form_modif_note = str_replace('!!contenu!!','',$form_modif_note); $date = formatdate(today()); $date_note=date("Ymd",time()); $form_modif_note = str_replace('!!date_note_btn!!',$date,$form_modif_note); $form_modif_note = str_replace('!!date_note!!',$date_note,$form_modif_note); $form_modif_note = str_replace('!!idnote!!','',$form_modif_note); $form_modif_note = str_replace('!!idaction!!',$this->num_action,$form_modif_note); $form_modif_note = str_replace('!!parent_text!!','',$form_modif_note); $form_modif_note = str_replace('!!id_note_parent!!','',$form_modif_note); $form_modif_note = str_replace('!!style!!','',$form_modif_note); } $path = "num_demande>".htmlentities($this->libelle_demande,ENT_QUOTES,$charset).""; $path .= " > num_action>".htmlentities($this->libelle_action,ENT_QUOTES,$charset).""; $form_modif_note = str_replace('!!path!!',$path,$form_modif_note); $form_modif_note = str_replace('!!btn_suppr!!',$btn_suppr,$form_modif_note); print $form_modif_note; } static function get_values_from_form(&$note){ global $contenu_note, $idaction,$idnote ,$iddemande , $iduser,$id_empr,$typeuser; global $date_note, $ck_rapport, $ck_prive, $ck_vue,$id_note_parent, $PMBuserid; $typeuser='1'; $note->id_note=$idnote; $note->num_action=$idaction; $note->num_demande=$iddemande; $note->contenu=$contenu_note; $note->num_note_parent=$id_note_parent; if(!$date_note){ $note->date_note=date("Y-m-d h:i:s",time()); }else{ $note->date_note=$date_note; } if($ck_prive){ $note->prive=1; }else{ $note->prive=0; } if($ck_rapport){ $note->rapport=1; }else{ $note->rapport=0; } if($ck_vue){ $note->notes_read_opac=0; }else{ $note->notes_read_opac=1; } $note->notes_num_user=$id_empr; $note->notes_type_user=$typeuser; } /* * Création/Modification d'une note */ static function save(&$note){ global $dbh; global $demandes_email_demandes, $pmb_type_audit; if($note->id_note){ //MODIFICATION $query = "UPDATE demandes_notes SET contenu='".$note->contenu."', date_note='".$note->date_note."', prive='".$note->prive."', rapport='".$note->rapport."', num_action='".$note->num_action."', notes_num_user='".$note->notes_num_user."', notes_type_user='".$note->notes_type_user."', num_note_parent='".$note->num_note_parent."', notes_read_gestion='1', notes_read_opac='".$note->notes_read_opac."' WHERE id_note='".$note->id_note."'"; pmb_mysql_query($query,$dbh); if($pmb_type_audit) audit::insert_modif(AUDIT_NOTE,$note->id_note); } else { //CREATION $query = "INSERT INTO demandes_notes SET contenu='".$note->contenu."', date_note='".$note->date_note."', prive='".$note->prive."', rapport='".$note->rapport."', num_action='".$note->num_action."', notes_num_user='".$note->notes_num_user."', notes_type_user='".$note->notes_type_user."', num_note_parent='".$note->num_note_parent."', notes_read_gestion='1', notes_read_opac='".$note->notes_read_opac."'"; pmb_mysql_query($query,$dbh); $note->id_note=pmb_mysql_insert_id($dbh); if($pmb_type_audit) audit::insert_creation(AUDIT_NOTE,$note->id_note); if(!$note->prive) { if ($demandes_email_demandes){ $note->fetch_data($note->id_note,$note->num_action); $note->send_alert_by_mail($note->notes_num_user,$note); } } } } /* * Suppression d'une note */ static function delete($note){ global $dbh; if($note->id_note){ $req = "delete from demandes_notes where id_note='".$note->id_note."'"; pmb_mysql_query($req,$dbh); $req = "delete from demandes_notes where num_note_parent='".$note->id_note."'"; pmb_mysql_query($req,$dbh); audit::delete_audit(AUDIT_NOTE,$note->id_note); } } static function show_dialog($notes,$num_action,$num_demande,$redirect_to='demandes_actions-show_consultation_form'){ global $form_dialog_note, $dbh, $msg, $charset,$id_empr; $form_dialog_note = str_replace('!!redirectto!!',$redirect_to,$form_dialog_note); $form_dialog_note = str_replace('!!idaction!!',$num_action,$form_dialog_note); $form_dialog_note = str_replace('!!iddemande!!',$num_demande,$form_dialog_note); $dialog=''; if(sizeof($notes)){ foreach($notes as $idNote=>$note){ //Utilisateur ou lecteur ? if($note->notes_type_user==="1"){ $side='note_opac'; }elseif($note->notes_type_user==="0"){ $side='note_gest'; } $dialog.='
'.$note->contenu.'
'; $dialog.='