altocompta/include/export_form_csv.php
Dany De Bontridder 39bd5bbecd Merged revisions 4134-4141 via svnmerge from
svn+ssh://danydb@svn/svn/phpcompta/branches/rel560

........
  r4134 | danydb | 2011-05-25 23:49:07 +0200 (Wed, 25 May 2011) | 1 line
  
  Fix bug Great Ledger for 8.2
........
  r4135 | danydb | 2011-05-27 20:29:44 +0200 (Fri, 27 May 2011) | 2 lines
  
  0000279: Paramètre -> Attribut
........
  r4136 | danydb | 2011-05-27 21:25:50 +0200 (Fri, 27 May 2011) | 2 lines
  
  0000278: Lettrage
........
  r4137 | danydb | 2011-05-27 21:33:42 +0200 (Fri, 27 May 2011) | 2 lines
  
  0000277: impression -> rapport
........
  r4138 | danydb | 2011-05-27 21:47:10 +0200 (Fri, 27 May 2011) | 1 line
  
  0000276: Impression -> poste
........
  r4139 | danydb | 2011-05-27 22:05:05 +0200 (Fri, 27 May 2011) | 2 lines
  
  0000273: Modèle à sauver
........
  r4140 | danydb | 2011-05-27 22:08:16 +0200 (Fri, 27 May 2011) | 2 lines
  
  0000272: Historique : tri des dates
........
  r4141 | danydb | 2011-05-27 22:09:58 +0200 (Fri, 27 May 2011) | 1 line
  
  0000275: Impression grand livre export PDF & CSV
........
2011-05-28 19:09:25 +00:00

104 lines
2.6 KiB
PHP

<?php
/*
* This file is part of PhpCompta.
*
* PhpCompta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* PhpCompta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* $Revision$ */
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/*! \file
* \brief Send a report in CSV format
*/
require_once ("ac_common.php");
require_once('class_database.php');
require_once ('class_user.php');
require_once("class_acc_report.php");
require_once("impress_inc.php");
header('Pragma: public');
header('Content-type: application/csv');
header('Content-Disposition: attachment;filename="rapport.csv"',FALSE);
require_once('class_dossier.php');
$gDossier=dossier::id();
/* Admin. Dossier */
$cn=new Database($gDossier);
$Form=new Acc_Report($cn,$_GET['form_id']);
$Form->get_name();
// Step ?
//--
if ( $_GET['p_step'] == 0 )
{
if ( $_GET ['type_periode'] == 0 )
$array=$Form->get_row( $_GET['from_periode'],$_GET['to_periode'], $_GET['type_periode']);
else
$array=$Form->get_row( $_GET['from_date'],$_GET['to_date'], $_GET['type_periode']);
if ( count($Form->row ) == 0 )
exit;
echo "\"Description\";".
"\"Montant\"\n";
foreach ( $Form->row as $op )
{
echo '"'.$op['desc'].'"'.";".
nb($op['montant']).
"\n";
}
}
else
{
// Gather all the data
//---
for ($e=$_GET['from_periode'];$e<=$_GET['to_periode'];$e+=$_GET['p_step'])
{
$periode=getPeriodeName($cn,$e);
if ( $periode == null ) continue;
$array[]=$Form->get_row($e,$e,$_GET['type_periode']);
$periode_name[]=$periode;
}
// Display column heading
//--
$x="";
printf ("Mois;");
foreach ($array[0] as $e)
{
printf("%s%s",$x,$e['desc']);
$x=";";
}
printf("\n");
// Display value for each line
//--
$a=0;
foreach ($array as $e )
{
print $periode_name[$a];
$a++;
foreach ($e as $elt)
{
printf(";%s",nb($elt['montant']));
}
printf("\n");
}
}
exit;
?>