[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 10/162: Currency : add SQL constraint + doc
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 10/162: Currency : add SQL constraint + doc |
Date: |
Sat, 11 Jul 2020 13:23:19 -0400 (EDT) |
sparkyx pushed a commit to annotated tag E-4
in repository noalyss.
commit cff9e49910ccf8c0be1611ace94d769580463e0f
Author: Dany De Bontridder <danydb@noalyss.eu>
AuthorDate: 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] annotated tag E-4 created (now c7c64a9), Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 02/162: Currency : add PHP Class for SQL table, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 04/162: Currency : add test file + database file + mtable, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 03/162: Currency : create view + add currency name to table currency, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 01/162: create currency SQL tables, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 05/162: html_page_start : protect query, improve code, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 10/162: Currency : add SQL constraint + doc,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 08/162: Currency = add a mode currency, possible to work without, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 06/162: Currency : add ajax call to delete one rate , add documentation , remove debug info, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 12/162: Action_Code : add validate, cancel and modify icon, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 15/162: insert_jrnx : add debug, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 07/162: Currency : add menu for currency, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 13/162: indent, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 14/162: INum : add function onchange with inplace edit, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 16/162: Currency : insert operation with currency in VEN and ACH, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 17/162: Currency : fix rounded bugs in detail operation, Dany De Bontridder, 2020/07/11
- [Noalyss-commit] [noalyss] 18/162: task #448 : Currency : display currency info into operation detail, Dany De Bontridder, 2020/07/11