[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 10/218: Currency : add SQL constraint + doc
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 10/218: Currency : add SQL constraint + doc |
Date: |
Thu, 12 Sep 2019 15:58:30 -0400 (EDT) |
sparkyx pushed a commit to branch entreprise
in repository noalyss.
commit cff9e49910ccf8c0be1611ace94d769580463e0f
Author: Dany De Bontridder <address@hidden>
Date: Sun Apr 22 17:05:04 2018 +0200
Currency : add SQL constraint + doc
---
include/class/currency_mtable.class.php | 20 ++++++++++++++++++--
include/lib/html_input.class.php | 1 +
include/template/currency_mtable_input.php | 25 ++++++++++++++++++++-----
include/template/currency_mtable_input_new.php | 19 ++++++++++++++++---
sql/upgrade.sql | 9 +++++++++
5 files changed, 64 insertions(+), 10 deletions(-)
diff --git a/include/class/currency_mtable.class.php
b/include/class/currency_mtable.class.php
index b3faf9e..4010596 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 ba6d1c4..cfabb49 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('<A HREF="#" tabindex="-1"
style="display:inline;color:red;background-color:transparent;padding-left:4px;padding-right:4px;text-decoration:none;"
onmouseover="displayBulle(\'%s\')" onclick="displayBulle(\'%s\')"
onmouseout="hideBulle(0)"> %s </A>',
$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 e48c6ee..59f6957 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');
<tr>
<td>
ISO
+ <?php $error=$this->get_error("cr_code_iso");
+ echo HtmlInput::errorbulle($error);
+ ?>
</td>
<td>
<?php echo $cr_code_iso->input(); ?>
@@ -38,7 +41,10 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas
permis');
</tr>
<tr>
<td>
- <?php echo _("Nom")?>
+ <?php echo _("Nom");
+ $error=$this->get_error("cr_name");
+ echo HtmlInput::errorbulle($error);
+ ?>
</td>
<td>
<?php echo $cr_name->input(); ?>
@@ -53,10 +59,14 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas
permis');
<table class="result" id="currency_rate_table">
<tr>
<th>
- <?php echo _("Date");?>
+ <?php echo _("Date");
+
+ ?>
</th>
<th>
- <?php echo _("Valeur")?>
+ <?php echo _("Valeur");
+
+ ?>
</th>
<th>
@@ -85,7 +95,10 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas
permis');
<?php endfor; ?>
<tr>
<td>
- <?php echo _("Date"); ?>
+ <?php echo _("Date");
+ $error=$this->get_error("str_from");
+ echo HtmlInput::errorbulle($error);
+ ?>
</td>
<td>
<?php echo $new_rate_date->input();?>
@@ -93,7 +106,9 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas
permis');
</tr>
<tr>
<td>
- <?php echo _("Valeur"); ?>
+ <?php echo _("Valeur");
+ $error=$this->get_error("ch_value");
+ echo HtmlInput::errorbulle($error);?>
</td>
<td>
<?php echo $new_rate_value->input();?>
diff --git a/include/template/currency_mtable_input_new.php
b/include/template/currency_mtable_input_new.php
index 88639b8..8a988b1 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');
<tr>
<td>
ISO
+ <?php $error=$this->get_error("cr_code_iso");
+ echo HtmlInput::errorbulle($error);
+ ?>
</td>
<td>
<?php echo $cr_code_iso->input(); ?>
@@ -38,7 +41,11 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas
permis');
</tr>
<tr>
<td>
- <?php echo _("Nom")?>
+ <?php echo _("Nom");
+ $error=$this->get_error("cr_name");
+ echo HtmlInput::errorbulle($error);
+ ?>
+
</td>
<td>
<?php echo $cr_name->input(); ?>
@@ -46,7 +53,10 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas
permis');
</tr>
<tr>
<td>
- <?php echo _("Date"); ?>
+ <?php echo _("Date");
+ $error=$this->get_error("str_from");
+ echo HtmlInput::errorbulle($error);
+ ?>
</td>
<td>
<?php echo $new_rate_date->input();?>
@@ -54,7 +64,10 @@ if (!defined('ALLOWED')) die('Appel direct ne sont pas
permis');
</tr>
<tr>
<td>
- <?php echo _("Valeur"); ?>
+ <?php echo _("Valeur");
+ $error=$this->get_error("ch_value");
+ echo HtmlInput::errorbulle($error);
+ ?>
</td>
<td>
<?php echo $new_rate_value->input();?>
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index b5d6ba8..14ccf36 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
- [Noalyss-commit] [noalyss] 01/218: create currency SQL tables, (continued)
- [Noalyss-commit] [noalyss] 01/218: create currency SQL tables, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 02/218: Currency : add PHP Class for SQL table, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 03/218: Currency : create view + add currency name to table currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 06/218: Currency : add ajax call to delete one rate , add documentation , remove debug info, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 12/218: Action_Code : add validate, cancel and modify icon, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 15/218: insert_jrnx : add debug, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 19/218: Task #448 : currency : cosmetic operation detail, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 07/218: Currency : add menu for currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 11/218: Currency : SQL menu change, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 14/218: INum : add function onchange with inplace edit, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 10/218: Currency : add SQL constraint + doc,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 05/218: html_page_start : protect query, improve code, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 08/218: Currency = add a mode currency, possible to work without, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 04/218: Currency : add test file + database file + mtable, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 21/218: Task #448 : issue with reconciliation amount, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 22/218: Task #448 : identical operation with currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 24/218: Task #448 : rounded value for VEN, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 27/218: Task #448 : delete unused currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 28/218: Task #448 : currency , EUR cannot be changed and not display, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 31/218: task #448 : currency always used and remove parameter 'use_currency' from parameters, add SQL script, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 38/218: Task #448 : currency improve detail of operation, Dany De Bontridder, 2019/09/12