noalyss Version-9
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
38
39/* Security */
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 foreach ($acc_account_ledger->row as $detail)
100 {
101
102 /*
103 [0] => 1 [jr_id] => 1
104 [1] => 01.02.2009 [j_date_fmt] => 01.02.2009
105 [2] => 2009-02-01 [j_date] => 2009-02-01
106 [3] => 0 [deb_montant] => 0
107 [4] => 12211.9100 [cred_montant] => 12211.9100
108 [5] => Ecriture douverture [description] => Ecriture douverture
109 [6] => Opération Diverses [jrn_name] => Opération Diverses
110 [7] => f [j_debit] => f
111 [8] => 17OD-01-1 [jr_internal] => 17OD-01-1
112 [9] => ODS1 [jr_pj_number] => ODS1 ) 1
113 */
114 /*
115 * separation per exercice
116 */
117 if ( $current_exercice == "") $current_exercice=$detail['p_exercice'];
118
119 if ( $current_exercice != $detail['p_exercice']) {
120
121 $pdf->SetFont('DejaVuCond','B',8);
122 $i=0;
123 $pdf->write_cell($width[$i], 6, $current_exercice, 0, 0, $lor[$i]);
124 $i++;
125 $pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]);
126 $i++;
127 $pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]);
128 $i++;
129 $pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]);
130 $i++;
131 $pdf->write_cell($width[$i], 6, 'Total du compte '.$acc_account_ledger->id, 0, 0, 'R');
132 $i++;
133 $pdf->write_cell($width[$i], 6, ($solde_d > 0 ? nbm($solde_d) : ''), 0, 0, $lor[$i]);
134 $i++;
135 $pdf->write_cell($width[$i], 6, ($solde_c > 0 ? nbm( $solde_c) : ''), 0, 0, $lor[$i]);
136 $i++;
137 $pdf->write_cell($width[$i], 6, nbm(abs($solde_c-$solde_d)), 0, 0, $lor[$i]);
138 $i++;
139 $pdf->write_cell(5, 6, ($solde_c > $solde_d ? 'C' : 'D'), 0, 0, 'L');
140 /*
141 * reset total and current_exercice
142 */
143 $current_exercice=$detail['p_exercice'];
144 $solde = 0.0;
145 $solde_d = 0.0;
146 $solde_c = 0.0;
147 $pdf->line_new();
148 $pdf->SetFont('DejaVuCond','',6);
149
150 }
151
152 if ($detail['cred_montant'] > 0)
153 {
154 $solde = bcsub ($solde,$detail['cred_montant']);
155 $solde_c = bcadd($solde_c,$detail['cred_montant']);
156 }
157 if ($detail['deb_montant'] > 0)
158 {
159 $solde = bcadd($solde,$detail['deb_montant']);
160 $solde_d = bcadd($solde_d,$detail['deb_montant']);
161 }
162
163 $i = 0;
164 $side=" ".$acc_account_ledger->get_amount_side($solde);
165 $pdf->LongLine($width[$i], 6, shrink_date($detail['j_date_fmt']), 0, $lor[$i]);
166 $i++;
167 $pdf->LongLine($width[$i], 6, $detail['jr_internal'], 0, $lor[$i] );
168 $i++;
169 /* limit set to 40 for the substring */
170 // $triple_point = (mb_strlen($detail['description']) > 40 ) ? '...':'';
171 // $pdf->LongLine($width[$i], 6, mb_substr($detail['description'],0,40).$triple_point, 0,$lor[$i]);
172 $pdf->LongLine($width[$i], 6,$detail['description'].'['.$detail['jr_optype'].']', 0,$lor[$i]);
173 $i++;
174 $pdf->write_cell($width[$i], 6, $detail['jr_pj_number'], 0, 0, $lor[$i]);
175 $i++;
176 $pdf->write_cell($width[$i], 6, ($detail['letter']!=-1)?$detail['letter']:'', 0, 0, $lor[$i]);
177 $i++;
178 $pdf->write_cell($width[$i], 6, ($detail['deb_montant'] > 0 ? nbm( $detail['deb_montant']) : ''), 0, 0, $lor[$i]);
179 $i++;
180 $pdf->write_cell($width[$i], 6, ($detail['cred_montant'] > 0 ? nbm( $detail['cred_montant']) : ''), 0, 0, $lor[$i]);
181 $i++;
182 $pdf->write_cell($width[$i], 6, nbm(abs( $solde)).$side, 0, 0, $lor[$i]);
183 $i++;
184 $pdf->line_new();
185
186 }
187
188
189 $pdf->SetFont('DejaVuCond','B',8);
190
191 $i = 0;
192 $pdf->write_cell($width[$i], 6, $current_exercice, 0, 0, $lor[$i]);
193 $i++;
194 $pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]);
195 $i++;
196 $pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]);
197 $i++;
198 $pdf->write_cell($width[$i], 6, '', 0, 0, $lor[$i]);
199 $i++;
200 $pdf->write_cell($width[$i], 6, 'Total du compte '.$acc_account_ledger->id, 0, 0, 'R');
201 $i++;
202 $pdf->write_cell($width[$i], 6, ($solde_d > 0 ? nbm($solde_d) : ''), 0, 0, $lor[$i]);
203 $i++;
204 $pdf->write_cell($width[$i], 6, ($solde_c > 0 ? nbm( $solde_c) : ''), 0, 0, $lor[$i]);
205 $i++;
206 $pdf->write_cell($width[$i], 6, nbm(abs($solde_c-$solde_d)), 0, 0, $lor[$i]);
207 $i++;
208 $pdf->write_cell(5, 6, ($solde_c > $solde_d ? 'C' : 'D'), 0, 0, 'L');
209
210 $pdf->line_new();
211
212}
213//Save PDF to file
214$pdf->Output("gl_comptes.pdf", 'D');
216?>
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
global $g_user
if no group available , then stop
$_REQUEST['ac']
$input_from id
Definition: balance.inc.php:63
Manage the account from the table jrn, jrnx or tmp_pcmn.
static get_used_accounting($from_date, $to_date, $from_accounting, $to_accounting)
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
$gDossier
$width
$a_accounting
$lor
$http
$pdf
if(count($a_accounting)==0) $header
$from_periode
$to_periode
$from_poste
$to_poste
$side