noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
export_form_csv.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00020 /*! \file
00021  * \brief Send a report in CSV format
00022  */
00023 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00024 require_once ("ac_common.php");
00025 require_once('class_database.php');
00026 require_once ('class_user.php');
00027 require_once("class_acc_report.php");
00028 require_once("class_impress.php");
00029 header('Pragma: public');
00030 header('Content-type: application/csv');
00031 header('Content-Disposition: attachment;filename="rapport.csv"',FALSE);
00032 
00033 require_once('class_dossier.php');
00034 $gDossier=dossier::id();
00035 
00036 /* Admin. Dossier */
00037 $cn=new Database($gDossier);
00038 
00039 $Form=new Acc_Report($cn,$_GET['form_id']);
00040 $Form->get_name();
00041 // Step ?
00042 //--
00043 $step=HtmlInput::default_value_get("p_step", 0);
00044 if (  $step == 0 )
00045 {
00046     if ( $_GET ['type_periode'] == 0 )
00047         $array=$Form->get_row( $_GET['from_periode'],$_GET['to_periode'], $_GET['type_periode']);
00048     else
00049         $array=$Form->get_row( $_GET['from_date'],$_GET['to_date'], $_GET['type_periode']);
00050 
00051 
00052     if ( count($Form->row ) == 0 )
00053         exit;
00054 
00055     echo       "\"Description\";".
00056     "\"Montant\"\n";
00057 
00058 
00059 
00060     foreach ( $Form->row as $op )
00061     {
00062         echo '"'.$op['desc'].'"'.";".
00063         nb($op['montant']).
00064         "\n";
00065 
00066     }
00067 }
00068 elseif ($step == 1)
00069 {
00070     // Gather all the data
00071     //---
00072     for ($e=$_GET['from_periode'];$e<=$_GET['to_periode'];$e+=$_GET['p_step'])
00073     {
00074         $periode=getPeriodeName($cn,$e);
00075         if ( $periode == null ) continue;
00076         $array[]=$Form->get_row($e,$e,$_GET['type_periode']);
00077         $periode_name[]=$periode;
00078     }
00079     // Display column heading
00080     //--
00081     $x="";
00082     printf ("Mois;");
00083     foreach ($array[0] as $e)
00084     {
00085         printf("%s%s",$x,$e['desc']);
00086         $x=";";
00087 
00088     }
00089     printf("\n");
00090     // Display value for each line
00091     //--
00092     $a=0;
00093     foreach ($array as $e )
00094     {
00095         print $periode_name[$a];
00096         $a++;
00097         foreach ($e as $elt)
00098         {
00099             printf(";%s",nb($elt['montant']));
00100         }
00101         printf("\n");
00102     }
00103 }
00104 exit;
00105 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations