Plugins  LAST
 All Data Structures Files Functions Variables Pages
class_pdf_card.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This file is a 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  * Copyright 2010 De Bontridder Dany <dany@alchimerys.be>
19 
20  *
21 */
22 require_once NOALYSS_INCLUDE.'/lib/class_pdf.php';
23 
24 
25 class Pdf_Card extends PDF
26 {
27  public function __construct (&$p_cn = null, $orientation = 'P', $unit = 'mm', $format = 'A4')
28  {
29 
30  if($p_cn == null) die("No database connection. Abort.");
31 
32  parent::__construct($p_cn,'P', 'mm', 'A4');
33  date_default_timezone_set ('Europe/Paris');
34  $this->total_page=0;
35 
36  }
37 
38  function setDossierInfo($dossier = "n/a")
39  {
40  $this->dossier = dossier::name()." ".$dossier;
41  }
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  }
52  function Footer()
53  {
54  //Position at 2 cm from bottom
55  $this->SetY(-20);
56  //Arial italic 8
57  $this->SetFont('Arial', 'I', 8);
58  //Page number
59  $this->Cell(0,8,'Date '.$this->date." - Page ".$this->PageNo().'/{nb}',0,0,'C');
60  $this->Ln(3);
61  // Created by NOALYSS
62  $this->Cell(0,8,'Created by NOALYSS, a professional opensource accounting software http://www.noalyss.eu',0,0,'C',false,'http://www.noalyss.eu');
63  }
64 
65 
66  function export()
67  {
68  // take all material from
69  $array=$this->cn->get_array("select a_id , f_id , vw_name,vw_description,
70  account_deb , account_cred , a_amount ,
71  a_nb_year , a_start
72  from amortissement.amortissement
73  left join vw_fiche_attr using(f_id)
74  where a_visible='Y'
75  order by vw_name ");
76 
77  $this->total_page=count($array);
78  $this->SetFont('DejaVu','BI',7);
79  bcscale(2);
80  // print all operation
81  for ($i=0;$i< count($array);$i++)
82  {
83  $this->SetFont('DejaVuCond','B',15);
84  $row=$array[$i];
85  $this->write_cell(0,0,$row['vw_name'],0,0,'C');
86 
87  $this->line_new(12);
88 
89  $this->SetFont('DejaVu','',7);
90  $this->write_cell(50,7,'Montant');
91  $this->write_cell(50,7,nbm($row['a_amount']));
92  $this->line_new(4);
93 
94  $this->write_cell(50,7,"Année d'achat");
95  $this->write_cell(50,7,$row['a_start']);
96  $this->line_new(4);
97 
98  $this->write_cell(50,7,"Poste charge");
99  $this->write_cell(50,7,$row['account_deb']);
100  $deb=$this->cn->get_value("select pcm_lib from tmp_pcmn where pcm_val=$1",
101  array($row['account_deb']));
102  $this->write_cell(120,7,$deb);
103  $this->line_new(4);
104 
105  $this->write_cell(50,7,"Poste contrepartie");
106  $this->write_cell(50,7,$row['account_cred']);
107  $cred=$this->cn->get_value("select pcm_lib from tmp_pcmn where pcm_val=$1",
108  array($row['account_cred']));
109  $this->write_cell(120,7,$cred);
110  $this->line_new(4);
111 
112  $this->write_cell(50,7,"Nbre annuités");
113  $this->write_cell(50,7,$row['a_nb_year']);
114  $this->line_new(12);
115 
116  /*
117  * Now we print for each year
118  */
119  $col=array('Année','Montant','Am. actés','Pièce','n° interne','%');
120  foreach ($col as $scol)
121  {
122  $this->write_cell(25,7,$scol,1);
123  }
124  $this->line_new();
125 
126  $array_year=$this->cn->get_array("select ad_id , ad_amount , a_id , ad_year , ad_percentage ".
127  " from amortissement.amortissement_detail ".
128  " where a_id=$1 order by ad_year",
129  array($row['a_id']));
130  for ($e=0;$e<count($array_year);$e++)
131  {
132  $this->write_cell(25,7,$array_year[$e]['ad_year'],1,0);
133  $this->write_cell(25,7,nbm($array_year[$e]['ad_amount']),1,0,'R');
134  $ret=$this->cn->exec_sql("select h_amount,h_pj,jr_internal from amortissement.amortissement_histo where a_id=$1 and h_year=$2",
135  array($row['a_id'],$array_year[$e]['ad_year']));
136  $value=$this->cn->fetch_array($ret,0);
137  $this->write_cell(25,7,nbm($value['h_amount']),1,0,'R');
138  $this->write_cell(25,7,$value['h_pj'],1,0);
139  $this->write_cell(25,7,$value['jr_internal'],1,0);
140  $pct=bcdiv($array_year[$e]['ad_amount'],$row['a_amount']);
141  $pct=bcmul($pct,100);
142  $this->write_cell(25,7,$pct,1,0,'R');
143 
144  $this->line_new();
145 
146  }// for all year
147  if ($i < count($array)) $this->AddPage();
148  } // for ... all card
149  $this->Output('toutes_les_fiches.pdf','I');
150  }
151 }
152 ?>
$ret
for($i=0;$i< Database::num_row($ret);$i++) $row
$dossier
Definition: index.php:32
if(!isset($_REQUEST['sb'])) $format
Definition: import_bank.php:43
__construct(&$p_cn=null, $orientation= 'P', $unit= 'mm', $format= 'A4')
if(isset($_POST['remove'])) $array
$categorie_appel name
setDossierInfo($dossier="n/a")