noalyss Version-9
export_form_pdf.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19*/
20
21// Copyright Author Dany De Bontridder danydb@aevalys.eu
22/*! \file
23 * \brief Send a report in PDF
24 */
25if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
26include_once("class/acc_report.class.php");
27include_once("lib/ac_common.php");
28include_once("lib/impress.class.php");
29require_once NOALYSS_INCLUDE.'/header_print.php';
31
32$form_id=$http->get('form_id','number');
33$type_periode=$http->get('type_periode',"number");
34
35
37
39
42$Libelle=sprintf("%s ",$Form->get_name());
43$pdf= new PDF($cn);
44$pdf->setDossierInfo($Libelle);
45$pdf->AliasNbPages();
46$pdf->AddPage();
47$pdf->SetAuthor('NOALYSS');
48$pdf->setTitle("Rapport ".$Libelle,true);
49
50// Step ??
51//--
52$step=$http->get('p_step',"string",0);
53if ( $step == 0 )
54{
55 // No step asked
56 //--
57 if ( $_GET ['type_periode'] == 0 )
58 {
59 $from_periode=$http->get('from_periode',"number");
60 $to_periode=$http->get('to_periode',"number");
62 }
63 else
64 {
65 try {
66 $from_date=$http->get('from_date',"date");
67 } catch (Exception $e) {
68 $from_date=date('d.m.Y');
69 }
70 try
71 {
72 $to_date=$http->get('to_date',"date");
73 }
74 catch (Exception $exc)
75 {
76 $to_date=date('d.m.Y');
77 }
78
80 }
81
82}
83else
84{
85 // yes with step
86 //--
87 $from_periode=$http->get('from_periode',"number");
88 $to_periode=$http->get('to_periode',"number");
89 $p_step=$http->get('p_step',"number");
90
92 {
94 if ( $periode == null ) continue;
95 $array[]=$Form->get_row($e,$e,'periode');
96 $periode_name[]=$periode;
97 }
98
99}
100
101
102$pdf->SetFont('DejaVuCond','',8);
103
104// without step
105if ( $step == 0 )
106{
107 if ( $type_periode == 0 )
108 {
111 {
112 $periode=sprintf(_("Période de %s à %s"),$q,getPeriodeName($cn,$to_periode));
113 }
114 else
115 {
116 $periode=sprintf(_("Période %s"),$q);
117 }
118 }
119 else
120 {
121 $periode=sprintf(_("Date %s jusque %s"),$from_date,$to_date);
122 }
123 $pdf->write_cell(0,7,$periode,'B');
124 $pdf->line_new();
125 for ($i=0;$i<count($array);$i++)
126 {
127 $pdf->write_cell(160,6,$array[$i]['desc']);
128 $pdf->write_cell(30,6,sprintf('% 12.2f',$array[$i]['montant']),0,0,'R');
129 $pdf->line_new();
130 }
131}
132else
133{ // With Step
134 $a=0;
135 foreach ($array as $e)
136 {
137 $pdf->write_cell(0,7,$periode_name[$a],'B');
138 $pdf->line_new();
139 $a++;
140 for ($i=0;$i<count($e);$i++)
141 {
142 $pdf->write_cell(160,6,$e[$i]['desc']);
143 $pdf->write_cell(30,6,sprintf('% 12.2f',$e[$i]['montant']),0,0,'R');
144 $pdf->line_new();
145 }
146 }
147}
148
149$fDate=date('dmy-Hi');
150$pdf->Output('rapport-'.$fDate.'.pdf','D');
151
152?>
getPeriodeName($p_cn, $p_id, $pos='p_start')
Show the periode which found thanks its id.
Definition: ac_common.php:605
$input_from id
Definition: balance.inc.php:63
$_GET['qcode']
Class rapport Create, view, modify and parse report.
static connect()
manage the http input (get , post, request) and extract from an array
API for creating PDF, unicode, based on tfpdf.
Definition: pdf.class.php:34
$gDossier
$form_id
foreach($array as $e) $fDate
$Libelle
$to_periode
$type_periode