Continue work for user profile

This commit is contained in:
sparkyx 2003-11-30 13:19:28 +00:00
parent b92c637d0d
commit 41d34ad290
8 changed files with 221 additions and 56 deletions

View file

@ -1,22 +1,22 @@
<?
/*
* This file is part of WCOMPTA.
* This file is part of PhpCompta.
*
* WCOMPTA is free software; you can redistribute it and/or modify
* PhpCompta 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,
* PhpCompta 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
* along with PhpCompta; 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
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/* $Revision$ */
include_once ("ac_common.php");
html_page_start($g_UserProperty['use_theme']);
@ -30,7 +30,11 @@ CheckUser();
include ("check_priv.php");
include_once ("top_menu_compta.php");
ShowMenuCompta($g_dossier,$g_UserProperty);
if ( isset ($g_jrn) ) {
$p_id=$g_jrn;
} else {
if (isset ($_GET["p_id"]) ) $p_id=$_GET["p_id"];
}
include_once("impress_inc.php");
ShowMenuComptaRight($g_dossier,$g_UserProperty);
@ -40,9 +44,9 @@ if ( $g_UserProperty['use_admin'] == 0 ) {
/* Cannot Access */
NoAccess();
}
if (isset ($_GET["p_id"]) && isset ($_GET["type"])) {
if ( isset ($_GET["type"])) {
if ( $type="jrn") {
$right=CheckJrn($g_dossier,$g_user,$_GET['p_id']);
$right=CheckJrn($g_dossier,$g_user,$p_id);
if ($right == 0 ){
/* Cannot Access */
NoAccess();

View file

@ -80,10 +80,23 @@ echo_debug("nom journal $p_jrn_name");
$p_jrn_class_cred=FormatString($_POST["p_jrn_class_cred"]);
// compute the jrn_def.jrn_def_code
$p_code=sprintf("%s-%02d",trim($_POST['p_jrn_type']),NextJrn($cn,$_POST['p_jrn_type']));
$p_jrn_fiche_deb="";
$p_jrn_fiche_cred="";
if ( isset ($_POST["FICHEDEB"])) {
$p_jrn_fiche_deb=join(",",$_POST["FICHEDEB"]);
}
if ( isset ($_POST["FICHECRED"])) {
$p_jrn_fiche_cred=join(",",$_POST["FICHECRED"]);
}
$Sql=sprintf("insert into jrn_def(jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_deb_max_line,jrn_cred_max_line,
jrn_def_type,jrn_def_code) values ('%s','%s','%s',%s,%s,'%s','%s')",
jrn_def_type,jrn_def_fiche_deb,jrn_def_fiche_cred,jrn_def_code)
values ('%s','%s','%s',%s,%s,'%s','%s','%s','%s')",
$p_jrn_name,$p_jrn_class_deb,$p_jrn_class_cred,
$l_deb_max_line,$l_cred_max_line,$_POST['p_jrn_type'],$p_code
$l_deb_max_line,$l_cred_max_line,$_POST['p_jrn_type'],
$p_jrn_fiche_deb,$p_jrn_fiche_cred,
$p_code
);
echo_debug($Sql);
$Res=ExecSql($cn,$Sql);
@ -155,6 +168,28 @@ echo '</SELECT>';
echo '</TD>';
echo '</TR>';
?>
<?
// Get all the fiches
echo '<tr> <td colspan="2"><H2 class="info"> Fiches (profile user)</H2></TD></TR>';
$Res=ExecSql($cn,"select fd_id,fd_label from fichedef order by fd_label");
$num=pg_NumRows($Res);
echo '<TR>';
echo '<th> Fiches Crédit</TH>';
echo '<th> Fiches Dédit</TH>';
echo '</TR>';
// Show the fiche in deb section
for ($i=0;$i<$num;$i++) {
$res=pg_fetch_array($Res,$i);
echo '<TR>';
printf ('<TD> <INPUT TYPE="CHECKBOX" VALUE="%s" NAME="FICHEDEB[]">%s</TD>',
$res['fd_id'],$res['fd_label']);
printf ('<TD> <INPUT TYPE="CHECKBOX" VALUE="%s" NAME="FICHECRED[]">%s</TD>',
$res['fd_id'],$res['fd_label']);
echo '</TR>';
}
?>
<TR><TD><INPUT TYPE="SUBMIT" VALUE="Sauve"></TD><TD><INPUT TYPE="RESET" VALUE="Reset"></TD></TR>
<?
echo '</TABLE>';

View file

@ -80,12 +80,23 @@ If ( isset ($_POST["JRN_UPD"] )) {
$p_jrn_name=$_POST['p_jrn_name'];
if (strlen(trim($p_jrn_name))==0) return;
$p_jrn_name=FormatString($p_jrn_name);
$p_jrn_fiche_deb="";
$p_jrn_fiche_cred="";
if ( isset ($_POST["FICHEDEB"])) {
$p_jrn_fiche_deb=join(",",$_POST["FICHEDEB"]);
}
if ( isset ($_POST["FICHECRED"])) {
$p_jrn_fiche_cred=join(",",$_POST["FICHECRED"]);
}
$Sql=sprintf("update jrn_def set jrn_def_name='%s',jrn_def_class_deb='%s',jrn_def_class_cred='%s',
jrn_deb_max_line=%s,jrn_cred_max_line=%s,jrn_def_ech=%s,jrn_def_ech_lib=%s
jrn_deb_max_line=%s,jrn_cred_max_line=%s,jrn_def_ech=%s,jrn_def_ech_lib=%s,jrn_def_fiche_deb='%s',
jrn_def_fiche_cred='%s'
where jrn_def_id=%s",
$p_jrn_name,$_POST['p_jrn_class_deb'],$_POST['p_jrn_class_cred'],
$l_deb_max_line,$l_cred_max_line,
$p_ech,$p_ech_lib,
$p_jrn_fiche_deb,$p_jrn_fiche_cred,
$g_jrn
);
echo_debug($Sql);
@ -93,16 +104,10 @@ If ( isset ($_POST["JRN_UPD"] )) {
}
}
ShowMenuJrn($g_dossier);
// $right=CheckJrn($g_dossier,$user,$g_jrn);
// if ($right == 0 ){
// /* Cannot Access */
// NoAccess();
// exit -1;
// }
$Res=ExecSql($cn,"select jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,".
"jrn_deb_max_line,jrn_cred_max_line,jrn_def_code".
",jrn_def_type,jrn_def_ech, jrn_def_ech_lib".
",jrn_def_type,jrn_def_ech, jrn_def_ech_lib,jrn_def_fiche_deb,jrn_def_fiche_cred".
" from jrn_def where".
" jrn_def_id=".$g_jrn);
$l_line=pg_fetch_array($Res,0);
@ -115,6 +120,7 @@ if ( isset ($_POST["PHPSESSID"] ) ) {
$search='<INPUT TYPE="BUTTON" VALUE="Cherche" OnClick="SearchPoste(\''.$sessid."')\">";
echo '<DIV CLASS="ccontent">';
echo '<H2 class="info"> Fiches (profile comptable)</H2>';
echo '<FORM ACTION="jrn_detail.php" METHOD="POST">';
echo '<INPUT TYPE="HIDDEN" NAME="JRN_UPD">';
echo '<TABLE>';
@ -168,19 +174,67 @@ echo '<TD> ';
$Res=ExecSql($cn,"select jrn_type_id,jrn_desc from jrn_type where ".
"trim(jrn_type_id)=trim('".$l_line['jrn_def_type']."')");
$Max=pg_NumRows($Res);
for ($i=0;$i<$Max;$i++) {
$Line=pg_fetch_array($Res,$i);
echo_debug("jrn type !".$Line['jrn_type_id']."!,!".$l_line['jrn_def_type']."!");
printf (' %s',$Line['jrn_desc']);
}
echo '</TD>';
echo '</TR>';
echo "<TR><TD> Code </TD><TD>".$l_line['jrn_def_code']."</TD></TR>";
?>
<TR><TD><INPUT TYPE="SUBMIT" VALUE="Sauve"></TD><TD><INPUT TYPE="RESET" VALUE="Reset"></TD></TR>
<?
echo '</TABLE>';
// Get all the fiches
echo '<H2 class="info"> Fiches (profile user)</H2>';
$Res=ExecSql($cn,"select fd_id,fd_label from fichedef order by fd_label");
$num=pg_NumRows($Res);
$rdeb=split(',',$l_line['jrn_def_fiche_deb']);
$rcred=split(',',$l_line['jrn_def_fiche_cred']);
echo '<TABLE>';
echo '<TR>';
echo '<th> Fiches Crédit</TH>';
echo '<th> Fiches Dédit</TH>';
echo '</TR>';
// Show the fiche in deb section
for ($i=0;$i<$num;$i++) {
$res=pg_fetch_array($Res,$i);
$CHECKED=" unchecked";
foreach ( $rdeb as $element) {
if ( $element == $res['fd_id'] ) {
$CHECKED="CHECKED";
break;
}
}
echo '<TR>';
printf ('<TD> <INPUT TYPE="CHECKBOX" VALUE="%s" NAME="FICHEDEB[]" %s>%s</TD>',
$res['fd_id'],$CHECKED,$res['fd_label']);
$CHECKED=" unchecked";
foreach ( $rcred as $element) {
if ( $element == $res['fd_id'] ) {
$CHECKED="CHECKED";
break;
}
}
printf ('<TD> <INPUT TYPE="CHECKBOX" VALUE="%s" NAME="FICHECRED[]" %s>%s</TD>',
$res['fd_id'],$CHECKED,$res['fd_label']);
echo '</TR>';
}
?>
<TABLE><TR><TD><INPUT TYPE="SUBMIT" VALUE="Sauve"></TD><TD><INPUT TYPE="RESET" VALUE="Reset"></TD></TR></TABLE>
<?
echo '</FORM>';
echo "</DIV>";
html_page_stop();

View file

@ -24,7 +24,7 @@ include_once("debug.php");
include_once("constant.php");
function echo_error ($p_log) {
$fdebug=fopen("/tmp/wcompta_error.log","a+");
$fdebug=fopen("/tmp/phpcompta_error.log","a+");
if ( $fdebug != false ) {
fwrite($fdebug,date("Ymd H:i:s").$p_log."\n");
fclose($fdebug);
@ -138,7 +138,7 @@ $bg="";
</HEAD>";
echo "<BODY $bg class=\"defaut\" $p_script>";
}
/* function
/* function html_page_stop()
* Purpose :
*
* parm :
@ -152,7 +152,7 @@ function html_page_stop()
echo "</BODY>";
echo "</HTML>";
}
/* function
/* function html_button_logout
* Purpose :
*
* parm :
@ -165,7 +165,7 @@ function html_page_stop()
function html_button_logout() {
echo "<A class=\"mtitle\" HREF=logout.php> Logout </A>";
}
/* function
/* function NoAccess
* Purpose :
*
* parm :
@ -185,7 +185,7 @@ function NoAccess() {
exit -1;
}
/* function
/* function FormatString($p_string)
* Purpose :
*
* parm :
@ -207,21 +207,14 @@ function FormatString($p_string)
$p_string=str_replace("'","\'",$p_string);
return $p_string;
}
/* function
* Purpose :
/* function GetUserType
* Purpose : get the type of an user (compta,developper or user)
*
* parm :
* -
* - param $p_user user_login
* gen :
* -
* return:
*/
/* GetUserType
* purpose : get the type of an user (compta,developper or user)
* param $p_user user_login
* return : the type of the user
* - none
* return: the type of the user
*/
function GetUserType($p_user)
{
@ -242,8 +235,6 @@ function GetUserType($p_user)
* - none
* return: none
*/
function Redirect($p_profile,$php_session) {
include_once("debug.php");
echo_debug("Session is $php_session");
@ -287,5 +278,19 @@ function ShowItem($p_array,$p_dir='V')
$ret.="</TABLE>";
return $ret;
}
/* function echo_warning
* Purpose : warns
*
* parm :
* - string
* gen :
* - none
* return:
* - none
*/
function echo_warning($p_string)
{
echo '<H2 class="info">'.$p_string."</H2>";
}
?>

View file

@ -24,15 +24,25 @@
// securite correspond a la table
// action
// access aux journaux
define ("ENCJRN",1);
// création facture
define("FACT",2);
// création aux fiche
define ("FICHE",3);
// Impression
define ("IMP",4);
//formulaire
define("FORM",5);
// Modif du Plan Comptable
define ("MPCMN",6);
// Gestion des journaux
define ("GJRN",7);
// Gestion des paramètres globaux
define ("PARM",8);
// Gestion de la sécurité
define ("SECU",9);
// Access à la centralisation
define ("CENTRALIZE",10);
define ("VEN",11);
define ("BQE",12);

View file

@ -183,9 +183,9 @@ function ViewFiche($p_cn,$p_type) {
for ( $i = 0; $i < $Max; $i++) {
$l_line=pg_fetch_array($Res,$i);
$div="<DIV>";
$span_mod='<span class="mtitle"><A class="mtitle" href="fiche.php?action=detail&fiche_id='.$l_line['f_id'].'"> Modifie</A></SPAN>';
$span_mod='<span class="mtitle"><A class="mtitle2" href="fiche.php?action=detail&fiche_id='.$l_line['f_id'].'"> Modifie</A></SPAN>';
$span_del='<span class="mtitle2" ALIGN="left">'.
'<A class="mtitle" href="fiche.php?f_fd_id='.$p_type.'&action=delete&fiche_id='.$l_line['f_id'].
'<A class="mtitle2" href="fiche.php?f_fd_id='.$p_type.'&action=delete&fiche_id='.$l_line['f_id'].
'"> delete</A></SPAN>';
$span_id='<SPAN style="background-color:lightgrey;">'.$l_line['f_id']."</SPAN>";
if ( $i %2 == 0 )
@ -389,15 +389,16 @@ function DefModele ($p_js,$p_array=null,$p_ligne=1)
echo '<FORM>';
}
/* function
* Purpose :
/* function AddModele
* Purpose : Add a modele into the database
*
* parm :
* -
* - connection
* - array
* gen :
* -
* - none
* return:
* -
* - none
*
*/
function AddModele($p_cn,$p_array) {
@ -458,15 +459,17 @@ function UpdateModele($p_cn,$p_fiche,$p_js) {
DefModele($p_js,$array,$array['ligne']);
}
/* function
* Purpose :
/* function GetDataModele
* Purpose : Return the info of an fiche identified by
* p_fiche
*
* parm :
* -
* - connection
* - fiche id
* gen :
* -
* - none
* return:
* -
* - array with all the data
*
*/
function GetDataModele($p_cn,$p_fiche) {
@ -594,5 +597,55 @@ function getFicheName($p_cn,$p_id) {
$st=pg_fetch_array($Res,0);
return $st['fd_label'];
}
/* function GetFicheJrn
* Purpose : Get all the fiche related to a "journal"
*
* parm :
* - p_cn connextion
* - j_jrn journal_id
* - $p_type : deb or cred
* gen :
* - none
* return: array containing the fiche(f_id),fiche(f_label)
*/
function GetFicheJrn($p_cn,$p_jrn,$p_type)
{
$get="";
if ( $p_type == 'deb' ) {
$get='jrn_def_fiche_deb';
}
if ( $p_type == 'cred' ) {
$get='jrn_def_fiche_cred';
}
if ( $get == "" ) {
echo_error("Invalid p_type function GetFicheJrn($p_cn,$p_jrn,$p_type)");
exit -1;
}
$Res=ExecSql($p_cn,"select $get as fiche from jrn_def where jrn_def_id=$p_jrn");
$Max=pg_NumRows($Res);
if ( $Max==0) {
echo_warning("No rows");
return null;
}
// Normally Max must be == 1
$list=pg_fetch_array($Res,0);
if ( $list['fiche']=="") {
echo_warning("No fiche");
return null;
}
$sql="select f_id, f_label from fiche where f_fd_id in (".$list['fiche'].") order by f_label";
$Res=ExecSql($p_cn,$sql);
$Max=pg_NumRows($Res);
if ($Max==0 ) return null;
// Get The result and put it into an array
for ($i=0;$i<$Max;$i++) {
$line=pg_fetch_array($Res,$i);
$f_id=$line['f_id'];
$f_label=$line['f_label'];
$a[$i]=array($f_id,$f_label);
}
return $a;
}
?>

View file

@ -589,7 +589,8 @@ function GetJrnProp($p_dossier,$p_jrn)
$l_dossier=sprintf("dossier%d",$p_dossier);
$cn=DbConnect($l_dossier);
$Res=ExecSql($cn,"select jrn_Def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_def_type,
jrn_deb_max_line,jrn_cred_max_line,jrn_def_ech,jrn_def_ech_lib,jrn_def_code
jrn_deb_max_line,jrn_cred_max_line,jrn_def_ech,jrn_def_ech_lib,jrn_def_code,
jrn_def_fiche_deb,jrn_def_fiche_deb
from jrn_Def
where jrn_def_id=$p_jrn");
$Count=pg_NumRows($Res);
@ -800,15 +801,16 @@ function ViewJrn($p_dossier,$p_user,$p_jrn,$p_array=null) {
function isClosed($p_cn,$p_period) {
return false;
}
/* function
* Purpose :
/* function GetData
* Purpose : Get data from jrnx where p_grpt=jrnx(j_grpt)
*
* parm :
* -
* - connection
* - p_grpt
* gen :
* -
* - none
* return:
* -
* - return array
*
*/
function GetData ($p_cn,$p_grpt) {

View file

@ -37,6 +37,8 @@ create table jrn_def
jrn_def_name text not null unique,
jrn_def_class_deb text,
jrn_def_class_cred text,
jrn_def_fiche_deb text ,
jrn_def_fiche_cred text ,
jrn_deb_max_line integer default 1,
jrn_cred_max_line integer default 1,
jrn_def_ech bool default false,