Adaptation for the user profile

This commit is contained in:
sparkyx 2003-11-15 11:27:58 +00:00
parent a2691da8f8
commit 5e5ca5992f
23 changed files with 691 additions and 282 deletions

View file

@ -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();

View file

@ -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 ) {

View file

@ -46,8 +46,8 @@ echo '<SCRIPT LANGUAGE="javascript" SRC="win_detail_jrn.js"></SCRIPT>';
/* 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" ) {

View file

@ -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);

View file

@ -32,7 +32,7 @@ include_once ("top_menu_compta.php");
echo '<SCRIPT LANGUAGE="javascript" SRC="win_search_poste.js"></SCRIPT>';
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 ){

View file

@ -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);

View file

@ -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 ){

View file

@ -1,28 +1 @@
<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 FINAL//EN">
<HTML>
<TITLE> Gnu Accountancy</TITLE>
<BODY BGCOLOR="white">
<BR><BR><BR><BR><BR>
<center>
<IMG SRC="image/logo7.jpg" alt="Logo">
<BR>
<form action=login.php method=post>
<TABLE BGCOLOR="#4851FF"><TR><TD>
<TABLE Bgcolor="#4851FF" BORDER=0 CELLSPACING=0>
<TR>
<TD><FONT COLOR="white"> LOGIN</FONT> </TD>
<TD><input type=text name=p_user></TD>
</TR>
<TR>
<TD><FONT color="white"> PASSWORD</FONT></TD>
<TD><INPUT TYPE=PASSWORD NAME=p_pass></TD>
</TR>
<TR>
<TD COLSPAN=2 ALIGN=CENTER><INPUT TYPE=SUBMIT value="Log in"></TD>
</TR>
</table>
</TD></TR></TABLE>
</form>
</Center>
</body>
</html>
<HTML><head><META HTTP-EQUIV="REFRESH" content="0;url=index.php"></head><body> Connecting... </body></html>

View file

@ -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);

View file

@ -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 ) {

View file

@ -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 ){

View file

@ -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 '<DIV CLASS="ccontent">';

View file

@ -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 '<H1 class="title"> Dossier </H1>';
echo "<TABLE>";
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='<TR class="odd">';
$td='<TD class="odd">';
} else {
$tr='<TR class="even">';
$td='<TD class="even">';
}
printf("%s $td <B> %s</B></TD> $td %s</TD> <td style=\"border-width:1pt;border-style:solid\";> %s</TD> <TD class=\"mtitle\"> <A class=\"mtitle\" HREF=\"compta.php?dos=%d\">%s</A></TD></TR>",
$tr,
$l_db['dos_name'],
$l_db['dos_description'],
$priv,
$l_db['dos_id'],
$action);
}
echo "</TABLE>";
$db_debut=15+$db_page;
if ($db_debut < $l_MaxLine) {
printf ("<A HREF=\"login.php?db_page=%d\">Suivant</A>",$db_debut);
}
if ( $db_page !=0 ) {
$db_debut=$db_page-15;
printf ("<A HREF=\"login.php?db_page=%d\">Précédent</A>",$db_debut);
}
}
?>
<?
html_page_stop();
?>

View file

@ -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 ){

View file

@ -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 '<DIV class="ccontent">';
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'];
}
?>
<H2 CLASS="info"> Password</H2>
<FORM ACTION="user_pref.php" METHOD="POST">
@ -115,6 +134,31 @@ $disp_style.="</SELECT>";
</TR>
</TABLE>
</FORM>
<?
// charge tous les profiles
$aprofile=array("compta","user");
$disp_pro="<SELECT NAME=\"profile_user\" >";
foreach ($aprofile as $st){
if ( $st == $g_UserProperty['use_usertype'] ) {
$disp_pro.='<OPTION VALUE="'.$st.'" SELECTED>'.$st;
} else {
$disp_pro.='<OPTION VALUE="'.$st.'">'.$st;
}
}
$disp_pro.="</SELECT>";
?>
<H2 class="info">Profile</H2>
<FORM ACTION="user_pref.php" METHOD="post">
<TABLE ALIGN="center">
<TR>
<TD> Style </TD>
<TD> <? print $disp_pro;?> </TD>
</TR>
<TR>
<td colspan=2> <INPUT TYPE="submit" Value="Sauve"></TD>
</TR>
</TABLE>
</FORM>
<?
@ -144,6 +188,7 @@ if ( isset ($g_dossier) ) {
</TABLE>
</FORM>
<?
}

View file

@ -31,8 +31,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);
if ( $g_UserProperty['use_admin']== 0 ) {
$r=CheckAction($g_dossier,$g_user,SECU);
if ($r == 0 ){
@ -50,7 +50,7 @@ $User=ExecSql($cn,"select use_id,use_first_name,use_name,use_login from ac_user
$MaxUser=pg_NumRows($User);
ShowMenuComptaRight($g_dossier);
ShowMenuComptaRight($g_dossier,$g_UserProperty['use_admin']);
echo '<DIV CLASS="ccontent">';
echo '<H2 class="info"> Sécurité </H2>';
@ -129,7 +129,7 @@ and use_active=1");
$Res=ExecSql($cn_dossier,"select jrn_def_id,jrn_def_name from jrn_def ");
$admin=CheckIsAdmin($l2_line['use_login']);
echo '<table align="CENTER">';
echo '<table align="CENTER" width="100%">';
$MaxJrn=pg_NumRows($Res);
for ( $i =0 ; $i < $MaxJrn; $i++ ) {
$l_line=pg_fetch_array($Res,$i);
@ -153,7 +153,7 @@ and use_active=1");
if ( $right == 1 ) {
echo '<TD class="mtitle"> <A CLASS="mtitle" HREF="user_sec.php?'.$l_change.'&access=X"> Pas d\'accès</A></TD>';
echo "<TD BGCOLOR=\"#3BCD27\">";
echo "Lecture accordée";
echo "Lecture ";
echo "</TD>";
echo '<TD class="mtitle"> <A CLASS="mtitle" HREF="user_sec.php?'.$l_change.'&access=W"> Ecriture</A></TD>';
}
@ -162,7 +162,7 @@ and use_active=1");
echo '<TD class="mtitle"> <A CLASS="mtitle" HREF="user_sec.php?'.$l_change.'&access=R"> Lecture</A></TD>';
echo "<TD BGCOLOR=\"#3BCD27\">";
echo "Ecriture accordée";
echo "Ecriture ";
echo "</TD>";
}
@ -171,7 +171,7 @@ and use_active=1");
echo '<TD class="mtitle"> Lecture </TD>';
echo "<TD BGCOLOR=\"#3BCD27\">";
echo "Ecriture accordée";
echo "Ecriture ";
echo "</TD>";
}
@ -209,7 +209,7 @@ and use_active=1");
$l_change=$l_change."&access=0";
echo '<TD class="mtitle"> <A CLASS="mtitle" HREF="user_sec.php?'.$l_change.'"> Pas d\'accès </A></TD>';
echo "<TD BGCOLOR=\"#3BCD27\">";
echo "Accès accordé";
echo "Accès ";
echo "</TD>";
}
@ -217,7 +217,7 @@ and use_active=1");
echo '<TD class="mtitle"> Change </TD>';
echo "<TD BGCOLOR=\"#3BCD27\">";
echo "Accès accordé";
echo "Accès ";
echo "</TD>";
}

View file

@ -232,4 +232,60 @@ function GetUserType($p_user)
$Ret=pg_fetch_row($Res,0);
return $Ret[0];
}
/* function Redirect
* Purpose : redirect following the user's profile
*
* parm :
* - p_profile (ac_users.use_usertype)
* - php_session PHPSESSID
* gen :
* - none
* return: none
*/
function Redirect($p_profile,$php_session) {
include_once("debug.php");
echo_debug("Session is $php_session");
if ( $p_profile =="compta" ) {
$URL="compta_login.php";
} else if ( $p_profile == "user") {
$URL="user_login.php";
}
else {
echo_error ("Undefined profile");
exit (-1);
}
echo "<META HTTP-EQUIV=\"REFRESH\" content=\"0;url=$URL?PHPSESSID=$php_session\">";
}
/* 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,$p_dir='V')
{
$ret="<TABLE>";
// direction Vertical
if ( $p_dir == 'V') {
foreach ($p_array as $all=>$href){
$ret.='<TR><TD CLASS="mtitle"><A class="mtitle" HREF="'.$href[0].'">'.$href[1].'</A></TD></TR>';
}
}
//direction Horizontal
else if ( $p_dir == 'H' ) {
$ret.="<TR>";
foreach ($p_array as $all=>$href){
$ret.='<TD CLASS="mtitle"><A class="mtitle" HREF="'.$href[0].'">'.$href[1].'</A></TD>';
}
$ret.="</TR>";
}
$ret.="</TABLE>";
return $ret;
}
?>

View file

@ -124,7 +124,7 @@ function CheckAction ( $p_dossier,$p_login,$p_action_id)
$Count=pg_NumRows($Res);
if ( $Count == 0 ) return 0;
if ( $Count == 1 ) return 1;
echo "<H2 class=\"error\"> Invalid action !!! </H2>";
echo "<H2 class=\"error\"> Invalid action !!! $Count select * from user_sec_act where ua_login='$p_login' and ua_act_id=$p_action_id </H2>";
}
/* function CheckIsAdmin
* Purpose : Check if an user is an administrator

160
include/compta_menu.php Normal file
View file

@ -0,0 +1,160 @@
<?
/*
* This file is part of WCOMPTA.
*
* WCOMPTA 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.
*
* WCOMPTA 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 WCOMPTA; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Auteur Dany De Bontridder ddebontridder@yahoo.fr
/* $Revision$ */
/* function c_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:
* - none
*
*/
function c_ShowMenuComptaRight($p_dossier=0,$p_admin,$p_more="")
{
include_once("ac_common.php");
echo '<div class="rmenu">';
echo '<TABLE>';
if ( $p_admin != 0 && $p_dossier != 0) {
echo '<TR><TD class="mtitle"> <A class="mtitle" HREF="admin_repo.php">Admin</A></TD></TR>';
}
echo '<TR><TD class="mtitle"> <A class="mtitle" HREF="login.php">Accueil</A></TD></TR>';
echo '<TR><TD class="mtitle"> <A class="mtitle" HREF="user_pref.php">Preference</A></TD></TR>';
if ( strlen ($p_more) != 0 ) {
printf ('<TR><TD class="mtitle"> %s </TD></TR>',$p_more);
}
echo '<TR><TD class="mtitle"> ';
html_button_logout();
echo ' </TD></TR>';
echo "</TABLE>";
echo '</div>';
}
/* 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 "<P> <H2 class=\"info2\"> $l_name </H2></P>";
echo '<div class="tmenu">';
echo '<TABLE><TR>';
// TODO echo '<TD class="mtitle"><A class="mtitle" HREF="facturation.php">Facturation</A></TD>';
echo '<TD class="mtitle"><A class="mtitle" HREF="enc_jrn.php">Encodage </A></TD>';
echo '<TD class="mtitle"<A class="mtitle" HREF="form.php">Formulaire </A> </TD>';
echo '<TD class="mtitle"><A class="mtitle" HREF="impress.php">Impression</A></TD>';
echo '<TD class="mtitle"><A class="mtitle" HREF="fiche.php">Fiche</A></TD>';
echo '<TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=1">Plan Comptable</A></TD>';
echo '<TD class="mtitle"><A class="mtitle" HREF="jrn_update.php">Journaux</A></TD>';
echo '<TD class="mtitle"><A class="mtitle" HREF="central.php">Centralise</A></TD>';
echo '<TD class="mtitle"><A class="mtitle" HREF="dossier_prefs.php">Paramètres</A></TD>';
echo "</TR>";
echo "</TABLE>";
echo '</div>';
}
/* 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 '<div class="searchmenu">';
echo '<TABLE>';
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 ('<TR><TD class="cell">%s</TD>',$l_line['jrn_def_name']);
if ( $right > 0 ) {
// Lecture
printf ('<TD class="mltitle"><A class="mtitle" HREF="enc_jrn.php?p_jrn=%s&action=view">Voir</A></TD>',
$l_line['jrn_def_id']);
}
// ecriture
if ( $right > 1 ) {
printf ('<TD class="mltitle"><A class="mtitle" HREF="enc_jrn.php?p_jrn=%s&action=record&max_deb=%s&max_cred=%s">Encoder</A></TD></TR>',
$l_line['jrn_def_id'],
$l_line['jrn_deb_max_line'],
$l_line['jrn_cred_max_line']);
}
}
echo "</TABLE>";
echo '</div>';
}
?>

View file

@ -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);

View file

@ -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'];
}
?>

View file

@ -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 "<P> <H2 class=\"info2\"> $l_name </H2></P>";
echo '<div class="tmenu">';
echo '<TABLE><TR>';
// TODO echo '<TD class="mtitle"><A class="mtitle" HREF="facturation.php">Facturation</A></TD>';
echo '<TD class="mtitle"><A class="mtitle" HREF="enc_jrn.php">Encodage </A></TD>';
echo '<TD class="mtitle"<A class="mtitle" HREF="form.php">Formulaire </A> </TD>';
echo '<TD class="mtitle"><A class="mtitle" HREF="impress.php">Impression</A></TD>';
echo '<TD class="mtitle"><A class="mtitle" HREF="fiche.php">Fiche</A></TD>';
echo '<TD class="mtitle"><A class="mtitle" HREF="pcmn_update.php?p_start=1">Plan Comptable</A></TD>';
echo '<TD class="mtitle"><A class="mtitle" HREF="jrn_update.php">Journaux</A></TD>';
echo '<TD class="mtitle"><A class="mtitle" HREF="central.php">Centralise</A></TD>';
echo '<TD class="mtitle"><A class="mtitle" HREF="dossier_prefs.php">Paramètres</A></TD>';
echo "</TR>";
echo "</TABLE>";
echo '</div>';
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 '<div class="rmenu">';
echo '<TABLE>';
if ( CheckAdmin() != 0 && $p_dossier != 0) {
echo '<TR><TD class="mtitle"> <A class="mtitle" HREF="admin_repo.php">Admin</A></TD></TR>';
if ( ! isset ( $p_auser['use_usertype'])) {
exit (1);
}
echo '<TR><TD class="mtitle"> <A class="mtitle" HREF="login.php">Accueil</A></TD></TR>';
echo '<TR><TD class="mtitle"> <A class="mtitle" HREF="user_pref.php">Preference</A></TD></TR>';
if ( strlen ($p_more) != 0 ) {
printf ('<TR><TD class="mtitle"> %s </TD></TR>',$p_more);
if ( $p_auser['use_usertype']=='compta') {
include_once("compta_menu.php");
c_ShowMenuComptaRight($p_dossier,$p_auser['use_admin'],$p_more);
}
echo '<TR><TD class="mtitle"> ';
html_button_logout();
echo ' </TD></TR>';
echo "</TABLE>";
echo '</div>';
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 '<div class="searchmenu">';
echo '<TABLE>';
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 ('<TR><TD class="cell">%s</TD>',$l_line['jrn_def_name']);
if ( $right > 0 ) {
// Lecture
printf ('<TD class="mltitle"><A class="mtitle" HREF="enc_jrn.php?p_jrn=%s&action=view">Voir</A></TD>',
$l_line['jrn_def_id']);
}
// ecriture
if ( $right > 1 ) {
printf ('<TD class="mltitle"><A class="mtitle" HREF="enc_jrn.php?p_jrn=%s&action=record&max_deb=%s&max_cred=%s">Encoder</A></TD></TR>',
$l_line['jrn_def_id'],
$l_line['jrn_deb_max_line'],
$l_line['jrn_cred_max_line']);
}
}
echo "</TABLE>";
echo '</div>';
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 '<DIV class="lmenu">';
echo $menu;
echo '</DIV>';
}
/* 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="<TABLE>";
foreach ($p_array as $all=>$href){
$ret.='<TR><TD CLASS="mtitle"><A class="mtitle" HREF="'.$href[0].'">'.$href[1].'</A></TD></TR>';
echo_debug($ret);
}
$ret.="</TABLE>";
return $ret;
}
?>

293
include/user_menu.php Normal file
View file

@ -0,0 +1,293 @@
<?
/*
* This file is part of WCOMPTA.
*
* WCOMPTA 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.
*
* WCOMPTA 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 WCOMPTA; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Auteur Dany De Bontridder ddebontridder@yahoo.fr
/* $Revision$ */
/* function u_ShowDossier
* Purpose : Show all the available folder
* for the users
* parm :
* - $p_user user login
* - $p_admin 1 if admin
* gen :
* - none
* return:
* - nothing
*
*/
function u_ShowDossier($p_user,$p_admin)
{
$p_array=GetAvailableFolder($p_user,$p_admin);
$result="<TABLE>";
for ($i=0;$i<sizeof($p_array);$i++) {
$id=$p_array[$i]['dos_id'];
$name= $p_array[$i]['dos_name'];
$desc=$p_array[$i]['dos_description'];
if ( $i%2 == 0)
$tr="odd";
else $tr="even";
$result.="<TR class=\"$tr\"><TD class=\"$tr\">";
$result.="<B>$name</B>";
$result.="</TD><TD class=\"$tr\">";
$result.=$desc;
$result.="</TD><TD class=\"mtitle\">";
$result.="<A class=\"mtitle\" HREF=\"user_compta.php?dos=$id\">Encoder</A>";
$result.="</TD></TR>";
}
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 '<div class="mtitle">';
echo "<TABLE align=center cellspadding=0><TR>";
if ( $p_admin !=0 ) {
/* Administrator Menu */
echo '<TD class="mtitle"><A class="mtitle" HREF=admin_repo.php>Administrator Menu</A></TD>';
}
if (strlen ( $p_item ) != 0 ) {
echo '<TD class="mtitle">'.$p_item.'</A></TD>';
}
echo ' <TD class="mtitle"> <A class="mtitle" HREF="user_pref.php">Préférence</A></TD>';
echo "<TD class=\"mtitle\">";
html_button_logout();
echo "</TD>";
echo "</TR></TABLE>";
echo "</div>";
}
/* 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 "<P> <H2 class=\"info2\"> $l_name </H2></P>";
$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 "<DIV class=\"tmenu\">";
echo $result;
echo "</DIV>";
}
/* 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 '<DIV class="rmenu">';
echo $menu;
echo '</DIV>';
}
/* 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 '<div class="searchmenu">';
echo '<TABLE><TR>';
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 '<H2 class="error"> Invalid Type</H2>';
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 '<TD class="cell">';
printf ('<A class="mtitle" HREF="%s?p_jrn=%s">%s</A></TD>',$ref,
$l_line['jrn_def_id'],$l_line['jrn_def_name']);
}
else {
echo '<TD class="selectedcell">';
printf ('%s</TD>',
$l_line['jrn_def_name']);
}
}
}
echo "</TABLE>";
echo '</div>';
}
?>