noalyss Version-9
export_poste_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');
24require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
25
27
28$r_poste=$http->request("poste_id");
29$from_periode=$http->request("from_periode");
30$to_periode=$http->request("to_periode");
31$ople=$http->request("ople");
32
33$export=new Noalyss_Csv(_('poste').'_'.$r_poste);
34
36
37/* Admin. Dossier */
39
40if ( isset ( $_REQUEST['poste_fille']) )
41{ //choisit de voir tous les postes
42 $a_poste=$cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text like $1||'%' order by pcm_val::text",array($r_poste));
43}
44else
45{
46 $a_poste=$cn->get_array("select pcm_val from tmp_pcmn where pcm_val = $1",array($r_poste));
47}
48bcscale(2);
49$export->send_header();
50if ( ! isset ($_REQUEST['oper_detail']))
51{
52 /*
53 * Without detail for accounting
54 */
55 if ( count($a_poste) == 0 )
56 exit;
57
58 foreach ($a_poste as $pos)
59 {
60 $Poste=new Acc_Account_Ledger($cn,$pos['pcm_val']);
62 $name=$Poste->get_name();
63 list($array,$tot_deb,$tot_cred)=$Poste->get_row_date( $from_periode,
65 $ople
66 );
67 if ( count($Poste->row ) == 0 )
68 continue;
69 $title=array();
70
71 $title[]=_("Date");
72 $title[]=_("Poste");
73 $title[]=_("n° pièce");
74 $title[]=_("Code journal");
75 $title[]=_("Nom journal");
76 $title[]=_("QuickCode");
77 $title[]=_("Lib.");
78 $title[]=_("Interne");
79 $title[]=_("Tiers");
80 $title[]=_("Description");
81 $title[]=_("Type");
82 $title[]=_("Code devise");
83 $title[]=_("Devise");
84 $title[]=_("Taux utilisé");
85 $title[]=_("Taux référence");
86 $title[]=_("Débit");
87 $title[]=_("Crédit");
88 $title[]=_("Prog.");
89 $title[]=_("Let.");
90 $export->write_header($title);
91
92 $prog=0;
94 $tot_cred=0;
95 $tot_deb=0;
96 $diff=0;
97 foreach ( $Poste->row as $op )
98 {
99 /*
100 * separation per exercice
101 */
102 if ( $current_exercice == "") $current_exercice=$op['p_exercice'];
103
104 if ( $current_exercice != $op['p_exercice']) {
105 $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur";
107 $export->add("");
108 $export->add("");
109 $export->add("");
110 $export->add(_("total"));
112 $export->add($solde_type);
113 $export->add("");
114 $export->add("");
115 $export->add("");
116 $export->add("");
117 $export->add("");
118 $export->add("");
119 $export->add("");
120 $export->add("");
121
122 $export->add($tot_deb,"number");
123 $export->add($tot_cred,"number");
124 $export->add($diff,"number");
125 $export->write();
126 /*
127 * reset total and current_exercice
128 */
129 $prog=0;
130 $current_exercice=$op['p_exercice'];
131 $tot_deb=0;$tot_cred=0;
132 }
133 $tiers=$operation->find_tiers($op['jr_id'],$op['j_id'],$op['j_qcode']);
134
135 $tot_deb=bcadd($tot_deb,$op['deb_montant']);
136 $tot_cred=bcadd($tot_cred,$op['cred_montant']);
137 $diff=bcsub($op['deb_montant'],$op['cred_montant']);
138 $prog=bcadd($prog,$diff);
139
140 $export->add($op['j_date_fmt']);
141 $export->add($pos['pcm_val']);
142 $export->add($op['jr_pj_number']);
143 $export->add($op['jrn_def_code']);
144 $export->add($op['jrn_def_name']);
145 $export->add($op['j_qcode']);
146 $export->add($name);
147 $export->add($op['jr_internal']);
148 $export->add($tiers);
149 $export->add($op['description']);
150 $export->add($op['jr_optype']);
151 $export->add($op['cr_code_iso']);
152 $export->add($op['oc_amount'],"number");
153 $export->add($op['currency_rate'],"number");
154 $export->add($op['currency_rate_ref'],"number");
155
156 $export->add($op['deb_montant'],"number");
157 $export->add($op['cred_montant'],"number");
158 $export->add(abs($prog),"number");
159 $export->add((($op['letter']!=-1)?strtoupper(base_convert($op['letter'],10,36)):""));
160
161 $export->write();
162
163
164 }
165 $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur";
167 $export->add("");
168 $export->add("");
169 $export->add("");
170 $export->add(_("total"));
172 $export->add($solde_type);
173 $export->add("");
174 $export->add("");
175 $export->add("");
176 $export->add("");
177
178 $export->add($tot_deb,"number");
179 $export->add($tot_cred,"number");
180 $export->add($diff,"number");
181 $export->write();
182 }
183}
184else
185{
186 /*
187 * detail of all operation
188 */
189 if ( count($a_poste) == 0 )
190 exit;
191
192 foreach ($a_poste as $pos)
193 {
194 $Poste=new Acc_Account_Ledger($cn,$pos['pcm_val']);
195 $Poste->get_name();
196 list($array,$tot_deb,$tot_cred)=$Poste->get_row_date($from_periode,
198 $ople
199 );
200 if ( count($Poste->row ) == 0 )
201 continue;
202 $title=array();
203 $title[]=_("Poste");
204 $title[]=_("Lib.");
205 $title[]=_("QuickCode");
206 $title[]=_("Interne");
207 $title[]=_("Date");
208 $title[]=_("Tiers");
209 $title[]=_("Description");
210 $title[]=_("Montant");
211 $title[]=_("D/C");
212 $export->write_header($title);
214
215
216 foreach ( $Poste->row as $a )
217 {
218 $op=new Acc_Operation($cn);
219 $op->jr_id=$a['jr_id'];
220 $result=$op->get_jrnx_detail();
221 foreach ( $result as $r)
222 {
223 $tiers=$operation->find_tiers($r['jr_id'], $r['j_id'], $r['j_qcode']);
224 $export->add($r['j_poste']);
225 $export->add($r['pcm_lib']);
226 $export->add($r['j_qcode']);
227 $export->add($r['jr_internal']);
228 $export->add($r['jr_date']);
229 $export->add($tiers);
230 $export->add($a['description']);
231 $export->add($a['jr_pj_number']);
232 $export->add($r['j_montant'],"number");
233 $export->add($r['debit']);
234 $export->write();
235
236 }
237
238
239
240 }
241 }
243}
244?>
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$op
Definition: ajax_admin.php:38
$_REQUEST['ac']
for($i=0; $i< count($plan); $i++)( $j==0) $a_poste
$input_from id
Definition: balance.inc.php:63
Manage the account from the table jrn, jrnx or tmp_pcmn.
this file match the tables jrn & jrnx the purpose is to remove or save accountant writing to these ta...
static connect()
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
foreach($a_poste as $pos) exit