noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
export_balance_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 Return the balance in CSV format
00022  */
00023 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00024 header('Pragma: public');
00025 header('Content-type: application/csv');
00026 header('Content-Disposition: attachment;filename="balance.csv"',FALSE);
00027 include_once ("ac_common.php");
00028 include_once("class_acc_balance.php");
00029 require_once('class_database.php');
00030 require_once('class_dossier.php');
00031 $gDossier=dossier::id();
00032 
00033 require_once("class_acc_ledger.php");
00034 $cn=new Database($gDossier);
00035 
00036 
00037 require_once ('class_user.php');
00038 
00039 $bal=new Acc_Balance($cn);
00040 $bal->jrn=null;
00041 switch( $_GET['p_filter'])
00042 {
00043 case 0:
00044         $bal->jrn=null;
00045     break;
00046 case 1:
00047     if (  isset($_GET['r_jrn']))
00048     {
00049         $selected=$_GET['r_jrn'];
00050         $array_ledger=$g_user->get_ledger('ALL',3);
00051         $array=get_array_column($array_ledger,'jrn_def_id');
00052         for ($e=0;$e<count($selected);$e++)
00053         {
00054             if (isset ($selected[$e]) && in_array ($selected[$e],$array) )
00055                 $bal->jrn[]=$selected[$e];
00056         }
00057     }
00058     break;
00059 case 2:
00060     if ( isset($_GET['r_cat']))   $bal->filter_cat($_GET['r_cat']);
00061     break;
00062 }
00063 
00064 $bal->from_poste=$_GET['from_poste'];
00065 $bal->to_poste=$_GET['to_poste'];
00066 if (isset($_GET['unsold'])) $bal->unsold=true;
00067 $prev = (isset($_GET['previous_exc'])) ? 1: 0;
00068 
00069 $row=$bal->get_row($_GET['from_periode'],
00070                    $_GET['to_periode'],
00071         $prev);
00072 $prev =  ( isset ($row[0]['sum_cred_previous'])) ?1:0;
00073 echo 'poste;libelle;';
00074 if ($prev  == 1 ) echo 'deb n-1;cred n-1;solde deb n-1;solde cred n-1;';
00075 echo 'deb;cred;solde deb;solde cred';
00076 printf("\n");
00077 foreach ($row as $r)
00078 {
00079     echo $r['poste'].';'.
00080     $r['label'].';';
00081     if ( $prev == 1 )
00082     {
00083        echo  nb($r['sum_deb_previous']).';'.
00084         nb($r['sum_cred_previous']).';'.
00085         nb($r['solde_deb_previous']).';'.
00086         nb($r['solde_cred_previous']).';';
00087     }
00088     echo nb($r['sum_deb']).';'.
00089     nb($r['sum_cred']).';'.
00090     nb($r['solde_deb']).';'.
00091     nb($r['solde_cred']);
00092     printf("\n");
00093 }
00094 
00095 
00096 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations