noalyss Version-9
export_fiche_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');
26include_once("class/acc_account_ledger.class.php");
27include_once("lib/ac_common.php");
28include_once("lib/impress.class.php");
29require_once NOALYSS_INCLUDE.'/header_print.php';
32$f_id=$http->request("f_id", "number");
33$from_periode=$http->get("from_periode","date");
34$to_periode=$http->get("to_periode","date");
35$ople=$http->get("ople");
36
38
40
42$pdf= new PDF($cn);
43$pdf->setDossierInfo(" Periode : ".$from_periode." - ".$to_periode);
44$pdf->AliasNbPages();
45$pdf->AddPage();
46$pdf->SetAuthor('NOALYSS');
47$pdf->setTitle(_("Détail fiche"),true);
48
49
52
53list($array,$tot_deb,$tot_cred)=$Fiche->get_row_date($from_periode,$to_periode,$_GET['ople']);
54// don't print empty account
55if ( count($array) == 0 )
56{
57 exit;
58}
59$size=array(13,25,20,60,12,20,20,20);
60$align=array('L','C','C','L','R','R','R','R');
61
62$Libelle=sprintf("(%s) %s [ %s ]",$Fiche->id,$Fiche->getName(),$Fiche->get_quick_code());
63$pdf->SetFont('DejaVu','',10);
64$pdf->write_cell(0,8,$Libelle,1,0,'C');
65$pdf->line_new();
66
67
68$pdf->SetFont('DejaVuCond','',8);
70$pdf->write_cell($size[$l],6,'Date',0,0,'L');
71$l++;
72$pdf->write_cell($size[$l],6,'Ref',0,0,'C');
73$l++;
74$pdf->write_cell($size[$l],6,'Journal',0,0,'C');
75$l++;
76$pdf->write_cell($size[$l],6,'Libellé',0,0,'L');
77$l++;
78$pdf->write_cell($size[$l],6,'Let',0,0,'R');
79$l++;
80$pdf->write_cell($size[$l],6,'Debit',0,0,'R');
81$l++;
82$pdf->write_cell($size[$l],6,'Credit',0,0,'R');
83$l++;
84$pdf->write_cell($size[$l],6,'Prog',0,0,'R');
85$l++;
86$pdf->line_new();
91bcscale(2);
92for ($e=0;$e<count($array);$e++)
93{
94 $row=$array[$e];
95 /*
96 * separation per exercice
97 */
98 if ( $current_exercice == "") $current_exercice=$row['p_exercice'];
99
100 if ( $current_exercice != $row['p_exercice']) {
101 $str_debit=sprintf("% 12.2f €",$tot_deb);
102 $str_credit=sprintf("% 12.2f €",$tot_cred);
104 if ( $diff_solde < 0 )
105 {
106 $solde=" "._("créditeur")." ";
107 $diff_solde=bcmul($diff_solde,-1);
108 }
109 else
110 {
111 $solde=" "._('débiteur')." ";
112 }
113 $str_diff_solde=sprintf("%12.2f €",$diff_solde);
114
115 $pdf->SetFont('DejaVu','B',8);
116 $pdf->LongLine(15,6,_('totaux'),0,'L');
117 $pdf->write_cell(15,6,$current_exercice,0,0,'L');
118 $pdf->LongLine(40,6,$solde,0,'L');
119 $pdf->write_cell(40,6,$str_debit,0,0,'R');
120 $pdf->write_cell(40,6,$str_credit,0,0,'R');
121 $pdf->write_cell(40,6,$str_diff_solde,0,0,'R');
122 $pdf->line_new();
123 /*
124 * reset total and current_exercice
125 */
126 $progress=0;
127 $current_exercice=$row['p_exercice'];
128 $tot_deb=0;$tot_cred=0;
129 $pdf->SetFont('DejaVuCond','',8);
130 }
131 $l=0;
132 $delta=bcsub($row['deb_montant'],$row['cred_montant']);
134
135 $date=shrink_date($row['j_date_fmt']);
136 $pdf->write_cell($size[$l],6,$date,0,0,$align[$l]);
137 $l++;
138 if ( $row['jr_pj_number'] == '')
139 $pdf->write_cell($size[$l],6,"",0,0,$align[$l]);
140 else
141 $pdf->write_cell($size[$l],6,$row['jr_pj_number'],0,0,$align[$l]);
142
143 $l++;
144 $pdf->write_cell($size[$l],6,mb_substr($row['jrn_def_code'],0,14),0,0,$align[$l]);
145 $l++;
146 $tiers=$operation->find_tiers($row['jr_id'], $row['j_id'], $row['j_qcode']);
147 $description=($tiers=="")?$row["description"]:"[".$tiers."]".$row['description'];
148
149 $pdf->LongLine($size[$l],6,($description.'('.$row['jr_internal'].")"),0,$align[$l]);
150
151 $l++;
152
153 $pdf->LongLine($size[$l],6,((!empty($row['letter']) && $row['letter']!=-1)?strtoupper(base_convert($row['letter'],10,36)):''),0,$align[$l]);
154 $l++;
155 $pdf->LongLine($size[$l],6,(sprintf('% 12.2f',$row['deb_montant'])),0,$align[$l]);
156 $l++;
157 $pdf->LongLine($size[$l],6,(sprintf('% 12.2f',$row['cred_montant'])),0,$align[$l]);
158 $l++;
159 $pdf->LongLine($size[$l],6,(sprintf('% 12.2f',abs($progress))),0,$align[$l]);
160 $l++;
161 $pdf->line_new();
162 $tot_deb=bcadd($tot_deb,$row['deb_montant']);
163 $tot_cred=bcadd($tot_cred,$row['cred_montant']);
164 /* -------------------------------------- */
165 /* if details are asked we show them here */
166 /* -------------------------------------- */
167 if ( isset($_GET['oper_detail']))
168 {
170 $detail->jr_id=$row['jr_id'];
171 $a_detail=$detail->get_jrnx_detail();
172 for ($f=0;$f<count($a_detail);$f++)
173 {
174 $l=0;
175 $pdf->write_cell($size[$l],6,'',0,0,$align[$l]);
176 $l++;
177 $pdf->write_cell($size[$l],6,$a_detail[$f]['j_qcode'],0,0,'L');
178 $l++;
179 $pdf->write_cell($size[$l],6,$a_detail[$f]['j_poste'],0,0,'R');
180 $l++;
181 if ( $a_detail[$f]['j_qcode']=='')
182 $lib=$a_detail[$f]['pcm_lib'];
183 else
184 {
185 $f_id=$cn->get_value('select f_id from vw_poste_qcode where j_qcode=$1',array($a_detail[$f]['j_qcode'])) ;
186 $lib=$cn->get_value('select ad_value from fiche_detail where ad_id=$1 and f_id=$2',
187 array(ATTR_DEF_NAME,$f_id));
188 }
189 $pdf->write_cell($size[$l],6,$lib,0,0,$align[$l]);
190 $l++;
191 $pdf->write_cell($size[$l],6,(($a_detail[$f]['letter']!=-1)?$a_detail[$f]['letter']:''),0,0,$align[$l]);
192 $l++;
193
194 $deb=($a_detail[$f]['debit']=='D')?$a_detail[$f]['j_montant']:'';
195 $cred=($a_detail[$f]['debit']=='C')?$a_detail[$f]['j_montant']:'';
196
197 $pdf->write_cell($size[$l],6,(sprintf('% 12.2f',$deb)),0,0,$align[$l]);
198 $l++;
199 $pdf->write_cell($size[$l],6,(sprintf('% 12.2f',$cred)),0,0,$align[$l]);
200 $l++;
201 $pdf->line_new();
202 }
203 }
204
205}
206$str_debit=sprintf("% 12.2f €",$tot_deb);
207$str_credit=sprintf("% 12.2f €",$tot_cred);
209if ( $diff_solde < 0 )
210{
211 $solde=" "._("créditeur")." ";
212 $diff_solde*=-1;
213}
214else
215{
216 $solde=" "._('débiteur')." ";
217}
218$str_diff_solde=sprintf("%12.2f €",$diff_solde);
219
220$pdf->SetFont('DejaVu','B',8);
221
222$pdf->write_cell(160,5,'Débit',0,0,'R');
223$pdf->write_cell(30,5,$str_debit,0,0,'R');
224$pdf->line_new();
225$pdf->write_cell(160,5,'Crédit',0,0,'R');
226$pdf->write_cell(30,5,$str_credit,0,0,'R');
227$pdf->line_new();
228$pdf->write_cell(160,5,'Solde '.$solde,0,0,'R');
229$pdf->write_cell(30,5,$str_diff_solde,0,0,'R');
230$pdf->line_new();
231
232// take saldo from 1st day until last
233if ($g_parameter->MY_REPORT=='N') {
234
235 $solde_until_now=$Fiche->get_solde_detail(" j_date <= to_date('$to_periode','DD.MM.YYYY') ");
236
237 $pdf->write_cell(40,5,"Solde global",0,0,'R');
238 $pdf->write_cell(40,5,"D : ".nbm($solde_until_now['debit']),0,0,'R');
239 $pdf->write_cell(40,5,"C : ".nbm($solde_until_now['credit']),0,0,'R');
240 $pdf->write_cell(40,5,"Delta : ".nbm($solde_until_now['solde'])." ".$Fiche->get_amount_side($solde_until_now['debit']-$solde_until_now['credit']),0,0,'R');
241 $pdf->line_new();
242
243}
244
245$fDate=date('dmy-Hi');
246$pdf->Output('fiche-'.$fDate.'.pdf','D');
247
248
249?>
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
$input_from id
Definition: balance.inc.php:63
$_GET['qcode']
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
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
if($g_parameter->MY_REPORT=='N') $fDate
for($e=0;$e< count($array);$e++) $str_debit
if(count($array)==0) $size
global $g_parameter
for($i=0;$i< $nb_jrn;$i++) $deb