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 class Acc_Report_Row
00028 {
00029 private static $variable=array(
00030 "name"=>"fo_label",
00031 "formula"=>"fo_formula",
00032 "id"=>"fo_id",
00033 "position"=>"fo_pos",
00034 "form_id"=>"fo_fr_id",
00035 "database"=>"db"
00036 );
00037 function __construct ($p_name=null,$p_formula=null)
00038 {
00039 $this->set_parameter("id",0);
00040
00041 $this->set_parameter("name",$p_name);
00042 $this->set_parameter("formula",$p_formula);
00043 }
00044 public function get_parameter($p_string)
00045 {
00046 if ( array_key_exists($p_string,self::$variable) )
00047 {
00048 $idx=self::$variable[$p_string];
00049 return $this->$idx;
00050 }
00051 else
00052 exit (__FILE__.":".__LINE__.'Erreur attribut inexistant');
00053 }
00054 public function set_parameter($p_string,$p_value)
00055 {
00056 if ( array_key_exists($p_string,self::$variable) )
00057 {
00058 $idx=self::$variable[$p_string];
00059 $this->$idx=$p_value;
00060 }
00061 else
00062 exit (__FILE__.":".__LINE__."$p_string ".'Erreur attribut inexistant');
00063
00064
00065 }
00066 public function get_info()
00067 {
00068 return var_export(self::$variable,true);
00069 }
00070
00071
00072
00073
00074
00075
00076 public function from_array($p_array)
00077 {
00078 extract ($p_array);
00079 $ret=array();
00080 $ix=0;
00081 $found=0;
00082 foreach ( $p_array as $r)
00083 {
00084
00085 if ( isset(${'form'.$ix}) && isset ( ${'text'.$ix} ))
00086 {
00087 $obj=new Acc_Report_Row( ${'text'.$ix},${'form'.$ix});
00088
00089 if ( isset(${'pos'.$ix}) && isNumber(${'pos'.$ix})==1 )
00090 $obj->set_parameter("position",${'pos'.$ix});
00091 else
00092 {
00093 $obj->set_parameter("position",$found);
00094 $found++;
00095 }
00096
00097 $obj->fo_id=0;
00098 $obj->fo_fr_id=$this->fo_fr_id;
00099 $obj->db=$this->db;
00100
00101 $ret[]=clone $obj;
00102 }
00103 $ix++;
00104
00105 }
00106 return $ret;
00107 }
00108 static function test_me()
00109 {
00110 $cn=new Database(dossier::id());
00111 $a=new Acc_Report_Row();
00112 $array=array("text0"=>"test1",
00113 "form0"=>"7%",
00114 "text1"=>"test2",
00115 "form1"=>"6%"
00116 );
00117 $a->db=$cn;
00118 $b=$a->from_array($array);
00119 print_r($b);
00120 echo $a->get_info();
00121 }
00122 }