noalyss Version-9
export_histo_csv.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/*!\file
23 * \brief history of the accountancy exported in CSV
24 */
25if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
26
28
29$ledger=new Acc_Ledger_Search($http->get("ledger_type"),0);
30
31list($sql,$where)=$ledger->build_search_sql($_GET);
32
33$order=" order by jr_date_order asc,substring(jr_pj_number,'[0-9]+$')::numeric asc ";
34
35$res=$cn->get_array($sql.$order);
36$title=array();
37$title[]=_("Internal");
38$title[]=_("Journal");
39$title[]=_("Date");
40$title[]=_("Echeance");
41$title[]=_("Paiement");
42$title[]=_("Piece");
43$title[]=_("qcode");
44$title[]=_("Tiers");
45$title[]=_("Description");
46$title[]=_("Note");
47$title[]=_("Montant opération");
48$title[]=_("Code Devise");
49$title[]=_("Taux");
50$export=new Noalyss_Csv("histo");
51$export->send_header();
52$export->write_header($title);
53
54for ($i=0;$i<count($res);$i++)
55 {
56 $export->add($res[$i]['jr_internal']);
57 $export->add($res[$i]['jrn_def_name']);
58 $export->add($res[$i]['str_jr_date']);
59 $export->add($res[$i]['str_jr_ech']);
60 $export->add($res[$i]['str_jr_date_paid']);
61 $export->add($res[$i]['jr_pj_number']);
62 $export->add($res[$i]['quick_code']);
63 $export->add($res[$i]['name']." ".$res[$i]['first_name']);
64 $export->add($res[$i]['jr_comment']);
65 $export->add($res[$i]['n_text']);
66
67 $amount=$res[$i]['jr_montant'];
68
69 if ( $res[$i]['total_invoice']!=null && $res[$i]['jr_montant']!=$res[$i]['total_invoice'])
70 $amount=$res[$i]['total_invoice'];
71 if ( $res[$i]['jrn_def_type'] == 'FIN')
72 {
73 $positive = $cn->get_value("select qf_amount from quant_fin where jr_id=$1",array($res[$i]['jr_id']));
74 if ( $positive !='' ) $amount=$positive;
75 }
76 $export->add($amount,"number");
77 $export->add($res[$i]['cr_code_iso']);
78 $export->add($res[$i]['currency_rate'],"number");
79
80
81 $export->write();
82
83 }
$_GET['qcode']
manage the http input (get , post, request) and extract from an array
Manage the CSV : manage files and write CSV record.