noalyss Version-9
export_fiche_detail_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// Copyright Author Dany De Bontridder danydb@aevalys.eu
20/*! \file
21 * \brief Send the poste list in csv
22 */
23if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
24include_once("lib/ac_common.php");
25
27
28$f_id=$http->request("f_id", "number");
29$from_periode=$http->get("from_periode");
30$to_periode=$http->get("to_periode");
31$ople=$http->get("ople");
32
34
35/* Admin. Dossier */
37
38
39
41$qcode=$Fiche->get_quick_code();
42
43$export=new Noalyss_Csv(_('fiche_').$qcode);
44$export->send_header();
45
46$Fiche->getName();
47list($array,$tot_deb,$tot_cred)=$Fiche->get_row_date(
50 $ople
51 );
52if ( count($Fiche->row ) == 0 )
53{
54 echo _("Aucune donnée");
55 return;
56}
57
58
59if ( ! isset ($_REQUEST['oper_detail']))
60{
61 $title=array();
62 $title=array(_("QCODE"),
63 _("Poste"),
64 _("Date"),
65 _("n° pièce"),
66 _("Code interne"),
67 _("Code journal"),
68 _("Nom journal"),
69 _("Tiers"),
70 _("Description"),
71 _("Type"),
72 _("Code devise"),
73 _("Devise"),
74 _("Taux utilisé") ,
75 _("Taux référence"),
76 _("Débit"),
77 _("Crédit"),
78 _("Prog."),
79 _("Let.")
80 );
81 $export->write_header($title);
82 $progress=0;
85 bcscale(2);
87 foreach ( $Fiche->row as $op )
88 {
89 /*
90 * separation per exercice
91 */
92 if ( $current_exercice == "") $current_exercice=$op['p_exercice'];
93
94 if ( $current_exercice != $op['p_exercice']) {
95 $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur";
97 $export->add("");
98 $export->add("");
99 $export->add("");
100 $export->add(_('total'));
102 $export->add($solde_type);
103 $export->add("");
104 $export->add("");
105 $export->add("");
106 $export->add("");
107 $export->add("");
108 $export->add("");
109 $export->add("");
110
111 $export->add($tot_deb,"number");
112 $export->add($tot_cred,"number");
113 $export->add($diff,"number");
114 /*
115 * reset total and current_exercice
116 */
117 $progress=0;
118 $current_exercice=$op['p_exercice'];
119 $tot_deb=0;$tot_cred=0;
120 $export->write();
121 }
122 $tiers=$operation->find_tiers($op['jr_id'], $op['j_id'], $op['j_qcode']);
123 $diff=bcsub($op['deb_montant'],$op['cred_montant']);
125 $tot_deb=bcadd($tot_deb,$op['deb_montant']);
126 $tot_cred=bcadd($tot_cred,$op['cred_montant']);
127 $export->add($op['j_qcode']);
128 $export->add($op['j_poste']);
129 $export->add($op['j_date_fmt']);
130 $export->add($op['jr_pj_number']);
131 $export->add($op['jr_internal']);
132 $export->add($op['jrn_def_code']);
133 $export->add($op['jrn_def_name']);
134 $export->add($tiers);
135 $export->add($op['description']);
136 $export->add($op['jr_optype']);
137 $export->add($op['cr_code_iso']);
138 $export->add($op['oc_amount'],"number");
139 $export->add($op['currency_rate'],"number");
140 $export->add($op['currency_rate_ref'],"number");
141 $export->add($op['deb_montant'],"number");
142 $export->add($op['cred_montant'],"number");
143 $export->add(abs($progress),"number");
144 if ( $op['letter'] !=-1 && ! empty($op['letter'])){
145 $export->add(strtoupper(base_convert($op['letter'],10,36)));
146 } else {
147 $export->add("");
148 }
149
150 $export->write();
151
152 }
153}
154else
155{
156 $title=array("Poste","Qcode","date","ref","internal",
157 "Description","Montant","D/C");
158
159 $export->write_header($title);
160
161 foreach ( $Fiche->row as $op )
162 {
163 $acc=new Acc_Operation($cn);
164 $acc->jr_id=$op['jr_id'];
165 $result= $acc->get_jrnx_detail();
166
167 foreach ( $result as $r)
168 {
169 $export->add($r['j_poste']);
170 $export->add($r['j_qcode']);
171 $export->add($r['jr_date']);
172 $export->add($op['jr_pj_number']);
173 $export->add($r['jr_internal']);
174 $export->add($r['description']);
175 $export->add($r['j_montant'],"number");
176 $export->add($r['debit']);
177 $export->write();
178
179 }
180
181
182
183 }
184}
185$solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur";
188$export->add("");
189$export->add("");
190$export->add("");
191$export->add(_("totaux"));
192$export->add("");
193$export->add($solde_type);
194$export->add($diff,"number");
195$export->add($tot_deb,"number");
196$export->add($tot_cred,"number");
197
198$export->write();
200?>
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$op
Definition: ajax_admin.php:38
$_REQUEST['ac']
$input_from id
Definition: balance.inc.php:63
this file match the tables jrn & jrnx the purpose is to remove or save accountant writing to these ta...
static connect()
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Definition: fiche.class.php:38
manage the http input (get , post, request) and extract from an array
Manage the CSV : manage files and write CSV record.
foreach( $Fiche->row as $op) $solde_type