noalyss Version-9
Public Member Functions | Static Public Member Functions
Anc_Balance_Simple Class Reference

manage the simple balance for CA, inherit from balance_ca More...

+ Inheritance diagram for Anc_Balance_Simple:
+ Collaboration diagram for Anc_Balance_Simple:

Public Member Functions

 display_csv ()
 Compute the csv export. More...
 
 display_form ($p_string="")
 Compute the form to display. More...
 
 display_html ()
 compute the html display More...
 
 display_pdf ()
 Display the result in pdf. More...
 
 load ()
 load the data from the database More...
 
 set_sql_filter ()
 Set the filter (account_date) More...
 
 show_button ($p_string="")
 Show the button to export in PDF or CSV. More...
 
- Public Member Functions inherited from Anc_Print
 __construct ($p_cn)
 
 check ()
 
 display_form ($p_hidden="")
 Compute the form to display. More...
 
 get_request ()
 complete the object with the data in $_REQUEST More...
 
 set_sql_filter ()
 Set the filter (account_date) More...
 

Static Public Member Functions

static test_me ()
 for testing and debuggind the class it must never be called from production system, it is intended only for developpers More...
 

Additional Inherited Members

- Data Fields inherited from Anc_Print
 $db
 
 $from
 
 $from_poste
 
 $to
 
 $to_poste
 

Detailed Description

manage the simple balance for CA, inherit from balance_ca

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

Member Function Documentation

◆ display_csv()

Anc_Balance_Simple::display_csv ( )

Compute the csv export.

Returns
string with the csv

Definition at line 228 of file anc_balance_simple.class.php.

229 {
230 $array=$this->load();
231 if ( is_array($array) == false )
232 {
233 return $array;
234
235 }
236 $csv=new Noalyss_Csv("ca_bal_simple");
237 $csv->send_header();
238 $r="";
239 foreach ( $array as $row)
240 {
241 // the name and po_id
242 $solde=($row['sum_cred']>$row['sum_deb'])?'C':'D';
243 $solde=($row['sum_cred']==$row['sum_deb'])?'0':$solde;
244 $csv->add($row['po_name']);
245 $csv->add($row['ga_description']);
246 $csv->add($row['sum_deb'],"number");
247 $csv->add($row['sum_cred'],"number");
248 $csv->add($row['solde'],"number");
249 $csv->add($row['debit'],"text");
250
251 $csv->write();
252 }
253 return $r;
254
255 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
load()
load the data from the database
Manage the CSV : manage files and write CSV record.

References $array, $csv, $r, $row, $solde, and load().

+ Here is the call graph for this function:

◆ display_form()

Anc_Balance_Simple::display_form (   $p_string = "")

Compute the form to display.

Parameters
$p_hiddenhidden tag to be included (gDossier,...)
Returns
string containing the data

Reimplemented from Anc_Print.

Definition at line 185 of file anc_balance_simple.class.php.

186 {
187 $r=parent::display_form($p_string);
188
189 $r.= HtmlInput::submit('Affiche', _('Rechercher'));
190
191 return $r;
192 }
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")

References $r, and HtmlInput\submit().

+ Here is the call graph for this function:

◆ display_html()

Anc_Balance_Simple::display_html ( )

compute the html display

Returns
string

Definition at line 124 of file anc_balance_simple.class.php.

125 {
126 $r="<table class=\"result\">";
127 $r.="<tr>";
128 $r.="<th>Poste comptable Analytique</th>";
129 $r.="<th>Groupe</th>";
130 $r.="<th>D&eacute;bit</th>";
131 $r.="<th>Cr&eacute;dit</th>";
132 $r.="<th>Solde</th>";
133 $r.="<th>D/C</th>";
134 $r.="</tr>";
135
136 $array=$this->load();
137 $odd=0;
138 if ( is_array($array) == false )
139 {
140 return $array;
141
142 }
143 bcscale(2);
144 $deb_side=0;$cred_side=0;
145 foreach ( $array as $row)
146 {
147 $odd++;
148
149 $r.=($odd%2==0)?'<tr class="odd">':'<tr class="even">';
150 // the name and po_id
151 // $r.=sprintf("<td>%s</td>",$row['po_id']);
152 $r.=sprintf("<td align=\"left\">%s</td>",h($row['po_name']));
153 $r.=sprintf("<td align=\"left\">%s</td>",h($row['ga_description']));
154 $r.=td(nbm($row['sum_deb']),' class="num"');
155 $r.=td(nbm($row['sum_cred']),' class="num"');
156 $r.=td(nbm($row['solde']),' class="num"');
157 $deb=($row['sum_deb'] > $row['sum_cred'])?"D":"C";
158 $deb=($row['solde'] == 0 )?'':$deb;
159 $r.=sprintf("<td>%s</td>",$deb);
160 $r.="</tr>";
161 $deb_side=bcadd($deb_side,$row['sum_deb']);
162 $cred_side=bcadd($cred_side,$row['sum_cred']);
163
164 }
165 $r.='<tr class="highlight">';
166 $r.=td(_("Total"));
167 $r.=td(" ");
168 $r.=td(nbm($deb_side),'class="num"');
169 $r.=td(nbm($cred_side),'class="num"');
170 $solde_side=abs(bcsub($deb_side,$cred_side));
171 $r.=td(nbm($solde_side),'class="num"');
172 if ( $deb_side == $cred_side ) $r.=td("=");
173 else if ( $deb_side > $cred_side ) $r.=td("D");
174 else $r.=td("C");
175 $r.="</table>";
176 return $r;
177 }
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
nbm($p_number, $p_dec=2)
format the number with a sep.
Definition: ac_common.php:137
h( $row[ 'oa_description'])
for($i=0;$i< $nb_jrn;$i++) $deb

References $array, $deb, $r, $row, h, load(), nbm(), and td().

+ Here is the call graph for this function:

◆ display_pdf()

Anc_Balance_Simple::display_pdf ( )

Display the result in pdf.

Returns
none

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

200 {
201 $array=$this->load();
202 $pdf=new PDFBalance_Simple($this->db);
203 $pdf->set_info($this->from_poste,$this->to_poste,$this->from,$this->to);
204 $pdf->AliasNbPages();
205 $pdf->AddPage();
206 $pdf->setTitle("Balance analytique",true);
207
208 $pdf->SetFont('DejaVu','',6);
209 for ($i=0;$i<count($array);$i++)
210 {
211 $row=$array[$i];
212 $pdf->write_cell(50,6,$row['po_name'],0,0,'L');
213 $pdf->write_cell(50,6,$row['ga_description'],0,0,'L');
214 $pdf->write_cell(20,6,sprintf('%s',nbm($row['sum_deb'])),0,0,'R');
215 $pdf->write_cell(20,6,sprintf('%s',nbm($row['sum_cred'])),0,0,'R');
216 $pdf->write_cell(20,6,sprintf('%s',nbm($row['solde'])),0,0,'R');
217 $pdf->write_cell(20,6,$row['debit'],0,0,'R');
218 $pdf->line_new();
219 }
220 $fDate=date('dmy-Hi');
221 $pdf->output('simple-balance-'.$fDate.'.pdf','D');
222
223 }
$anc_grandlivre from_poste
$anc_grandlivre to
$anc_grandlivre to_poste
$anc_grandlivre from
$SecUser db

References $array, $fDate, $i, $pdf, $row, db, from, from_poste, load(), nbm(), to, and to_poste.

+ Here is the call graph for this function:

◆ load()

Anc_Balance_Simple::load ( )

load the data from the database

Returns
array or null

Definition at line 40 of file anc_balance_simple.class.php.

41 {
42 $filter=$this->set_sql_filter();
43 // sum debit
44
45 $sql="select m.po_id,sum(deb) as sum_deb,sum(cred) as sum_cred,";
46 $sql.=" po_name||' '||coalesce(po_description,'') as po_name";
47 $sql.=",ga_description ";
48 $sql.=" from ";
49 $sql.=" (select po_id,case when oa_debit='t' then oa_amount else 0 end as deb,";
50 $sql.="case when oa_debit='f' then oa_amount else 0 end as cred ";
51 $sql.=" from operation_analytique join poste_analytique using(po_id)";
52 $sql.=(empty($filter) == false)?" where ".$filter:"";
53 $sql.=" ) as m join poste_analytique using (po_id)";
54 $sql.=" left join groupe_analytique on ( poste_analytique.ga_id=groupe_analytique.ga_id)";
55 $sql.=" where poste_analytique.pa_id=".$this->pa_id;
56 $sql.=" group by po_id,po_name,po_description,ga_description";
57 $sql.=" order by po_name";
58
59 $res=$this->db->exec_sql($sql);
60
61 if ( Database::num_row($res) == 0 ) {
62 $this->has_data=0;
63 return null;
64 }
65 $a=array();
66 $count=0;
68 foreach ($array as $row)
69 {
70 $a[$count]['po_id']=$row['po_id'];
71 $a[$count]['sum_deb']=$row['sum_deb'];
72 $a[$count]['sum_cred']=$row['sum_cred'];
73 $a[$count]['po_name']=$row['po_name'];
74 $a[$count]['ga_description']=$row['ga_description'];
75 $a[$count]['solde']=abs($row['sum_deb']-$row['sum_cred']);
76 $a[$count]['debit']=($row['sum_deb']>$row['sum_cred'])?"debit":"credit";
77 $count++;
78 }
79 $this->has_data=$count;
80 return $a;
81
82
83 }
$filter
set_sql_filter()
Set the filter (account_date)
static fetch_all($ret)
wrapper for the function pg_fetch_all
static num_row($ret)
wrapper for the function pg_num_rows
$count

References $a, $array, $count, $filter, $res, $row, $sql, db, DatabaseCore\fetch_all(), DatabaseCore\num_row(), and set_sql_filter().

Referenced by display_csv(), display_html(), and display_pdf().

+ Here is the call graph for this function:

◆ set_sql_filter()

Anc_Balance_Simple::set_sql_filter ( )

Set the filter (account_date)

Returns
return the string to add to load

Reimplemented from Anc_Print.

Definition at line 91 of file anc_balance_simple.class.php.

92 {
93 $sql="";
94 $and="";
95 if ( $this->from != "" )
96 {
97 $sql.=" oa_date >= to_date('".$this->from."','DD.MM.YYYY')";
98 $and=" and ";
99 }
100 if ( $this->to != "" )
101 {
102 $sql.=" $and oa_date <= to_date('".$this->to."','DD.MM.YYYY')";
103 $and=" and ";
104 }
105 if ( $this->from_poste != "" )
106 {
107 $sql.=" $and upper(po_name)>= upper('".$this->from_poste."')";
108 $and=" and ";
109 }
110 if ( $this->to_poste != "" )
111 {
112 $sql.=" $and upper(po_name)<= upper('".$this->to_poste."')";
113 $and=" and ";
114 }
115 return $sql;
116
117 }

References $sql, from, from_poste, to, and to_poste.

Referenced by load().

◆ show_button()

Anc_Balance_Simple::show_button (   $p_string = "")

Show the button to export in PDF or CSV.

Parameters
$url_csvurl of the csv
$url_pdfurl of the pdf
$p_stringhidden data to include in the form
Returns
string with the button

Definition at line 265 of file anc_balance_simple.class.php.

266 {
267 $r="";
268 $r.= '<form method="GET" action="export.php" style="display:inline">';
269 $r.= $p_string;
270 $r.= dossier::hidden();
271 $r.= HtmlInput::hidden("to",$this->to);
272 $r.= HtmlInput::hidden("act","PDF:AncBalSimple");
273
274 $r.= HtmlInput::hidden("from",$this->from);
275 $r.= HtmlInput::hidden("pa_id",$this->pa_id);
276 $r.= HtmlInput::hidden("from_poste",$this->from_poste);
277 $r.= HtmlInput::hidden("to_poste",$this->to_poste);
278 $r.=HtmlInput::submit('bt_pdf',"Export en PDF");
279 $r.= '</form>';
280
281 $r.= '<form method="GET" action="export.php" style="display:inline">';
282 $r.= HtmlInput::hidden("act","CSV:AncBalSimple");
283 $r.= HtmlInput::hidden("to",$this->to);
284 $r.= HtmlInput::hidden("from",$this->from);
285 $r.= HtmlInput::hidden("pa_id",$this->pa_id);
286 $r.= HtmlInput::hidden("from_poste",$this->from_poste);
287 $r.= HtmlInput::hidden("to_poste",$this->to_poste);
288 $r.= $p_string;
289 $r.= dossier::hidden();
290 $r.=HtmlInput::submit('bt_csv',"Export en CSV");
291 $r.= '</form>';
292 return $r;
293 }
$anc pa_id
static hidden($p_name, $p_value, $p_id="")

References $r, from, from_poste, HtmlInput\hidden(), pa_id, HtmlInput\submit(), to, and to_poste.

+ Here is the call graph for this function:

◆ test_me()

static Anc_Balance_Simple::test_me ( )
static

for testing and debuggind the class it must never be called from production system, it is intended only for developpers

Parameters

param

Parameters

return none

Definition at line 306 of file anc_balance_simple.class.php.

307 {
308 // call the page with ?gDossier=14
310
312 $bal->get_request();
313
314 echo '<form method="GET">';
315
316 echo $bal->display_form();
317 echo '</form>';
318 if ( isset($_GET['result']))
319 {
320 echo $bal->show_button("","");
321 echo "<h1>HTML</h1>";
322 echo $bal->display_html();
323 echo "<h1>CSV</h1>";
324 echo $bal->display_csv();
325 /* echo "<h1>pdf</h1>"; */
326 /* echo $bal->display_pdf(); */
327
328 }
329
330 }
$_GET['qcode']
manage the simple balance for CA, inherit from balance_ca
static connect()

References $_GET, $a, $bal, and Dossier\connect().

+ Here is the call graph for this function:

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