fetch_data($id,$lazzy_load); } public function fetch_data($id=0,$lazzy_load=true){ global $iddemande; if($this->id_action && !$id){ $id=$this->id_action; }elseif(!$this->id_action && $id){ $this->id_action=$id; } $this->type_action = 0; $this->date_action = '0000-00-00'; $this->deadline_action = '0000-00-00'; $this->sujet_action = ''; $this->detail_action = ''; $this->cout = 0; $this->progression_action = 0; $this->time_elapsed = 0; $this->num_demande = 0; $this->statut_action = 0; $this->libelle_demande = ''; $this->prive_action = 0; $this->actions_num_user = 0; $this->actions_type_user = 0; $this->actions_read_gestion = 0; $this->actions_read_opac = 0; if($this->id_action){ $req = "select id_action,type_action,statut_action, sujet_action, detail_action,date_action,deadline_action,temps_passe, cout, progression_action, prive_action, num_demande, titre_demande, actions_num_user,actions_type_user,actions_read_gestion,actions_read_opac from demandes_actions join demandes on num_demande=id_demande where id_action='".$this->id_action."'"; $res=pmb_mysql_query($req); if(pmb_mysql_num_rows($res)){ $obj = pmb_mysql_fetch_object($res); $this->type_action = $obj->type_action; $this->date_action = $obj->date_action; $this->deadline_action = $obj->deadline_action; $this->sujet_action = $obj->sujet_action; $this->detail_action = $obj->detail_action; $this->cout = $obj->cout; $this->progression_action = $obj->progression_action; $this->time_elapsed = $obj->temps_passe; $this->num_demande = $obj->num_demande; $this->statut_action = $obj->statut_action; $this->libelle_demande = $obj->titre_demande; $this->prive_action = $obj->prive_action; $this->actions_num_user = $obj->actions_num_user; $this->actions_type_user = $obj->actions_type_user; $this->actions_read_gestion = $obj->actions_read_gestion; $this->actions_read_opac = $obj->actions_read_opac; } } if(empty($this->workflow)){ $this->workflow = new workflow('ACTIONS','INITIAL'); $this->list_type = $this->workflow->getTypeList(); $this->list_statut = $this->workflow->getStateList(); } $iddemande = intval($iddemande); if($iddemande) { $this->num_demande = $iddemande; $req = "select titre_demande from demandes where id_demande='".$iddemande."'"; $res = pmb_mysql_query($req); $this->libelle_demande = pmb_mysql_result($res,0,0); } //On remonte les notes if($this->id_action){ $this->notes=array(); //On charge la liste d'id des notes $query='SELECT id_note,date_note FROM demandes_notes WHERE num_action='.$this->id_action.' ORDER BY id_note ASC'; $result=pmb_mysql_query($query); while($note=pmb_mysql_fetch_array($result,PMB_MYSQL_ASSOC)){ if($lazzy_load){ $this->notes[$note['id_note']]=new stdClass(); $this->notes[$note['id_note']]->id_note=$note['id_note']; $this->notes[$note['id_note']]->date_note=$note['date_note']; $this->notes[$note['id_note']]->id_action=$this->id_action; }else{ $this->notes[$note['id_note']]=new demandes_notes($note['id_note'],$this->id_action); } } $this->last_modified=$this->get_last_modified_note(); } } /* * Cherche la note la plus récente grace à l'audit */ public function get_last_modified_note(){ $temp=0; foreach($this->notes as $note){ //On cherche la derniere note modifiée if(!$temp){ $temp=$note; } $dateLast_modified= new DateTime($temp->date_note); $dateNote= new DateTime($note->date_note); if($dateLast_modified->format('U') < $dateNote->format('U')){ $temp = $note; } } if($temp){ return $temp; } } public function get_path() { global $charset; $path = "num_demande>".htmlentities($this->libelle_demande,ENT_QUOTES,$charset).""; if($this->id_action) { $path .= " > id_action>".htmlentities($this->sujet_action,ENT_QUOTES,$charset).""; } return $path; } /* * Affichage du formulaire de création/modification */ public function show_modif_form(){ global $js_modif_action, $content_form_modif_action,$msg, $charset; print $js_modif_action; print "