db=$p_cn; $this->id=$p_id; $this->name=""; $this->description=""; $this->get(); } /*!\brief get the list of all existing PA * \return an array of PA (not object) * */ function get_list() { $array=array(); $sql="select pa_id as id,pa_name as name,". "pa_description as description from plan_analytique order by pa_name"; $ret=ExecSql($this->db,$sql); $array=pg_fetch_all($ret); return $array; } function get() { if ( $this->id==0) return; $sql="select pa_name,pa_description from plan_analytique where pa_id=".$this->id; $ret= ExecSql($this->db,$sql); if ( pg_NumRows($ret) == 0) { return; } $a= pg_fetch_array($ret,0); $this->name=$a['pa_name']; $this->description=$a['pa_description']; } function delete() { if ( $this->id == 0 ) return; ExecSql($this->db,"delete from plan_analytique where pa_id=".$this->id); } function update() { if ( $this->id==0) return; $name=FormatString($this->name); if ( strlen($name) == 0) return; $description=FormatString($this->description); ExecSql($this->db,"update plan_analytique set pa_name='".$name."'". ", pa_description='".$description."'". " where pa_id=".$this->id); } function add() { $name=FormatString($this->name); if ( strlen($name) == 0) return; if ( $this->isAppend() == false) return; $description=FormatString($this->description); ExecSql($this->db,"insert into plan_analytique(pa_name,pa_description)". " values (". "'".$name."',". "'".$description."')"); $this->id=getSequence($this->db,'plan_analytique_pa_id_seq'); } function form() { $wName=new widget('TEXT','Nom','pa_name',$this->name); $wName->table=1; $wDescription=new widget('TEXT','Description','pa_description',$this->description); $wDescription->table=1; $wId=new widget("HIDDEN","pa_id",$this->id); $ret="