noalyss Version-9
Public Member Functions | Data Fields | Private Attributes
Acc_Report Class Reference

Class rapport Create, view, modify and parse report. More...

+ Collaboration diagram for Acc_Report:

Public Member Functions

 __construct ($p_cn, $p_id=-1)
 Constructor. More...
 
 create ()
 display a form for creating a new report by importing it or set manually More...
 
 delete ()
 
 exist ($p_id=0)
 check if a report exist More...
 
 export_csv ($p_file)
 write to a file the definition of a report More...
 
 get_form_definition ()
 
 get_list ()
 get a list from form_definition of all defined form More...
 
 get_name ()
 Return the report's name. More...
 
 get_row ($p_start, $p_end, $p_type_date)
 return all the row and parse formula from a report More...
 
 input_name ($name)
 
 load ()
 the fr_id MUST be set before calling More...
 
 make_array ()
 To make a SELECT button with the needed value, it is used by the SELECT widget. More...
 
 save ()
 save into form and form_def More...
 
 set_form_definition ($form_definition)
 
 upload ()
 upload a definition of a report and insert it into the database More...
 

Data Fields

 $nb
 
 $row
 

Private Attributes

 $form_definition
 

Detailed Description

Class rapport Create, view, modify and parse report.

Definition at line 32 of file acc_report.class.php.

Constructor & Destructor Documentation

◆ __construct()

Acc_Report::__construct (   $p_cn,
  $p_id = -1 
)

Constructor.

Definition at line 41 of file acc_report.class.php.

42 {
43 $this->form_definition=new Form_Definition_SQL($p_cn,$p_id);
44 }
ORM abstract of the table public.form_definition.

References $p_id.

Member Function Documentation

◆ create()

Acc_Report::create ( )

display a form for creating a new report by importing it or set manually

Definition at line 242 of file acc_report.class.php.

243 {
244 require_once NOALYSS_INCLUDE."/template/acc_report-create.php";
245 }

◆ delete()

Acc_Report::delete ( )

Definition at line 133 of file acc_report.class.php.

134 {
135 $this->form_definition->delete();
136 }

◆ exist()

Acc_Report::exist (   $p_id = 0)

check if a report exist

Parameters
$p_id,optional,ifgiven check the report with this fr_id
Returns
return true if the report exist otherwise false

Definition at line 231 of file acc_report.class.php.

232 {
233 $c=$this->form_definition->getp("fr_id");
234 if ( $p_id != 0 ) $c=$p_id;
235 $ret=$this->form_definition->cn->exec_sql("select fr_label from form_definition where fr_id=$1",array($c));
236 if (Database::num_row($ret) == 0) return false;
237 return true;
238 }
static num_row($ret)
wrapper for the function pg_num_rows

References $p_id, $ret, and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ export_csv()

Acc_Report::export_csv (   $p_file)

write to a file the definition of a report

Parameters
p_fileis the file name (default php://output)

Definition at line 173 of file acc_report.class.php.

174 {
175 $this->load();
176
177 fputcsv($p_file,array($this->form_definition->getp("fr_label")));
178 $array=$this->form_definition->get_cn()->get_array("select fo_label,fo_pos,fo_formula
179 from form_detail
180 where fo_fr_id=$1
181 order by fo_pos"
182 ,array($this->form_definition->getp("fr_id"))
183 );
184
185 foreach ($array as $row)
186 {
187 fputcsv($p_file,array($row["fo_label"],
188 $row["fo_pos"],
189 $row["fo_formula"])
190 );
191 }
192
193 }
load()
the fr_id MUST be set before calling

References $array, $row, and load().

+ Here is the call graph for this function:

◆ get_form_definition()

Acc_Report::get_form_definition ( )

Definition at line 45 of file acc_report.class.php.

46 {
48 }

References $form_definition.

◆ get_list()

Acc_Report::get_list ( )

get a list from form_definition of all defined form

Returns
array of object rapport

Definition at line 143 of file acc_report.class.php.

144 {
145 $sql="select fr_id,fr_label from form_definition order by fr_label";
146 $ret=$this->form_definition->cn->exec_sql($sql);
147 if ( Database::num_row($ret) == 0 ) return array();
149 $obj=array();
150 foreach ($array as $row)
151 {
152 $tmp=new Acc_Report($this->form_definition->cn);
153 $tmp->id=$row['fr_id'];
154 $tmp->name=$row['fr_label'];
155 $obj[]=clone $tmp;
156 }
157 return $obj;
158 }
Class rapport Create, view, modify and parse report.
static fetch_all($ret)
wrapper for the function pg_fetch_all

References $array, $obj, $ret, $row, $sql, $tmp, DatabaseCore\fetch_all(), and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ get_name()

Acc_Report::get_name ( )

Return the report's name.

Definition at line 57 of file acc_report.class.php.

58 {
59 return $this->form_definition->getp("fr_label");
60 }

◆ get_row()

Acc_Report::get_row (   $p_start,
  $p_end,
  $p_type_date 
)

return all the row and parse formula from a report

Parameters
$p_startstart periode
$p_endend periode
$p_type_datetype of the date : periode (or 0) or calendar (or 1)

Definition at line 68 of file acc_report.class.php.

69 {
70 if (DEBUGNOALYSS > 1) {
71 tracedebug("impress.debug.log",__FILE__."71.get_row({$p_start},{$p_end},{$p_type_date})");
72 }
73 $Res=$this->form_definition->cn->exec_sql("select fo_id ,
74 fo_fr_id,
75 fo_pos,
76 fo_label,
77 fo_formula,
78 fr_label from form_detail
79 inner join form_definition on fr_id=fo_fr_id
80 where fr_id =$1
81 order by fo_pos",array($this->form_definition->getp("fr_id")));
83 if ($Max==0)
84 {
85 $this->row=0;
86 return null;
87 }
88 $col=array();
89
90 if ( $p_type_date == '0' || $p_type_date=="periode") {
91 $type_date=0;
92 } elseif ($p_type_date == '1' || $p_type_date=="calendar") {
93 $type_date=1;
94 } else {
95 throw new Exception("ACR93:invalid type_date [ {$p_type_date} ] ");
96 }
97
98
99 for ($i=0;$i<$Max;$i++)
100 {
102
103 $col[]=Impress::parse_formula($this->form_definition->cn,
104 $l_line['fo_label'],
105 $l_line['fo_formula'],
106 $p_start,
107 $p_end,
108 true,
109 $type_date
110 );
111
112 } //for ($i
113 $this->row=$col;
114 return $col;
115 }
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static parse_formula($p_cn, $p_label, $p_formula, $p_start, $p_end, $p_eval=true, $p_type_date=0, $p_sql="")
$Res
$p_end
$p_start
if( $delta< 0) elseif( $delta==0)

References $i, $Max, $p_end, $p_start, $Res, elseif, DatabaseCore\fetch_array(), DatabaseCore\num_row(), and Impress\parse_formula().

+ Here is the call graph for this function:

◆ input_name()

Acc_Report::input_name (   $name)
Parameters
IText$name

Definition at line 250 of file acc_report.class.php.

251 {
252 $name=new IText("fr_name",$name);
253 $name->id="fr_name_inplace";
254
255 $iName=new Inplace_Edit($name);
256 $iName->set_callback("ajax_misc.php");
257 $iName->add_json_param("op", "report_definition");
258 $iName->add_json_param("sa", "change_name");
259 $iName->add_json_param("gDossier", Dossier::id());
260 $iName->add_json_param("p_id", $this->form_definition->getp("fr_id"));
261 return $iName;
262 }
static id()
return the 'gDossier' value after a check
Html Input.
Definition: itext.class.php:30
Inplace_edit class for ajax update of HtmlInput object.

References $name, and Dossier\id().

+ Here is the call graph for this function:

◆ load()

Acc_Report::load ( )

the fr_id MUST be set before calling

Definition at line 128 of file acc_report.class.php.

128 :void
129 {
130 $this->form_definition->load();
131
132 }

Referenced by export_csv().

◆ make_array()

Acc_Report::make_array ( )

To make a SELECT button with the needed value, it is used by the SELECT widget.

Returns
string with html code

Definition at line 163 of file acc_report.class.php.

164 {
165 $sql=$this->form_definition->cn->make_array("select fr_id,fr_label from form_definition order by fr_label");
166 return $sql;
167 }

References $sql.

◆ save()

Acc_Report::save ( )

save into form and form_def

Definition at line 120 of file acc_report.class.php.

121 {
122 $this->form_definition->save();
123 }

◆ set_form_definition()

Acc_Report::set_form_definition (   $form_definition)

Definition at line 50 of file acc_report.class.php.

50 : void
51 {
52 $this->form_definition=$form_definition;
53 }

References $form_definition.

◆ upload()

Acc_Report::upload ( )

upload a definition of a report and insert it into the database

Definition at line 197 of file acc_report.class.php.

198 {
199 if ( empty ($_FILES) ) return;
200 if ( noalyss_strlentrim($_FILES['report']['tmp_name'])== 0 )
201 {
202 alert("Nom de fichier est vide");
203 return;
204 }
205 $file_report=tempnam('tmp','file_report');
206 if ( move_uploaded_file($_FILES['report']['tmp_name'],$file_report))
207 {
208 // File is uploaded now we can try to parse it
209 $file=fopen($file_report,'r');
210 $data=fgetcsv($file);
211 if ( empty($data) ) return;
212 $array=array();
213 $cn=$this->form_definition->cn;
214 $id=$this->form_definition->getp("fr_id");
215 while($data=fgetcsv($file))
216 {
218 $obj->setp("fo_label",$data[0]);
219 $obj->setp("fo_pos",$data[1]);
220 $obj->set("fo_formula",$data[2]);
221 $obj->setp("fo_fr_id",$id);
222 $obj->insert();
223 }
224 }
225 }
noalyss_strlentrim($p_string)
Definition: ac_common.php:1549
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738
ORM abstract of the table public.form_detail.

References $array, $cn, $data, $file, $id, $obj, alert(), and noalyss_strlentrim().

+ Here is the call graph for this function:

Field Documentation

◆ $form_definition

Acc_Report::$form_definition
private

form_definition_sql

Definition at line 35 of file acc_report.class.php.

Referenced by get_form_definition(), and set_form_definition().

◆ $nb

Acc_Report::$nb

Definition at line 37 of file acc_report.class.php.

◆ $row

Acc_Report::$row

Definition at line 36 of file acc_report.class.php.

Referenced by export_csv(), and get_list().


The documentation for this class was generated from the following file: