noalyss Version-9
impress_rapport.inc.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19/*! \file
20 * \brief print first the report in html and propose to print it in pdf
21 * file included by user_impress
22 *
23 * some variable are already defined ($cn, $g_user ...)
24 */
25if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
27$access_code=$http->request('ac');
28//-----------------------------------------------------
29// If print is asked
30// First time in html
31// after in pdf or cvs
32//-----------------------------------------------------
33if ( isset( $_GET['bt_html'] ) )
34{
35
36 // step asked ?
37 //--
38 try
39 {
40 $Form=new Acc_Report($cn,$http->get('form_id',"number"));
41 $Form->get_name();
42 $type_periode=$http->get("type_periode", "number", -1);
43
44 if ($type_periode==1)
45 {
46 $from_date=$http->get("from_date", "date");
47 $to_date=$http->get("to_date", "date");
48 $array=$Form->get_row(
52 }
53 // Printing asked by range of date
54 if ($type_periode==0)
55 {
56 $from_periode=$http->get("from_periode");
57 $to_periode=$http->get("to_periode");
58 $p_step=$http->get('p_step');
59 if ( $http->get("p_step","number")==1) {
60 // step are asked
61 //--
63 $e+=$p_step)
64 {
65
67 if ($periode==null)
68 continue;
69 $array[]=$Form->get_row($e, $e, $type_periode);
70 $periode_name[]=$periode;
71 }
72 } else {
73 $array=$Form->get_row(
74 $http->get('from_periode',"number"),
75 $http->get('to_periode',"number"),
77 }
78 }
79 }
80 catch (Exception $ex)
81 {
82 alert($ex->getMessage());
83
84 }
85
86
87
88 $rep="";
89
90 $hid=new IHidden();
91 echo '<div class="content">';
92 $form_id=$Form->get_form_definition()->getp("fr_id");
93 $form_label=h($Form->get_form_definition()->getp("fr_label"));
94
95 if ($type_periode == 0)
96 {
97
99 echo '<h2 >'.$form_id
100 ." ".$form_label
101 ." - ".getPeriodeName($cn,$from_periode,'p_start')
102 ." ".$t
103 .'</h2>';
104 }
105 else
106 {
107 echo '<h2 >'.$form_id." ".$form_label.
108 ' Date :'.
110 " au ".
111 $to_date.
112 '</h2>';
113 }
114 echo '<table >';
115 echo '<TR>';
116 $id=uniqid("export_");
117
118 echo '<TD><form method="GET" ACTION="?" ';
119 printf( 'id="%s" onsubmit="download_document_form(\'%s\')">',$id,$id);
120
121 echo dossier::hidden().
122 $hid->input("form_id",$form_id).
123 HtmlInput::submit('bt_other',"Autre Rapport").
124 $hid->input("type","rapport").
125 $hid->input("ac",$access_code)."</form></TD>";
126
127 echo '<TD><form method="GET" ACTION="export.php" ';
128 $id=uniqid("export_");
129 printf( 'id="%s" onsubmit="download_document_form(\'%s\')">',$id,$id);
130
131 echo HtmlInput::submit('bt_pdf',"Export PDF").
132 HtmlInput::hidden('act','PDF:report').
133 dossier::hidden().
134 $hid->input("type","rapport").
135 $hid->input("ac",$access_code).
136 $hid->input("form_id",$form_id);
137 if ( isset($from_periode)) echo $hid->input("from_periode",$from_periode);
138 if ( isset($to_periode)) echo $hid->input("to_periode",$to_periode);
139 if (isset($p_step)) echo $hid->input("p_step",$p_step);
140 if ( isset($from_date)) echo $hid->input("from_date",$from_date);
141 if ( isset($to_date)) echo $hid->input("to_date",$to_date);
142 echo $hid->input("type_periode",$type_periode);
143
144
145
146
147 echo "</form></TD>";
148
149 echo '<TD><form method="GET" ACTION="export.php" ';
150 $id=uniqid("export_");
151 printf( 'id="%s" onsubmit="download_document_form(\'%s\')">',$id,$id);
152
153 echo HtmlInput::hidden('act','CSV:report').
154 HtmlInput::submit('bt_csv',"Export CSV").
155 dossier::hidden().
156 $hid->input("type","form").
157 $hid->input("ac",$access_code).
158 $hid->input("form_id",$form_id);
159 if ( isset($from_periode)) echo $hid->input("from_periode",$from_periode);
160 if ( isset($to_periode)) echo $hid->input("to_periode",$to_periode);
161 if (isset($p_step)) echo $hid->input("p_step",$p_step);
162 if ( isset($from_date)) echo $hid->input("from_date",$from_date);
163 if ( isset($to_date)) echo $hid->input("to_date",$to_date);
164 echo $hid->input("type_periode",$_GET['type_periode']);
165
166
167 echo "</form></TD>";
168
169 echo "</TR>";
170
171 echo "</table>";
172
173 if ( empty($array) )
174 exit;
175 if ( $type_periode== 0 )
176 {
177 if ( $p_step == 0)
178 { // check the step
179 // show tables
181 }
182 else
183 {
184 $a=0;
185 foreach ( $array as $e)
186 {
187 printf( '<h2>%s</h2> ',$periode_name[$a]);
188 $a++;
190 }
191 }
192 }
193 else
194 {
196 }
197 echo "</div>";
198 exit;
199}
200
201//-----------------------------------------------------
202// Show the jrn and date
203//-----------------------------------------------------
204$ret=$cn->make_array("select fr_id,fr_label
205 from form_definition
206 order by fr_label");
207if ( sizeof($ret) == 0 )
208{
209 echo "Aucun Rapport";
210 return;
211}
212//-----------------------------------------------------
213// Form
214//-----------------------------------------------------
215echo '<div class="content">';
216$exercice=$http->get("exercice","number",$g_user->get_exercice());
217/*
218 * Let you change the exercice
219 */
220echo '<fieldset><legend>'._('Exercice').'</legend>';;
221echo '<form method="GET" ';
222printf( ' onsubmit="waiting_box()">');
223
224echo 'Choisissez un autre exercice :';
226$wex=$ex->select('exercice',$exercice,
227 sprintf(' onchange="updatePeriode(\'%s\',\'exercice\',\'from_periode\',\'to_periode\',1)"',Dossier::id(),$exercice));
228echo $wex->input();
229echo dossier::hidden();
230echo HtmlInput::get_to_hidden(array('ac','type'));
231
232echo '</fieldset>';
233
234
235echo '<FORM METHOD="GET" onsubmit="waiting_box()">';
237echo $hidden->input("ac",$access_code);
238echo $hidden->input("type","rapport");
239echo dossier::hidden();
240
241echo '<TABLE><TR>';
243$w->selected=$http->request("form_id","string",0);
244$w->table=1;
245print td(_("Choisissez le rapport"));
246print $w->input("form_id",$ret);
247print '</TR>';
248//-- calendrier ou periode comptable
249$aCal=array(
250 array('value'=>0,'label'=>_('P&eacute;riode comptable')),
251 array('value'=>1,'label'=>_('Calendrier'))
252 );
253
254$w->javascript=' onchange=enable_type_periode();';
255$w->id='type_periode';
256echo '<tr>';
257print td('Type de date : ');
258echo $w->input('type_periode',$aCal);
259echo '</Tr>';
260$w->javascript='';
261print '<TR>';
262// filter on the current year
263$filter_year=" where p_exercice='".sql_string($exercice)."'";
265$periode_start_select->table=1;
267$periode_end_select->table=1;
268$periode_start=$cn->make_array("select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end");
269print td("P&eacute;riode comptable : Depuis");
270echo $periode_start_select->input('from_periode',$periode_start);
271print td(" jusqu'à ");
272$periode_end=$cn->make_array("select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end");
273print $periode_end_select->input('to_periode',$periode_end);
274print "</TR>";
275echo '<tr>';
276//--- by date
277$date_from=new IDate('from_date');
278$date_from->id='from_date';
279$date_to=new IDate('to_date');
280$date_to->id='to_date';
281
282echo td(_("Calendrier depuis :"));
283echo td($date_from->input('from_date'));
284echo td(_("jusque"));
285echo td($date_to->input('to_date'));
286echo '</tr>';
287
288$aStep=array(
289 array('value'=>0,'label'=>_('Pas d\'étape')),
290 array('value'=>1,'label'=>_('1 mois'))
291 );
292echo '<tr>';
293echo td(_('Par étape de'));
294$w->id='p_step';
295echo $w->input('p_step',$aStep);
296echo '</TR>';
297
298echo '</TABLE>';
299echo '<span class="notice"> '._('Attention : vous ne pouvez pas utiliser les &eacute;tapes avec les dates calendriers.').'</span>';
300echo '<br>';
301echo '<span class="notice">'._('Les clauses FROM sont ignorés avec les dates calendriers').'</span>';
302echo '<br>';
303print HtmlInput::submit('bt_html',_('Visualisation'));
304
305echo '</FORM>';
306echo '<script>enable_type_periode()</script>';
307echo '<hr>';
308echo '</div>';
309//-----------------------------------------------------
310// Function
311//-----------------------------------------------------
313{
314
315 echo '<TABLE class="result">';
316 echo "<TR>".
317 "<TH> Description </TH>".
318 "<TH> montant </TH>".
319 "</TR>";
320 $i=0;
321 foreach ( $p_array as $op )
322 {
323 $i++;
324 $class= ( $i % 2 == 0 )?' class="odd"':' class="even"';
325
326 echo "<TR $class>".
327 "<TD>".h($op['desc'])."</TD>".
328 "<TD align=\"right\">".nbm($op['montant'])."</TD>".
329 "</TR>";
330 }
331 echo "</table>";
332
333}
334
335?>
getPeriodeName($p_cn, $p_id, $pos='p_start')
Show the periode which found thanks its id.
Definition: ac_common.php:605
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738
$op
Definition: ajax_admin.php:38
h( $row[ 'oa_description'])
$_GET['qcode']
$class
Class rapport Create, view, modify and parse report.
static id()
return the 'gDossier' value after a check
about the accountancy period (usually 1 year starting in January until december) = exercice
static hidden($p_name, $p_value, $p_id="")
static get_to_hidden($array)
transform $_GET data to hidden
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
Definition: idate.class.php:34
Html Input.
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
for($e=0; $e< count($afiche); $e++) exit
$form_id
$type_periode
global $http
global $g_user
$periode_end_select
ShowReportResult($p_array)
$periode_start_select
if(isset( $_GET['bt_html'])) $ret