noalyss Version-9
print_ledger_simple_without_vat.class.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/*!
23 * \file
24 * \brief this class extends PDF and let you export the detailled printing
25 * of any ledgers
26 */
27/*!
28 * \class Print_Ledger_Simple_Without_Vat
29 * \brief this class extends PDF and let you export the detailled printing
30 * of any ledgers
31 */
32
34{
35 public function __construct ($p_cn,$p_jrn,$p_from,$p_to,$p_filter_operation)
36 {
37
38
39 parent::__construct($p_cn,'L', 'mm', 'A4',$p_jrn,$p_from,$p_to,$p_filter_operation);
40 $this->jrn_type=$p_jrn->get_type();
41 //----------------------------------------------------------------------
42 /* report
43 *
44 * get rappel to initialize amount rap_xx
45 *the easiest way is to compute sum from quant_
46 */
47 $this->previous=$this->get_ledger()->previous_amount($p_from);
48
49
50 $this->rap_htva=$this->previous['price'];
51 $this->rap_tvac=$this->previous['price'];
52 $this->rap_priv=$this->previous['priv'];
53
54 }
55
56 function setDossierInfo($dossier = "n/a")
57 {
58 $this->dossier = dossier::name()." ".$dossier;
59 }
60 /**
61 *@brief write the header of each page
62 */
63 function Header()
64 {
65 //Arial bold 12
66 $this->SetFont('DejaVu', 'B', 12);
67 //Title
68 $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
69 //Line break
70 $this->Ln(20);
71 $this->SetFont('DejaVu', 'B', 8);
72 /* column header */
73 $this->Cell(15,6,'Pièce');
74 $this->Cell(15,6,'Date');
75 $this->Cell(20,6,'ref');
76 if ( $this->jrn_type=='ACH')
77 $this->Cell(60,6,'Client');
78 else
79 $this->Cell(60,6,'Fournisseur');
80 $this->Cell(105,6,'Commentaire');
81 if ( $this->jrn_type=='ACH')
82 {
83 $this->Cell(15,6,'Privé',0,0,'R');
84 }
85 $this->Cell(15,6,'Prix',0,0,'R');
86
87 $this->Ln(5);
88
89 $this->SetFont('DejaVu','',6);
90 // page Header
91 $this->Cell(215,6,'report',0,0,'R'); /* HTVA */
92 if ( $this->jrn_type != 'VEN')
93 {
94 $this->Cell(15,6,sprintf('%.2f',$this->rap_priv),0,0,'R'); /* prive */
95 }
96 $this->Cell(15,6,sprintf('%.2f',$this->rap_htva),0,0,'R'); /* HTVA */
97
98
99
100
101 $this->Ln(6);
102 //total page
103 $this->tp_htva=0.0;
104 $this->tp_tvac=0.0;
105 $this->tp_priv=0;
106 $this->tp_nd=0;
107 }
108 /**
109 *@brief write the Footer
110 */
111 function Footer()
112 {
113 //Position at 3 cm from bottom
114 $this->SetY(-20);
115 /* write reporting */
116 $this->Cell(215,6,'Total page ','T',0,'R'); /* HTVA */
117 if ( $this->jrn_type !='VEN')
118 {
119 $this->Cell(15,6,sprintf('%.2f',$this->tp_priv),'T',0,'R'); /* prive */
120 }
121 $this->Cell(15,6,sprintf('%.2f',$this->tp_htva),'T',0,'R'); /* HTVA */
122 $this->Cell(0,6,'','T',0,'R'); /* line */
123 $this->Ln(2);
124
125 $this->Cell(215,6,'report',0,0,'R'); /* HTVA */
126 if ( $this->jrn_type !='VEN')
127 {
128 $this->Cell(15,6,sprintf('%.2f',$this->rap_priv),0,0,'R'); /* prive */
129 }
130 $this->Cell(15,6,sprintf('%.2f',$this->rap_htva),0,0,'R'); /* HTVA */
131 $this->Ln(2);
132
133 //Arial italic 8
134 $this->SetFont('Arial', 'I', 8);
135 //Page number
136 $this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
137 // Created by NOALYSS
138 $this->Cell(0,8,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'R',false,'https://www.noalyss.eu');
139 }
140
141 /**
142 *@brief export the ledger in PDF
143 */
144 function export()
145 {
146
147 $ledger_history=Acc_Ledger_History::factory($this->cn,
148 array($this->get_ledger()->id),
149 $this->get_from(),
150 $this->get_to(),
151 'D',
152 $this->get_filter_operation());
153
154 $ledger_history->get_row();
155 $a_jrn=$ledger_history->get_data();
156
157 if ( empty($a_jrn ) ) return;
158
159 // Prepare the query for reconcile date
160 $prepared_query=new Prepared_Query($this->cn);
161 $prepared_query->prepare_reconcile_date();
162
163 $ledger=$this->get_ledger();
164
165 for ( $i=0;$i<count($a_jrn);$i++)
166 {
167
168 $row=$a_jrn[$i];
169 $this->LongLine(15,5,($row['jr_pj_number']),0);
170 $this->write_cell(15,5,$row['str_date_short'],0,0);
171 $this->write_cell(20,5,$row['jr_internal'],0,0);
172 list($qc,$name)=$this->get_tiers($row['jr_id'],$this->jrn_type);
173 $this->write_cell(20,5,$qc,0,0);
174 $this->LongLine(40,5,$name,0,'L');
175
176 $this->LongLine(105,5,$row['jr_comment'],0,'L');
177
178 /* get other amount (without vat, total vat included, private, ND */
179 $other=$ledger->get_other_amount($a_jrn[$i]['jr_grpt_id']);
180 $this->tp_htva+=$other['price'];
181 $this->tp_priv+=$other['priv'];
182 $this->rap_htva+=$other['price'];
183 $this->rap_priv+=$other['priv'];
184
185
186 if ( $ledger_history->get_ledger_type() !='VEN')
187 {
188 $this->write_cell(15,5,sprintf("%.2f",$other['priv']),0,0,'R');
189 }
190
191 $this->write_cell(15,5,sprintf("%.2f",$other['price']),0,0,'R');
192 $ret_reconcile=$this->cn->execute('reconcile_date',array($row['jr_id']));
194 $str_payment="";
195 if ($max > 0) {
196 $sep="";
197 for ($e=0;$e<$max;$e++) {
199 $msg=( $row['qcode_bank'] != "")?"[".$row['qcode_bank']."]":$row['jr_internal'];
200 $str_payment=$row['jr_date'].$msg.$sep;
201 $sep=' , ';
202 }
203 $this->write_cell (50,5,$str_payment);
204 }
205 $this->line_new(5);
206 }
207 }
208
209}
$input_from cn
Definition: balance.inc.php:66
$from_poste name
static factory(Database $cn, $pa_ledger, $p_from, $p_to, $p_mode, $p_paid)
Build the right object.
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
line_new($p_step=null)
Print all the cell stored and call Ln (new line)
LongLine($w, $h, $txt, $border=0, $align='', $fill=false)
write_cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
get_tiers($p_jr_id, $p_jrn_type)
retrieve the client name and quick_code
Definition: pdf.class.php:84
$dossier
Definition: pdf.class.php:38
contains prepared query used in different classes of the application
this class extends PDF and let you export the detailled printing of any ledgers
__construct($p_cn, $p_jrn, $p_from, $p_to, $p_filter_operation)
Parent class for the print_ledger class.
$ledger
concerned Ledger