noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
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
30 protected $show_col; //!< $show_col (bool) show columns
31
32 public function __construct (Database $p_cn,Acc_Ledger $p_jrn,$p_from,$p_to,$p_filter_operation)
33 {
34
35 parent::__construct($p_cn,'L', 'mm', 'A4',$p_jrn,$p_from,$p_to,$p_filter_operation);
36 $this->show_col=true;
37 }
38
39 function setDossierInfo($dossier = "n/a")
40 {
41 $this->dossier = dossier::name()." ".$dossier;
42 }
43 /**
44 *@brief write the header of each page
45 */
46 function Header()
47 {
48 //Arial bold 12
49 $this->SetFont('DejaVu', 'B', 12);
50 //Title
51 $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
52 //Line break
53 $this->Ln(20);
54 $high=6;
55 $this->SetFont('DejaVu', '', 6);
56 $this->write_cell(20, $high, _('Date'),0,0, 'L', false);
57 $this->write_cell(20, $high, _('Numéro interne'), 0,0, 'L', false);
58 $this->write_cell(50, $high, _('Code'),0,0,'L',false);
59 $this->write_cell(80, $high, _('Libellé'),0,0,'L',false);
60 $this->write_cell(20, $high, _('Tot HTVA'), 0, 0,'R', false,'R', false);
61 $this->write_cell(20, $high, _('Tot TVA NP'), 0, 0,'R', false, false);
62 $this->write_cell(20, $high, _("Autre Tx"), 0, 0, 'R', false);
63 $this->write_cell(20, $high, _('Tot TVA'), 0, 0, 'R', false);
64 $this->write_cell(20, $high, _('TVAC'), 0, 0, 'R', false);
65 $this->line_new(6);
66 $this->show_col=true;
67
68 }
69 /**
70 *@brief write the Footer
71 */
72 function Footer()
73 {
74 $this->Ln(2);
75 $this->SetFont('Arial', 'I', 8);
76 $this->Cell(50,8,' Journal '.$this->get_ledger()->get_name(),0,0,'C');
77 //Arial italic 8
78 //Page number
79 $this->Cell(30,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
80 // Created by NOALYSS
81 $this->Cell(0,8,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'R',false,'https://www.noalyss.eu');
82 }
83
84
85 /**
86 *@brief export the ledger in PDF
87 */
88 function export()
89 {
90 bcscale(2);
91 $jrn_type=$this->get_ledger()->get_type();
92
93 switch ($jrn_type)
94 {
95 case 'VEN':
96 $ledger=new Acc_Ledger_Sale($this->cn, $this->get_ledger()->jrn_def_id);
97 $ret_detail=$ledger->get_detail_sale($this->get_from(),$this->get_to(), $this->filter_operation);
98 break;
99 case 'ACH':
100 $ledger=new Acc_Ledger_Purchase($this->cn, $this->get_ledger()->jrn_def_id);
101 $ret_detail=$ledger->get_detail_purchase($this->get_from(),$this->get_to(),$this->filter_operation);
102 break;
103 default:
104 die (__FILE__.":".__LINE__.'Journal invalide');
105 break;
106 }
107 if ( $ret_detail == null ) return;
108
109 $prepared_query=new Prepared_Query($this->cn);
110 $prepared_query->prepare_reconcile_date();
111
112 $nb=Database::num_row($ret_detail);
113 $this->SetFont('DejaVu', '', 6);
114 $internal="";
115 $this->fill_row(0);
116 $high=8;
117 $high_lg=8;
118 for ( $i=0;$i< $nb ;$i++)
119 {
120
121 $row=Database::fetch_array($ret_detail, $i);
122 if ($internal != $row['jr_internal'])
123 {
124
125 // Print the general info line width=270mm
126 $this->write_multi(20, $high_lg, $row['jr_date'],1, 'L', true);
127 $this->write_cell(20, $high,$row['jr_pj_number'].".". $row['jr_internal'], 1, 0, 'L', true);
128 $this->write_multi(50, $high_lg, $row['quick_code']." ".$row['tiers_name'],1,'L',true);
129 $this->write_multi(80, $high_lg, $row['jr_comment'],1,'L',true);
130 $this->write_cell(20, $high, nbm($row['htva']), 1, 0, 'R', true);
131 $this->write_cell(20, $high, nbm($row['tot_tva_np']), 1, 0, 'R', true);
132 $this->write_cell(20, $high, nbm($row['other_tax_amount']), 1, 0, 'R', true);
133 $this->write_cell(20, $high, nbm($row['tot_vat']), 1, 0, 'R', true);
134 $sum=noalyss_bcadd($row['htva'],$row['tot_vat']);
135 $sum=noalyss_bcadd($row['other_tax_amount'],$sum);
136 $sum=noalyss_bcsub($sum,$row['tot_tva_np']);
137 $this->write_cell(20, $high, nbm($sum), 1, 0, 'R', true);
138 $internal=$row['jr_internal'];
139 $this->line_new(6);
140 // Payment info
141 // Prepare the query for reconcile date
142 $ret_reconcile=$this->cn->execute('reconcile_date', array($row['jr_id']));
144 for ($e=0; $e<$max; $e++)
145 {
147 $msg=( $ret_row['qcode_bank']!="")?"[".$ret_row['qcode_bank']."]":$ret_row['jr_internal'];
148 $this->write_cell(200, $high,
149 sprintf(_("Paiement montant %s date %s methoded %s "), $ret_row['jr_montant'],
150 $ret_row['jr_date'], $msg
151 ));
152 $this->line_new(6);
153 }
154 // on the first line, the code for each column is displaid
155 if ( $this->show_col == true ) {
156
157
158 // Header detail
159 $this->write_multi(30,$high_lg,_('QuickCode'));
160 $this->write_cell(30,$high,_('Poste'));
161 $this->write_multi(70,$high_lg,_('Libellé'));
162 $this->write_cell(20,$high,_('Prix/Unit'),0,0,'R');
163 $this->write_cell(20,$high,_('Quant.'),0,0,'R');
164 $this->write_cell(20,$high,_('HTVA'),0,0,'R');
165 $this->write_cell(20,$high,_('TVA NP'),0,0,'R');
166 $this->write_cell(20,$high,_('Code TVA'));
167 $this->write_cell(20,$high,_('TVA'),0,0,'R');
168 $this->write_cell(20,$high,_('TVAC'),0,0,'R');
169 $this->line_new(6);
170 $this->show_col=false;
171 }
172 }
173 // Print detail sale / purchase
174 $this->write_multi(30,$high_lg,$row['j_qcode']);
175 $this->write_cell(30,$high,$row['j_poste']);
176 $comment=($row['j_text']=="")?$row['item_name']:$row['j_text'];
177 $this->write_multi(70,$high_lg,$comment);
178 $this->write_cell(20,$high,nbm($row['price_per_unit']),0,0,'R');
179 $this->write_cell(20,$high,nbm($row['quantity']),0,0,'R');
180 $this->write_cell(20,$high,nbm($row['price']),0,0,'R');
181 $this->write_cell(20,$high,nbm($row['vat_sided']),0,0,'R');
182 $this->write_cell(20,$high,$row['tva_label']);
183 $this->write_cell(20,$high,nbm($row['vat']),0,0,'R');
184 $sum=bcadd($row['price'],$row['vat']);
185 $this->write_cell(20,$high,nbm($sum),0,0,'R');
186 $this->line_new(6);
187
188 }
189 }
190
191}
192?>
noalyss_bcsub($p_first, $p_second, $p_decimal=4)
noalyss_bcadd($p_first, $p_second, $p_decimal=4)
nbm($p_number, $p_dec=2)
format the number with a sep.
margin jrn_def_id
$input_from cn
_("actif, passif,charge,...")
: input, confirm and save new operations in edger of purchase the $_POST data is an array with these ...
: input, confirm and save new operations in edger of sales the $_POST data is an array with these key...
Class for jrn, class acc_ledger for manipulating the ledger AND some acc.
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)
write_cell($width, $height=0, $txt='', $border=0, $interline=0, $align='', $fill=false, $link='')
add a cell the text is not cut and don't return to this line if too large
write_multi($width, $interline, $txt, $border=0, $align='', $fill=false)
add a cell with automatic return to the line if the text is too long
fill_row($enable)
set color for row ,
$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)
$show_col
$show_col (bool) show columns
Parent class for the print_ledger class.
$ledger
concerned Ledger