Plugins  LAST
 All Data Structures Files Functions Variables Pages
raw.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 /* $Revision$ */
20 
21 // Copyright (c) 2002 Author Dany De Bontridder dany@alchimerys.be
22 
23 /*!\file
24  * \brief raw file for PDF
25  */
26 require_once('amortis_constant.php');
27 require_once NOALYSS_INCLUDE.'/lib/class_noalyss_csv.php';
28 
29 extract ($_REQUEST);
30 bcscale(2);
31 /* export all cards in PDF */
32 if ( isset($_REQUEST['pdf_all']))
33  {
34  require_once('include/class_pdf_card.php');
35  global $cn;
36  $a=new Pdf_Card($cn);
37  $a->setDossierInfo(dossier::id());
38  $a->AliasNbPages('{nb}');
39  $a->AddPage();
40  $a->export();
41  exit();
42  }
43 /*
44  * Export the list per year in CSV
45  */
46 if ( isset ($_REQUEST['csv_list_year']))
47 {
48 
49  $year=HtmlInput::default_value_request('csv_list_year','0000');
50 
51  $csv_list_year=new Noalyss_Csv("amortissement-$year");
52  $csv_list_year->send_header();
53  $csv_list_year->write_header(array(_('Code'),
54  _('Description'),
55  _('Date acquisition'),
56  _('Année Achat'),
57  _('Montant Achat'),
58  _('Nombre annuités'),
59  _("Montant à amortir"),
60  _('Amortissement'),
61  _('Restant')));
62 
63 
64  $sql="select * from amortissement.amortissement where a_id
65  in (select a_id from amortissement.amortissement_detail where ad_year=$1)";
66  $array=$cn->get_array($sql,array($year));
67  bcscale(2);
68  for ($i=0;$i<count($array);$i++)
69  {
70  $fiche=new fiche($cn,$array[$i]['f_id']);
71  $remain=$cn->get_value("select coalesce(sum(ad_amount),0) from amortissement.amortissement_detail
72  where a_id=$1 and ad_year >= $2",
73  array($array[$i]['a_id'],$year));
74  $amortize=$cn->get_value("select ad_amount from amortissement.amortissement_detail
75  where a_id=$1 and ad_year = $2",
76  array($array[$i]['a_id'],$year));
77  $toamortize=bcsub($remain,$amortize);
78 
79 
80  $csv_list_year->add($fiche->strAttribut(ATTR_DEF_QUICKCODE));
81  $csv_list_year->add($fiche->strAttribut(ATTR_DEF_NAME));
82  $csv_list_year->add(format_date($array[$i]['a_date']));
83  $csv_list_year->add($array[$i]['a_start']);
84  $csv_list_year->add($array[$i]['a_amount'],'number');
85  $csv_list_year->add($array[$i]['a_nb_year'],'number');
86  $csv_list_year->add($remain,'number');
87  $csv_list_year->add($amortize,'number');
88  $csv_list_year->add($toamortize,'number');
89 
90  $csv_list_year->write();
91 
92  }
93 }
94 
95 /* export all cards in PDF */
96 if ( isset($_REQUEST['pdf_list_year']))
97  {
98  require_once('include/class_amortissement_table_pdf.php');
99  global $cn;
100  $year=$_REQUEST['pdf_list_year'];
101  $a=new Amortissement_Table_PDF($cn);
102  $a->SetTitle('Amortissement '.$year);
103  $a->SetAuthor('NOALYSS');
104  $a->SetCreator('NOALYSS');
105  $a->year=$year;
106  $a->setDossierInfo(dossier::id());
107  $a->AliasNbPages('{nb}');
108  $a->AddPage();
109  $a->export();
110  exit();
111  }
112 /*
113  * Export to CSV all the listing
114  */
115 if ( isset($_GET['csv_material']))
116  {
117  $csv_material=new Noalyss_Csv("listing-material");
118  $csv_material->send_header();
119  $csv_material->write_header(array(
120  _('Visible'),
121  _('Code'),
122  _('Nom'),
123  _('Description'),
124  _('Date acquisition'),
125  _('Année Achat'),
126  _('Nombre annuités'),
127  _('Poste Charge'),
128  _('Poste amortissement'),
129  _('Fiche Charge'),
130  _('Fiche Amortissement acté'),
131  _('Montant Achat'),
132  _("Montant amorti"),
133  _("Montant à amortir"),
134  ));
135 
136  $ret=$cn->get_array("select * from amortissement.v_amortissement_summary order by a_start,a_date");
137  for ($i=0;$i<count($ret);$i++)
138  {
139  $csv_material->add($ret[$i]['a_visible']);
140  $csv_material->add($ret [$i]['quick_code']);
141  $csv_material->add($ret [$i]['vw_name']);
142  $csv_material->add($ret [$i]['vw_description']);
143  $csv_material->add(format_date($ret[$i]['a_date']));
144  $csv_material->add($ret[$i]['a_start']);
145  $csv_material->add($ret[$i]['a_nb_year'],"number");
146  $csv_material->add($ret[$i]['account_deb']);
147  $csv_material->add($ret[$i]['account_cred']);
148  $csv_material->add($ret[$i]['card_cred_qcode']);
149  $csv_material->add($ret[$i]['card_deb_qcode']);
150  $csv_material->add($ret[$i]['a_amount'],'number');
151  $csv_material->add($ret[$i]['amort_done'],'number');
152  $remain=bcsub($ret[$i]['a_amount'],$ret[$i]['amort_done']);
153  $csv_material->add($remain,"number");
154  $csv_material->write();
155  }
156  }
157 /*
158  * Export to PDF all the listing
159  */
160 if ( isset($_GET['pdf_material']))
161  {
162  require_once('include/class_amortissement_material_pdf.php');
163  global $cn;
165  $a->SetTitle('Amortissement ');
166  $a->SetAuthor('NOALYSS');
167  $a->SetCreator('NOALYSS');
168  $a->setDossierInfo(dossier::id());
169  $a->AliasNbPages('{nb}');
170  $a->AddPage();
171  $a->export();
172  exit();
173 
174 
175  }
176 
177 
178 ?>
$sql
Definition: raw.php:28
$select_type id
$ret
$array
Definition: raw.php:31
$cn
Definition: raw.php:26
$_REQUEST['sb']
Definition: am_print.php:39