noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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.
 
 create ()
 display a form for creating a new report by importing it or set manually
 
 delete ()
 
 exist ($p_id=0)
 check if a report exist
 
 export_csv ($p_file)
 write to a file the definition of a report
 
 get_form_definition ()
 
 get_list ()
 get a list from form_definition of all defined form
 
 get_name ()
 Return the report's name.
 
 get_row ($p_start, $p_end, $p_type_date)
 return all the row and parse formula from a report
 
 input_name ($name)
 
 load ()
 the fr_id MUST be set before calling
 
 make_array ()
 To make a SELECT button with the needed value, it is used by the SELECT widget.
 
 save ()
 save into form and form_def
 
 set_form_definition ($form_definition)
 
 upload ()
 upload a definition of a report and insert it into the database
 

Data Fields

 $id
 
 $name
 
 $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 43 of file acc_report.class.php.

44 {
45 $this->form_definition=new Form_Definition_SQL($p_cn,$p_id);
46 }

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 244 of file acc_report.class.php.

245 {
246 require_once NOALYSS_INCLUDE."/template/acc_report-create.php";
247 }

◆ delete()

Acc_Report::delete ( )

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

136 {
137 $this->form_definition->delete();
138 }

◆ 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 233 of file acc_report.class.php.

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

References $c, $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 175 of file acc_report.class.php.

176 {
177 $this->load();
178
179 fputcsv($p_file,array($this->form_definition->getp("fr_label")));
180 $array=$this->form_definition->get_cn()->get_array("select fo_label,fo_pos,fo_formula
181 from form_detail
182 where fo_fr_id=$1
183 order by fo_pos"
184 ,array($this->form_definition->getp("fr_id"))
185 );
186
187 foreach ($array as $row)
188 {
189 fputcsv($p_file,array($row["fo_label"],
190 $row["fo_pos"],
191 $row["fo_formula"])
192 );
193 }
194
195 }
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 47 of file acc_report.class.php.

48 {
50 }

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 145 of file acc_report.class.php.

146 {
147 $sql="select fr_id,fr_label from form_definition order by fr_label";
148 $ret=$this->form_definition->cn->exec_sql($sql);
149 if ( Database::num_row($ret) == 0 ) return array();
151 $obj=array();
152 foreach ($array as $row)
153 {
154 $tmp=new Acc_Report($this->form_definition->cn);
155 $tmp->id=$row['fr_id'];
156 $tmp->name=$row['fr_label'];
157 $obj[]=clone $tmp;
158 }
159 return $obj;
160 }
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 59 of file acc_report.class.php.

60 {
61 return $this->form_definition->getp("fr_label");
62 }

◆ 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 70 of file acc_report.class.php.

71 {
72 if (DEBUGNOALYSS > 1) {
73 tracedebug("impress.debug.log",__FILE__."71.get_row({$p_start},{$p_end},{$p_type_date})");
74 }
75 $Res=$this->form_definition->cn->exec_sql("select fo_id ,
76 fo_fr_id,
77 fo_pos,
78 fo_label,
79 fo_formula,
80 fr_label from form_detail
81 inner join form_definition on fr_id=fo_fr_id
82 where fr_id =$1
83 order by fo_pos",array($this->form_definition->getp("fr_id")));
85 if ($Max==0)
86 {
87 $this->row=0;
88 return null;
89 }
90 $col=array();
91
92 if ( $p_type_date == '0' || $p_type_date=="periode") {
93 $type_date=0;
94 } elseif ($p_type_date == '1' || $p_type_date=="calendar") {
95 $type_date=1;
96 } else {
97 throw new Exception("ACR93:invalid type_date [ {$p_type_date} ] ");
98 }
99
100
101 for ($i=0;$i<$Max;$i++)
102 {
104
105 $col[]=Impress::parse_formula($this->form_definition->cn,
106 $l_line['fo_label'],
107 $l_line['fo_formula'],
108 $p_start,
109 $p_end,
110 true,
111 $type_date
112 );
113
114 } //for ($i
115 $this->row=$col;
116 return $col;
117 }
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="")
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 252 of file acc_report.class.php.

253 {
254 $name=new IText("fr_name",$name);
255 $name->id="fr_name_inplace";
256
257 $iName=new Inplace_Edit($name);
258 $iName->set_callback("ajax_misc.php");
259 $iName->add_json_param("op", "report_definition");
260 $iName->add_json_param("sa", "change_name");
261 $iName->add_json_param("gDossier", Dossier::id());
262 $iName->add_json_param("p_id", $this->form_definition->getp("fr_id"));
263 return $iName;
264 }

References $name.

◆ load()

Acc_Report::load ( )

the fr_id MUST be set before calling

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

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

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 165 of file acc_report.class.php.

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

References $sql.

◆ save()

Acc_Report::save ( )

save into form and form_def

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

123 {
124 $this->form_definition->save();
125 }

◆ set_form_definition()

Acc_Report::set_form_definition ( $form_definition)

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

52 : void
53 {
54 $this->form_definition=$form_definition;
55 }

References $form_definition.

◆ upload()

Acc_Report::upload ( )

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

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

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

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().

◆ $id

Acc_Report::$id

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

Referenced by upload().

◆ $name

Acc_Report::$name

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

Referenced by input_name().

◆ $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: