noalyss Version-9
print_operation_currency.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * PhpCompta 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 2 of the License, or
9 * (at your option) any later version.
10 *
11 * PhpCompta 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 PhpCompta; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20// Copyright (2002-2021) Author Dany De Bontridder <danydb@noalyss.eu>
21
22/**
23 * @file
24 * @brief manage the operation in currency : export CSV, export PDF , output in HTML
25 */
26/**
27 * @class Print_Operation_Currency
28 * @brief manage the operation in currency : export CSV , output in HTML
29 */
31{
32
34
35
37 {
38 $this->data_operation=$data_operation;
39 }
40
41
42
43 /**
44 * @brief build a Print_Operation_Currency Object thanks the http request ($_REQUEST) with the right Filter
45 * @param string $p_search possible values are "by_card" if we filter by card, by_account if we
46 * filter by accounting, by_category or empty if we take everything
47 */
48 static function build($p_search)
49 {
50 $http=new HttpInput();
51 $from_account=$http->request("from_account", "string", "");
52 $to_account=$http->request("to_account", "string", "");
53 $currency_code=$http->request("p_currency_code", "string", "0");
54 $from_date=$http->request("from_date", "date", "");
55 $to_date=$http->request("to_date", "date", "");
56 $card=$http->request("card","string","");
57 $card_category_id=$http->request("card_category_id","string","0");
59 if ($p_search=='by_card')
60 {
62 }
63 elseif ($p_search=='by_accounting')
64 {
66 $to_date,$currency_code,$from_account,$to_account);
67 }
68 elseif ($p_search=="by_category")
69 {
71 $currency_code,$card_category_id);
72 }
73 elseif ($p_search=="all")
74 {
76 }
77 else
78 {
79 throw new Exception("PROC67 Invalid parameter");
80 }
81
84 }
85 /**
86 * @brief return Data_Currency_Operation with a possible filter
87 * @return type
88 */
89 public function getData_operation()
90 {
92 }
93
94 /**
95 * @brief return Data_Currency_Operation with a possible filter
96 * @return type
97 */
99 {
100 $this->data_operation=$data_operation;
101 }
102 /**
103 * @brief Display in HTML
104 * @return string
105 */
106 function export_html()
107 {
108 $aData=$this->data_operation->get_data();
109 if ( empty ($aData)){
110 return h2(_("Aucune donnée"),'class="error"');
111 }
112 $date=_("Date");
113 $accounting=_("Poste comptable");
114 $card_qcode=_("Fiche");
115 $receipt=_("Pièce");
116 $internal=_("Internal");
117 $comment=_("Libellé");
118 $amount=_("Montant");
119 $amount_currency=_("Mont. Devise");
120 $rate_ref=_("Taux de référence");
121 $rate=_("Taux utilisé");
122 $currency=_("Devise");
123 $r=HtmlInput::filter_table("pcur01_tb", '0,1,2,3,4,5,6,7,8,9,10', 1);
124 $r.=<<<EOF
125<table id="pcur01_tb" class="result">
126<tr>
127 <th>{$date}</th>
128 <th>{$accounting}</th>
129 <th>{$card_qcode}</th>
130 <th>{$receipt}</th>
131 <th>{$comment}</th>
132 <th>{$internal}</th>
133 <th>{$currency}</th>
134 <th class="num">{$amount}</th>
135 <th class="num">{$rate}</th>
136 <th class="num">{$rate_ref}</th>
137 <th class="num">{$amount_currency}</th>
138</tr>
139
140EOF;
141 $nb_data=count($aData);
142 for ($i=0;$i<$nb_data;$i++)
143 {
144 $r.="<tr>";
145 $r.=td($aData[$i]['j_date']);
146 $r.=td($aData[$i]['j_poste']);
147 $r.=td($aData[$i]['fiche_qcode']);
148 $r.=td($aData[$i]['jr_pj_number']);
149 $r.=td($aData[$i]['jr_comment']);
150 $r.="<td>";
151 $r.=HtmlInput::detail_op($aData[$i]['jr_id'], $aData[$i]['jr_internal']);
152 $r.="</td>";
153 $r.=td($aData[$i]['currency_code_iso']);
154 $r.=td(nbm($aData[$i]['j_montant'],2),'class="num"');
155 $r.=td(round($aData[$i]['currency_rate'],4),'class="num"');
156 $r.=td(round($aData[$i]['currency_rate_ref'],4),'class="num"');
157 $r.=td(nbm($aData[$i]['oc_amount'],4),'class="num"');
158 $r.="</tr>";
159 }
160 $r.="</table>";
161 return $r;
162
163 }
164 /**
165 * @brief Output in CSV
166 */
167 function export_csv(Noalyss_CSV $export)
168 {
169 $aData=$this->data_operation->get_data();
170
171 $date=_("Date");
172 $accounting=_("Poste comptable");
173 $card_qcode=_("Fiche");
174 $receipt=_("Pièce");
175 $internal=_("Internal");
176 $comment=_("Libellé");
177 $amount=_("Montant");
178 $amount_currency=_("Mont. Devise");
179 $rate_ref=_("Taux de référence");
180 $rate=_("Taux utilisé");
181 $currency=_("Devise");
182
183 $export->write_header(array ($date,
185 $card_qcode,
186 $receipt,
187 $comment,
188 $internal,
189 $currency,
190 $amount,
191 $rate,
192 $rate_ref,
193 $amount_currency));
194 $nb_data=count($aData);
195 for ($i=0;$i<$nb_data;$i++)
196 {
197 $export->add($aData[$i]['j_date']);
198 $export->add($aData[$i]['j_poste']);
199 $export->add($aData[$i]['fiche_qcode']);
200 $export->add($aData[$i]['jr_pj_number']);
201 $export->add($aData[$i]['jr_comment']);
202 $export->add($aData[$i]['jr_internal']);
203 $export->add($aData[$i]['currency_code_iso']);
204 $export->add(nbm($aData[$i]['j_montant'],2),"number");
205 $export->add(round($aData[$i]['currency_rate'],4),"number");
206 $export->add(round($aData[$i]['currency_rate_ref'],4),"number");
207 $export->add(nbm($aData[$i]['oc_amount'],4),"number");
208 $export->write();
209 }
210 }
211
212}
213
214?>
h2($p_string, $p_class="", $raw="")
Definition: ac_common.php:68
th($p_string, $p_extra='', $raw='')
Definition: ac_common.php:58
tr($p_string, $p_extra='')
Definition: ac_common.php:88
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
nbm($p_number, $p_dec=2)
format the number with a sep.
Definition: ac_common.php:137
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
build the SQL and fetch data of data currency operation from database ,
static connect()
filter data in currency from datase , inherit from Data_Currency_Operation, filter on a range of acco...
filter data in currency from datase , inherit from Data_Currency_Operation, filter on card category
filter data in currency froqm datase , inherit from Data_Currency_Operation, filter on a specific car...
static detail_op($p_jr_id, $p_mesg)
return a string containing the html code for calling the modifyOperation
static filter_table($p_table_id, $p_col, $start_row)
filter the rows in a table and keep the colored row in alternance
manage the http input (get , post, request) and extract from an array
manage the operation in currency : export CSV , output in HTML
getData_operation()
return Data_Currency_Operation with a possible filter
export_csv(Noalyss_CSV $export)
Output in CSV.
__construct(Data_Currency_Operation $data_operation)
static build($p_search)
build a Print_Operation_Currency Object thanks the http request ($_REQUEST) with the right Filter
setData_operation($data_operation)
return Data_Currency_Operation with a possible filter
$all table
$print_operation_currency
if( $delta< 0) elseif( $delta==0)