Export to CSV for ANC Table
This commit is contained in:
parent
9ca86abf6c
commit
1f51a6e637
3 changed files with 97 additions and 2 deletions
|
|
@ -23,7 +23,6 @@
|
|||
/*!\file
|
||||
* \brief manage all the export to CSV or PDF
|
||||
* act can be
|
||||
* * CVS/histo
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -157,7 +156,10 @@ switch( $_GET['act'])
|
|||
require_once('export_balance_pdf.php');
|
||||
exit();
|
||||
break;
|
||||
|
||||
case 'CSV/AncTable':
|
||||
require_once('export_table_csv.php');
|
||||
exit();
|
||||
break;
|
||||
default:
|
||||
alert('Action inconnue '.$_GET['act']);
|
||||
exit();
|
||||
|
|
|
|||
|
|
@ -31,11 +31,23 @@ class Anc_Table extends Anc_Print
|
|||
{
|
||||
$this->cn=$p_cn;
|
||||
}
|
||||
/**
|
||||
*@brief get the parameters
|
||||
*/
|
||||
function get_request()
|
||||
{
|
||||
parent::get_request();
|
||||
$this->card_poste=HtmlInput::default_value('card_poste',1,$_GET);
|
||||
}
|
||||
/**
|
||||
*@brief display form to get the parameter
|
||||
* - card_poste 1 by card, 2 by account
|
||||
* - from_poste
|
||||
* - to_poste
|
||||
* - from from date
|
||||
* - to until date
|
||||
* - pa_id Analytic plan to use
|
||||
*/
|
||||
function display_form($p_hidden='')
|
||||
{
|
||||
$r=parent::display_form($p_hidden);
|
||||
|
|
@ -239,4 +251,51 @@ class Anc_Table extends Anc_Print
|
|||
}
|
||||
|
||||
}
|
||||
function export_csv()
|
||||
{
|
||||
bcscale(2);
|
||||
|
||||
if ( $this->card_poste=='1')
|
||||
{
|
||||
$this->load_card();
|
||||
|
||||
echo '"Fiche"';
|
||||
foreach ($this->aheader as $h)
|
||||
{
|
||||
echo ';"'.$h['po_name'].'"';
|
||||
}
|
||||
echo ',"Total"';
|
||||
printf("\r\n");
|
||||
/*
|
||||
* Show all the result
|
||||
*/
|
||||
|
||||
for ($i=0;$i<count($this->arow);$i++)
|
||||
{
|
||||
|
||||
printf('"%s"',$this->arow[$i]['j_qcode'].' '.$this->arow[$i]['name']);
|
||||
$tot_row=0;
|
||||
for ($x=0;$x<count($this->aheader);$x++)
|
||||
{
|
||||
$amount=$this->db->get_value($this->sql,array($this->arow[$i]['f_id'],$this->aheader[$x]['po_id']));
|
||||
if ($amount==null)$amount=0;
|
||||
if ( isset($tot_col[$x]))
|
||||
{
|
||||
$tot_col[$x]=bcadd($tot_col[$x],$amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tot_col[$x]=$amount;
|
||||
}
|
||||
printf(";%s",nb($amount));
|
||||
$tot_row=bcadd($tot_row,$amount);
|
||||
}
|
||||
printf(";%s",nb($tot_row));
|
||||
printf("\r\n");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
34
include/export_table_csv.php
Normal file
34
include/export_table_csv.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?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 export the anc tables in CSV
|
||||
*/
|
||||
|
||||
header('Pragma: public');
|
||||
header('Content-type: application/csv');
|
||||
header('Content-Disposition: attachment;filename="histo-export.csv"',FALSE);
|
||||
|
||||
require_once('class_anc_table.php');
|
||||
$atable=new Anc_Table($cn);
|
||||
$atable->get_request();
|
||||
$atable->export_csv();
|
||||
Loading…
Add table
Add a link
Reference in a new issue