00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 class parm_code {
00022 var $db;
00023 var $p_code;
00024 var $p_value;
00025 var $p_comment;
00026
00027 function parm_code($p_cn,$p_id=-1)
00028 {
00029 $this->db=$p_cn;
00030 $this->p_code=$p_id;
00031 if ( $p_id != -1 )
00032 $this->Get();
00033 }
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 function LoadAll() {
00048 $sql="select * from parm_code order by p_code";
00049 $Res=ExecSql($this->db,$sql);
00050 $r= pg_fetch_all($Res);
00051 $idx=0;
00052 $array=array();
00053
00054 if ( $r === false ) return null;
00055 foreach ($r as $row )
00056 {
00057 $o=new parm_code($this->db,$row['p_code']);
00058 $array[$idx]=$o;
00059 $idx++;
00060 }
00061
00062 return $array;
00063 }
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 function Save()
00076 {
00077
00078 if ( $this->p_code== -1) return;
00079 $this->p_comment=FormatString($this->p_comment);
00080 $this->p_value=FormatString($this->p_value);
00081 $this->p_code=FormatString($this->p_code);
00082 $sql="update parm_code set ".
00083 "p_comment='".$this->p_comment."' ".
00084 ",p_value='".$this->p_value."' ".
00085 "where p_code='".$this->p_code."'";
00086 $Res=ExecSql($this->db,$sql);
00087 }
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 function Display()
00100 {
00101 $r="";
00102 $r.= '<TD>'.$this->p_code.'</TD>';
00103 $r.= '<TD>'.$this->p_comment.'</TD>';
00104 $r.= '<TD>'.$this->p_value.'</TD>';
00105
00106 return $r;
00107 }
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 function Input()
00120 {
00121 $comment=new widget("text");
00122 $comment->name='p_comment';
00123 $comment->value=$this->p_comment;
00124 $value=new widget("text");
00125 $value->name='p_value';
00126 $value->value=$this->p_value;
00127 $poste=new widget("text");
00128 $poste->SetReadOnly(true);
00129 $poste->name='p_code';
00130 $poste->value=$this->p_code;
00131 $r="";
00132 $r.= '<TD>'.$poste->IOValue().'</TD>';
00133 $r.= '<TD>'.$comment->IOValue().'</TD>';
00134 $r.= '<TD>'.$value->IOValue().'</TD>';
00135
00136 return $r;
00137
00138 }
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153 function Get() {
00154 if ( $this->p_code == -1 ) return "p_code non initialisé";
00155 $sql=sprintf("select * from parm_code where p_code='%s' ",
00156 $this->p_code);
00157 $Res=ExecSql($this->db,$sql);
00158
00159 if ( pg_NumRows($Res) == 0 ) return 'INCONNU';
00160 $row= pg_fetch_array($Res,0);
00161 $this->p_value=$row['p_value'];
00162 $this->p_comment=$row['p_comment'];
00163
00164 }
00165
00166 }