noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
export_gl_pdf.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
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/*! \file
23 * \brief create GL comptes as 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');
30$from_periode = $http->get("from_periode","date");
31$to_periode = $http->get("to_periode","date");
32$from_poste = $http->get("from_poste");
33$to_poste = $http->get("to_poste");
34
35bcscale(2);
36
37$gDossier=dossier::id();
38
39/* Security */
40$cn=Dossier::connect();
41$g_user->Check();
42$g_user->check_dossier($gDossier);
43
45
46$pdf = new PDF($cn);
47$pdf->setDossierInfo(_(" Periode : ").$from_periode." - ".$to_periode);
48$pdf->AliasNbPages();
49$pdf->AddPage();
50$pdf->setTitle("Grand Livre",true);
51$pdf->SetAuthor('NOALYSS');
52
53if ( count($a_accounting) == 0 )
54{
55 $pdf->Output();
56 return;
57}
58
59// Header
60$header = array( _("Date"), _("Référence"), _("Libellé"), _("Pièce"),_("Let"), _("Débit"), _("Crédit"), _("Solde") );
61// Left or Right aligned
62$lor = array( "L" , "L" , "L" , "L" , "R", "R" , "R" , "R" );
63// Column widths (in mm)
64$width = array( 13 , 20 , 60 , 15 , 12 , 20 , 20 , 20 );
65$l=(isset($_REQUEST['letter']))?2:0;
66$s=(isset($_REQUEST['solded']))?1:0;
67
68foreach ($a_accounting as $accounting_item)
69{
70
71 $acc_account_ledger=new Acc_Account_Ledger($cn,$accounting_item['pcm_val']);
72
73 $array1=$acc_account_ledger->get_row_date($from_periode,$to_periode,$l,$s);
74 // don't print empty account
75 if (empty($array1) || count($array1[0]) == 0 )
76 {
77 continue;
78 }
79 $array=$array1[0];
80 $tot_deb=$array1[1];
81 $tot_cred=$array1[2];
82
83 $pdf->SetFont('DejaVuCond','',10);
84 $Libelle=sprintf("%s - %s ",$accounting_item['pcm_val'],$accounting_item['pcm_lib']);
85 $pdf->write_cell(0, 7, $Libelle, 1, 1, 'C');
86
87 $pdf->SetFont('DejaVuCond','',6);
88 for($i=0;$i<count($header);$i++)
89 $pdf->write_cell($width[$i], 4, $header[$i], 0, 0, $lor[$i]);
90 $pdf->line_new();
91
92 $pdf->SetFont('DejaVuCond','',7);
93
94
95 $solde = 0.0;
96 $solde_d = 0.0;
97 $solde_c = 0.0;
99 $idx=0;
100 foreach ($acc_account_ledger->row as $detail)
101 {
102
103 /*
104 [0] => 1 [jr_id] => 1
105 [1] => 01.02.2009 [j_date_fmt] => 01.02.2009
106 [2] => 2009-02-01 [j_date] => 2009-02-01
107 [3] => 0 [deb_montant] => 0
108 [4] => 12211.9100 [cred_montant] => 12211.9100
109 [5] => Ecriture douverture [description] => Ecriture douverture
110 [6] => Opération Diverses [jrn_name] => Opération Diverses
111 [7] => f [j_debit] => f
112 [8] => 17OD-01-1 [jr_internal] => 17OD-01-1
113 [9] => ODS1 [jr_pj_number] => ODS1 ) 1
114 */
115 /*
116 * separation per exercice
117 */
118 if ( $current_exercice == "") $current_exercice=$detail['p_exercice'];
119
120 if ( $current_exercice != $detail['p_exercice']) {
121
122 $pdf->SetFont('DejaVuCond','B',8);
123 $i=0;
124 $pdf->write_cell($width[$i], 6, $current_exercice, 0, 0, $lor[$i]);
125 $i++;
126 $pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]);
127 $i++;
128 $pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]);
129 $i++;
130 $pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]);
131 $i++;
132 $pdf->write_cell($width[$i], 6, 'Total du compte '.$acc_account_ledger->id, 0, 0, 'R');
133 $i++;
134 $pdf->write_cell($width[$i], 6, ($solde_d > 0 ? nbm($solde_d) : ''), 0, 0, $lor[$i]);
135 $i++;
136 $pdf->write_cell($width[$i], 6, ($solde_c > 0 ? nbm( $solde_c) : ''), 0, 0, $lor[$i]);
137 $i++;
138 $pdf->write_cell($width[$i], 6, nbm(abs($solde_c-$solde_d)), 0, 0, $lor[$i]);
139 $i++;
140 $pdf->write_cell(5, 6, ($solde_c > $solde_d ? 'C' : 'D'), 0, 0, 'L');
141 /*
142 * reset total and current_exercice
143 */
144 $current_exercice=$detail['p_exercice'];
145 $solde = 0.0;
146 $solde_d = 0.0;
147 $solde_c = 0.0;
148 $pdf->line_new();
149 $pdf->SetFont('DejaVuCond','',6);
150 $idx=0;
151 }
152
153 if ($detail['cred_montant'] > 0)
154 {
155 $solde = bcsub ($solde,$detail['cred_montant']);
156 $solde_c = bcadd($solde_c,$detail['cred_montant']);
157 }
158 if ($detail['deb_montant'] > 0)
159 {
160 $solde = bcadd($solde,$detail['deb_montant']);
161 $solde_d = bcadd($solde_d,$detail['deb_montant']);
162 }
163
164 $i = 0;
165 $idx++;
166 $fill=$pdf->is_fill($idx);
167 $side=" ".$acc_account_ledger->get_amount_side($solde);
168 $pdf->write_multi($width[$i], 6, shrink_date($detail['j_date_fmt']), 0, $lor[$i],fill:$fill);
169 $i++;
170 $pdf->write_multi($width[$i], 6, $detail['jr_internal'], 0, $lor[$i] ,fill:$fill);
171 $i++;
172 /* limit set to 40 for the substring */
173 // $triple_point = (mb_strlen($detail['description']) > 40 ) ? '...':'';
174 // $pdf->write_multi($width[$i], 6, mb_substr($detail['description'],0,40).$triple_point, 0,$lor[$i]);
175 $pdf->write_multi($width[$i], 6,$detail['description'].'['.$detail['jr_optype'].']', 0,$lor[$i],fill:$fill);
176 $i++;
177 $pdf->write_cell($width[$i], 6, $detail['jr_pj_number'], 0, 0, $lor[$i],fill:$fill);
178 $i++;
179 $pdf->write_cell($width[$i], 6, ($detail['letter']!=-1)?$detail['letter']:'', 0, 0, $lor[$i],fill:$fill);
180 $i++;
181 $pdf->write_cell($width[$i], 6, ($detail['deb_montant'] > 0 ? nbm( $detail['deb_montant']) : ''), 0, 0, $lor[$i],fill:$fill);
182 $i++;
183 $pdf->write_cell($width[$i], 6, ($detail['cred_montant'] > 0 ? nbm( $detail['cred_montant']) : ''), 0, 0, $lor[$i],fill:$fill);
184 $i++;
185 $pdf->write_cell($width[$i], 6, nbm(abs( $solde)).$side, 0, 0, $lor[$i],fill:$fill);
186 $i++;
187 $pdf->line_new();
188
189 }
190
191
192 $pdf->SetFont('DejaVuCond','B',8);
193
194 $i = 0;
195 $pdf->write_cell($width[$i], 6, $current_exercice, 0, 0, $lor[$i]);
196 $i++;
197 $pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]);
198 $i++;
199 $pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]);
200 $i++;
201 $pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]);
202 $i++;
203 $pdf->write_cell($width[$i], 6, 'Total du compte '.$acc_account_ledger->id, 0, 0, 'R');
204 $i++;
205 $pdf->write_cell($width[$i], 6, ($solde_d > 0 ? nbm($solde_d) : ''), 0, 0, $lor[$i]);
206 $i++;
207 $pdf->write_cell($width[$i], 6, ($solde_c > 0 ? nbm( $solde_c) : ''), 0, 0, $lor[$i]);
208 $i++;
209 $pdf->write_cell($width[$i], 6, nbm(abs($solde_c-$solde_d)), 0, 0, $lor[$i]);
210 $i++;
211 $pdf->write_cell(5, 6, ($solde_c > $solde_d ? 'C' : 'D'), 0, 0, 'L');
212
213 $pdf->line_new();
214
215}
216//Save PDF to file
217$pdf->Output("gl_comptes.pdf", 'D');
219?>
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_user
if no group available , then stop
$_REQUEST['ac']
$from_poste
_("actif, passif,charge,...")
$to_poste
Manage the account from the table jrn, jrnx or tmp_pcmn.
static get_used_accounting($from_date, $to_date, $from_accounting, $to_accounting)
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
for($e=0; $e< count($afiche); $e++) exit
if(count($array)==0) $acc_account_ledger
$a_accounting
if(count($a_accounting)==0) $header
$side