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

class_fiche_def.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 fiche_def_ref 
00031 {
00032   var $frd_id;           
00033   var $frd_text;         
00034   var $frd_class_base;   
00035   var $attribut;         
00036                          /* it is used with dynamic variables */
00037 
00038   function fiche_def_ref($p_cn,$p_frd_id=-1)
00039     {
00040       $this->db=$p_cn;
00041       $this->frd_id=$p_frd_id;
00042       $this->attribut=array('frd_id','frd_text','frd_class_base');
00043     }
00051   function LoadAll()
00052     {
00053       $sql="select * from fiche_def_ref order by frd_id";
00054       $Res=ExecSql($this->db,$sql);
00055       $all=pg_fetch_all($Res);
00056       if ( $Res == false ) return array();
00057       $idx=0;
00058       $array=array();
00059       foreach ($all as $row) 
00060         {
00061           $o=new fiche_def_ref($this->db);
00062 
00063           foreach (  $this->attribut as  $value)
00064             {
00065               $o->$value=$row[$value];
00066             }
00067           $array[$idx]=$o;
00068           $idx++;
00069         }
00070       return $array;
00071     }
00078   function Display() 
00079     {
00080       $r="";
00081       foreach ( $this->attribut as $value) 
00082         {
00083           $r.="<TD>".$this->$value.'</TD>';
00084         }
00085       return $r;
00086     }
00097   function Input()
00098     {
00099       $r="";
00100       $h=new widget('hidden');
00101       $r.='<li>Id          :'.$h->IOValue('frd_id',$this->frd_id).$this->frd_id."</li>";
00102       $w=new widget("text");
00103       $r.='<li>Commentaire  :'.$w->IOValue('frd_text',$this->frd_text)."</li>";
00104       $t=new widget('text');
00105       $r.='<li>Poste de base:'.$t->IOValue('frd_class_base',$this->frd_class_base)."</li>";
00106 
00107       return $r;
00108     }
00117   function Save()
00118     {
00119       $sql="update fiche_def_ref set frd_text='".
00120         $this->frd_text."' ,  frd_class_base='".$this->frd_class_base."'".
00121         " where frd_id=".$this->frd_id;
00122       $Res=ExecSql($this->db,$sql);
00123     }
00131   function Get()
00132     {
00133       $sql="select * from  fiche_def_ref ".
00134         " where frd_id=".$this->frd_id;
00135       $Res=ExecSql($this->db,$sql);
00136       if ( pg_NumRows($Res) == 0 ) return null;
00137       $r=pg_fetch_array($Res,0);
00138       $this->frd_text=$r['frd_text'];
00139       $this->frd_class_base=$r['frd_class_base'];
00140     }
00141 
00142 }
00143 ?>