noalyss Version-9
print_ledger_detail.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/*!
29 * \class Print_Ledger_Detail
30 * \brief this class extends PDF and let you export the detailled printing
31 * of any ledgers
32 */
33
34
36{
37 public function __construct (Database $p_cn , Acc_Ledger $ledger,$p_from,$p_to)
38 {
39
40 parent::__construct($p_cn,'L', 'mm', 'A4',$ledger,$p_from,$p_to,'all');
41
42 }
43
44 function setDossierInfo($dossier = "n/a")
45 {
46 $this->dossier = dossier::name()." ".$dossier;
47 }
48
49 function Header()
50 {
51 //Arial bold 12
52 $this->SetFont('DejaVu', 'B', 12);
53 //Title
54 $this->Cell(0,10,$this->dossier, 'B', 0, 'C');
55 //Line break
56 $this->Ln(20);
57 }
58 function Footer()
59 {
60 //Position at 2 cm from bottom
61 $this->SetY(-20);
62 //Arial italic 8
63 $this->SetFont('Arial', 'I', 8);
64 //Page number
65 $this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'L');
66 // Created by NOALYSS
67 $this->Cell(0,8,'Created by NOALYSS, online on https://www.noalyss.eu',0,0,'R',false,'https://www.noalyss.eu');
68
69 }
70
71
72 function export()
73 {
74
75 // detailled printing
76 $rap_deb=0;
77 $rap_cred=0;
78 // take all operations from jrn
79 $array=$this->get_ledger()->get_operation($this->get_from(),$this->get_to());
80
81 $this->SetFont('DejaVu','BI',7);
82 $this->write_cell(215,7,'report Débit',0,0,'R');
83 $this->write_cell(30,7,nbm($rap_deb),0,0,'R');
84 $this->line_new(4);
85 $this->write_cell(215,7,'report Crédit',0,0,'R');
86 $this->write_cell(30,7,nbm($rap_cred),0,0,'R');
87 $this->line_new(4);
88
89 // print all operation
90 for ($i=0;$i< count($array);$i++)
91 {
92 $this->SetFont('DejaVuCond','B',7);
93 $row=$array[$i];
94
95 $this->LongLine(20,7,$row['pj']);
96 $this->write_cell(15,7,$row['date_fmt']);
97 $this->write_cell(20,7,$row['internal']);
98 $this->LongLine(170,7,$row['comment']);
99 $this->write_cell(20,7,nbm($row['montant']),0,0,'R');
100
101 $this->line_new();
102 // get the entries
103 $aEntry=$this->cn->get_array("select j_id,j_poste,j_qcode,j_montant,j_debit, j_text,".
104 " case when j_text='' or j_text is null then pcm_lib else j_text end as desc,".
105 " pcm_lib ".
106 " from jrnx join tmp_pcmn on (j_poste=pcm_val) where j_grpt = $1".
107 " order by j_debit desc,j_id",
108 array($row['jr_grpt_id']));
109 for ($j=0;$j<count($aEntry);$j++)
110 {
111 $this->SetFont('DejaVuCond','',7);
112 $entry=$aEntry[$j];
113 // $this->write_cell(15,6,$entry['j_id'],0,0,'R');
114 $this->write_cell(32,6,$entry['j_qcode'],0,0,'R');
115 $this->write_cell(23,6,$entry['j_poste'],0,0,'R');
116
117 // if j_qcode is not empty retrieve name
118 if ( $entry['j_text'] =='' && $entry['j_qcode'] != '')
119 {
120 $f_id=$this->cn->get_value('select f_id from vw_poste_qcode where j_qcode=$1',array($entry['j_qcode']));
121 if ($f_id != '')
122 $name=$this->cn->get_value('select ad_value from fiche_detail where f_id=$1 and ad_id=1',
123 array($f_id));
124 else
125 $name=$entry['pcm_lib'];
126 }
127 else
128 $name=$entry['desc'];
129 $this->write_cell(150,6,$name,0,0,'L');
130
131 // print amount
132 $str_amount=nbm($entry['j_montant']);
133 if ( $entry['j_debit']=='t')
134 {
135 $this->write_cell(20,6,$str_amount,0,0,'R');
136 $this->write_cell(20,6,'',0,0,'R');
137 }
138 else
139 {
140 $this->write_cell(20,6,'',0,0,'R');
141 $this->write_cell(20,6,$str_amount,0,0,'R');
142 }
143 $this->line_new(4);
144 }
145 }
146 }
147}
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
$from_poste name
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
this class extends PDF and let you export the detailled printing of any ledgers
__construct(Database $p_cn, Acc_Ledger $ledger, $p_from, $p_to)
Parent class for the print_ledger class.
$ledger
concerned Ledger