diff --git a/html/compta.php b/html/compta.php index c4b8384b0..651720cf0 100644 --- a/html/compta.php +++ b/html/compta.php @@ -49,25 +49,14 @@ if ( $g_UserProperty['use_admin'] == 0 ) { } SyncRight($g_dossier,$g_user); -$g_UserType=GetUserType($g_user); -session_register($g_UserType); -switch ($g_UserType) { - case 'compta': - include ("top_menu_compta.php"); - break; - case 'developper': - include ("top_menu_compta.php"); - break; - case 'user': - include ("top_menu_compta.php"); - break; - default: - echo_error("Error type doesn't exist"); - break; -} -ShowMenuCompta($g_dossier); -ShowMenuComptaRight($g_dossier); +include ("top_menu_compta.php"); + +// Show Top Menu +ShowMenuCompta($g_dossier,$g_UserProperty); + +// Show Menu on the right side +ShowMenuComptaRight($g_dossier,$g_UserProperty); html_page_stop(); diff --git a/html/dossier_prefs.php b/html/dossier_prefs.php index 0d2601d78..37369435c 100644 --- a/html/dossier_prefs.php +++ b/html/dossier_prefs.php @@ -31,10 +31,11 @@ include_once ("postgres.php"); CheckUser(); include("preference.php"); - include_once ("top_menu_compta.php"); -ShowMenuCompta($g_dossier); -ShowMenuComptaRight($g_dossier); + + +ShowMenuCompta($g_dossier,$g_UserProperty); +ShowMenuComptaRight($g_dossier,$g_UserProperty); include_once ("check_priv.php"); if ( $g_UserProperty['use_admin'] == 0 ) { diff --git a/html/enc_jrn.php b/html/enc_jrn.php index 6aa6ef8a4..2b87456e3 100644 --- a/html/enc_jrn.php +++ b/html/enc_jrn.php @@ -46,8 +46,8 @@ echo ''; /* Get MaxLine */ include_once("poste.php"); include_once ("top_menu_compta.php"); -ShowMenuCompta($g_dossier); -ShowMenuComptaRight($g_dossier); +ShowMenuCompta($g_dossier,$g_UserProperty); +ShowMenuComptaRight($g_dossier,$g_UserProperty); if ( $g_UserProperty['use_admin'] == 0 ) { $r=CheckAction($g_dossier,$g_user,ENCJRN); if ($r == 0 ){ @@ -65,7 +65,7 @@ if ( $g_UserProperty['use_admin'] == 0 ) { } -ShowMenuJrnUser($g_dossier,$g_user); +ShowMenuJrnUser($g_dossier,$g_UserProperty); if ( isset ( $_GET["action"] )) { if ( $_GET["action"] == "view" ) { diff --git a/html/facturation.php b/html/facturation.php index e5dcfba88..af42a8030 100644 --- a/html/facturation.php +++ b/html/facturation.php @@ -29,7 +29,7 @@ include_once ("postgres.php"); /* CheckUser */ CheckUser(); include ("top_menu_compta.php"); -ShowMenuCompta($g_dossier); +ShowMenuCompta($g_dossier,$g_UserProperty); if ( $g_UserProperty['use_admin']==0 ) { $r=CheckAction($g_dossier,$g_user,FACT); @@ -43,7 +43,7 @@ include_once("facture_inc.php"); $l_dossier=sprintf("dossier%d",$g_dossier); $cn=DbConnect($l_dossier); ShowMenuComptaLeft($g_dossier,MENU_FACT); -ShowMenuComptaRight($g_dossier); +ShowMenuComptaRight($g_dossier,$g_UserProperty); if ( $_GET["action"] ) { if ($_GET["fact"] == "all" ) { ViewFactAll($cn); diff --git a/html/fiche.php b/html/fiche.php index e335c5c34..4fa945615 100644 --- a/html/fiche.php +++ b/html/fiche.php @@ -32,7 +32,7 @@ include_once ("top_menu_compta.php"); echo ''; CheckUser(); include ("check_priv.php"); -ShowMenuCompta($g_dossier); +ShowMenuCompta($g_dossier,$g_UserProperty); if ( isset($_POST["PHPSESSID"] )) { @@ -54,7 +54,7 @@ if ( isset($_POST['add_modele']) ) { -ShowMenuComptaRight($g_dossier); +ShowMenuComptaRight($g_dossier,$g_UserProperty); if ( $g_UserProperty['use_admin'] == 0 ) { $r=CheckAction($g_dossier,$g_user,FICHE); if ($r == 0 ){ diff --git a/html/form.php b/html/form.php index cfb52e5f5..c249e8611 100644 --- a/html/form.php +++ b/html/form.php @@ -34,10 +34,10 @@ CheckUser(); include_once("form_inc.php"); include_once ("top_menu_compta.php"); -ShowMenuCompta($g_dossier); +ShowMenuCompta($g_dossier,$g_UserProperty); include ("check_priv.php"); -ShowMenuComptaRight($g_dossier); +ShowMenuComptaRight($g_dossier,$g_UserProperty); if ( $g_UserProperty['use_admin'] == 0 ) { $r=CheckAction($g_dossier,$g_user,FORM); diff --git a/html/impress.php b/html/impress.php index a2748fa9e..4acd9e887 100644 --- a/html/impress.php +++ b/html/impress.php @@ -29,11 +29,11 @@ include_once ("postgres.php"); CheckUser(); include ("check_priv.php"); include_once ("top_menu_compta.php"); -ShowMenuCompta($g_dossier); +ShowMenuCompta($g_dossier,$g_UserProperty); include_once("impress_inc.php"); -ShowMenuComptaRight($g_dossier); +ShowMenuComptaRight($g_dossier,$g_UserProperty); if ( $g_UserProperty['use_admin'] == 0 ) { $r=CheckAction($g_dossier,$g_user,IMP); if ($r == 0 ){ diff --git a/html/index.html b/html/index.html index e79a44e17..8537cfb08 100644 --- a/html/index.html +++ b/html/index.html @@ -1,28 +1 @@ - - - Gnu Accountancy - -




-
- Logo -
-
-
- - - - - - - - - - - - -
LOGIN
PASSWORD
-
-
-
- - + Connecting... diff --git a/html/jrn_add.php b/html/jrn_add.php index 5ebd63129..74749102e 100644 --- a/html/jrn_add.php +++ b/html/jrn_add.php @@ -31,8 +31,8 @@ include_once ("postgres.php"); CheckUser(); include_once("check_priv.php"); include_once ("top_menu_compta.php"); -ShowMenuCompta($g_dossier); -ShowMenuComptaRight($g_dossier); +ShowMenuCompta($g_dossier,$g_UserProperty); +ShowMenuComptaRight($g_dossier,$g_UserProperty); if ( $g_UserProperty['use_admin'] == 0 ) { $r=CheckAction($g_dossier,$g_user,SECU); diff --git a/html/jrn_detail.php b/html/jrn_detail.php index 30889caf0..2a5288f44 100644 --- a/html/jrn_detail.php +++ b/html/jrn_detail.php @@ -29,8 +29,8 @@ include_once ("postgres.php"); CheckUser(); include_once ("top_menu_compta.php"); -ShowMenuCompta($g_dossier); -ShowMenuComptaRight($g_dossier); +ShowMenuCompta($g_dossier,$g_UserProperty); +ShowMenuComptaRight($g_dossier,$g_UserProperty); include_once("check_priv.php"); if ( $g_UserProperty['use_admin'] == 0 ) { diff --git a/html/jrn_update.php b/html/jrn_update.php index 6e7552300..a4584eba3 100644 --- a/html/jrn_update.php +++ b/html/jrn_update.php @@ -32,8 +32,8 @@ CheckUser(); include_once ("check_priv.php"); include_once ("top_menu_compta.php"); -ShowMenuCompta($g_dossier); -ShowMenuComptaRight($g_dossier); +ShowMenuCompta($g_dossier,$g_UserProperty); +ShowMenuComptaRight($g_dossier,$g_UserProperty); if ( $g_UserProperty['use_admin'] == 0 ) { $r=CheckAction($g_dossier,$g_user,GJRN); if ($r == 0 ){ diff --git a/html/line_update.php b/html/line_update.php index ce934e7be..e6592817e 100644 --- a/html/line_update.php +++ b/html/line_update.php @@ -43,7 +43,7 @@ if ( $g_UserProperty['use_admin'] == 0 ) { } include ("top_menu_compta.php"); -ShowMenuComptaRight($g_dossier); +ShowMenuComptaRight($g_dossier,$g_UserProperty); $l_Db=sprintf("dossier%d",$g_dossier); echo '
'; diff --git a/html/login.php b/html/login.php index 5081a644a..11e8898d7 100644 --- a/html/login.php +++ b/html/login.php @@ -19,8 +19,6 @@ // Auteur Dany De Bontridder ddebontridder@yahoo.fr include_once ("ac_common.php"); - - /* $Revision$ */ include ("postgres.php"); @@ -39,97 +37,25 @@ if ( isset ($_POST["p_user"] ) ) { CheckUser(); $g_UserProperty=GetUserProperty($cn,$g_user); session_register("g_UserProperty"); - - html_page_start($g_UserProperty['use_theme']); + if ( isset ( $_GET["PHPSESSID"]) ) + $p_sessid= $_GET["PHPSESSID"]; + else + $p_sessid= $_POST["PHPSESSID"]; + + + Redirect($g_UserProperty['use_usertype'],$p_sessid); } else { - if ( strlen($g_user) != 0 ) { - echo_debug("user is not null"); - html_page_start($g_UserProperty['use_theme']); - } else - { - html_page_start("classic"); + if (isset ($g_UserProperty['use_usertype'])) { + if ( isset ( $_GET["PHPSESSID"]) ) + $p_sessid= $_GET["PHPSESSID"]; + else + $p_sessid= $_POST["PHPSESSID"]; + + Redirect($g_UserProperty['use_usertype'],$p_sessid); } } -if ( isset ($db_page) ) { - echo_debug("db_page is set ".$db_page); -} else -{ - echo_debug("db_page is NOT set"); - $db_page=0; - -} - - -echo_debug("USER=$g_user - "); -echo_debug("PAGE = $db_page"); - -echo_debug("theme =".$g_UserProperty['use_theme']); - -include("top_menu_compta.php"); -// Show the first menu -ShowMenu($g_UserProperty['use_admin']); -if ( $g_UserProperty['use_admin'] != 0 || $g_user=='webcompta' ) { - /* Administrator */ - $l_MaxLine=0; - $r_database=ShowDossier('all',$db_page,$db_page+15,&$l_MaxLine); - $action="Encoder"; - $priv="Administrateur"; - } else { - /* User */ - $l_MaxLine=0; - $r_database=ShowDossier('lim',$db_page,$db_page+15,&$l_MaxLine); - $priv="Utilisateur"; - } - -echo '

Dossier

'; -echo ""; - -if ( $r_database != null ) { - $row=0; - foreach ( $r_database as $l_db ) { - $row++; - if ( $l_db['priv_priv'] == "W") { - $action="Encoder"; - } else { - $action="Lire"; - } - - if ( $row %2 == 0 ) { - $tr=''; - $td=''; - $td=' $td %s", - $tr, - $l_db['dos_name'], - $l_db['dos_description'], - $priv, - $l_db['dos_id'], - $action); - - - } - - echo "
'; - } else { - $tr='
'; - } - printf("%s $td %s %s %s
"; - $db_debut=15+$db_page; - if ($db_debut < $l_MaxLine) { - printf ("Suivant",$db_debut); - } - if ( $db_page !=0 ) { - $db_debut=$db_page-15; - printf ("Précédent",$db_debut); - } - -} -?> - - - diff --git a/html/pcmn_update.php b/html/pcmn_update.php index ba17415b0..a49822661 100644 --- a/html/pcmn_update.php +++ b/html/pcmn_update.php @@ -33,8 +33,8 @@ CheckUser(); include_once ("top_menu_compta.php"); include_once ("check_priv.php"); -ShowMenuCompta($g_dossier); -ShowMenuComptaRight($g_dossier); +ShowMenuCompta($g_dossier,$g_UserProperty); +ShowMenuComptaRight($g_dossier,$g_UserProperty); if ( $g_UserProperty['use_admin'] == 0 ) { $r=CheckAction($g_dossier,$g_user,MPCMN); if ($r == 0 ){ diff --git a/html/user_pref.php b/html/user_pref.php index 692bc19a8..9932a3ed2 100644 --- a/html/user_pref.php +++ b/html/user_pref.php @@ -32,20 +32,29 @@ if ( isset ( $_POST['style_user']) ) { $g_UserProperty['use_theme']=$_POST['style_user']; } +// Met à jour le profil +if ( isset ( $_POST['profile_user']) ) { + $g_UserProperty['use_usertype']=$_POST['profile_user']; +} html_page_start($g_UserProperty['use_theme']); /* Admin. Dossier */ CheckUser(); +// show the top menu depending of the use_style +// comta style + include_once ("top_menu_compta.php"); if ( isset ($g_dossier) ) { - if ( $g_dossier != 0 ) ShowMenuCompta($g_dossier); - ShowMenuComptaRight($g_dossier); -} else { - ShowMenuComptaRight(); -} + if ( $g_dossier != 0 ) ShowMenuCompta($g_dossier,$g_UserProperty); + ShowMenuComptaRight($g_dossier,$g_UserProperty); + } else { + ShowMenuComptaRight(0,$g_UserProperty); + } + + echo '
'; if ( isset ($spass) ) { @@ -74,6 +83,16 @@ if ( isset ( $_POST['style_user']) ) { $g_UserProperty['use_theme']=$_POST['style_user']; } +// Met à jour le profil +if ( isset ( $_POST['profile_user']) ) { + $CnRepo=DbConnect(); + $Res=ExecSql($CnRepo, + "update ac_users set use_usertype='".$_POST['profile_user']. + "' where use_login='$g_user'"); + $g_UserProperty['use_usertype']=$_POST['profile_user']; + +} + ?>

Password

@@ -115,6 +134,31 @@ $disp_style.="";
+"; +foreach ($aprofile as $st){ + if ( $st == $g_UserProperty['use_usertype'] ) { + $disp_pro.='
'; +} +/* function ShowMenuCompta + * Purpose : Montre le menu du haut + * + * parm : + * - dossier + * - $p_user array ($g_UserProperty) + * gen : + * - none + * return: + * - none + * + */ + +function c_ShowMenuCompta($p_dossier) +{ + include_once("postgres.php"); + $l_name=GetDossierName($p_dossier); + echo "

$l_name

"; + echo '
'; + echo ''; + // TODO echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + + echo ""; + echo "
FacturationEncodage Formulaire ImpressionFichePlan ComptableJournauxCentraliseParamètres
"; + echo '
'; + } +/* function c_ShowMenuJrnUser($p_dossier,$p_user) + * Purpose : Show the Menu from the jrn encode + * page + * + * parm : + * - $p_dossier + * - $p_user + * gen : + * - none + * return: + * - none + * + */ + +function c_ShowMenuJrnUser($p_dossier,$p_user) +{ + + echo '
'; + echo ''; + + include_once("postgres.php"); + $l_jrn=sprintf("dossier%d",$p_dossier); + $Cn=DbConnect($l_jrn); + if ( CheckAdmin() ==0) { + $Ret=ExecSql($Cn,"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 + from jrn_def join jrn_type on jrn_def_type=jrn_type_id + join user_sec_jrn on uj_jrn_id=jrn_def_id + where + uj_login='$p_user' + and uj_priv !='X' + "); + } else { + $Ret=ExecSql($Cn,"select jrn_def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_deb_max_line,jrn_cred_max_line, + jrn_type_id,jrn_desc,'W' as uj_priv + from jrn_def join jrn_type on jrn_def_type=jrn_type_id"); + + } + $Max=pg_NumRows($Ret); + include_once("check_priv.php"); + + for ($i=0;$i<$Max;$i++) { + $l_line=pg_fetch_array($Ret,$i); + // Admin have always rights + if ( CheckAdmin() == 0 ){ + $right=CheckJrn($p_dossier,$p_user,$l_line['jrn_def_id']); + }else { + $right=3; + } + + printf ('',$l_line['jrn_def_name']); + if ( $right > 0 ) { + // Lecture + printf ('', + $l_line['jrn_def_id']); + } + // ecriture + if ( $right > 1 ) { + printf ('', + $l_line['jrn_def_id'], + $l_line['jrn_deb_max_line'], + $l_line['jrn_cred_max_line']); + } + } + echo "
%sVoirEncoder
"; + echo '
'; + +} + +?> diff --git a/include/constant.php b/include/constant.php index a0143cb0f..537b2e3b7 100644 --- a/include/constant.php +++ b/include/constant.php @@ -34,7 +34,10 @@ define ("GJRN",7); define ("PARM",8); define ("SECU",9); define ("CENTRALIZE",10); - +define ("VEN",11); +define ("BQE",12); +define ("ODS",13); +define ("ACH",14); // Erreur define ("NOERROR",0); diff --git a/include/postgres.php b/include/postgres.php index 70c099a13..47e346801 100644 --- a/include/postgres.php +++ b/include/postgres.php @@ -347,19 +347,44 @@ function SyncRight($p_dossier,$p_user) { * gen : * - * return: an array + * containing use_admin + * use_usertype + * use_theme + * use_name + * use_login */ function GetUserProperty($p_cn,$p_user) { - $sql="select use_admin,use_usertype,use_theme + $sql="select use_login,use_first_name,use_name,use_admin,use_usertype,use_theme from ac_users where use_login='$p_user'"; $Ret=ExecSql($p_cn,$sql); if ( pg_NumRows($Ret) == 0) - return array('use_admin'=>0, + return array('use_first_name'=>'?', + 'use_name'=>'Unknown', + 'use_admin'=>0, 'use_usertype'=>'user', - 'use_theme'=>'classic'); + 'use_theme'=>'classic', + 'use_login'=>$p_user); $a=pg_fetch_array($Ret,0); return $a; } +/* function GetModeleId + * Purpose : Give the mod_id from modeledef + * + * parm : + * - p_cn database connection (repository) + * - p_modname template name + * gen : + * - none + * return: + * template id or 0 if not found + */ +function GetModeleId($p_cn,$p_modname) { + $Res=ExecSql($p_cn,"select mod_id from modeledef where mod_name='$p_modname'"); + if (pg_NumRows($Res) == 0) return 0; + $name=pg_fetch_array($Res,0); + return $name['mod_id']; +} ?> diff --git a/include/top_menu_compta.php b/include/top_menu_compta.php index d54eac064..a25445892 100644 --- a/include/top_menu_compta.php +++ b/include/top_menu_compta.php @@ -61,6 +61,7 @@ * * parm : * - dossier + * - $p_user array ($g_UserProperty) * gen : * - none * return: @@ -68,27 +69,19 @@ * */ -function ShowMenuCompta($p_dossier) +function ShowMenuCompta($p_dossier,$pa_user) { - include_once("postgres.php"); - $l_name=GetDossierName($p_dossier); - echo "

$l_name

"; - echo '
'; - echo ''; - // TODO echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - - - echo ""; - echo "
FacturationEncodage Formulaire ImpressionFichePlan ComptableJournauxCentraliseParamètres
"; - echo '
'; + if ( ! isset ( $pa_user ) ) { + exit (1); + } + if ( $pa_user['use_usertype'] == 'compta' ) { + include_once ("compta_menu.php"); + c_ShowMenuCompta($p_dossier); + } else + if ( $pa_user['use_usertype']=='user') { + include_once ("user_menu.php"); + u_ShowMenuCompta($p_dossier); + } } /* function * Purpose : @@ -157,6 +150,7 @@ function ShowMenuComptaLeft($p_dossier,$p_item) * (preference, logout and admin) * parm : * - $p_dossier the current dossier + * - $p_auser array $g_UserProperty * - $p_more code * gen : * - none @@ -164,24 +158,20 @@ function ShowMenuComptaLeft($p_dossier,$p_item) * - none * */ -function ShowMenuComptaRight($p_dossier=0,$p_more="") +function ShowMenuComptaRight($p_dossier=0,$p_auser,$p_more="") { - include_once("ac_common.php"); - echo '
'; - echo ''; - if ( CheckAdmin() != 0 && $p_dossier != 0) { - echo ''; + if ( ! isset ( $p_auser['use_usertype'])) { + exit (1); } - echo ''; - echo ''; - if ( strlen ($p_more) != 0 ) { - printf ('',$p_more); + if ( $p_auser['use_usertype']=='compta') { + include_once("compta_menu.php"); + c_ShowMenuComptaRight($p_dossier,$p_auser['use_admin'],$p_more); } - echo ''; - echo "
Admin
Accueil
Preference
%s
'; - html_button_logout(); - echo '
"; - echo '
'; + else + if ( $p_auser['use_usertype']=='user') { + include_once("user_menu.php"); + u_ShowMenuComptaRight($p_dossier,$p_auser['use_admin'],$p_more); + } } /* function ShowMenuAdminGlobalRight($p_dossier=0) * Purpose : @@ -274,12 +264,14 @@ function ShowMenuJrn($p_dossier) } /* function ShowMenuJrnUser($p_dossier,$p_user) - * Purpose : Show the Menu from the jrn encode - * page + * Purpose : Display and Show the Menu from the jrn encode + * page following the use_usertype (compta,user,...) * * parm : * - $p_dossier - * - $p_user + * - $p_auser + * - $p_type (ACH, BQE, VEN) + * - $p_jrn what journal * gen : * - none * return: @@ -287,57 +279,17 @@ function ShowMenuJrn($p_dossier) * */ -function ShowMenuJrnUser($p_dossier,$p_user) +function ShowMenuJrnUser($p_dossier,$p_auser,$p_type=-1,$p_jrn=-1) { - echo '
'; - echo ''; - - include_once("postgres.php"); - $l_jrn=sprintf("dossier%d",$p_dossier); - $Cn=DbConnect($l_jrn); - if ( CheckAdmin() ==0) { - $Ret=ExecSql($Cn,"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 - from jrn_def join jrn_type on jrn_def_type=jrn_type_id - join user_sec_jrn on uj_jrn_id=jrn_def_id - where - uj_login='$p_user' - and uj_priv !='X' - "); - } else { - $Ret=ExecSql($Cn,"select jrn_def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_deb_max_line,jrn_cred_max_line, - jrn_type_id,jrn_desc,'W' as uj_priv - from jrn_def join jrn_type on jrn_def_type=jrn_type_id"); - - } - $Max=pg_NumRows($Ret); - include_once("check_priv.php"); - - for ($i=0;$i<$Max;$i++) { - $l_line=pg_fetch_array($Ret,$i); - // Admin have always rights - if ( CheckAdmin() == 0 ){ - $right=CheckJrn($p_dossier,$p_user,$l_line['jrn_def_id']); - }else { - $right=3; - } - - printf ('',$l_line['jrn_def_name']); - if ( $right > 0 ) { - // Lecture - printf ('', - $l_line['jrn_def_id']); - } - // ecriture - if ( $right > 1 ) { - printf ('', - $l_line['jrn_def_id'], - $l_line['jrn_deb_max_line'], - $l_line['jrn_cred_max_line']); - } - } - echo "
%sVoirEncoder
"; - echo '
'; + if ( ! isset ($p_auser['use_usertype'] ) ) exit (-1); + if ($p_auser['use_usertype'] == 'compta' ) { + include_once("compta_menu.php"); + c_ShowMenuJrnUser($p_dossier,$p_auser['use_login']); + } + if ($p_auser['use_usertype'] == 'user' ) { + include_once("user_menu.php"); + u_ShowMenuJrnUser($p_dossier,$p_auser['use_login'],$p_type,$p_jrn); + } } /* function ShowMenuRecherche @@ -563,27 +515,13 @@ function ShowMenuJrnUserImp($p_cn,$p_user,$p_dossier) /* return : none */ function ShowMenuAdminGlobal() { - $item[0]=array("admin_repo.php?action=user_mgt","Gestion utilisateurs"); - $item[1]=array("admin_repo.php?action=dossier_mgt","Gestion Dossiers"); + include_once("ac_common.php"); + $item[0]=array("admin_repo.php?action=user_mgt","Utilisateurs"); + $item[1]=array("admin_repo.php?action=dossier_mgt","Dossiers"); + $item[2]=array("admin_repo.php?action=modele_mgt","Modèles"); $menu=ShowItem($item); echo ''; } -/* function ShowItem($p_array) */ -/* purpose : store the string which print */ -/* the content of p_array in a table */ -/* used to display the menu */ -/* parameter : array */ -/* return : string */ -function ShowItem($p_array) -{ - $ret=""; - foreach ($p_array as $all=>$href){ - $ret.=''; - echo_debug($ret); - } - $ret.="
'.$href[1].'
"; - return $ret; -} ?> diff --git a/include/user_menu.php b/include/user_menu.php new file mode 100644 index 000000000..ad51fe1ee --- /dev/null +++ b/include/user_menu.php @@ -0,0 +1,293 @@ +"; + for ($i=0;$i"; + $result.="$name"; + $result.=""; + $result.=$desc; + $result.=""; + $result.="Encoder"; + $result.=""; + } + return $result; +} +/* function u_ShowDossier + * Purpose : Get all the available folders + * for the users + * parm : + * - $p_user user login + * - $p_admin 1 if admin + * gen : + * - none + * return: + * - array containing ac_dossier.dos_id + * ac_dossier.dos_name + * ac_dossier.dos_description + * + */ +function GetAvailableFolder($p_user,$p_admin) +{ + $filter=""; + if ($p_admin==0) { + // show only available folders + // if user is not an admin + $filter="and use_login='$p_user' "; + + } + $sql="select dos_id,dos_name,dos_description from ac_users + natural join jnt_use_dos + natural join ac_dossier + where use_active=1 ".$filter; + include_once("postgres.php"); + $cn=DbConnect(); + $Res=ExecSql($cn,$sql); + $max=pg_numRows($Res); + for ($i=0;$i<$max;$i++) { + $array[]=pg_fetch_array($Res,$i); + } + return $array; +} +/* function u_ShowMenu + * Purpose : Show The login menu + * + * parm : + * - $p_admin 1 if admin + * - $p_item item to add + * gen : + * - none + * return: + * - nothing + * + */ + function u_ShowMenu($p_admin,$p_check = 1,$p_item="") +{ + /* $p_check == 1 si test sur Admin */ + include_once("postgres.php"); + echo '
'; + echo ""; + if ( $p_admin !=0 ) { + /* Administrator Menu */ + echo ''; + } + + if (strlen ( $p_item ) != 0 ) { + echo ''; + } + + echo ' '; + + echo ""; + echo "
Administrator Menu'.$p_item.' Préférence"; + html_button_logout(); + echo "
"; + echo "
"; +} +/* function u_ShowMenuCompta + * purpose : show the top menu for + * the user profile + * parm : p_dossier + * + * return: none + * + * gen : none + */ +function u_ShowMenuCompta($p_dossier) +{ + include_once("postgres.php"); + $l_name=GetDossierName($p_dossier); + echo "

$l_name

"; + + $p_array=array(array("user_facture.php" ,"Vente"), + array("user_achat.php","Achat"), + array("user_banque.php","Banque"), + array("user_od.php","Op. Diverses"), + array("fiche.php?p_dossier=$p_dossier","Fiche"), + array("not_implemented.php","Avancé"), + array("dossier_prefs.php","Paramètre") + ); + + $result=ShowItem($p_array,'H'); + echo "
"; + + echo $result; + echo "
"; + + + + +} +/* function ShowMenuComptaRight + * Purpose : Display menu on the Right + * (preference, logout and admin) + * parm : + * - $p_dossier the current dossier + * - $p_admin $g_UserProperty['use_admin'] 1 if admin + * - $p_more code + * gen : + * - none + * return: + * - string containing the html menu + * + */ +function u_ShowMenuComptaRight($p_dossier=0,$p_admin,$p_more="") +{ + include_once("ac_common.php"); + $i=0; + if ( $p_admin != 0 && $p_dossier != 0) { + $p_array[$i++]=array("admin_repo.php","Admin"); + } + $p_array[$i++]=array('login.php','Accueil'); + $p_array[$i++]=array('user_pref.php','Preference'); + $p_array[$i]=array('logout.php','logout'); + $menu=ShowItem($p_array); + echo '
'; + echo $menu; + echo '
'; + +} +/* function u_ShowMenuJrnUser($p_dossier,$p_user) + * Purpose : Show the Menu from the jrn encode + * page + * + * parm : + * - $p_dossier + * - $p_user + * - $p_type type of journal (VEN,ACH,BQE,ODS) + * - $p_jrn journal + * gen : + * - none + * return: + * - none + * + */ + +function u_ShowMenuJrnUser($p_dossier,$p_user,$p_type,$p_jrn) +{ + include_once ("debug.php"); + include_once("constant.php"); + echo_debug("U_SHOWMENUJRNUSER PTYPE=$p_type"); + echo '
'; + echo ''; + include_once("postgres.php"); + $l_jrn=sprintf("dossier%d",$p_dossier); + $Cn=DbConnect($l_jrn); + + switch ($p_type) { + case ACH : + $type='ACH'; + $ref="user_achat.php"; + break; + case VEN: + $type='VEN'; + $ref="user_facture.php"; + break; + case BQE: + $type='FIN'; + $ref="user_banque.php"; + break; + case ODS: + $type="OD"; + $ref="user_od.php"; + break; + default: + echo '

Invalid Type

'; + exit(-1); + } + $l_jrn=sprintf("dossier%d",$p_dossier); + $Cn=DbConnect($l_jrn); + + if ( CheckAdmin() ==0) { + $Ret=ExecSql($Cn,"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 + from jrn_def join jrn_type on jrn_def_type=jrn_type_id + join user_sec_jrn on uj_jrn_id=jrn_def_id + where + uj_login='$p_user' + and uj_priv !='X' + and jrn_def_type='$type' + "); + } else { + $Ret=ExecSql($Cn,"select jrn_def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_deb_max_line,jrn_cred_max_line, + jrn_type_id,jrn_desc,'W' as uj_priv + from jrn_def join jrn_type on jrn_def_type=jrn_type_id where + jrn_def_type='$type'"); + + } + $Max=pg_NumRows($Ret); + include_once("check_priv.php"); + + for ($i=0;$i<$Max;$i++) { + $l_line=pg_fetch_array($Ret,$i); + // Admin have always rights + if ( CheckAdmin() == 0 ){ + $right=CheckJrn($p_dossier,$p_user,$l_line['jrn_def_id']); + }else { + $right=3; + } + + + if ( $right > 0 ) { + // Minimum Lecture + echo_debug("p_jrn = $p_jrn "); + if ( $l_line['jrn_def_id'] != $p_jrn ) { + echo '',$ref, + $l_line['jrn_def_id'],$l_line['jrn_def_name']); + } + else { + echo '', + $l_line['jrn_def_name']); + } + } + } + echo "
'; + printf ('%s'; + printf ('%s
"; + echo '
'; + +} + +?>