diff --git a/html/admin/sql/patch/upgrade73.sql b/html/admin/sql/patch/upgrade73.sql new file mode 100644 index 000000000..d17cf2de2 --- /dev/null +++ b/html/admin/sql/patch/upgrade73.sql @@ -0,0 +1,33 @@ +begin; +DROP FUNCTION if exists comptaproc.get_action_tree(); + +CREATE OR REPLACE FUNCTION comptaproc.action_get_tree(p_id bigint) + RETURNS setof bigint AS +$BODY$ + +declare + e bigint; + i bigint; +begin + for e in select ag_id from action_gestion where ag_ref_ag_id=p_id + loop + if e = 0 then + return; + end if; + return next e; + for i in select ag_id from action_gestion where ag_ref_ag_id=e + loop + if i = 0 then + return; + end if; + return next i; + end loop; + end loop; + return; + +end; +$BODY$ + LANGUAGE 'plpgsql' VOLATILE; + +update version set val=74; +commit; \ No newline at end of file diff --git a/include/class_action.php b/include/class_action.php index 79d9548b3..d7efab9e6 100644 --- a/include/class_action.php +++ b/include/class_action.php @@ -506,8 +506,10 @@ class Action // show the list of the concern operation if ( $this->db->count_sql('select * from action_gestion where ag_ref_ag_id!=0 and ag_ref_ag_id='.$this->ag_id. - " limit 2") > 0 ) - $r.=$this->myList($p_base,""," and ag_ref_ag_id=".$this->ag_id); + " limit 2") > 0 ) { + $sql=sprintf(" and ag_id in (select action_get_tree from comptaproc.action_get_tree(%s)) ",$this->ag_id); + $r.=$this->myList($p_base,"",$sql); + } return $r; } diff --git a/include/constant.php b/include/constant.php index 6fe63b05d..1ff65656a 100644 --- a/include/constant.php +++ b/include/constant.php @@ -26,7 +26,7 @@ require_once ('config.inc.php'); require_once('constant.security.php'); -define ("DBVERSION",73); +define ("DBVERSION",74); define ("MAX_COMPTE",4); define ('MAX_ARTICLE',9);