noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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
37$gDossier=dossier::id();
38
39$cn=Dossier::connect();
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,$http->get('ople'));
54// don't print empty account
55if ( count($array) == 0 )
56{
57 exit;
58}
59
62// label warning if the saldo is incorrect
64if (in_array($type,array('CHA','ACT','PASINV','PROINV')) && $tot_deb<$tot_cred)
65{
66
67 $label=_("Solde créditeur au lieu de débiteur").mb_chr(9888);
68}
69if (in_array($type,array('PRO','PAS','ACTINV','CHAINV')) && $tot_deb>$tot_cred)
70{
71
72 $label=_("Solde débiteur au lieu de créditeur").mb_chr(9888);
73}
74
75
76$size=array(13,25,20,60,12,20,20,20);
77$align=array('L','C','C','L','R','R','R','R');
78
79$Libelle=sprintf("(%s) %s %s [ %s ]",$Fiche->id,$Fiche->getName(),$Fiche->get_attribute(ATTR_DEF_FIRST_NAME,0),$Fiche->get_quick_code());
80$pdf->SetFont('DejaVu','',10);
81$pdf->write_cell(0,8,$Libelle,1,0,'C');
82$pdf->line_new();
83if ( $label !="" )
84{
85 // warning about side
86 $pdf->SetTextColor(255,39,24);
87 $pdf->write_cell(0,8,$label,1,0,'C',fill: false);
88 $pdf->line_new();
89}
90$pdf->SetTextColor(0);
91$pdf->SetFont('DejaVuCond','',8);
93$pdf->write_cell($size[$l],6,'Date',0,0,'L');
94$l++;
95$pdf->write_cell($size[$l],6,'Ref',0,0,'C');
96$l++;
97$pdf->write_cell($size[$l],6,'Journal',0,0,'C');
98$l++;
99$pdf->write_cell($size[$l],6,'Libellé',0,0,'L');
100$l++;
101$pdf->write_cell($size[$l],6,'Let',0,0,'R');
102$l++;
103$pdf->write_cell($size[$l],6,'Debit',0,0,'R');
104$l++;
105$pdf->write_cell($size[$l],6,'Credit',0,0,'R');
106$l++;
107$pdf->write_cell($size[$l],6,'Prog',0,0,'R');
108$l++;
109$pdf->line_new();
114bcscale(2);
115for ($e=0;$e<count($array);$e++)
116{
117 $row=$array[$e];
118 /*
119 * separation per exercice
120 */
121 if ( $current_exercice == "") $current_exercice=$row['p_exercice'];
122
123 if ( $current_exercice != $row['p_exercice']) {
124 $str_debit=sprintf("% 12.2f ",$tot_deb);
125 $str_credit=sprintf("% 12.2f ",$tot_cred);
127 if ( $diff_solde < 0 )
128 {
129 $solde=" "._("créditeur")." ";
130 $diff_solde=bcmul($diff_solde,-1);
131 }
132 else
133 {
134 $solde=" "._('débiteur')." ";
135 }
136 $str_diff_solde=sprintf("%12.2f ",$diff_solde);
137
138 $pdf->SetFont('DejaVu','B',8);
139 $pdf->write_multi(15,6,_('totaux'),0,'L');
140 $pdf->write_cell(15,6,$current_exercice,0,0,'L');
141 $pdf->write_multi(40,6,$solde,0,'L');
142 $pdf->write_cell(40,6,$str_debit,0,0,'R');
143 $pdf->write_cell(40,6,$str_credit,0,0,'R');
144 $pdf->write_cell(40,6,$str_diff_solde,0,0,'R');
145 $pdf->line_new();
146 /*
147 * reset total and current_exercice
148 */
149 $progress=0;
150 $current_exercice=$row['p_exercice'];
151 $tot_deb=0;$tot_cred=0;
152 $pdf->SetFont('DejaVuCond','',8);
153 }
154 $l=0;
155 $delta=bcsub($row['deb_montant'],$row['cred_montant']);
157
158 $date=shrink_date($row['j_date_fmt']);
159 $pdf->write_cell($size[$l],6,$date,0,0,$align[$l]);
160 $l++;
161 if ( $row['jr_pj_number'] == '')
162 $pdf->write_cell($size[$l],6,"",0,0,$align[$l]);
163 else
164 $pdf->write_cell($size[$l],6,$row['jr_pj_number'],0,0,$align[$l]);
165
166 $l++;
167 $pdf->write_cell($size[$l],6,mb_substr($row['jrn_def_code'],0,14),0,0,$align[$l]);
168 $l++;
169 $tiers=$operation->find_tiers($row['jr_id'], $row['j_id'], $row['j_qcode']);
170 $description=($tiers=="")?$row["description"]:"[".$tiers."]".$row['description'];
171
172 $pdf->write_multi($size[$l],6,($description.'('.$row['jr_internal'].")"),0,$align[$l]);
173
174 $l++;
175
176 $pdf->write_multi($size[$l],6,((!empty($row['letter']) && $row['letter']!=-1)?strtoupper(base_convert($row['letter'],10,36)):''),0,$align[$l]);
177 $l++;
178 $pdf->write_multi($size[$l],6,(sprintf('% 12.2f',$row['deb_montant'])),0,$align[$l]);
179 $l++;
180 $pdf->write_multi($size[$l],6,(sprintf('% 12.2f',$row['cred_montant'])),0,$align[$l]);
181 $l++;
182 $pdf->write_multi($size[$l],6,(sprintf('% 12.2f',abs($progress))),0,$align[$l]);
183 $l++;
184 $pdf->line_new();
185 $tot_deb=bcadd($tot_deb,$row['deb_montant']);
186 $tot_cred=bcadd($tot_cred,$row['cred_montant']);
187 /* -------------------------------------- */
188 /* if details are asked we show them here */
189 /* -------------------------------------- */
190 if ( isset($_GET['oper_detail']))
191 {
193 $detail->jr_id=$row['jr_id'];
194 $a_detail=$detail->get_jrnx_detail();
195 for ($f=0;$f<count($a_detail);$f++)
196 {
197 $l=0;
198 $pdf->write_cell($size[$l],6,'',0,0,$align[$l]);
199 $l++;
200 $pdf->write_cell($size[$l],6,$a_detail[$f]['j_qcode'],0,0,'L');
201 $l++;
202 $pdf->write_cell($size[$l],6,$a_detail[$f]['j_poste'],0,0,'R');
203 $l++;
204 if ( $a_detail[$f]['j_qcode']=='')
205 $lib=$a_detail[$f]['pcm_lib'];
206 else
207 {
208 $f_id=$cn->get_value('select f_id from vw_poste_qcode where j_qcode=$1',array($a_detail[$f]['j_qcode'])) ;
209 $lib=$cn->get_value('select ad_value from fiche_detail where ad_id=$1 and f_id=$2',
210 array(ATTR_DEF_NAME,$f_id));
211 }
212 $pdf->write_cell($size[$l],6,$lib,0,0,$align[$l]);
213 $l++;
214 $pdf->write_cell($size[$l],6,(($a_detail[$f]['letter']!=-1)?$a_detail[$f]['letter']:''),0,0,$align[$l]);
215 $l++;
216
217 $deb=($a_detail[$f]['debit']=='D')?$a_detail[$f]['j_montant']:'';
218 $cred=($a_detail[$f]['debit']=='C')?$a_detail[$f]['j_montant']:'';
219
220 $pdf->write_cell($size[$l],6,(sprintf('% 12.2f',$deb)),0,0,$align[$l]);
221 $l++;
222 $pdf->write_cell($size[$l],6,(sprintf('% 12.2f',$cred)),0,0,$align[$l]);
223 $l++;
224 $pdf->line_new();
225 }
226 }
227
228}
229$str_debit=sprintf("% 12.2f ",$tot_deb);
230$str_credit=sprintf("% 12.2f ",$tot_cred);
232if ( $diff_solde < 0 )
233{
234 $solde=" "._("créditeur")." ";
235 $diff_solde*=-1;
236}
237else
238{
239 $solde=" "._('débiteur')." ";
240}
241$str_diff_solde=sprintf("%12.2f ",$diff_solde);
242
243$pdf->SetFont('DejaVu','B',8);
244
245$pdf->write_cell(160,5,'Débit',0,0,'R');
246$pdf->write_cell(30,5,$str_debit,0,0,'R');
247$pdf->line_new();
248$pdf->write_cell(160,5,'Crédit',0,0,'R');
249$pdf->write_cell(30,5,$str_credit,0,0,'R');
250$pdf->line_new();
251$pdf->write_cell(160,5,'Solde '.$solde,0,0,'R');
252$pdf->write_cell(30,5,$str_diff_solde,0,0,'R');
253$pdf->line_new();
254
255// take saldo from 1st day until last
256if ($g_parameter->MY_REPORT=='N') {
257
258 $solde_until_now=$Fiche->get_solde_detail(" j_date <= to_date('$to_periode','DD.MM.YYYY') ");
259
260 $pdf->write_cell(40,5,"Solde global",0,0,'R');
261 $pdf->write_cell(40,5,"D : ".nbm($solde_until_now['debit']),0,0,'R');
262 $pdf->write_cell(40,5,"C : ".nbm($solde_until_now['credit']),0,0,'R');
263 $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');
264 $pdf->line_new();
265
266}
267
268$fDate=date('dmy-Hi');
269$pdf->Output('fiche-'.$fDate.'.pdf','D');
270
271
272?>
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
_("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...
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
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
const ATTR_DEF_FIRST_NAME
Definition constant.php:245
const ATTR_DEF_ACCOUNT
Definition constant.php:222
for($e=0; $e< count($afiche); $e++) exit
if(count($array)==0) $acc_account_ledger
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
for($i=0;$i< $nb_jrn;$i++) $deb