noalyss
Version-9
include
export
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
*/
23
if
( ! defined (
'ALLOWED'
) ) die(
'Appel direct ne sont pas permis'
);
24
require_once NOALYSS_INCLUDE.
'/lib/ac_common.php'
;
25
26
$http
=
new
HttpInput
();
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
35
$gDossier
=
dossier::id
();
36
37
/* Admin. Dossier */
38
$cn
=
Dossier::connect
();
39
40
if
( 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
}
44
else
45
{
46
$a_poste
=
$cn
->get_array(
"select pcm_val from tmp_pcmn where pcm_val = $1"
,array(
$r_poste
));
47
}
48
bcscale(2);
49
$export
->send_header();
50
if
( ! 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'
]);
61
$operation
=
new
Acc_Operation
(
$cn
);
62
$name
=$Poste->get_name();
63
list(
$array
,
$tot_deb
,
$tot_cred
)=$Poste->get_row_date(
$from_periode
,
64
$to_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;
93
$current_exercice
=
""
;
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"
;
106
$diff
=abs(
$tot_deb
-
$tot_cred
);
107
$export
->add(
""
);
108
$export
->add(
""
);
109
$export
->add(
""
);
110
$export
->add(_(
"total"
));
111
$export
->add(
$current_exercice
);
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"
;
166
$diff
=abs(
$tot_deb
-
$tot_cred
);
167
$export
->add(
""
);
168
$export
->add(
""
);
169
$export
->add(
""
);
170
$export
->add(_(
"total"
));
171
$export
->add(
$current_exercice
);
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
}
184
else
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
,
197
$to_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
);
213
$operation
=
new
Acc_Operation
(
$cn
);
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
}
242
exit
;
243
}
244
?>
$r
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
Definition:
ajax_add_concerned_card.php:53
$a
$a
Definition:
ajax_add_concerned_card.php:108
$array
$array
Definition:
ajax_add_concerned_card.php:115
$op
$op
Definition:
ajax_admin.php:38
$pos
$pos
Definition:
ajax_anc_key_compute.php:51
$name
$name
Definition:
ajax_get_profile.php:66
$_REQUEST
$_REQUEST['ac']
Definition:
ajax_search_action.php:26
$tiers
$tiers
Definition:
ajax_search_operation.php:39
$result
$result
Definition:
anc_great_ledger.inc.php:26
$a_poste
for($i=0; $i< count($plan); $i++)( $j==0) $a_poste
Definition:
anc_key_input.php:93
id
$input_from id
Definition:
balance.inc.php:63
Acc_Account_Ledger
Manage the account from the table jrn, jrnx or tmp_pcmn.
Definition:
acc_account_ledger.class.php:28
Acc_Operation
this file match the tables jrn & jrnx the purpose is to remove or save accountant writing to these ta...
Definition:
acc_operation.class.php:34
Dossier\connect
static connect()
Definition:
dossier.class.php:295
HttpInput
manage the http input (get , post, request) and extract from an array
Definition:
http_input.class.php:38
Noalyss_Csv
Manage the CSV : manage files and write CSV record.
Definition:
noalyss_csv.class.php:34
$diff
$diff
Definition:
compta_fin_rec.inc.php:310
$operation
$operation
Definition:
compta_fin_rec.inc.php:263
$title
$title
Definition:
export_balance_csv.php:72
$solde_type
foreach( $Fiche->row as $op) $solde_type
Definition:
export_fiche_detail_csv.php:185
$current_exercice
$current_exercice
Definition:
export_fiche_detail_pdf.php:90
$tot_deb
$tot_deb
Definition:
export_fiche_detail_pdf.php:87
$tot_cred
$tot_cred
Definition:
export_fiche_detail_pdf.php:88
$r_poste
$r_poste
Definition:
export_poste_detail_csv.php:28
$gDossier
$gDossier
Definition:
export_poste_detail_csv.php:35
exit
foreach($a_poste as $pos) exit
Definition:
export_poste_detail_csv.php:192
$cn
$cn
Definition:
export_poste_detail_csv.php:38
$http
$http
Definition:
export_poste_detail_csv.php:26
$ople
$ople
Definition:
export_poste_detail_csv.php:31
$export
$export
Definition:
export_poste_detail_csv.php:33
$from_periode
$from_periode
Definition:
export_poste_detail_csv.php:29
$to_periode
$to_periode
Definition:
export_poste_detail_csv.php:30