[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 143/218: Currency : precision 6, display defa
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 143/218: Currency : precision 6, display default currency , protect used currency against delete |
Date: |
Thu, 12 Sep 2019 15:58:56 -0400 (EDT) |
sparkyx pushed a commit to branch entreprise
in repository noalyss.
commit 5c40f5f5f035d5d255a7ea829d4a2830bc0ad83e
Author: Dany De Bontridder <address@hidden>
Date: Fri Jan 4 17:11:35 2019 +0100
Currency : precision 6,
display default currency ,
protect used currency against delete
---
include/class/currency_mtable.class.php | 45 +++++++++++++++++++++++++--------
1 file changed, 35 insertions(+), 10 deletions(-)
diff --git a/include/class/currency_mtable.class.php
b/include/class/currency_mtable.class.php
index 89ddf5a..fa6203e 100644
--- a/include/class/currency_mtable.class.php
+++ b/include/class/currency_mtable.class.php
@@ -29,7 +29,7 @@ require_once
NOALYSS_INCLUDE.'/database/currency_history_sql.class.php';
/**
* Manage the configuration of currency , add currency, rate, remove and
update
- * Concerned tables are v_currency_last_value _SQL , Currency_SQL ,
Currency_History_SQL
+ * Concerned tables are v_currency_last_value_SQL , Currency_SQL ,
Currency_History_SQL
* currency_id = 0 for the default currency , -1 for a new one
*/
class Currency_MTable extends Manage_Table_SQL
@@ -40,12 +40,12 @@ class Currency_MTable extends Manage_Table_SQL
* @param Data $p_table
* @example test_currency_mtable.php
*/
- function __construct(Data_SQL $p_table)
+ function __construct(V_Currency_Last_Value_SQL $p_table)
{
parent::__construct($p_table);
// If currency , cannot be deleted
- if ($this->is_currency_used()==TRUE)
+ if ($this->is_currency_used($p_table->currency_id)==TRUE)
{
$this->set_delete_row(FALSE);
}
@@ -68,11 +68,17 @@ class Currency_MTable extends Manage_Table_SQL
/**
* returns TRUE the currency is used otherwise FALSE. We cannot delete a
currency which is used in a
* operation
+ * @param integer $p_id currency_id
* @returns boolean true if currency is used
- * @todo Currency_MTable.is_currency_used to implement
*/
- function is_currency_used()
+ function is_currency_used($p_id)
{
+ global $cn;
+ $cnt_used=$cn->get_value(" select count(*) from jrn where
currency_id=$1",[$p_id]);
+ if ($cnt_used > 0)
+ {
+ return TRUE;
+ }
return FALSE;
}
/**
@@ -92,7 +98,7 @@ class Currency_MTable extends Manage_Table_SQL
currency_id=$1", array($record->currency_id));
$new_rate_date=new IDate("new_rate_date");
$new_rate_value=new INum("new_rate_value");
- $new_rate_value->prec=4;
+ $new_rate_value->prec=6;
if ($record->currency_id!=-1)
{
require NOALYSS_TEMPLATE."/currency_mtable_input.php";
@@ -286,23 +292,42 @@ class Currency_MTable extends Manage_Table_SQL
function from_request()
{
$http=new HttpInput();
-
$this->table->cr_code_iso=mb_strtoupper(strip_tags($http->request("cr_code_iso")));
- $this->table->cr_name=strip_tags($http->request("cr_name"));
+ $this->table->cr_code_iso=mb_strtoupper($http->request("cr_code_iso"));
+ $this->table->cr_name=$http->request("cr_name");
$this->table->currency_id=$http->request("p_id", "number");
$this->table->ch_value=$http->request("new_rate_value");
$this->table->str_from=$http->request("new_rate_date");
}
/**
- * We don't display the default currency (id := -1)
+ *
+ * We cannot modify the default currency (id := 0)
*/
function display_row($p_row)
{
if ($p_row['currency_id']==0)
{
+ $this->set_update_row(FALSE);
+ $this->set_delete_row(FALSE);
+ parent::display_row($p_row);
return;
}
+ if ($this->is_currency_used($p_row['currency_id'])==TRUE)
+ {
+ $this->set_delete_row(FALSE);
+ } else {
+ $this->set_delete_row(TRUE);
+
+ }
+ $this->set_update_row(TRUE);
parent::display_row($p_row);
}
-
+ /**
+ * Delete after checking the currency is not used
+ */
+ function delete()
+ {
+ $id=$this->get_table()->currency_id;
+ if ( $this->is_currency_used($id) == FALSE)
$this->table->delete();
+ }
}
- [Noalyss-commit] [noalyss] 78/218: Bug : ajax fails if wait_box does not exist, (continued)
- [Noalyss-commit] [noalyss] 78/218: Bug : ajax fails if wait_box does not exist, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 105/218: Background color, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 92/218: Merge branch 'master' into r700-currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 98/218: Fin currency : detail operation show currency , rate and amount, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 97/218: Fin : currency , add missing info into Operation_Currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 113/218: change background, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 95/218: currency : adapt for FIN, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 122/218: Currency : display correctly the saldo at the end / beginning operation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 136/218: Translation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 115/218: Currency : ledger printing for FIN + detail operation, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 143/218: Currency : precision 6, display default currency , protect used currency against delete,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 149/218: Currency : purchase, save all detail also in currency, fix problem with the advance payment, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 151/218: Task #1660 : place the button for the inventory on the top, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 157/218: Merge branch 'r700-currency' of gitlab.noalyss.eu:noalyss/noalyss into r700-currency, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 75/218: Improve waiting box, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 171/218: Mantis #0001666: Export CSV depuis histo ne filtre pas par journal, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 175/218: mantis #1690: Bug : impossible d'utiliser < dans Inplace_Edit Use base64_decode to protect the string in serialize, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 194/218: TEST : fix some little bugs, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 199/218: Merge with dev7109, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 215/218: Improve Doxygen, Dany De Bontridder, 2019/09/12
- [Noalyss-commit] [noalyss] 217/218: Mantis #0001442: CA - facilité de manipulation - effacement Button for cleaning detail analytique in operation, Dany De Bontridder, 2019/09/12