27 require_once NOALYSS_INCLUDE.
'/lib/class_pdf.php';
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);
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');
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));
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);
67 $this->SetFont(
'DejaVu',
'', 7);
68 for ($i=0; $i<count(
$array); $i++)
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);
82 $this->SetFillColor(220, 221, 255);
87 $this->SetFillColor(0, 0, 0);
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);
103 $tot=$this->cn->get_value(
" select coalesce(sum(a_amount),0) from amortissement.amortissement where a_start=$1", array($this->year));
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');
110 $this->write_cell(60, 8,
"Amortissement", 1, 0,
'R');
111 $this->write_cell(60, 8, nb($tot_amort), 1, 0,
'R');
115 $this->write_cell(60, 8,
"Valeur net", 1, 0,
'R');
116 $this->write_cell(60, 8, nb($tot_net), 1, 0,
'R');
119 $this->Output(
'tab-amort.pdf',
'I');
if(isset($_POST['remove'])) $array