[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 07/218: Currency : add menu for currency
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 07/218: Currency : add menu for currency |
Date: |
Thu, 12 Sep 2019 15:58:29 -0400 (EDT) |
sparkyx pushed a commit to branch entreprise
in repository noalyss.
commit 27fa5a90ed84644e666641692c1e3e9b9685aad5
Author: Dany De Bontridder <address@hidden>
Date: Sun Apr 22 16:18:23 2018 +0200
Currency : add menu for currency
---
html/ajax_misc.php | 4 ++-
include/acc_currency_cfg.inc.php | 45 ++++++++++++++++++++++++++
include/ajax/ajax_currency.php | 69 ++++++++++++++++++++++++++++++++--------
sql/upgrade.sql | 8 +++++
4 files changed, 111 insertions(+), 15 deletions(-)
diff --git a/html/ajax_misc.php b/html/ajax_misc.php
index db1fc7c..5fa6fc5 100644
--- a/html/ajax_misc.php
+++ b/html/ajax_misc.php
@@ -246,7 +246,9 @@ $path = array(
// TVA param
"tva_parameter"=>"ajax_tva_parameter",
// Currency , delete a rate
- "CurrencyRateDelete"=>"ajax_currency"
+ "CurrencyRateDelete"=>"ajax_currency",
+ // Currency , add / remove / update currency
+ "CurrencyManage"=>"ajax_currency"
) ;
if (array_key_exists($op, $path)) {
diff --git a/include/acc_currency_cfg.inc.php b/include/acc_currency_cfg.inc.php
new file mode 100644
index 0000000..1b6d391
--- /dev/null
+++ b/include/acc_currency_cfg.inc.php
@@ -0,0 +1,45 @@
+<?php
+
+/*
+ * This file is part of NOALYSS.
+ *
+ * PhpCompta is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * PhpCompta is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with PhpCompta; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+// Copyright (2018) Author Dany De Bontridder <address@hidden>
+
+if (!defined('ALLOWED')) { die('Appel direct ne sont pas permis'); }
+
+/**
+ * @file
+ * @brief CFGCURRENCY Manage the currency and the rate
+ * @example test_currency_mtable.php
+ */
+
+require_once NOALYSS_INCLUDE."/class/currency_mtable.class.php";
+require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php";
+require_once NOALYSS_INCLUDE.'/database/v_currency_last_value_sql.class.php';
+
+$currency=new V_Currency_Last_Value_SQL($cn);
+
+
+
+$currency_table=new Currency_MTable($currency);
+
+$currency_table->set_callback("ajax_misc.php");
+$currency_table->add_json_param("op", "CurrencyManage");
+echo '<div class="content">';
+$currency_table->create_js_script();
+$currency_table->display_table();
+echo '</div>';
\ No newline at end of file
diff --git a/include/ajax/ajax_currency.php b/include/ajax/ajax_currency.php
index e1068c5..a0bf869 100644
--- a/include/ajax/ajax_currency.php
+++ b/include/ajax/ajax_currency.php
@@ -21,7 +21,9 @@
if (!defined('ALLOWED'))
die('Appel direct ne sont pas permis');
-
+require_once NOALYSS_INCLUDE."/class/currency_mtable.class.php";
+require_once NOALYSS_INCLUDE."/lib/manage_table_sql.class.php";
+require_once NOALYSS_INCLUDE.'/database/v_currency_last_value_sql.class.php';
/**
* @file
* @brief Ajax response for currency related calls
@@ -49,7 +51,7 @@ catch (Exception $ex)
*/
if ($g_user->check_module('CFGCURRENCY')==0)
{
- // return;
+ // return;
}
/*
@@ -58,32 +60,71 @@ if ($g_user->check_module('CFGCURRENCY')==0)
switch ($act)
{
case 'CurrencyRateDelete':
- try {
- $currency_rate_id=$http->get("currency_rate_id","number");
+ try
+ {
+ $currency_rate_id=$http->get("currency_rate_id", "number");
// check that a least one rate is remaining for this currency
-
// 1. get the currency
- $currency_id=$cn->get_value("select currency_id from
currency_history where id=$1",[$currency_rate_id]);
-
+ $currency_id=$cn->get_value("select currency_id from
currency_history where id=$1", [$currency_rate_id]);
+
// 2. get the number of rate
- if ( $currency_id == "") {
+ if ($currency_id=="")
+ {
throw new Exception(_("Taux inexistant"));
}
- $cnt=$cn->get_value("select count(*) from currency_history where
currency_id=$1",[$currency_id]);
-
+ $cnt=$cn->get_value("select count(*) from currency_history where
currency_id=$1", [$currency_id]);
+
// 3. if number of rate > 1 , then delete
- if ( $cnt > 1)
+ if ($cnt>1)
{
- $cn->exec_sql("delete from currency_history where
id=$1",[$currency_rate_id]);
+ $cn->exec_sql("delete from currency_history where id=$1",
[$currency_rate_id]);
$a_answer['status']=_("OK");
$a_answer['content']=_("Taux effacé");
- } else {
+ }
+ else
+ {
$a_answer['content']=_("Non effacé : Il faut au moins un
taux");
}
- } catch (Exception $ex) {
+ }
+ catch (Exception $ex)
+ {
$a_answer['content']=$ex->getMessage();
}
break;
+ case 'CurrencyManage':
+ $table=$http->request('table');
+ $action=$http->request('action');
+ $p_id=$http->request('p_id', "number");
+ $ctl_id=$http->request('ctl');
+ $currency=new V_Currency_Last_Value_SQL($cn,$p_id);
+ $currency_table=new Currency_MTable($currency);
+
+ $currency_table->set_callback("ajax_misc.php");
+ $currency_table->add_json_param("op", "CurrencyManage");
+ /*
+ * we're in ajax part
+ */
+ if ($action=="input")
+ {
+ $currency_table->set_object_name($ctl_id);
+ header('Content-type: text/xml; charset=UTF-8');
+ echo $currency_table->ajax_input()->saveXML();
+ return;
+ }
+ elseif ($action=="save")
+ {
+ $currency_table->set_object_name($ctl_id);
+ header('Content-type: text/xml; charset=UTF-8');
+ echo $currency_table->ajax_save()->saveXML();
+ return;
+ }
+ elseif ($action=="delete")
+ {
+ $currency_table->set_object_name($ctl_id);
+ header('Content-type: text/xml; charset=UTF-8');
+ echo $currency_table->ajax_delete()->saveXML();
+ return;
+ }
}
$jsson=json_encode($a_answer,
JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_NUMERIC_CHECK);
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index 001b69c..cd61331 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -1,3 +1,11 @@
+INSERT INTO public.menu_ref
+(me_code, me_menu, me_file, me_url, me_description, me_parameter,
me_javascript, me_type, me_description_etendue)
+VALUES('CFGCURRENCY', 'Conf. Devises', 'acc_currency_cfg.inc.php', NULL,
'Devises', NULL,NULL,'ME','Permet de configurer les devises');
+
+INSERT INTO public.profile_menu
+(pm_id, me_code, me_code_dep, p_id, p_order, p_type_display, pm_default,
pm_id_dep)
+VALUES(nextval('profile_menu_pm_id_seq'), 'CFGCURRENCY', 'PARAM', 1, 50, 'E',
0, 45);
+
-- Drop table
-- DROP TABLE public.currency
- [Noalyss-commit] [noalyss] branch entreprise created (now 0030779), Dany De Bontridder, 2019/09/12
- [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 <=
- [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, 2019/09/12
- [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