noalyss Version-9
export_form_csv.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// Copyright Author Dany De Bontridder danydb@aevalys.eu
20/*! \file
21 * \brief Send a report in CSV format
22 */
23if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
24require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
26
28
29/* Admin. Dossier */
31
32$form_id=$http->get('form_id','number');
33$type_periode=$http->get('type_periode',"number");
34
35
36
38$Form->get_name();
39
40$export=new Noalyss_Csv('report');
41$export->send_header();
42// Step ?
43//--
44$p_step=$http->get('p_step',"string",0);
45if ( $p_step == 0 )
46{
47 if ( $type_periode == 0 )
48 {
49 $from_periode=$http->get('from_periode',"number");
50 $to_periode=$http->get('to_periode',"number");
52 }
53 else
54 {
55 $from_date=$http->get('from_date',"date");
56 $to_date=$http->get('to_date',"date");
58 }
59
60
61 if ( count($Form->row ) == 0 )
62 exit;
63
64 $title=array(_("Description"),
65 _("Montant"));
66
67 $export->write_header($title);
68
69 foreach ( $Form->row as $op )
70 {
71 $export->add($op['desc']);
72 $export->add($op['montant'],"number");
73 $export->write();
74 }
75}
76elseif ($p_step == 1)
77{
78 // Gather all the data
79 //---
80 $from_periode=$http->get('from_periode',"number");
81 $to_periode=$http->get('to_periode',"number");
82 $p_step=$http->get('p_step',"number");
83
85 {
87 if ( $periode == null ) continue;
88 $array[]=$Form->get_row($e,$e,$type_periode);
89 $periode_name[]=$periode;
90 }
91 // Display column heading
92 //--
93 $title=array();
94 $title[0]=_("Mois");
95 $i=1;
96 foreach ($array[0] as $e)
97 {
98 $title[$i]=$e['desc'];
99 $i++;
100 }
101 $export->write_header($title);
102 // Display value for each line
103 //--
104 $a=0;
105 foreach ($array as $e )
106 {
107 $export->add( $periode_name[$a]);
108 $a++;
109 foreach ($e as $elt)
110 {
111 $export->add($elt['montant'],"number");
112 }
113 $export->write();
114 }
115}
117?>
getPeriodeName($p_cn, $p_id, $pos='p_start')
Show the periode which found thanks its id.
Definition: ac_common.php:605
$op
Definition: ajax_admin.php:38
$input_from id
Definition: balance.inc.php:63
Class rapport Create, view, modify and parse report.
static connect()
manage the http input (get , post, request) and extract from an array
Manage the CSV : manage files and write CSV record.
$gDossier
$form_id
if($p_step==0) elseif($p_step==1) exit
$type_periode
if( $delta< 0) elseif( $delta==0)