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");
77 $cnt_used=
$cn->get_value(
" select count(*) from jrn where currency_id=$1",[
$p_id]);
90 $cr_code_iso=
new IText(
"cr_code_iso", $record->cr_code_iso);
91 $cr_code_iso->size=10;
92 $cr_name=
new IText(
"cr_name", $record->cr_name);
94 $a_histo=$record->cn->get_array(
"select id,to_char(ch_from,'DD.MM.YYYY') as str_from,ch_value
98 currency_id=$1", array($record->currency_id));
99 $new_rate_date=
new IDate(
"new_rate_date");
100 $new_rate_value=
new INum(
"new_rate_value");
101 $new_rate_value->prec=6;
102 if ($record->currency_id!=-1)
104 require NOALYSS_TEMPLATE.
"/currency_mtable_input.php";
108 require NOALYSS_TEMPLATE.
"/currency_mtable_input_new.php";
127 if (
$table->currency_id == 0) {
129 $this->
set_error(
"cr_code_iso",
_(
"Devise par défaut ne peut être changée"));
132 if (trim(
$table->cr_code_iso)==
"")
135 $this->
set_error(
"cr_code_iso",
_(
"Code iso ne peut pas être vide"));
138 if (trim(
$table->cr_name)==
"")
141 $this->
set_error(
"cr_name",
_(
"Nom ne peut pas être vide"));
144 if (
$table->currency_id==-1)
150 $this->
set_error(
"str_from",
_(
"Date incorrecte, il faut au moins une valeur"));
155 $this->
set_error(
"ch_value",
_(
"Valeur incorrecte, il faut au moins une valeur"));
160 if (trim(
$table->str_from) ==
"" && trim(
$table->ch_value)==
"")
171 $this->
set_error(
"str_from",
_(
"Date incorrecte"));
176 $this->
set_error(
"ch_value",
_(
"Valeur incorrecte"));
184 and ch_from >= to_date($2,'DD.MM.YYYY') ", array(
$table->currency_id,
$table->str_from));
188 $this->
set_error(
"str_from",
_(
"Date doit être après la dernière valeur"));
194 $this->
set_error(
"str_from",
_(
"Valeur manquante"));
198 $cnt=
$cn->get_value(
"select count(*) from currency where id != $1 and cr_code_iso=$2",
203 $this->
set_error(
"cr_code_iso",
_(
"Code ISO existe déjà"));
206 if ( trim(mb_strlen(
$table->cr_code_iso))>10)
209 $this->
set_error(
"cr_code_iso",
_(
"Code ISO trop long max = 10"));
212 if ( trim(mb_strlen(
$table->cr_name))>80)
215 $this->
set_error(
"cr_name",
_(
"Nom trop long max=80"));
219 $this->
set_error(
"ch_value",
_(
"Valeur incorrecte"));
234 $cn=Dossier::connect();
240 if ($record->currency_id==-1)
244 $currency->setp(
"cr_code_iso", mb_strtoupper($record->cr_code_iso));
245 $currency->setp(
"cr_name", $record->cr_name);
249 $currency_history->setp(
"ch_value", $record->ch_value);
250 $currency_history->setp(
"ch_from", $record->str_from);
251 $currency_history->setp(
"currency_id",
$currency->id);
252 $currency_history->insert();
255 $this->
table->load();
261 $currency->setp(
"cr_code_iso", mb_strtoupper($record->cr_code_iso));
262 $currency->setp(
"cr_name", $record->cr_name);
265 if ($record->str_from!=
"")
268 $currency_history->setp(
"ch_value", $record->ch_value);
269 $currency_history->setp(
"ch_from", $record->str_from);
270 $currency_history->setp(
"currency_id",
$currency->id);
271 $currency_history->insert();
276 catch (Exception
$ex)
295 $this->
table->cr_code_iso=mb_strtoupper(
$http->request(
"cr_code_iso"));
296 $this->
table->cr_name=
$http->request(
"cr_name");
297 $this->
table->currency_id=
$http->request(
"p_id",
"number");
298 $this->
table->ch_value=
$http->request(
"new_rate_value");
299 $this->
table->str_from=
$http->request(
"new_rate_date");
307 if ($p_row[
'currency_id']==0)
311 parent::display_row($p_row);
323 parent::display_row($p_row);
isDate($p_date)
Verifie qu'une date est bien formaté en d.m.y et est valable.
for($i=0; $i< $nb_vatex_code; $i++)($i % 2==0) ? " odd " $cnt
_("actif, passif,charge,...")
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)