noalyss Version-9
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);
38
39/* Security */
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');
69foreach ($a_poste as $poste)
70{
71 $Poste=new Acc_Account_Ledger($cn,$poste['pcm_val']);
72
73 list($array,$tot_deb,$tot_cred)=$Poste->get_row_date($from_periode,$to_periode,$_GET['ople']);
74 // don't print empty account
75 if ( count($array) == 0 )
76 {
77 continue;
78 }
79 $Libelle=sprintf("(%s) %s ",$Poste->id,$Poste->get_name());
80 $pdf->SetFont('DejaVuCond','',10);
81 $pdf->write_cell(0,8,$Libelle,1,0,'C');
82 $pdf->line_new();
83
84 $pdf->SetFont('DejaVuCond','',8);
85 $l=0;
86 $pdf->write_cell($size[$l],6,_('Date'),0,0,'L');
87 $l++;
88 $pdf->write_cell($size[$l],6,_('Ref'),0,0,'C');
89 $l++;
90 $pdf->write_cell($size[$l],6,_('Journal'),0,0,'C');
91 $l++;
92 $pdf->LongLine($size[$l],6,_('Libellé'),0,'L');
93 $l++;
94 $pdf->write_cell($size[$l],6,_('Let'),0,0,'R');
95 $l++;
96 $pdf->write_cell($size[$l],6,_('Debit'),0,0,'R');
97 $l++;
98 $pdf->write_cell($size[$l],6,_('Credit'),0,0,'R');
99 $l++;
100 $pdf->write_cell($size[$l],6,_('Prog'),0,0,'R');
101 $l++;
102 $pdf->line_new();
103 $tot_deb=0;
104 $tot_cred=0;
105 $prog=0;
107 bcscale(2);
108 for ($e=0;$e<count($array);$e++)
109 {
110 $row=$array[$e];
111 /*
112 * separation per exercice
113 */
114 if ( $current_exercice == "") $current_exercice=$row['p_exercice'];
115
116 if ( $current_exercice != $row['p_exercice']) {
117 $str_debit=sprintf("% 12.2f €",$tot_deb);
118 $str_credit=sprintf("% 12.2f €",$tot_cred);
120 if ( $diff_solde < 0 )
121 {
122 $solde=_(" C ");
123 $diff_solde=bcmul($diff_solde,-1);
124 }
125 else
126 {
127 $solde=_(" D ");
128 }
129 $str_diff_solde=sprintf("%12.2f €",$diff_solde);
130
131 $pdf->SetFont('DejaVu','B',8);
132 $pdf->write_cell(15,6,_('totaux'),0,0,'L');
133 $pdf->write_cell(15,6,$current_exercice,0,0,'L');
134 $pdf->write_cell(40,6,$solde,0,'L');
135 $pdf->write_cell(40,6,$str_debit,0,0,'R');
136 $pdf->write_cell(40,6,$str_credit,0,0,'R');
137 $pdf->write_cell(40,6,$str_diff_solde,0,0,'R');
138 $pdf->line_new();
139 /*
140 * reset total and current_exercice
141 */
142 $prog=0;
143 $current_exercice=$row['p_exercice'];
144 $tot_deb=0;$tot_cred=0;
145 $pdf->SetFont('DejaVuCond','',8);
146 }
147 $l=0;
148 $diff=bcsub($row['deb_montant'],$row['cred_montant']);
149 $prog=bcadd($prog,$diff);
150
151 $date=shrink_date($row['j_date_fmt']);
152 $pdf->write_cell($size[$l],6,$date,0,0,$align[$l]);
153 $l++;
154 if ( $row['jr_pj_number'] == '')
155 $pdf->write_cell($size[$l],6,$row['jr_internal'],0,0,$align[$l]);
156 else
157 $pdf->write_cell($size[$l],6,$row['jr_pj_number'],0,0,$align[$l]);
158 $l++;
159 $pdf->write_cell($size[$l],6,mb_substr($row['jrn_def_code'],0,14),0,0,$align[$l]);
160 $l++;
161 $tiers=$operation->find_tiers($row['jr_id'], $row['j_id'], $row['j_qcode']);
162 $description=($tiers=="")?$row["description"]:"[".$tiers."]".$row['description'];
163 $pdf->LongLine($size[$l],6, $description,0,$align[$l]);
164 $l++;
165 $pdf->write_cell($size[$l],6,(($row['letter']!=-1)?$row['letter']:''),0,0,$align[$l]);
166 $l++;
167 $pdf->write_cell($size[$l],6,(sprintf('% 12.2f',$row['deb_montant'])),0,0,$align[$l]);
168 $l++;
169 $pdf->write_cell($size[$l],6,(sprintf('% 12.2f',$row['cred_montant'])),0,0,$align[$l]);
170 $l++;
171 $solde="=";
172 if ( $prog < 0 )
173 $solde=_('C');
174 elseif ($prog > 0)
175 {
176 $solde=_("D");
177 }
178 $pdf->write_cell($size[$l],6,(sprintf('% 12.2f %s',abs($prog),$solde)),0,0,$align[$l]);
179 $l++;
180 $pdf->line_new();
181 $tot_deb=bcadd($tot_deb,$row['deb_montant']);
182 $tot_cred=bcadd($tot_cred,$row['cred_montant']);
183 /* -------------------------------------- */
184 /* if details are asked we show them here */
185 /* -------------------------------------- */
186 if ( isset($_GET['oper_detail']))
187 {
189 $detail->jr_id=$row['jr_id'];
190 $a_detail=$detail->get_jrnx_detail();
191 for ($f=0;$f<count($a_detail);$f++)
192 {
193 $l=0;
194 $pdf->write_cell($size[$l],6,'',0,0,$align[$l]);
195 $l++;
196 $pdf->write_cell($size[$l],6,$a_detail[$f]['j_qcode'],0,0,$align[$l]);
197 $l++;
198 $pdf->write_cell($size[$l],6,$a_detail[$f]['j_poste'],0,0,$align[$l]);
199 $l++;
200 if ( $a_detail[$f]['j_qcode']=='')
201 $lib=$a_detail[$f]['pcm_lib'];
202 else
203 {
204 $f_id=$cn->get_value('select f_id from vw_poste_qcode where j_qcode=$1',array($a_detail[$f]['j_qcode'])) ;
205 $lib=$cn->get_value('select ad_value from fiche_detail where ad_id=$1 and f_id=$2',
206 array(ATTR_DEF_NAME,$f_id));
207 }
208 $pdf->write_cell($size[$l],6,$lib,0,0,$align[$l]);
209 $l++;
210 $pdf->write_cell($size[$l],6,(($a_detail[$f]['letter']!=-1)?$a_detail[$f]['letter']:''),0,0,$align[$l]);
211 $l++;
212
213 $deb=($a_detail[$f]['debit']=='D')?$a_detail[$f]['j_montant']:'';
214 $cred=($a_detail[$f]['debit']=='C')?$a_detail[$f]['j_montant']:'';
215
216 $pdf->write_cell($size[$l],6,(sprintf('% 12.2f',$deb)),0,0,$align[$l]);
217 $l++;
218 $pdf->write_cell($size[$l],6,(sprintf('% 12.2f',$cred)),0,0,$align[$l]);
219 $l++;
220 $pdf->line_new();
221 }
222 }
223 }
224 $str_debit=sprintf("% 12.2f €",$tot_deb);
225 $str_credit=sprintf("% 12.2f €",$tot_cred);
227 $solde=" = ";
228 if ( $diff_solde < 0 )
229 {
230 $solde=_(" C ");
231 $diff_solde=bcmul($diff_solde,-1);
232 }
233 elseif ( $diff_solde > 0)
234 {
235 $solde=_(" D ");
236 }
237 $str_diff_solde=sprintf("%12.2f €",$diff_solde);
238
239 $pdf->SetFont('DejaVu','B',8);
240
241 $pdf->write_cell(160,5,_("Débit"),0,0,'R');
242 $pdf->write_cell(30,5,$str_debit,0,0,'R');
243 $pdf->line_new();
244 $pdf->write_cell(160,5,_('Crédit'),0,0,'R');
245 $pdf->write_cell(30,5,$str_credit,0,0,'R');
246 $pdf->line_new();
247 $pdf->write_cell(160,5,'Solde '.$solde,0,0,'R');
248 $pdf->write_cell(30,5,$str_diff_solde,0,0,'R');
249 $pdf->line_new();
250
251 // take saldo from 1st day until last
252 if ($g_parameter->MY_REPORT=='N') {
253
254 $solde_until_now=$Poste->get_solde_detail(" j_date <= to_date('$to_periode','DD.MM.YYYY') ");
255
256 $pdf->write_cell(40,5,"Solde global",0,0,'R');
257 $pdf->write_cell(40,5,"D : ".nbm($solde_until_now['debit']),0,0,'R');
258 $pdf->write_cell(40,5,"C : ".nbm($solde_until_now['credit']),0,0,'R');
259 $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');
260 $pdf->line_new();
261
262 }
263}
264$fDate=date('dmy-Hi');
265$pdf->Output('poste-'.$fDate.'-'.$poste_id.'.pdf','D');
266?>
shrink_date($p_date)
shrink the date, make a date shorter for the printing
Definition: ac_common.php:826
nbm($p_number, $p_dec=2)
format the number with a sep.
Definition: ac_common.php:137
for($i=0; $i< count($plan); $i++)( $j==0) $a_poste
$input_from id
Definition: balance.inc.php:63
$_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...
static connect()
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:216
for($e=0; $e< count($afiche); $e++) exit
for($e=0;$e< count($array);$e++) $str_debit
if(count($a_poste)==0) $size
foreach($a_poste as $poste) $fDate
global $g_parameter
if( $delta< 0) elseif( $delta==0)
for($i=0;$i< $nb_jrn;$i++) $deb