Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 require_once("class_itext.php");
00029 require_once('class_acc_account_ledger.php');
00030
00031 class Acc_Parm_Code
00032 {
00033 var $db;
00034 var $p_code;
00035 var $p_value;
00036 var $p_comment;
00037
00038 function Acc_Parm_Code($p_cn,$p_id=-1)
00039 {
00040 $this->db=$p_cn;
00041 $this->p_code=$p_id;
00042 if ( $p_id != -1 )
00043 $this->load();
00044 }
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 function load_all()
00055 {
00056 $sql="select * from parm_code order by p_code";
00057 $Res=$this->db->exec_sql($sql);
00058 $r= Database::fetch_all($Res);
00059 $idx=0;
00060 $array=array();
00061
00062 if ( $r === false ) return null;
00063 foreach ($r as $row )
00064 {
00065 $o=new Acc_Parm_Code($this->db,$row['p_code']);
00066 $array[$idx]=$o;
00067 $idx++;
00068 }
00069
00070 return $array;
00071 }
00072
00073
00074
00075
00076
00077
00078
00079 function save()
00080 {
00081
00082 if ( $this->p_code== -1) return;
00083
00084 $acc=new Acc_Account_Ledger($this->db,$this->p_value);
00085 if ( $acc->load() == false )
00086 {
00087 alert("Ce compte n'existe pas");
00088 }
00089 else
00090 {
00091 $this->p_comment=sql_string($this->p_comment);
00092 $this->p_value=sql_string($this->p_value);
00093 $this->p_code=sql_string($this->p_code);
00094 $sql="update parm_code set ".
00095 "p_comment='".$this->p_comment."' ".
00096 ",p_value='".$this->p_value."' ".
00097 "where p_code='".$this->p_code."'";
00098 $Res=$this->db->exec_sql($sql);
00099 }
00100 }
00101
00102
00103
00104
00105
00106
00107
00108 function display()
00109 {
00110 $r="";
00111 $r.= '<TD>'.$this->p_code.'</TD>';
00112 $r.= '<TD>'.h($this->p_comment).'</TD>';
00113 $r.= '<TD>'.$this->p_value.'</TD>';
00114
00115 return $r;
00116 }
00117
00118
00119
00120
00121
00122
00123
00124 function form()
00125 {
00126 $comment=new IText();
00127 $comment->name='p_comment';
00128 $comment->value=$this->p_comment;
00129 $comment->size=45;
00130 $value=new IPoste();
00131 $value->name='p_value';
00132 $value->value=$this->p_value;
00133 $value->size=7;
00134 $value->set_attribute('ipopup','ipop_account');
00135 $value->set_attribute('account','p_value');
00136 $poste=new IText();
00137 $poste->setReadOnly(true);
00138 $poste->size=strlen($this->p_code)+1;
00139 $poste->name='p_code';
00140 $poste->value=$this->p_code;
00141 $r="";
00142 $r.='<tr>';
00143 $r.='<td align="right"> Code </td>';
00144 $r.= '<TD>'.$poste->input().'</TD>';
00145 $r.='</tr>';
00146 $r.='<tr>';
00147 $r.='<td align="right"> Commentaire </td>';
00148 $r.= '<TD>'.$comment->input().'</TD>';
00149 $r.='</tr>';
00150 $r.='<tr>';
00151 $r.='<td align="right"> Poste comptable </td>';
00152 $r.= '<TD>'.$value->input();
00153 $r.='<span id="p_value_label"></span></td>';
00154 $r.='</tr>';
00155 $r.=Dossier::hidden();
00156 return $r;
00157
00158 }
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 function load()
00169 {
00170 if ( $this->p_code == -1 ) return "p_code non initialisé";
00171 $sql='select * from parm_code where p_code=$1 ';
00172
00173 $Res=$this->db->exec_sql($sql,array($this->p_code));
00174
00175 if ( Database::num_row($Res) == 0 ) return 'INCONNU';
00176 $row= Database::fetch_array($Res,0);
00177 $this->p_value=$row['p_value'];
00178 $this->p_comment=$row['p_comment'];
00179
00180 }
00181
00182 }