noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
class_acc_report_row.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS 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  *   NOALYSS 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 NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 
00022 /*!\file
00023  * \brief this class  maps the table form, which is a child table for formdef
00024  */
00025 
00026 /*!\brief  manipulate the form_def's child table (form) */
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     /*!\brief Convert an array into an array of row_rapport object
00071      *        the fo_id is 0, position = 0, the fo_frd_id (form_id) is
00072      *  the one of the current object, the db is also the current one
00073      *\param $p_array contains the value
00074      *\return an array of Acc_Report_Row object
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 }
 All Data Structures Namespaces Files Functions Variables Enumerations