noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
export_poste_detail_pdf.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * NOALYSS is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with NOALYSS; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19*/
20
21// Copyright Author Dany De Bontridder danydb@aevalys.eu
22/*! \file
23 * \brief send the account list in PDF
24 */
25if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
26require_once NOALYSS_INCLUDE.'/lib/ac_common.php';
27require_once NOALYSS_INCLUDE.'/header_print.php';
29
31
32$poste_id=$http->request("poste_id");
33$from_periode=$http->request("from_periode");
34$to_periode=$http->request("to_periode");
35$ople=$http->request("ople");
36$poste_fille=$http->request("poste_fille","string",-1);
37$gDossier=dossier::id();
38
39/* Security */
40$cn=Dossier::connect();
41
42if ( $poste_fille <> -1)
43{ //choisit de voir tous les postes
44 $a_poste=$cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text like $1||'%' order by pcm_val::text",array($poste_id));
45}
46else
47{
48 $a_poste=$cn->get_array("select pcm_val from tmp_pcmn where pcm_val::text = $1 ",array($poste_id));
49}
50tracedebug("exportpostedetail",$a_poste,"a_poste");
52
54$pdf->setDossierInfo(sprintf(_(" Période : %s %s"),$from_periode,$to_periode));
55$pdf->AliasNbPages();
56$pdf->AddPage();
57$pdf->SetAuthor('NOALYSS');
58$pdf->setTitle(_("Détail poste comptable"),true);
59
60
61if ( count($a_poste) == 0 )
62{
63 $pdf->Output('poste.pdf','D');
64 exit;
65}
66$size=array(13,25,13,65,12,20,20,20);
67$align=array('L','C','C','L','R','R','R','R');
69
70foreach ($a_poste as $poste)
71{
72 $Poste=new Acc_Account_Ledger($cn,$poste['pcm_val']);
73
74 list($array,$tot_deb,$tot_cred)=$Poste->get_row_date($from_periode,$to_periode,$_GET['ople']);
75 // don't print empty account
76 if ( count($array) == 0 )
77 {
78 continue;
79 }
80 $Libelle=sprintf("(%s) %s ",$Poste->id,$Poste->get_name());
81 $pdf->SetFont('DejaVuCond','',10);
82 $pdf->write_cell(0,8,$Libelle,1,0,'C');
83 $pdf->line_new();
84
85 $type=$Poste->get_type();
86 // label warning if the saldo is incorrect
87 $label="";
88 if (in_array($type,array('CHA','ACT','PASINV','PROINV')) && $tot_deb<$tot_cred)
89 {
90
91 $label=_("Solde créditeur au lieu de débiteur").mb_chr(9888);
92 }
93 if (in_array($type,array('PRO','PAS','ACTINV','CHAINV')) && $tot_deb>$tot_cred)
94 {
95
96 $label=_("Solde débiteur au lieu de créditeur").mb_chr(9888);
97 }
98 if ( $label !="" )
99 {
100 // warning about side
101 $pdf->SetTextColor(255,39,24);
102 $pdf->write_cell(0,8,$label,1,0,'C',fill:false);
103 $pdf->line_new();
104 }
105 $pdf->SetTextColor(0);
106 $pdf->SetFont('DejaVuCond','',8);
107 $l=0;
108 $pdf->write_cell($size[$l],8,_('Date'),0,0,'L');
109 $l++;
110 $pdf->write_cell($size[$l],8,_('Ref'),0,0,'C');
111 $l++;
112 $pdf->write_cell($size[$l],8,_('Journal'),0,0,'C');
113 $l++;
114 $pdf->write_multi($size[$l],8,_('Libellé'),0,'L');
115 $l++;
116 $pdf->write_cell($size[$l],8,_('Let'),0,0,'R');
117 $l++;
118 $pdf->write_cell($size[$l],8,_('Debit'),0,0,'R');
119 $l++;
120 $pdf->write_cell($size[$l],8,_('Credit'),0,0,'R');
121 $l++;
122 $pdf->write_cell($size[$l],8,_('Prog'),0,0,'R');
123 $l++;
124 $pdf->line_new();
125 $tot_deb=0;
126 $tot_cred=0;
127 $prog=0;
129 bcscale(2);
130 for ($e=0;$e<count($array);$e++)
131 {
132 $row=$array[$e];
133 /*
134 * separation per exercice
135 */
136 if ( $current_exercice == "") $current_exercice=$row['p_exercice'];
137
138 if ( $current_exercice != $row['p_exercice']) {
139 $str_debit=sprintf("% 12.2f ",$tot_deb);
140 $str_credit=sprintf("% 12.2f ",$tot_cred);
142 if ( $diff_solde < 0 )
143 {
144 $solde=_(" C ");
145 $diff_solde=bcmul($diff_solde,-1);
146 }
147 else
148 {
149 $solde=_(" D ");
150 }
151 $str_diff_solde=sprintf("%12.2f ",$diff_solde);
152
153 $pdf->SetFont('DejaVu','B',8);
154 $pdf->write_cell(15,8,_('totaux'),0,0,'L');
155 $pdf->write_cell(15,8,$current_exercice,0,0,'L');
156 $pdf->write_cell(40,8,$solde,0,'L');
157 $pdf->write_cell(40,8,$str_debit,0,0,'R');
158 $pdf->write_cell(40,8,$str_credit,0,0,'R');
159 $pdf->write_cell(40,8,$str_diff_solde,0,0,'R');
160 $pdf->line_new();
161 /*
162 * reset total and current_exercice
163 */
164 $prog=0;
165 $current_exercice=$row['p_exercice'];
166 $tot_deb=0;$tot_cred=0;
167 $pdf->SetFont('DejaVuCond','',8);
168 }
169 $l=0;
170 $diff=bcsub($row['deb_montant'],$row['cred_montant']);
171 $prog=bcadd($prog,$diff);
172 $fill=(isset($_GET['oper_detail']))?$pdf->is_fill(0):$pdf->is_fill($e);
173 $date=shrink_date($row['j_date_fmt']);
174 $pdf->write_cell($size[$l],8,$date,0,0,$align[$l],fill:$fill);
175 $l++;
176 if ( $row['jr_pj_number'] == '')
177 $pdf->write_cell($size[$l],8,$row['jr_internal'],0,0,$align[$l],fill:$fill);
178 else
179 $pdf->write_cell($size[$l],8,$row['jr_pj_number'],0,0,$align[$l],fill:$fill);
180 $l++;
181 $pdf->write_cell($size[$l],8,mb_substr($row['jrn_def_code'],0,14),0,0,$align[$l],fill:$fill);
182 $l++;
183 $tiers=$operation->find_tiers($row['jr_id'], $row['j_id'], $row['j_qcode']);
184 $description=($tiers=="")?$row["description"]:"[".$tiers."]".$row['description'];
185 $pdf->write_multi($size[$l],8, $description,0,$align[$l],fill:$fill);
186 $l++;
187 $pdf->write_cell($size[$l],8,(($row['letter']!=-1)?$row['letter']:''),0,0,$align[$l],fill:$fill);
188 $l++;
189 $pdf->write_cell($size[$l],8,(sprintf('% 12.2f',$row['deb_montant'])),0,0,$align[$l],fill:$fill);
190 $l++;
191 $pdf->write_cell($size[$l],8,(sprintf('% 12.2f',$row['cred_montant'])),0,0,$align[$l],fill:$fill);
192 $l++;
193 $solde="=";
194 if ( $prog < 0 )
195 $solde=_('C');
196 elseif ($prog > 0)
197 {
198 $solde=_("D");
199 }
200 $pdf->write_cell($size[$l],8,(sprintf('% 12.2f %s',abs($prog),$solde)),0,0,$align[$l],fill:$fill);
201 $l++;
202 $pdf->line_new(8);
203 $tot_deb=bcadd($tot_deb,$row['deb_montant']);
204 $tot_cred=bcadd($tot_cred,$row['cred_montant']);
205 /* -------------------------------------- */
206 /* if details are asked we show them here */
207 /* -------------------------------------- */
208 if ( isset($_GET['oper_detail']))
209 {
211 $detail->jr_id=$row['jr_id'];
212 $a_detail=$detail->get_jrnx_detail();
213 for ($f=0;$f<count($a_detail);$f++)
214 {
215 $l=0;
216 $pdf->write_cell($size[$l],6,'',0,0,$align[$l]);
217 $l++;
218 $pdf->write_cell($size[$l],6,$a_detail[$f]['j_qcode'],0,0,$align[$l]);
219 $l++;
220 $pdf->write_cell($size[$l],6,$a_detail[$f]['j_poste'],0,0,$align[$l]);
221 $l++;
222 if ( $a_detail[$f]['j_qcode']=='')
223 $lib=$a_detail[$f]['pcm_lib'];
224 else
225 {
226 $f_id=$cn->get_value('select f_id from vw_poste_qcode where j_qcode=$1',array($a_detail[$f]['j_qcode'])) ;
227 $lib=$cn->get_value('select ad_value from fiche_detail where ad_id=$1 and f_id=$2',
228 array(ATTR_DEF_NAME,$f_id));
229 }
230 $pdf->write_cell($size[$l],6,$lib,0,0,$align[$l]);
231 $l++;
232 $pdf->write_cell($size[$l],6,(($a_detail[$f]['letter']!=-1)?$a_detail[$f]['letter']:''),0,0,$align[$l]);
233 $l++;
234
235 $deb=($a_detail[$f]['debit']=='D')?$a_detail[$f]['j_montant']:'';
236 $cred=($a_detail[$f]['debit']=='C')?$a_detail[$f]['j_montant']:'';
237
238 $pdf->write_cell($size[$l],6,(sprintf('% 12.2f',$deb)),0,0,$align[$l]);
239 $l++;
240 $pdf->write_cell($size[$l],6,(sprintf('% 12.2f',$cred)),0,0,$align[$l]);
241 $l++;
242 $pdf->line_new();
243 }
244 }
245 }
246 $str_debit=sprintf("% 12.2f ",$tot_deb);
247 $str_credit=sprintf("% 12.2f ",$tot_cred);
249 $solde=" = ";
250 if ( $diff_solde < 0 )
251 {
252 $solde=_(" C ");
253 $diff_solde=bcmul($diff_solde,-1);
254 }
255 elseif ( $diff_solde > 0)
256 {
257 $solde=_(" D ");
258 }
259 $str_diff_solde=sprintf("%12.2f ",$diff_solde);
260
261 $pdf->SetFont('DejaVu','B',8);
262 $pdf->line_new();
263 $pdf->write_cell(160,5,_("Débit"),0,0,'R');
264 $pdf->write_cell(30,5,$str_debit,0,0,'R');
265 $pdf->line_new();
266 $pdf->write_cell(160,5,_('Crédit'),0,0,'R');
267 $pdf->write_cell(30,5,$str_credit,0,0,'R');
268 $pdf->line_new();
269 $pdf->write_cell(160,5,'Solde '.$solde,0,0,'R');
270 $pdf->write_cell(30,5,$str_diff_solde,0,0,'R');
271 $pdf->line_new();
272
273 // take saldo from 1st day until last
274 if ($g_parameter->MY_REPORT=='N') {
275
276 $solde_until_now=$Poste->get_solde_detail(" j_date <= to_date('$to_periode','DD.MM.YYYY') ");
277
278 $pdf->write_cell(40,5,"Solde global",0,0,'R');
279 $pdf->write_cell(40,5,"D : ".nbm($solde_until_now['debit']),0,0,'R');
280 $pdf->write_cell(40,5,"C : ".nbm($solde_until_now['credit']),0,0,'R');
281 $pdf->write_cell(40,5,"Delta : ".nbm($solde_until_now['solde'])." ".$Poste->get_amount_side($solde_until_now['debit']-$solde_until_now['credit']),0,0,'R');
282 $pdf->line_new();
283
284 }
285}
286$fDate=date('dmy-Hi');
287$pdf->Output('poste-'.$fDate.'-'.$poste_id.'.pdf','D');
288?>
shrink_date($p_date)
shrink the date, make a date shorter for the printing
nbm($p_number, $p_dec=2)
format the number with a sep.
global $g_parameter
for($i=0; $i< count($plan); $i++)( $j==0) $a_poste
_("actif, passif,charge,...")
$_GET['qcode']
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...
manage the http input (get , post, request) and extract from an array
API for creating PDF, unicode, based on tfpdf.
Definition pdf.class.php:34
const ATTR_DEF_NAME
Definition constant.php:223
for($e=0; $e< count($afiche); $e++) exit
for($e=0;$e< count($array);$e++) $str_debit
if(in_array( $type, array( 'CHA', 'ACT', 'PASINV', 'PROINV')) &&$tot_deb< $tot_cred) if(in_array($type, array('PRO', 'PAS', 'ACTINV', 'CHAINV')) && $tot_deb > $tot_cred) $size
if( $delta< 0) elseif( $delta==0)
for($i=0;$i< $nb_jrn;$i++) $deb