00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00030 class parm_code {
00031 var $db;
00032 var $p_code;
00033 var $p_value;
00034 var $p_comment;
00035
00036 function parm_code($p_cn,$p_id=-1)
00037 {
00038 $this->db=$p_cn;
00039 $this->p_code=$p_id;
00040 if ( $p_id != -1 )
00041 $this->Get();
00042 }
00052 function LoadAll() {
00053 $sql="select * from parm_code order by p_code";
00054 $Res=ExecSql($this->db,$sql);
00055 $r= pg_fetch_all($Res);
00056 $idx=0;
00057 $array=array();
00058
00059 if ( $r === false ) return null;
00060 foreach ($r as $row )
00061 {
00062 $o=new parm_code($this->db,$row['p_code']);
00063 $array[$idx]=$o;
00064 $idx++;
00065 }
00066
00067 return $array;
00068 }
00076 function Save()
00077 {
00078
00079 if ( $this->p_code== -1) return;
00080 $this->p_comment=FormatString($this->p_comment);
00081 $this->p_value=FormatString($this->p_value);
00082 $this->p_code=FormatString($this->p_code);
00083 $sql="update parm_code set ".
00084 "p_comment='".$this->p_comment."' ".
00085 ",p_value='".$this->p_value."' ".
00086 "where p_code='".$this->p_code."'";
00087 $Res=ExecSql($this->db,$sql);
00088 }
00096 function Display()
00097 {
00098 $r="";
00099 $r.= '<TD>'.$this->p_code.'</TD>';
00100 $r.= '<TD>'.$this->p_comment.'</TD>';
00101 $r.= '<TD>'.$this->p_value.'</TD>';
00102
00103 return $r;
00104 }
00112 function Input()
00113 {
00114 $comment=new widget("text");
00115 $comment->name='p_comment';
00116 $comment->value=$this->p_comment;
00117 $value=new widget("text");
00118 $value->name='p_value';
00119 $value->value=$this->p_value;
00120 $poste=new widget("text");
00121 $poste->SetReadOnly(true);
00122 $poste->name='p_code';
00123 $poste->value=$this->p_code;
00124 $r="";
00125 $r.= '<TD>'.$poste->IOValue().'</TD>';
00126 $r.= '<TD>'.$comment->IOValue().'</TD>';
00127 $r.= '<TD>'.$value->IOValue().'</TD>';
00128
00129 return $r;
00130
00131 }
00132
00141 function Get() {
00142 if ( $this->p_code == -1 ) return "p_code non initialisé";
00143 $sql=sprintf("select * from parm_code where p_code='%s' ",
00144 $this->p_code);
00145 $Res=ExecSql($this->db,$sql);
00146
00147 if ( pg_NumRows($Res) == 0 ) return 'INCONNU';
00148 $row= pg_fetch_array($Res,0);
00149 $this->p_value=$row['p_value'];
00150 $this->p_comment=$row['p_comment'];
00151
00152 }
00153
00154 }