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

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: 1.3 $ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00030 class parm_code {
00031   var $db;        
00032   var $p_code;    
00033   var $p_value;   
00034   var $p_comment; 
00035  // constructor
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       // if p_code=="" nothing to save
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 }