diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 3bde11bb6..11ed14cd7 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -537,7 +537,7 @@ EOF; case 'create_menu'; require_once 'ajax_create_menu.php'; break; - case 'mod_menu'; + case 'modify_menu'; require_once 'ajax_mod_menu.php'; break; default: diff --git a/html/export.php b/html/export.php index ac56c6de1..3145e3dcc 100644 --- a/html/export.php +++ b/html/export.php @@ -26,17 +26,17 @@ * */ - +global $g_user; require_once('class_database.php'); require_once('class_user.php'); $gDossier=dossier::id(); $cn=new Database($gDossier); -$user=new User($cn); -$user->Check(); -$action=$user->check_dossier($gDossier); +$g_user=new User($cn); +$g_user->Check(); +$action=$g_user->check_dossier($gDossier); -if ( $action=='X' || ! isset($_GET['act']) || $user->check_print($_GET['act'])==0 ) +if ( $action=='X' || ! isset($_GET['act']) || $g_user->check_print($_GET['act'])==0 ) { echo alert('Accès interdit'); redirect("do.php?".dossier::get()); diff --git a/html/js/scripts.js b/html/js/scripts.js index 9971f9f2d..37d342e25 100644 --- a/html/js/scripts.js +++ b/html/js/scripts.js @@ -1302,11 +1302,11 @@ function create_menu(p_dossier) } ); } -function mod_menu(p_dossier,me_code) +function modify_menu(p_dossier,me_code) { waiting_box(); removeDiv('divmenu'); - var qs="op=mod_menu&gDossier="+p_dossier+"&ctl=divmenu&me_code="+me_code; + var qs="op=modify_menu&gDossier="+p_dossier+"&ctl=divmenu&me_code="+me_code; var action=new Ajax.Request ( 'ajax_misc.php', { diff --git a/include/ajax_add_menu.php b/include/ajax_add_menu.php index 799381b27..eed6e00c8 100644 --- a/include/ajax_add_menu.php +++ b/include/ajax_add_menu.php @@ -29,8 +29,9 @@ $ame_code_dep=$cn->make_array(" select me_code,me_code||' '||me_menu||' '||coalesce(me_description,'') from menu_ref where - me_file is null and me_javascript is null and me_type<>'PR' - UNION ALL + me_file is null and me_javascript is null and me_url is null and me_type<>'PR' and me_type <> 'SP' + and me_code in (select me_code from profile_menu where p_id=".sql_string($p_id).")". + " UNION ALL select me_code,me_code||' '||me_menu||' '||coalesce(me_description,'') from menu_ref where me_code='EXT' diff --git a/include/ajax_get_menu_detail.php b/include/ajax_get_menu_detail.php index 6df72abb7..8d311469b 100644 --- a/include/ajax_get_menu_detail.php +++ b/include/ajax_get_menu_detail.php @@ -29,13 +29,18 @@ // retrieve data $profile=$cn->get_value("select p_id from profile_menu where pm_id=$1",array($pm_id)); $a_value=$cn->make_array("select me_code,me_code||' '||me_menu||' '||coalesce(me_description,'') from menu_ref",0); -$a_value_null=$cn->make_array("select me_code,me_code||' '||me_menu||' '||coalesce(me_description,'') from menu_ref +$ame_code_dep=$cn->make_array(" + select me_code,me_code||' '||me_menu||' '||coalesce(me_description,'') from + menu_ref where - me_code in (select me_code from profile_menu where p_id=$profile and p_type_display<>'P' and pm_id <> $pm_id) - UNION ALL + me_file is null and me_javascript is null and me_url is null and me_type<>'PR' and me_type <> 'SP' + and me_code in (select me_code from profile_menu where p_id=".sql_string($profile).")". + " UNION ALL select me_code,me_code||' '||me_menu||' '||coalesce(me_description,'') from menu_ref where - me_code='EXT'",1); + me_code='EXT' + order by 1 + ",1); $a_type=$cn->make_array("select pm_type,pm_desc from profile_menu_type",1); $array=$cn->get_array("select p_id,pm_id,me_code,me_code_dep,p_order,p_type_display,pm_default @@ -54,7 +59,7 @@ $me_code->value=$a_value; $me_code->selected=$array[0]['me_code']; $me_code_dep=new ISelect('me_code_dep'); -$me_code_dep->value=$a_value_null; +$me_code_dep->value=$ame_code_dep; $me_code_dep->selected=$array[0]['me_code_dep']; $p_order=new Inum('p_order',$array[0]['p_order']); diff --git a/include/ajax_mod_menu.php b/include/ajax_mod_menu.php index 4252d7ecc..f9c70f54d 100644 --- a/include/ajax_mod_menu.php +++ b/include/ajax_mod_menu.php @@ -5,7 +5,7 @@ $msg="Modification ".$m->me_code.' '.h($m->me_menu); echo '
'; require_once 'template/menu_detail.php'; -echo HtmlInput::submit('mod_menu','Sauver'); +echo HtmlInput::submit('modify_menu','Sauver'); echo HtmlInput::button_close('divmenu'); echo '
'; ?> diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index 24e02a207..da9f9059d 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -340,6 +340,7 @@ class Acc_Ledger extends jrn_def_sql */ function get_row($p_from,$p_to,$p_limit=-1,$p_offset=-1) { + global $g_user; $periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','jr_tech_per'); $cond_limite=($p_limit!=-1)?" limit ".$p_limit." offset ".$p_offset:""; @@ -379,7 +380,10 @@ class Acc_Ledger extends jrn_def_sql jr_montant, j_qcode, jr_rapt as oc, j_tech_per as periode from jrnx left join jrn on ". - "jr_grpt_id=j_grpt left join tmp_pcmn on pcm_val=j_poste where ". + "jr_grpt_id=j_grpt left join tmp_pcmn on pcm_val=j_poste + join jrn_def on (jr_def_id=jrn_def_id) + where ". + $g_user->get_ledger_sql()." and ". " ".$periode." order by j_date::date,substring(jr_pj_number,'\\\\d+$') asc,j_grpt,j_debit desc ". $cond_limite); @@ -494,9 +498,10 @@ class Acc_Ledger extends jrn_def_sql */ function get_rowSimple($p_from,$p_to,$trunc=0,$p_limit=-1,$p_offset=-1) { + global $g_user; // Grand-livre : id= 0 //--- - $jrn=($this->id == 0 )?"":"and jrn_def_id = ".$this->id; + $jrn=($this->id == 0 )?"and ".$g_user->get_ledger_sql():"and jrn_def_id = ".$this->id; $periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','jr_tech_per'); @@ -2679,13 +2684,14 @@ class Acc_Ledger extends jrn_def_sql */ function get_operation($p_from,$p_to) { - $jrn=($this->id==0)?'':' and jr_def_id = '.$this->id; + global $g_user; + $jrn=($this->id==0)?'and '.$g_user->get_ledger_sql():' and jr_def_id = '.$this->id; $sql="select jr_id as id ,jr_internal as internal, ". "jr_pj_number as pj,jr_grpt_id,". " to_char(jr_date,'DDMMYY') as date_fmt, ". " jr_comment as comment, jr_montant as montant ,". " jr_grpt_id,jr_def_id". - " from jrn where ". + " from jrn join jrn_def on (jr_def_id=jrn_def_id) where ". " jr_date >= (select p_start from parm_periode where p_id = $1) and jr_date <= (select p_end from parm_periode where p_id = $2)" . ' '.$jrn.' order by jr_date,substring(jr_pj_number,\'\\\d+$\')::numeric asc'; diff --git a/include/class_pre_operation.php b/include/class_pre_operation.php index 8e20665d9..f1321c442 100644 --- a/include/class_pre_operation.php +++ b/include/class_pre_operation.php @@ -184,7 +184,7 @@ class Pre_operation_detail $this->db=$p_cn; $this->operation=new Pre_operation($this->db); $this->valid=array('ledger'=>'jrn_def_id','ledger_type'=>'jrn_type','direct'=>'od_direct'); - + $this->jrn_def_id=-1; } @@ -224,6 +224,7 @@ class Pre_operation_detail } public function get_operation() { + if ( $this->jrn_def_id=='') return array(); $value=$this->db->make_array("select od_id,od_name from op_predef ". " where jrn_def_id=".sql_string($this->jrn_def_id). " and od_direct ='".sql_string($this->od_direct)."'". diff --git a/include/impress_jrn.inc.php b/include/impress_jrn.inc.php index 0d1729eca..d0b58baaf 100644 --- a/include/impress_jrn.inc.php +++ b/include/impress_jrn.inc.php @@ -42,7 +42,7 @@ if ( $g_user->Admin() == 0 && $g_user->is_local_admin()==0) join user_sec_jrn on uj_jrn_id=jrn_def_id where uj_login='$g_user->login' - and uj_priv !='X' + and uj_priv in ('R','W') "; $ret=$cn->make_array($sql); } @@ -52,7 +52,6 @@ else from jrn_def join jrn_type on jrn_def_type=jrn_type_id"); } - // Count the forbidden journaux $NoPriv=$cn->count_sql("select jrn_def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv, jrn_deb_max_line,jrn_cred_max_line @@ -63,7 +62,7 @@ $NoPriv=$cn->count_sql("select jrn_def_id,jrn_def_name,jrn_def_class_deb,jrn_def and uj_priv ='X' "); // Pour voir tout les journal ? -if ( $NoPriv == 0 ) +if ( $NoPriv == 0 && $ret != null ) { $a=count($ret); $all=array('value'=>0,'label'=>'Tous les journaux'); diff --git a/include/menu.inc.php b/include/menu.inc.php index 03f36eb99..b80be93b0 100644 --- a/include/menu.inc.php +++ b/include/menu.inc.php @@ -71,7 +71,7 @@ if (isset($_POST['mod_plugin'])) /** * if post save then we save a new one */ -if ( isset($_POST['create_menu'])|| isset($_POST['mod_menu'])) +if ( isset($_POST['create_menu'])|| isset($_POST['modify_menu'])) { extract($_POST); $menu_ref=new Menu_Ref($cn); @@ -90,7 +90,7 @@ if ( isset($_POST['create_menu'])|| isset($_POST['mod_menu'])) { $menu_ref->insert(); } - elseif (isset($_POST['mod_menu'])) + elseif (isset($_POST['modify_menu'])) { if ($menu_ref->verify() == 0) $menu_ref->update(); @@ -183,7 +183,7 @@ for ($i = 0; $i < Database::num_row($ret); $i++) $js = sprintf('%s', $gDossier, $row->me_code, $row->me_code); break; case 'ME': - $js = sprintf('%s', $gDossier, $row->me_code, $row->me_code); + $js = sprintf('%s', $gDossier, $row->me_code, $row->me_code); break; } $class = ( $i % 2 == 0) ? $class = ' class="odd"' : $class = ' class="even"'; diff --git a/include/profile.inc.php b/include/profile.inc.php index 6ec61ce46..fcc0ac8e1 100644 --- a/include/profile.inc.php +++ b/include/profile.inc.php @@ -118,11 +118,8 @@ if (isset($_POST['mod'])) try { $cn->start(); - $me_code_dep=$cn->get_value("select me_code from profile_menu where - pm_id=$1",array($pm_id)); - $cn->exec_sql("delete from profile_menu where pm_id in - (select pm_id from profile_menu where me_code_dep=$1 and p_id=$2)", - array($me_code_dep,$p_id)); + $cn->exec_sql("delete from profile_menu where pm_id in (select * from get_menu_dependency($1)", + array($pm_id)); $cn->exec_sql("delete from profile_menu where pm_id=$1", array($pm_id)); $cn->commit(); diff --git a/sql/upgrade.sql b/sql/upgrade.sql index 5b51f1749..096ada98c 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -1,6 +1,28 @@ -update attr_def set ad_type='numeric' where ad_id=20; -insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent,pcm_type) select split_part(tva_poste,',',1),tva_comment,substring(split_part(tva_poste,',',1),1,3),'PAS' from tva_rate where split_part(tva_poste,',',1) not in (select pcm_val from tmp_pcmn); -insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent,pcm_type) select split_part(tva_poste,',',2),tva_comment,substring(split_part(tva_poste,',',2),1,3),'ACT' from tva_rate where split_part(tva_poste,',',2) not in (select pcm_val from tmp_pcmn); -update attr_def set ad_type='numeric',ad_size=6 where ad_id=20; -update attr_def set ad_type='poste' where ad_id=5; -update attr_def set ad_size=10 where ad_type='poste'; +CREATE OR REPLACE FUNCTION comptaproc.get_menu_dependency(profile_menu_id int) + RETURNS SETOF int AS +$BODY$ +declare + i int; + x int; + e int; +begin + for x in select pm_id,me_code + from profile_menu + where me_code_dep in (select me_code from profile_menu where pm_id=profile_menu_id) + and p_id = (select p_id from profile_menu where pm_id=profile_menu_id) + loop + return next x; + + for e in select * from comptaproc.get_menu_dependency_pm(x) + loop + return next e; + end loop; + + end loop; + return; +end; +$BODY$ +LANGUAGE plpgsql; + +delete from profile_menu where p_id=2 and me_code_dep='DIVPARM'; +delete from profile_menu where p_id=2 and me_code_dep='MOD';