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 @@ + +/* + * This file is part of PhpCompta. + * + * PhpCompta is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpCompta is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PhpCompta; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +/* $Revision$ */ +// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr +class parm_code { + var $db; // database connection + var $p_code; // parm_code.p_code primary key + var $p_value; // parm_code.p_value + var $p_comment; // parm_code.p_comment + // constructor + function parm_code($p_cn,$p_id=-1) + { + $this->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