Plugins  LAST
 All Data Structures Files Functions Variables Pages
class_amortissement_material_pdf.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * Copyright (C) 2014 Dany De Bontridder <dany@alchimerys.be>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 require_once NOALYSS_INCLUDE.'/lib/class_pdf.php';
20 
21 class Amortissement_Material_PDF extends PDFLand
22 {
23 
24  function header()
25  {
26  parent::header();
27  $this->setFont('DejaVu', 'B', 14);
28  $this->Cell(190, 10, _('Amortissement : Liste de biens'), 1, 2, 'C');
29  $this->Ln();
30  $this->col_size=array('qcode'=>40, 'name'=>85,'desc'=>120, 'date.purch'=>20, 'year.purch'=>20, '#amort'=>10,'amount.purch'=>30, 'amount.amort'=>30, '%'=>20, 'amount.remain'=>30,'amount.delta'=>30);
31 
32  $this->setFont('DejaVu', 'B', 7);
33  $this->Cell($this->col_size['qcode'], 8, _('QCode'));
34  $this->Cell($this->col_size['name'], 8, _('Nom'));
35  $this->Cell($this->col_size['date.purch'], 8, _('Date achat'));
36  $this->Cell($this->col_size['year.purch'], 8, _('AnnĂ©e achat'));
37  $this->Cell($this->col_size['#amort'], 8, _('Nbre'), 0, 0, 'R');
38  $this->Cell($this->col_size['amount.purch'], 8, _('Montant'), 0, 0, 'R');
39  $this->Cell($this->col_size['amount.amort'], 8, _('A amortir'), 0, 0, 'R');
40  $this->Cell($this->col_size['amount.delta'], 8, _('Val. Comptable Net'), 0, 0, 'R');
41  $this->Ln();
42  }
43 
44  function export()
45  {
46  global $cn;
47  $this->SetFont('DejaVu', '', 7);
48  $ret=$cn->get_array("select * from amortissement.v_amortissement_summary where a_visible='Y' order by a_start,a_date");
49  bcscale(2);
51 
52  for ($i=0;$i<count($ret);$i++)
53  {
54  if ($i%2==0)
55  {
56  $this->SetFillColor(220, 221, 255);
57  $fill=1;
58  }
59  else
60  {
61  $this->SetFillColor(0, 0, 0);
62  $fill=0;
63  }
64 
65  $this->write_cell($this->col_size['qcode'], 8, $ret[$i]['quick_code'], 0, 0, 'L', $fill);
66  $this->write_cell($this->col_size['name'], 8, $ret[$i]['vw_name'], 0, 0, 'L', $fill);
67  $this->write_cell($this->col_size['date.purch'], 8, format_date($ret[$i]['a_date']), 0, 0, 'L', $fill);
68  $this->write_cell($this->col_size['year.purch'], 8, $ret[$i]['a_start'], 0, 0, 'C', $fill);
69  $this->write_cell($this->col_size['#amort'], 8, round($ret[$i]['a_nb_year']), 0, 0, 'R', $fill);
70  $this->write_cell($this->col_size['amount.purch'], 8, nb($ret[$i]['a_amount']), 0, 0, 'R', $fill);
71  $this->write_cell($this->col_size['amount.amort'], 8, nb($ret[$i]['amort_done']), 0, 0, 'R', $fill);
72  $delta=bcsub($ret[$i]['a_amount'],$ret[$i]['amort_done']);
73  $this->write_cell($this->col_size['amount.delta'], 8, nb($delta), 0, 0, 'R', $fill);
74 
75  $tot_purchase=bcadd($tot_purchase,$ret[$i]['a_amount']);
76  $tot_amorti=bcadd($tot_amorti,$ret[$i]['amort_done']);
77  $tot_remain=bcadd($tot_remain,$delta);
78 
79  $this->line_new();
80  }
81  $deca=$this->col_size['qcode']+$this->col_size['name']+$this->col_size['date.purch']+$this->col_size['year.purch']+$this->col_size['#amort'];
82  $this->write_cell($deca+$this->col_size['amount.purch'],8,nb($tot_purchase) ,0,0,'R',0);
83  $this->write_cell($this->col_size['amount.amort'],8,nb($tot_amorti) ,0,0,'R',0);
84  $this->write_cell($this->col_size['amount.delta'],8,nb($tot_remain) ,0,0,'R',0);
85  $this->line_new();
86  $this->Output('listing-amort.pdf', 'I');
87  }
88 
89 }
$tot_amorti
$ret
$tot_purchase
$tot_remain
global $cn