Plugins  LAST
 All Data Structures Files Functions Variables Pages
class_tva_parameter.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This file is part of NOALYSS.
4  *
5  * NOALYSS is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * NOALYSS is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with NOALYSS; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 /* $Revision$ */
20 
21 // Copyright (c) 2002 Author Dany De Bontridder dany@alchimerys.be
22 
23 /*!\file
24  * \brief
25  */
26 
27 
28 /*!\brief
29  *
30  *
31  */
33 {
34  private static $variable=array("code"=>"pcode","value"=>"pvalue","account"=>'paccount');
35  function __construct ($p_init) {
36  $this->cn=$p_init;
37  }
38  public function get_parameter($p_string) {
39  if ( array_key_exists($p_string,self::$variable) ) {
40  $idx=self::$variable[$p_string];
41  return $this->$idx;
42  }
43  else
44  throw new Exception("Attribut inexistant $p_string");
45  }
46  public function set_parameter($p_string,$p_value) {
47  if ( array_key_exists($p_string,self::$variable) ) {
48  $idx=self::$variable[$p_string];
49  $this->$idx=$p_value;
50  }
51  else
52  throw new Exception("Attribut inexistant $p_string");
53 
54 
55  }
56  public function get_info() { return var_export(self::$variable,true); }
57  public function verify() {
58  // Verify that the elt we want to add is correct
59  }
60  /**
61  *@brief retrieve * row thanks a condition
62  */
63  public function seek($cond,$p_array=null)
64  {
65  /*
66  $sql="select * from * where $cond";
67  return $this->cn->get_array($cond,$p_array)
68  */
69  }
70  public function insert() {
71  if ( $this->verify() != 0 ) return;
72 
73  $sql="insert into tva_belge.parameter (pcode,pvalue,paccount) ".
74  " values ($1,$2) ";
75  $this->tva_id=$this->cn->exec_sql(
76  $sql,
77  array($this->pcode,
78  $this->pvalue,
79  $this->paccount)
80  );
81 
82  }
83 
84  public function update() {
85  if ( $this->verify() != 0 ) return;
86 
87  $sql="update tva_belge.parameter set pvalue=$1,paccount=$2 ".
88  " where pcode = $3";
89  $res=$this->cn->exec_sql(
90  $sql,
91  array($this->pvalue,
92  $this->paccount,
93  $this->pcode)
94  );
95 
96  }
97 
98  public function load() {
99 
100  $sql="select pcode from tva_belge.parameter where pcode=$1";
101 
102  $res=$this->cn->get_array(
103  $sql,
104  array($this->pcode)
105  );
106 
107  if ( count($res) == 0 ) return -1;
108  for ($i=0;$i<count($res);$i++) { $this->pcode=$res[$i]['pcode'];$this->pvalue=$res[$i]['pvalue'];$this->paccount=$res[$i]['paccount']; }
109  return 0;
110  }
111  /**
112  *@brief check that this accounting does exist in the accounting plan
113  *@param $p_code code to check
114  *@return the number of row found (0 if none)
115  */
116  public function exist_pcmn($p_code) {
117  $count=$this->cn->get_value('select count(*) from tmp_pcmn where pcm_val::text like $1',array($p_code));
118  return $count;
119  }
120  /**
121  *@brief show the content of the table tva_belge.parameter
122  */
123  public function display() {
124  global $cn;$cn=$this->cn;
125 
126  $res=$this->cn->get_array("select pcode from tva_belge.parameter");
127 
128  ob_start();
129  require_once('form_parameter.php');
130  $r=ob_get_contents();
131  ob_end_clean();
132  return $r;
133  }
134  /*!\brief
135  *\param
136  *\return
137  *\note
138  *\see
139  *\todo
140  */
141  static function test_me() {
142  }
143 
144 }
145 
146 /* test::test_me(); */
seek($cond, $p_array=null)
retrieve * row thanks a condition
$r
set_parameter($p_string, $p_value)
get_parameter($p_string)
exist_pcmn($p_code)
check that this accounting does exist in the accounting plan
$res
display()
show the content of the table tva_belge.parameter
$sql
global $cn