noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
export_histo_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 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 
00022 /*!\file
00023  * \brief  history of the accountancy exported in CSV
00024  */
00025 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00026 header('Pragma: public');
00027 header('Content-type: application/csv');
00028 header('Content-Disposition: attachment;filename="histo-export.csv"',FALSE);
00029 
00030 $ledger=new Acc_Ledger($cn,0);
00031 list($sql,$where)=$ledger->build_search_sql($_GET);
00032 
00033 $order=" order by jr_date_order asc,substring(jr_pj_number,'[0-9]+$')::numeric asc ";
00034 
00035 $res=$cn->get_array($sql.$order);
00036 
00037 printf('"%s";',"Internal");
00038 printf('"%s";',"Journal");
00039 printf('"%s";',"Date");
00040 printf('"%s";',"Echeance");
00041 printf('"%s";',"Paiement");
00042 printf('"%s";',"Piece");
00043 printf('"%s";"";',"Tiers");
00044 printf('"%s";',"Description");
00045 printf('"%s";',"Note");
00046 printf('"%s"',"Montant opération");
00047 printf("\r\n");
00048 
00049 for ($i=0;$i<count($res);$i++)
00050   {
00051     printf('"%s";',$res[$i]['jr_internal']);
00052     printf('"%s";',$res[$i]['jrn_def_name']);
00053     printf('"%s";',$res[$i]['str_jr_date']);
00054     printf('"%s";',$res[$i]['str_jr_ech']);
00055     printf('"%s";',$res[$i]['str_jr_date_paid']);
00056     printf('"%s";',$res[$i]['jr_pj_number']);
00057     printf('"%s";',$res[$i]['quick_code']);
00058     printf('"%s %s";',$res[$i]['name'],$res[$i]['first_name']);
00059     printf('"%s";',$res[$i]['jr_comment']);
00060     printf('"%s";',$res[$i]['n_text']);
00061 
00062     $amount=$res[$i]['jr_montant'];
00063 
00064         if ( $res[$i]['total_invoice']!=null && $res[$i]['jr_montant']!=$res[$i]['total_invoice'])
00065                 $amount=$res[$i]['total_invoice'];
00066     if ( $res[$i]['jrn_def_type'] == 'FIN')
00067       {
00068                 $positive = $cn->get_value("select qf_amount from quant_fin where jr_id=$1",array($res[$i]['jr_id']));
00069                 if ( $positive !='' ) $amount=$positive;
00070       }
00071     printf('%s',nb($amount));
00072 
00073     printf("\r\n");
00074 
00075   }
 All Data Structures Namespaces Files Functions Variables Enumerations