From 328005d6c53d52ddd3f572a1029265f801b2e58c Mon Sep 17 00:00:00 2001 From: sparkyx Date: Mon, 1 May 2006 17:47:22 +0000 Subject: [PATCH] Task 5406 : add parameters setting --- include/class_parm_code.php | 166 ++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 include/class_parm_code.php diff --git a/include/class_parm_code.php b/include/class_parm_code.php new file mode 100644 index 000000000..6a4db221d --- /dev/null +++ b/include/class_parm_code.php @@ -0,0 +1,166 @@ +db=$p_cn; + $this->p_code=$p_id; + if ( $p_id != -1 ) + $this->Get(); + } +/* function LoadAll + ************************************************** + * Purpose : + * Load all parmCode + * return an array of parm_code object + * + * parm : + * - none + * gen : + * - + * return: array + */ + + function LoadAll() { + $sql="select * from parm_code"; + $Res=ExecSql($this->db,$sql); + $r= pg_fetch_all($Res); + $idx=0; + $array=array(); + + if ( $r === false ) return null; + foreach ($r as $row ) + { + $o=new parm_code($this->db,$row['p_code']); + $array[$idx]=$o; + $idx++; + } + + return $array; + } + /* function Save + ************************************************** + * Purpose : update a parm_object into the database + * p_code is _not_ updatable + * parm : + * - none + * gen : + * - none + * return: + * nothing + */ + function Save() + { + // if p_code=="" nothing to save + if ( $this->p_code== -1) return; + $this->p_comment=FormatString($this->p_comment); + $this->p_value=FormatString($this->p_value); + $this->p_code=FormatString($this->p_code); + $sql="update parm_code set ". + "p_comment='".$this->p_comment."' ". + ",p_value='".$this->p_value."' ". + "where p_code='".$this->p_code."'"; + $Res=ExecSql($this->db,$sql); + } +/* function Display + ************************************************** + * Purpose : Display an object, with the tag + * + * parm : + * - none + * gen : + * - none + * return: + * string + */ + function Display() + { + $r=""; + $r.= ''.$this->p_code.''; + $r.= ''.$this->p_comment.''; + $r.= ''.$this->p_value.''; + + return $r; + } +/* function Input + ************************************************** + * Purpose : Display a form to enter info about + * a parm_code object with the tag + * + * parm : + * - none + * gen : + * - none + * return: string + */ + function Input() + { + $comment=new widget("text"); + $comment->name='p_comment'; + $comment->value=$this->p_comment; + $value=new widget("text"); + $value->name='p_value'; + $value->value=$this->p_value; + $poste=new widget("text"); + $poste->SetReadOnly(true); + $poste->name='p_code'; + $poste->value=$this->p_code; + $r=""; + $r.= ''.$poste->IOValue().''; + $r.= ''.$comment->IOValue().''; + $r.= ''.$value->IOValue().''; + + return $r; + + } + +/* function Get + ************************************************** + * Purpose : + * Complete a parm_code object thanks the p_code + + * + * parm : + * - none + * gen : + * - + * return: array + */ + + function Get() { + if ( $this->p_code == -1 ) return "p_code non initialisé"; + $sql=sprintf("select * from parm_code where p_code='%s'", + $this->p_code); + $Res=ExecSql($this->db,$sql); + + if ( pg_NumRows($Res) == 0 ) return 'INCONNU'; + $row= pg_fetch_array($Res,0); + $this->p_value=$row['p_value']; + $this->p_comment=$row['p_comment']; + + } + +}