Main Page | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals

class_parm_code.php

Go to the documentation of this file.
00001 <?
00002 /*
00003  *   This file is part of PhpCompta.
00004  *
00005  *   PhpCompta is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   PhpCompta is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with PhpCompta; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 /* $Revision$ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00021 class parm_code {
00022   var $db; // database connection
00023   var $p_code; // parm_code.p_code primary key
00024   var $p_value; // parm_code.p_value 
00025   var $p_comment; // parm_code.p_comment
00026  // constructor
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 /* function LoadAll
00035  **************************************************
00036  * Purpose : 
00037  *  Load all parmCode
00038  *  return an array of parm_code object
00039  *        
00040  * parm : 
00041  *      - none
00042  * gen :
00043  *      -
00044  * return: array
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   /* function Save
00065  **************************************************
00066  * Purpose : update a parm_object into the database
00067  *        p_code is _not_ updatable
00068  * parm : 
00069  *      - none
00070  * gen :
00071  *      - none
00072  * return:
00073  *     nothing
00074  */
00075   function Save() 
00076     {
00077       // if p_code=="" nothing to save
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 /* function Display
00089  **************************************************
00090  * Purpose : Display an object, with the <TD> tag
00091  *        
00092  * parm : 
00093  *      - none
00094  * gen :
00095  *      - none
00096  * return:
00097  *     string
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 /* function Input
00109  **************************************************
00110  * Purpose : Display a form to enter info about
00111  *        a parm_code object with the <TD> tag
00112  *    
00113  * parm : 
00114  *      - none
00115  * gen :
00116  *      - none
00117  * return: string
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 /* function Get
00141  **************************************************
00142  * Purpose : 
00143  * Complete a parm_code object thanks the p_code 
00144 
00145  *        
00146  * parm : 
00147  *      - none
00148  * gen :
00149  *      -
00150  * return: array
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 }

Generated on Wed May 31 21:39:15 2006 for phpcompta by  doxygen 1.4.4