[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 15/20: Menu : fix problem when cloning
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 15/20: Menu : fix problem when cloning |
Date: |
Sat, 24 Oct 2015 21:45:04 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 840b67478282dda1ff3982e1aa89c87bf6a547ff
Author: Dany De Bontridder <address@hidden>
Date: Sat Oct 24 21:51:33 2015 +0200
Menu : fix problem when cloning
---
include/profile.inc.php | 13 +++++++++--
sql/upgrade.sql | 49 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 3 deletions(-)
diff --git a/include/profile.inc.php b/include/profile.inc.php
index eb5a388..1ba3915 100644
--- a/include/profile.inc.php
+++ b/include/profile.inc.php
@@ -154,10 +154,17 @@ if (isset($_POST['clone']))
select 'copie de '||p_name,p_desc,with_calc,
with_direct_form from profile where p_id=$1 returning
p_id", array($p_id));
$cn->exec_sql("
- insert into profile_menu
(p_id,me_code,me_code_dep,p_order,p_type_display,pm_default)
- select
$1,me_code,me_code_dep,p_order,p_type_display,pm_default from profile_menu
- where p_id=$2
+ insert into profile_menu
(p_id,me_code,me_code_dep,p_order,p_type_display,pm_default)
+ select
$1,me_code,me_code_dep,p_order,p_type_display,pm_default from profile_menu
+ where p_id=$2
", array($new_id, $p_id));
+ $cn->exec_sql("select menu_complete_dependency($1)",array($new_id));
+ $cn->exec_sql("update profile_menu
+ set pm_id_dep=(select distinct higher_dep
+ from v_menu_dependency as a
+ where
+ a.pm_id= profile_menu.pm_id)
+ where pm_id_dep is null and p_id=$1",array($new_id));
$cn->commit();
$p_id=$new_id;
}
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index f759a9c..298cfe8 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -253,3 +253,52 @@ end;
LANGUAGE plpgsql ;
update attr_def set ad_extra=4 where ad_id in (6,7);
+
+CREATE OR REPLACE FUNCTION comptaproc.menu_complete_dependency(n_profile
numeric)
+ RETURNS void AS
+$BODY$
+declare
+ n_count integer;
+ csr_root_menu cursor (p_profile numeric) is select pm_id,
+ me_code,
+ me_code_dep
+
+ from profile_menu
+ where
+ me_code in
+ (select a.me_code_dep
+ from profile_menu as a
+ join profile_menu as b on (a.me_code=b.me_code and
a.me_code_dep=b.me_code_dep and a.pm_id <> b.pm_id and a.p_id=b.p_id)
+ where a.p_id=n_profile)
+ and p_id=p_profile;
+
+begin
+ for duplicate in csr_root_menu(n_profile)
+ loop
+ raise notice 'found %',duplicate;
+ update profile_menu set pm_id_dep = duplicate.pm_id
+ where pm_id in (select a.pm_id
+ from profile_menu as a
+ left join profile_menu as b on
(a.me_code=b.me_code and a.me_code_dep=b.me_code_dep)
+ where
+ a.p_id=n_profile
+ and b.p_id=n_profile
+ and a.pm_id_dep is null
+ and a.me_code_dep = duplicate.me_code
+ and a.pm_id < b.pm_id);
+ end loop;
+
+ for duplicate in csr_root_menu(n_profile)
+ loop
+ select count(*) into n_count from profile_menu where
p_id=n_profile and pm_id_dep = duplicate.pm_id;
+ raise notice '% use % times',duplicate,n_count;
+ if n_count = 0 then
+ raise notice ' Update with %',duplicate;
+ update profile_menu set pm_id_dep = duplicate.pm_id
where p_id = n_profile and me_code_dep = duplicate.me_code and pm_id_dep is
null;
+ end if;
+
+ end loop;
+
+end;
+$BODY$
+LANGUAGE plpgsql ;
\ No newline at end of file
- [Noalyss-commit] [noalyss] 02/20: Task #1187 - Problème avec la CA - totaux inégaux #0001187 : rounded problem, (continued)
- [Noalyss-commit] [noalyss] 02/20: Task #1187 - Problème avec la CA - totaux inégaux #0001187 : rounded problem, Dany De Bontridder, 2015/10/24
- [Noalyss-commit] [noalyss] 08/20: security, Dany De Bontridder, 2015/10/24
- [Noalyss-commit] [noalyss] 09/20: security, Dany De Bontridder, 2015/10/24
- [Noalyss-commit] [noalyss] 05/20: translation, Dany De Bontridder, 2015/10/24
- [Noalyss-commit] [noalyss] 10/20: security, Dany De Bontridder, 2015/10/24
- [Noalyss-commit] [noalyss] 12/20: protect variable, Dany De Bontridder, 2015/10/24
- [Noalyss-commit] [noalyss] 11/20: security, Dany De Bontridder, 2015/10/24
- [Noalyss-commit] [noalyss] 13/20: protect variable, Dany De Bontridder, 2015/10/24
- [Noalyss-commit] [noalyss] 14/20: Round value , due to the 4 dec in Sale and Expense, Dany De Bontridder, 2015/10/24
- [Noalyss-commit] [noalyss] 17/20: After cloning a profil, show it and select the default tab, Dany De Bontridder, 2015/10/24
- [Noalyss-commit] [noalyss] 15/20: Menu : fix problem when cloning,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 18/20: After cloning a profil, show it and select the default tab, Dany De Bontridder, 2015/10/24
- [Noalyss-commit] [noalyss] 19/20: Menu : highlight selected menu, Dany De Bontridder, 2015/10/24
- [Noalyss-commit] [noalyss] 20/20: Menu : highlight selected menu, Dany De Bontridder, 2015/10/24
- [Noalyss-commit] [noalyss] 16/20: Security, Dany De Bontridder, 2015/10/24