Plugins  LAST
 All Data Structures Files Functions Variables Pages
class_amortissement_table_pdf.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of NOALYSS.
5  *
6  * NOALYSS isfree 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 2 of the License, or
9  * (at your option) any later version.
10  *
11  * NOALYSS isdistributed 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 NOALYSS; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 // Copyright (2014) Author Dany De Bontridder <dany@alchimerys.be>
21 
22 /**
23  * @file
24  * @brief
25  * @param type $name Descriptionara
26  */
27 require_once NOALYSS_INCLUDE.'/lib/class_pdf.php';
28 
29 class Amortissement_Table_PDF extends PDFLand
30 {
31 
32  function header()
33  {
34  parent::header();
35  $this->setFont('DejaVu', 'B', 14);
36  $this->Cell(200, 10, _('Amortissement ').$this->year, 1, 2, 'C');
37  $col_size=array('code'=>20, 'desc'=>80, 'date.purch'=>20, 'year.purch'=>20, 'amount.purch'=>30, '#amort'=>10, 'amount.amort'=>30, '%'=>20, 'amount.remain'=>20);
38  $this->Ln();
39  $this->SetFont('DejaVu', 'BI', 7);
40  $this->Cell($col_size['code'], 8, _('Code'));
41  $this->Cell($col_size['desc'], 8, _('Description'));
42  $this->Cell($col_size['date.purch'], 8, _('Date achat'));
43  $this->Cell($col_size['year.purch'], 8, _('Année achat'));
44  $this->Cell($col_size['amount.purch'], 8, _('Montant'), 0, 0, 'R');
45  $this->Cell($col_size['#amort'], 8, _('Nbre'), 0, 0, 'R');
46  $this->Cell($col_size['amount.amort'], 8, _('A amortir'), 0, 0, 'R');
47  $this->Cell($col_size['%'], 8, _('%'), 0, 0, 'R');
48  $this->Cell($col_size['amount.remain'], 8, _('Dot'), 0, 0, 'R');
49  $this->Cell($col_size['amount.remain'], 8, _('Reste'), 0, 0, 'R');
50  $this->Ln();
51 
52  }
53 
54  function export()
55  {
56  $sql=" select * from amortissement.amortissement where a_id
57  in (select a_id from amortissement.amortissement_detail where ad_year=$1)";
58  $array=$this->cn->get_array($sql, array($this->year));
59  $tot_amort=0;
60  $tot_net=0;
61  $col_size=array('code'=>20, 'desc'=>80, 'date.purch'=>20, 'year.purch'=>20, 'amount.purch'=>30, '#amort'=>10, 'amount.amort'=>30, '%'=>20, 'amount.remain'=>20);
62 
63  bcscale(2);
64 
65 
66  $this->line_new();
67  $this->SetFont('DejaVu', '', 7);
68  for ($i=0; $i<count($array); $i++)
69  {
70  $fiche=new fiche($this->cn, $array[$i]['f_id']);
71  $remain=$this->cn->get_value("select coalesce(sum(ad_amount), 0) from amortissement.amortissement_detail
72  where a_id=$1 and ad_year >= $2", array($array[$i]['a_id'], $this->year));
73  $amortize=$this->cn->get_value("select ad_amount from amortissement.amortissement_detail
74  where a_id=$1 and ad_year=$2", array($array[$i]['a_id'], $this->year));
75  $pct=$this->cn->get_value("select ad_percentage from amortissement.amortissement_detail
76  where a_id=$1 and ad_year = $2", array($array[$i]['a_id'], $this->year));
77  $toamortize=bcsub($remain, $amortize);
78  $tot_amort=bcadd($tot_amort, $amortize);
79  $tot_net=bcadd($tot_net, $toamortize);
80  if ($i%2==0)
81  {
82  $this->SetFillColor(220, 221, 255);
83  $fill=1;
84  }
85  else
86  {
87  $this->SetFillColor(0, 0, 0);
88  $fill=0;
89  }
90  $this->write_cell($col_size['code'], 8, $fiche->strAttribut(ATTR_DEF_QUICKCODE), 0, 0, 'L', $fill);
91  $this->write_cell($col_size['desc'], 8, $fiche->strAttribut(ATTR_DEF_NAME), 0, 0, 'L', $fill);
92  $this->write_cell($col_size['date.purch'], 8, format_date($array[$i]['a_date']), 0, 0, 'L', $fill);
93  $this->write_cell($col_size['year.purch'], 8, $array[$i]['a_start'], 0, 0, 'C', $fill);
94  $this->write_cell($col_size['amount.purch'], 8, nb($array[$i]['a_amount']), 0, 0, 'R', $fill);
95  $this->write_cell($col_size['#amort'], 8, nb($array[$i]['a_nb_year']), 0, 0, 'R', $fill);
96  $this->write_cell($col_size['amount.amort'], 8, nb($remain), 0, 0, 'R', $fill);
97  $this->write_cell($col_size['%'], 8, nb($pct), 0, 0, 'R', $fill);
98  $this->write_cell($col_size['%'], 8, nb($amortize), 0, 0, 'R', $fill);
99  $this->write_cell($col_size['amount.remain'], 8, nb($toamortize), 0, 0, 'R', $fill);
100  $this->line_new();
101  }
102  $this->line_new(10);
103  $tot=$this->cn->get_value(" select coalesce(sum(a_amount),0) from amortissement.amortissement where a_start=$1", array($this->year));
104  $this->setX(40);
105  $this->write_cell(60, 8, "Acquisition de l'année", 1, 0, 'R');
106  $this->write_cell(60, 8, nb($tot), 1, 0, 'R');
107  $this->line_new();
108 
109  $this->setX(40);
110  $this->write_cell(60, 8, "Amortissement", 1, 0, 'R');
111  $this->write_cell(60, 8, nb($tot_amort), 1, 0, 'R');
112  $this->line_new();
113 
114  $this->setX(40);
115  $this->write_cell(60, 8, "Valeur net", 1, 0, 'R');
116  $this->write_cell(60, 8, nb($tot_net), 1, 0, 'R');
117  $this->line_new();
118 
119  $this->Output('tab-amort.pdf', 'I');
120  }
121 
122 }
123 
124 ?>
if(isset($_POST['remove'])) $array
$tot
$sql