noalyss  Version-9
acc_report_row.class.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 
20 // Copyright Author Dany De Bontridder danydb@aevalys.eu
21 
22 /*!\file
23  * \brief this class maps the table form, which is a child table for formdef
24  */
25 
26 /*!\brief manipulate the form_def's child table (form) */
28 {
29  private static $variable=array(
30  "name"=>"fo_label",
31  "formula"=>"fo_formula",
32  "id"=>"fo_id",
33  "position"=>"fo_pos",
34  "form_id"=>"fo_fr_id",
35  "database"=>"db"
36  );
37  function __construct ($p_name=null,$p_formula=null)
38  {
39  $this->set_parameter("id",0);
40 
41  $this->set_parameter("name",$p_name);
42  $this->set_parameter("formula",$p_formula);
43  }
44  public function get_parameter($p_string)
45  {
46  if ( array_key_exists($p_string,self::$variable) )
47  {
48  $idx=self::$variable[$p_string];
49  return $this->$idx;
50  }
51  else
52  throw new Exception("Attribut inexistant $p_string");
53  }
54  public function set_parameter($p_string,$p_value)
55  {
56  if ( array_key_exists($p_string,self::$variable) )
57  {
58  $idx=self::$variable[$p_string];
59  $this->$idx=$p_value;
60  }
61  else
62  throw new Exception("Attribut inexistant $p_string");
63 
64 
65  }
66  public function get_info()
67  {
68  return var_export(self::$variable,true);
69  }
70  /*!\brief Convert an array into an array of row_rapport object
71  * the fo_id is 0, position = 0, the fo_frd_id (form_id) is
72  * the one of the current object, the db is also the current one
73  *\param $p_array contains the value
74  *\return an array of Acc_Report_Row object
75  */
76  public function from_array($p_array)
77  {
78  extract ($p_array, EXTR_SKIP);
79  $ret=array();
80  $ix=0;
81  $found=0;
82  foreach ( $p_array as $r)
83  {
84 
85  if ( isset(${'form'.$ix}) && isset ( ${'text'.$ix} ))
86  {
87  $obj=new Acc_Report_Row( ${'text'.$ix},${'form'.$ix});
88 
89  if ( isset(${'pos'.$ix}) && isNumber(${'pos'.$ix})==1 )
90  $obj->set_parameter("position",${'pos'.$ix});
91  else
92  {
93  $obj->set_parameter("position",$found);
94  $found++;
95  }
96 
97  $obj->fo_id=0;
98  $obj->fo_fr_id=$this->fo_fr_id;
99  $obj->db=$this->db;
100 
101  $ret[]=clone $obj;
102  }
103  $ix++;
104 
105  }
106  return $ret;
107  }
108  static function test_me()
109  {
111  $a=new Acc_Report_Row();
112  $array=array("text0"=>"test1",
113  "form0"=>"7%",
114  "text1"=>"test2",
115  "form1"=>"6%"
116  );
117  $a->db=$cn;
118  $b=$a->from_array($array);
119  print_r($b);
120  echo $a->get_info();
121  }
122 }
$ret
$ret
Definition: ajax_display_letter.php:52
$b
$b
Definition: export_balance_pdf.php:109
Acc_Report_Row\from_array
from_array($p_array)
Convert an array into an array of row_rapport object the fo_id is 0, position = 0,...
Definition: acc_report_row.class.php:76
Acc_Report_Row\__construct
__construct($p_name=null, $p_formula=null)
Definition: acc_report_row.class.php:37
Acc_Report_Row\test_me
static test_me()
Definition: acc_report_row.class.php:108
$ix
$ix
Definition: dashboard.php:161
Dossier\connect
static connect()
Definition: dossier.class.php:284
$array
$array
Definition: ajax_add_concerned_card.php:118
Acc_Report_Row\set_parameter
set_parameter($p_string, $p_value)
Definition: acc_report_row.class.php:54
Acc_Report_Row\$variable
static $variable
Definition: acc_report_row.class.php:29
Acc_Report_Row
manipulate the form_def's child table (form)
Definition: acc_report_row.class.php:27
$a
$a
Definition: ajax_add_concerned_card.php:111
Acc_Report_Row\get_info
get_info()
Definition: acc_report_row.class.php:66
isNumber
isNumber($p_int)
Definition: ac_common.php:221
$obj
$obj
Definition: ajax_accounting.php:45
$r
$r
Definition: ajax_add_concerned_card.php:56
$idx
$idx
Definition: ajax_bookmark.php:79
$cn
$cn
Definition: ajax_anc_accounting.php:31
Acc_Report_Row\get_parameter
get_parameter($p_string)
Definition: acc_report_row.class.php:44
$p_array
$p_array
Definition: ajax_view_mod_stock.php:34