noalyss Version-9
print_ledger_detail_item.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// Copyright Author Dany De Bontridder danydb@aevalys.eu
20/**
21 * Print detail of operation PURCHASE or SOLD plus the items
22 * There is no report of the different amounts
23 *
24 * @author danydb
25 */
26
28{
29 public function __construct (Database $p_cn,Acc_Ledger $p_jrn,$p_from,$p_to,$p_filter_operation)
30 {
31
32 parent::__construct($p_cn,'L', 'mm', 'A4',$p_jrn,$p_from,$p_to,$p_filter_operation);
33 $this->show_col=true;
34 }
35
36 function setDossierInfo($dossier = "n/a")
37 {
38 $this->dossier = dossier::name()." ".$dossier;
39 }
40 /**
41 *@brief write the header of each page
42 */
43 function Header()
44 {
45 //Arial bold 12
46 $this->SetFont('DejaVu', 'B', 12);
47 //Title
48 $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
49 //Line break
50 $this->Ln(20);
51 $high=6;
52 $this->SetFont('DejaVu', '', 6);
53 $this->write_cell(20, $high, _('Date'),0,0, 'L', false);
54 $this->write_cell(20, $high, _('Numéro interne'), 0,0, 'L', false);
55 $this->write_cell(50, $high, _('Code'),0,0,'L',false);
56 $this->write_cell(80, $high, _('Libellé'),0,0,'L',false);
57 $this->write_cell(20, $high, _('Tot HTVA'), 0, 0,'R', false,'R', false);
58 $this->write_cell(20, $high, _('Tot TVA NP'), 0, 0,'R', false, false);
59 $this->write_cell(20, $high, _("Autre Tx"), 0, 0, 'R', false);
60 $this->write_cell(20, $high, _('Tot TVA'), 0, 0, 'R', false);
61 $this->write_cell(20, $high, _('TVAC'), 0, 0, 'R', false);
62 $this->line_new(6);
63 $this->show_col=true;
64
65 }
66 /**
67 *@brief write the Footer
68 */
69 function Footer()
70 {
71 $this->Ln(2);
72 $this->SetFont('Arial', 'I', 8);
73 $this->Cell(50,8,' Journal '.$this->get_ledger()->get_name(),0,0,'C');
74 //Arial italic 8
75 //Page number
76 $this->Cell(30,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
77 // Created by NOALYSS
78 $this->Cell(0,8,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'R',false,'https://www.noalyss.eu');
79 }
80
81
82 /**
83 *@brief export the ledger in PDF
84 */
85 function export()
86 {
87 bcscale(2);
88 $jrn_type=$this->get_ledger()->get_type();
89
90 switch ($jrn_type)
91 {
92 case 'VEN':
93 $ledger=new Acc_Ledger_Sale($this->cn, $this->get_ledger()->jrn_def_id);
94 $ret_detail=$ledger->get_detail_sale($this->get_from(),$this->get_to(), $this->filter_operation);
95 break;
96 case 'ACH':
97 $ledger=new Acc_Ledger_Purchase($this->cn, $this->get_ledger()->jrn_def_id);
98 $ret_detail=$ledger->get_detail_purchase($this->get_from(),$this->get_to(),$this->filter_operation);
99 break;
100 default:
101 die (__FILE__.":".__LINE__.'Journal invalide');
102 break;
103 }
104 if ( $ret_detail == null ) return;
105
106 $prepared_query=new Prepared_Query($this->cn);
107 $prepared_query->prepare_reconcile_date();
108
109 $nb=Database::num_row($ret_detail);
110 $this->SetFont('DejaVu', '', 6);
111 $internal="";
112 $this->SetFillColor(220,221,255);
113 $high=4;
114 for ( $i=0;$i< $nb ;$i++)
115 {
116
117 $row=Database::fetch_array($ret_detail, $i);
118 if ($internal != $row['jr_internal'])
119 {
120
121 // Print the general info line width=270mm
122 $this->LongLine(20, $high, $row['jr_date'],1, 'L', true);
123 $this->write_cell(20, $high,$row['jr_pj_number'].".". $row['jr_internal'], 1, 0, 'L', true);
124 $this->LongLine(50, $high, $row['quick_code']." ".$row['tiers_name'],1,'L',true);
125 $this->LongLine(80, $high, $row['jr_comment'],1,'L',true);
126 $this->write_cell(20, $high, nbm($row['htva']), 1, 0, 'R', true);
127 $this->write_cell(20, $high, nbm($row['tot_tva_np']), 1, 0, 'R', true);
128 $this->write_cell(20, $high, nbm($row['other_tax_amount']), 1, 0, 'R', true);
129 $this->write_cell(20, $high, nbm($row['tot_vat']), 1, 0, 'R', true);
130 $sum=noalyss_bcadd($row['htva'],$row['tot_vat']);
131 $sum=noalyss_bcadd($row['other_tax_amount'],$sum);
132 $sum=noalyss_bcsub($sum,$row['tot_tva_np']);
133 $this->write_cell(20, $high, nbm($sum), 1, 0, 'R', true);
134 $internal=$row['jr_internal'];
135 $this->line_new(6);
136 // Payment info
137 // Prepare the query for reconcile date
138 $ret_reconcile=$this->cn->execute('reconcile_date', array($row['jr_id']));
140 for ($e=0; $e<$max; $e++)
141 {
143 $msg=( $ret_row['qcode_bank']!="")?"[".$ret_row['qcode_bank']."]":$ret_row['jr_internal'];
144 $this->write_cell(200, $high,
145 sprintf(_("Paiement montant %s date %s methoded %s "), $ret_row['jr_montant'],
146 $ret_row['jr_date'], $msg
147 ));
148 $this->line_new(6);
149 }
150 // on the first line, the code for each column is displaid
151 if ( $this->show_col == true ) {
152
153
154 // Header detail
155 $this->LongLine(30,$high,_('QuickCode'));
156 $this->write_cell(30,$high,_('Poste'));
157 $this->LongLine(70,$high,_('Libellé'));
158 $this->write_cell(20,$high,_('Prix/Unit'),0,0,'R');
159 $this->write_cell(20,$high,_('Quant.'),0,0,'R');
160 $this->write_cell(20,$high,_('HTVA'),0,0,'R');
161 $this->write_cell(20,$high,_('TVA NP'),0,0,'R');
162 $this->write_cell(20,$high,_('Code TVA'));
163 $this->write_cell(20,$high,_('TVA'),0,0,'R');
164 $this->write_cell(20,$high,_('TVAC'),0,0,'R');
165 $this->line_new(6);
166 $this->show_col=false;
167 }
168 }
169 // Print detail sale / purchase
170 $this->LongLine(30,$high,$row['j_qcode']);
171 $this->write_cell(30,$high,$row['j_poste']);
172 $comment=($row['j_text']=="")?$row['item_name']:$row['j_text'];
173 $this->LongLine(70,$high,$comment);
174 $this->write_cell(20,$high,nbm($row['price_per_unit']),0,0,'R');
175 $this->write_cell(20,$high,nbm($row['quantity']),0,0,'R');
176 $this->write_cell(20,$high,nbm($row['price']),0,0,'R');
177 $this->write_cell(20,$high,nbm($row['vat_sided']),0,0,'R');
178 $this->write_cell(20,$high,$row['tva_label']);
179 $this->write_cell(20,$high,nbm($row['vat']),0,0,'R');
180 $sum=bcadd($row['price'],$row['vat']);
181 $this->write_cell(20,$high,nbm($sum),0,0,'R');
182 $this->line_new(6);
183
184 }
185 }
186
187}
188?>
noalyss_bcsub($p_first, $p_second, $p_decimal=4)
Definition: ac_common.php:1557
noalyss_bcadd($p_first, $p_second, $p_decimal=4)
Definition: ac_common.php:1563
nbm($p_number, $p_dec=2)
format the number with a sep.
Definition: ac_common.php:137
margin jrn_def_id
$input_from cn
Definition: balance.inc.php:66
$from_poste name
Handle the ledger of purchase,.
Handle the ledger of sold,.
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
contains the class for connecting to Noalyss
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='')
$dossier
Definition: pdf.class.php:38
contains prepared query used in different classes of the application
Print detail of operation PURCHASE or SOLD plus the items There is no report of the different amounts...
Header()
write the header of each page
__construct(Database $p_cn, Acc_Ledger $p_jrn, $p_from, $p_to, $p_filter_operation)
Parent class for the print_ledger class.
$ledger
concerned Ledger
$jrn_type[]