id_note = $id_note; if($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 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 = mysql_query($req,$dbh); if(mysql_num_rows($res)){ $obj = 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; } else { $this->date_note = '0000-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; } } else { $this->date_note = '0000-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; } 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 = mysql_query($req,$dbh); $obj = 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'"; $form_modif_note = str_replace('!!cancel_action!!',$act_cancel,$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); $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); //Parent $nots = new demandes_notes($this->num_note_parent); $form_modif_note = str_replace('!!parent_text!!',$nots->contenu,$form_modif_note); $form_modif_note = str_replace('!!id_note_parent!!',$nots->id_note,$form_modif_note); $form_modif_note = str_replace('!!style!!',"",$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); //Parent $form_modif_note = str_replace('!!parent_text!!',$nots->contenu,$form_modif_note); $form_modif_note = str_replace('!!id_note_parent!!',$nots->id_note,$form_modif_note); $form_modif_note = str_replace('!!style!!',"style='display:none'",$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; } /* * Création/Modification d'une demande */ function save(){ global $dbh, $contenu_note, $idaction, $id_note_parent; global $date_note, $ck_rapport, $ck_prive, $PMBuserid; global $demandes_email_demandes; if($this->id_note){ //MODIFICATION $req = "update demandes_notes set contenu='".$contenu_note."', date_note='".$date_note."', prive='".($ck_prive ? 1 : 0)."', rapport='".($ck_rapport ? 1 : 0)."', num_action='".$idaction."', notes_num_user='".$PMBuserid."', notes_type_user='0', num_note_parent='".$id_note_parent."' where id_note='".$this->id_note."'"; $req_up = "update demandes_actions set actions_read='1' where id_action='".$idaction."'"; mysql_query($req_up,$dbh); } else { //CREATION $req = "insert into demandes_notes set contenu='".$contenu_note."', date_note='".$date_note."', prive='".($ck_prive ? 1 : 0)."', rapport='".($ck_rapport ? 1 : 0)."', num_action='".$idaction."', num_note_parent='".$id_note_parent."', notes_num_user='".$PMBuserid."', notes_type_user='0'"; if(!$ck_prive) { if ($demandes_email_demandes) $this->send_alert_by_mail($PMBuserid,$id_note_parent); $req_up = "update demandes_actions set actions_read='1' where id_action='".$idaction."'"; mysql_query($req_up,$dbh); } } mysql_query($req,$dbh); } /* * Suppression d'une note */ function delete(){ global $dbh; if($this->id_note){ $req = "delete from demandes_notes where id_note='".$this->id_note."'"; mysql_query($req,$dbh); $req = "delete from demandes_notes where num_note_parent='".$this->id_note."'"; mysql_query($req,$dbh); } } /* * Affichage de la liste des notes associées à une action */ function show_list_notes($idaction=0){ global $form_table_note, $dbh, $msg, $charset; $req = "select id_note, CONCAT(SUBSTRING(contenu,1,50),'','...') as titre, contenu, date_note, prive, rapport,notes_num_user,notes_type_user from demandes_notes where num_action='".$idaction."' and num_note_parent=0 order by date_note desc ,id_note desc"; $res = mysql_query($req,$dbh); $liste =""; if(mysql_num_rows($res)){ while(($note = mysql_fetch_object($res))){ $createur = $this->getCreateur($note->notes_num_user,$note->notes_type_user); $contenu = "