diff --git a/include/class/currency_mtable.class.php b/include/class/currency_mtable.class.php index b3faf9e21..401059683 100644 --- a/include/class/currency_mtable.class.php +++ b/include/class/currency_mtable.class.php @@ -108,6 +108,8 @@ class Currency_MTable extends Manage_Table_SQL * - Name cannot be empty * - At least one rate * - Date of the rate + * - code iso is max 10 char + * - name is max 80 * */ function check() @@ -184,8 +186,22 @@ class Currency_MTable extends Manage_Table_SQL $is_error++; $this->set_error("cr_code_iso", _("Code ISO existe déjà")); } - - + // - check size + if ( trim(mb_strlen($table->cr_code_iso))>10) + { + $is_error++; + $this->set_error("cr_code_iso", _("Code ISO trop long max = 10")); + } + // - check size + if ( trim(mb_strlen($table->cr_name))>80) + { + $is_error++; + $this->set_error("cr_name", _("Nom trop long max=80")); + } + if ( $table->ch_value < 0 || $table->ch_value == 0) { + $is_error++; + $this->set_error("ch_value", _("Valeur incorrecte")); + } if ($is_error==0) { return TRUE; diff --git a/include/lib/html_input.class.php b/include/lib/html_input.class.php index ba6d1c4e8..cfabb4980 100755 --- a/include/lib/html_input.class.php +++ b/include/lib/html_input.class.php @@ -261,6 +261,7 @@ class HtmlInput static function errorbulle($p_comment) { global $g_failed; + if ( $p_comment == "") return ""; $r=sprintf(' %s ', $p_comment, $p_comment, $g_failed); return $r; diff --git a/include/template/currency_mtable_input.php b/include/template/currency_mtable_input.php index e48c6ee5f..59f695781 100644 --- a/include/template/currency_mtable_input.php +++ b/include/template/currency_mtable_input.php @@ -31,6 +31,9 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas permis'); ISO + get_error("cr_code_iso"); + echo HtmlInput::errorbulle($error); + ?> input(); ?> @@ -38,7 +41,10 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas permis'); - + get_error("cr_name"); + echo HtmlInput::errorbulle($error); + ?> input(); ?> @@ -53,10 +59,14 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
- + - + @@ -85,7 +95,10 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
- + get_error("str_from"); + echo HtmlInput::errorbulle($error); + ?> input();?> @@ -93,7 +106,9 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
- + get_error("ch_value"); + echo HtmlInput::errorbulle($error);?> input();?> diff --git a/include/template/currency_mtable_input_new.php b/include/template/currency_mtable_input_new.php index 88639b86d..8a988b15b 100644 --- a/include/template/currency_mtable_input_new.php +++ b/include/template/currency_mtable_input_new.php @@ -31,6 +31,9 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
ISO + get_error("cr_code_iso"); + echo HtmlInput::errorbulle($error); + ?> input(); ?> @@ -38,7 +41,11 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
- + get_error("cr_name"); + echo HtmlInput::errorbulle($error); + ?> + input(); ?> @@ -46,7 +53,10 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
- + get_error("str_from"); + echo HtmlInput::errorbulle($error); + ?> input();?> @@ -54,7 +64,10 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
- + get_error("ch_value"); + echo HtmlInput::errorbulle($error); + ?> input();?> diff --git a/sql/upgrade.sql b/sql/upgrade.sql index b5d6ba8a4..14ccf3633 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -36,6 +36,8 @@ CREATE TABLE public.currency_history ( ALTER TABLE public.currency ADD cr_name varchar(80) NULL; +ALTER TABLE public.currency_history ADD CONSTRAINT currency_history_check CHECK (ch_value > 0) ; + -- Create view to manage the table create view v_currency_last_value as with recent_rate as @@ -57,5 +59,12 @@ currency as cr1 join recent_rate on (currency_id=cr1.id) join currency_history as ch1 on (recent_rate.currency_id=ch1.currency_id and rc_from=ch1.ch_from); +COMMENT ON COLUMN public.currency_history.id IS 'pk' ; +COMMENT ON COLUMN public.currency_history.ch_value IS 'rate of currency depending of currency of the folder' ; +COMMENT ON COLUMN public.currency_history.ch_from IS 'Date when the rate is available' ; +COMMENT ON COLUMN public.currency_history.currency_id IS 'FK to currency' ; +COMMENT ON COLUMN public.currency.cr_code_iso IS 'Code ISO' ; +COMMENT ON COLUMN public.currency.cr_name IS 'Name of the currency' ; + insert into "parameter" values ('MY_CURRENCY','N'); \ No newline at end of file