26require_once NOALYSS_INCLUDE.
'/database/currency_sql.class.php';
27require_once NOALYSS_INCLUDE.
'/database/currency_history_sql.class.php';
44 parent::__construct($p_table);
62 $this->a_order=array(
"cr_code_iso",
"currency_id",
"currency_history_id",
"cr_name",
"ch_value",
"str_from");
76 $cnt_used=
$cn->get_value(
" select count(*) from jrn where currency_id=$1",[
$p_id]);
89 $cr_code_iso=
new IText(
"cr_code_iso", $record->cr_code_iso);
90 $cr_code_iso->size=10;
91 $cr_name=
new IText(
"cr_name", $record->cr_name);
93 $a_histo=$record->cn->get_array(
"select id,to_char(ch_from,'DD.MM.YYYY') as str_from,ch_value
97 currency_id=$1", array($record->currency_id));
98 $new_rate_date=
new IDate(
"new_rate_date");
99 $new_rate_value=
new INum(
"new_rate_value");
100 $new_rate_value->prec=6;
101 if ($record->currency_id!=-1)
103 require NOALYSS_TEMPLATE.
"/currency_mtable_input.php";
107 require NOALYSS_TEMPLATE.
"/currency_mtable_input_new.php";
126 if (
$table->currency_id == 0) {
128 $this->
set_error(
"cr_code_iso", _(
"Devise par défaut ne peut être changée"));
131 if (trim(
$table->cr_code_iso)==
"")
134 $this->
set_error(
"cr_code_iso", _(
"Code iso ne peut pas être vide"));
137 if (trim(
$table->cr_name)==
"")
140 $this->
set_error(
"cr_name", _(
"Nom ne peut pas être vide"));
143 if (
$table->currency_id==-1)
149 $this->
set_error(
"str_from", _(
"Date incorrecte, il faut au moins une valeur"));
154 $this->
set_error(
"ch_value", _(
"Valeur incorrecte, il faut au moins une valeur"));
159 if (trim(
$table->str_from) ==
"" && trim(
$table->ch_value)==
"")
170 $this->
set_error(
"str_from", _(
"Date incorrecte"));
175 $this->
set_error(
"ch_value", _(
"Valeur incorrecte"));
183 and ch_from >= to_date($2,'DD.MM.YYYY') ", array(
$table->currency_id,
$table->str_from));
187 $this->
set_error(
"str_from", _(
"Date doit être après la dernière valeur"));
193 $this->
set_error(
"str_from", _(
"Valeur manquante"));
197 $cnt=
$cn->get_value(
"select count(*) from currency where id != $1 and cr_code_iso=$2",
202 $this->
set_error(
"cr_code_iso", _(
"Code ISO existe déjà"));
205 if ( trim(mb_strlen(
$table->cr_code_iso))>10)
208 $this->
set_error(
"cr_code_iso", _(
"Code ISO trop long max = 10"));
211 if ( trim(mb_strlen(
$table->cr_name))>80)
214 $this->
set_error(
"cr_name", _(
"Nom trop long max=80"));
218 $this->
set_error(
"ch_value", _(
"Valeur incorrecte"));
239 if ($record->currency_id==-1)
243 $currency->setp(
"cr_code_iso", mb_strtoupper($record->cr_code_iso));
244 $currency->setp(
"cr_name", $record->cr_name);
248 $currency_history->setp(
"ch_value", $record->ch_value);
249 $currency_history->setp(
"ch_from", $record->str_from);
250 $currency_history->setp(
"currency_id",
$currency->id);
251 $currency_history->insert();
254 $this->
table->load();
260 $currency->setp(
"cr_code_iso", mb_strtoupper($record->cr_code_iso));
261 $currency->setp(
"cr_name", $record->cr_name);
264 if ($record->str_from!=
"")
267 $currency_history->setp(
"ch_value", $record->ch_value);
268 $currency_history->setp(
"ch_from", $record->str_from);
269 $currency_history->setp(
"currency_id",
$currency->id);
270 $currency_history->insert();
275 catch (Exception
$ex)
294 $this->
table->cr_code_iso=mb_strtoupper(
$http->request(
"cr_code_iso"));
295 $this->
table->cr_name=
$http->request(
"cr_name");
296 $this->
table->currency_id=
$http->request(
"p_id",
"number");
297 $this->
table->ch_value=
$http->request(
"new_rate_value");
298 $this->
table->str_from=
$http->request(
"new_rate_date");
306 if ($p_row[
'currency_id']==0)
310 parent::display_row($p_row);
322 parent::display_row($p_row);
Manage the configuration of currency , add currency, rate, remove and update Concerned tables are v_c...
display_row($p_row)
We cannot modify the default currency (id := 0)
save()
Either insert a new currency + one rate or add a rate to an existing currency.
__construct(V_Currency_Last_Value_SQL $p_table)
from_request()
Fill the object from request parameters :
input()
Box to enter either a new currency or update a existing one.
check()
Check that the value are correct :
is_currency_used($p_id)
returns TRUE the currency is used otherwise FALSE.
abstract of the table public.currency
abstract of the table public.currency_history
Html Input : Input a date format dd.mm.yyyy The property title should be set to indicate what it is e...
This class handles only the numeric input, the input will call a javascript to change comma to period...
Purpose is to propose a librairy to display a table content and allow to update and delete row ,...
set_icon_mod($pString)
Set the icon to modify at the right ,the first col or left of the row, if the mod if custom ,...
set_delete_row($p_value)
Enable or disable the deletion of rows.
set_col_type($p_key, $p_value, $p_array=NULL)
set the type of a column , it will change in the input db box , the select must supply an array of po...
set_update_row($p_value)
Enable or disable the updating of rows.
set_sort_column($p_col)
set the column to sort by default
set_property_visible($p_key, $p_value)
set a column of the data row visible or not
set_error($p_col, $p_message)
set the error message for a wrong input
set_col_label($p_key, $p_display)
set the name to display for a column
class_currency_history_sql.php
if( $delta< 0) elseif( $delta==0)