noalyss Version-9
print_ledger_fin.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 print a listing of financial
25 */
26/*!
27 * \class Print_Ledger_Financial
28 * \brief print a listing of financial
29 */
30
32{
33 private $rap_amount; /* amount from begining exercice */
34 private $tp_amount; /* amount total page */
35
36 function __construct(Database $p_cn, Acc_Ledger $p_jrn,$p_from,$p_to)
37 {
38 parent::__construct($p_cn,'P','mm','A4',$p_jrn,$p_from,$p_to,'all');
39 $this->jrn_type=$p_jrn->get_type();
40
41 // report from begin exercice
42 $this->rap_amount=0;
43
44 // total page
45 $this->tp_amount=0;
46
47 $amount=$this->get_ledger()->previous_amount($this->get_from());
48 $this->rap_amount=$amount['amount'];
49 }
50 function Header()
51 {
52 //Arial bold 12
53 $this->SetFont('DejaVu', 'B', 12);
54 //Title
55 $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
56 //Line break
57 $this->SetFont('DejaVu', 'B', 7);
58 $this->Ln(10);
59 $this->Cell(40,6,_('report'),0,0,'R');
60 $this->Cell(40,6,nbm($this->rap_amount),0,0,'R');
61 $this->Ln(6);
62 $this->SetFont('DejaVu', 'B', 7);
63 $this->Cell(15,6,_('Piece'));
64 $this->Cell(10,6,_('Date'));
65 $this->Cell(10,6,_('Interne'));
66 $this->Cell(40,6,_('Dest/Orig'));
67 $this->Cell(60,6,_('Commentaire'));
68 $this->Cell(20,6,_('Devise'),0,0,'R');
69 $this->Cell(20,6,_('Montant'),0,0,'R');
70 $this->Ln(6);
71
72 }
73 function Footer()
74 {
75 $this->SetFont('DejaVu', 'B', 7);
76
77 $this->Cell(40,6,_('Total page'),0,0,'R');
78 $this->Cell(40,6,nbm($this->tp_amount),0,0,'R');
79 bcscale(2);
80 $this->rap_amount=bcadd($this->rap_amount,$this->tp_amount);
81 $this->Cell(40,6,_('Total à reporter'),0,0,'R');
82 $this->Cell(40,6,nbm($this->rap_amount),0,0,'R');
83 $this->tp_amount=0;
84 //Position at 2 cm from bottom
85 $this->SetY(-20);
86 //Arial italic 8
87 $this->SetFont('Arial', 'I', 8);
88 //Page number
89 $this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'C');
90 $this->Ln(3);
91 // Created by NOALYSS
92 $this->Cell(0,8,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'C',false,'https://www.noalyss.eu');
93
94 }
95 /**
96 *@brief print the pdf for a financial ledger
97 */
98 function export()
99 {
100 $ledger=$this->get_ledger();
101 $a_jrn=$ledger->get_operation($this->get_from(),$this->get_to());
102
103 $this->SetFont('DejaVu', '', 6);
104 if ( $a_jrn == null ) return;
105 bcscale(2);
106
107 $prepare=new Prepared_Query($this->cn);
108 $prepare->prepare_currency();
109
110 for ( $i=0;$i<count($a_jrn);$i++)
111 {
112 $row=$a_jrn[$i];
113 $this->write_cell(15,5,$row['pj']);
114 $this->write_cell(10,5,$row['date_fmt']);
115 $this->write_cell(10,5,$row['internal']);
116
117 $name=$ledger->get_tiers($this->jrn_type,$row['id']);
118 $this->write_cell(40,5,$name,0,0,'L');
119
120 $this->LongLine(60,5,$row['comment'],0,'L');
121 $amount=$this->cn->get_value('select qf_amount from quant_fin where jr_id=$1',array( $row['id']));
122 $ret_amount_cur=$this->cn->execute("amount_cur",array($row['id']));
123
124 if ( $this->cn->count($ret_amount_cur) == 1) {
125
126 $amount_cur=Database::fetch_result($ret_amount_cur, 0,1);
127 $this->write_cell(20,5,sprintf('%s %s',nbm($amount_cur),$row['cr_code_iso']),0,0,'R');
128 } else {
129
130 $this->write_cell(20,5,"",0,0,'R');
131 }
132 $this->write_cell(20,5,sprintf('%s',nbm($amount)),0,0,'R');
133 $this->line_new(5);
134 $this->tp_amount=bcadd($this->tp_amount,$amount);
135
136 }
137 }
138}
nbm($p_number, $p_dec=2)
format the number with a sep.
Definition: ac_common.php:137
$input_from cn
Definition: balance.inc.php:66
static fetch_result($ret, $p_row=0, $p_col=0)
wrapper for the function pg_fetch_all
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='')
contains prepared query used in different classes of the application
print a listing of financial
export()
print the pdf for a financial ledger
__construct(Database $p_cn, Acc_Ledger $p_jrn, $p_from, $p_to)
Parent class for the print_ledger class.
$ledger
concerned Ledger