From 41d34ad290da214fe8d695f8647b7683d73d8b10 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sun, 30 Nov 2003 13:19:28 +0000 Subject: [PATCH] Continue work for user profile --- html/impress.php | 20 ++++++----- html/jrn_add.php | 39 ++++++++++++++++++++-- html/jrn_detail.php | 72 +++++++++++++++++++++++++++++++++++----- include/ac_common.php | 43 +++++++++++++----------- include/constant.php | 10 ++++++ include/fiche_inc.php | 77 ++++++++++++++++++++++++++++++++++++------- include/jrn.php | 14 ++++---- sql/journal.sql | 2 ++ 8 files changed, 221 insertions(+), 56 deletions(-) diff --git a/html/impress.php b/html/impress.php index 4acd9e887..3ebe10a43 100644 --- a/html/impress.php +++ b/html/impress.php @@ -1,22 +1,22 @@ '; echo ''; echo ''; ?> +

Fiches (profile user)

'; +$Res=ExecSql($cn,"select fd_id,fd_label from fichedef order by fd_label"); +$num=pg_NumRows($Res); + + +echo ''; +echo ' Fiches Crédit'; +echo ' Fiches Dédit'; +echo ''; +// Show the fiche in deb section +for ($i=0;$i<$num;$i++) { + $res=pg_fetch_array($Res,$i); + echo ''; + printf (' %s', + $res['fd_id'],$res['fd_label']); + printf (' %s', + $res['fd_id'],$res['fd_label']); + echo ''; +} +?> '; diff --git a/html/jrn_detail.php b/html/jrn_detail.php index 526fd53eb..538d07eb6 100644 --- a/html/jrn_detail.php +++ b/html/jrn_detail.php @@ -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='"; echo '
'; +echo '

Fiches (profile comptable)

'; echo '
'; echo ''; echo ''; @@ -168,19 +174,67 @@ echo ''; echo ''; echo ""; + + ?> - + '; +// Get all the fiches +echo '

Fiches (profile user)

'; +$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 '
'; $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 '
Code ".$l_line['jrn_def_code']."
'; +echo ''; +echo ''; +echo ''; +echo ''; +// 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 ''; + printf ('', + $res['fd_id'],$CHECKED,$res['fd_label']); + $CHECKED=" unchecked"; + foreach ( $rcred as $element) { + if ( $element == $res['fd_id'] ) { + $CHECKED="CHECKED"; + break; + } + } + + printf ('', + $res['fd_id'],$CHECKED,$res['fd_label']); + echo ''; +} + + +?> + +
Fiches Crédit Fiches Dédit
%s %s
+'; echo "
"; html_page_stop(); diff --git a/include/ac_common.php b/include/ac_common.php index 97703bcef..8e6b31e0f 100644 --- a/include/ac_common.php +++ b/include/ac_common.php @@ -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=""; "; echo ""; } -/* function +/* function html_page_stop() * Purpose : * * parm : @@ -152,7 +152,7 @@ function html_page_stop() echo ""; echo ""; } -/* function +/* function html_button_logout * Purpose : * * parm : @@ -165,7 +165,7 @@ function html_page_stop() function html_button_logout() { echo " Logout "; } -/* 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.=""; return $ret; } +/* function echo_warning + * Purpose : warns + * + * parm : + * - string + * gen : + * - none + * return: + * - none + */ +function echo_warning($p_string) +{ + echo '

'.$p_string."

"; +} ?> diff --git a/include/constant.php b/include/constant.php index dcec1ef4b..2cc0ecc1c 100644 --- a/include/constant.php +++ b/include/constant.php @@ -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); diff --git a/include/fiche_inc.php b/include/fiche_inc.php index 2e0e4fa09..aa5f38410 100644 --- a/include/fiche_inc.php +++ b/include/fiche_inc.php @@ -183,9 +183,9 @@ function ViewFiche($p_cn,$p_type) { for ( $i = 0; $i < $Max; $i++) { $l_line=pg_fetch_array($Res,$i); $div="
"; - $span_mod=' Modifie'; + $span_mod=' Modifie'; $span_del=''. - ' delete'; $span_id=''.$l_line['f_id'].""; if ( $i %2 == 0 ) @@ -389,15 +389,16 @@ function DefModele ($p_js,$p_array=null,$p_ligne=1) echo ''; } -/* 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; +} ?> diff --git a/include/jrn.php b/include/jrn.php index 29b604b09..b42ba5592 100644 --- a/include/jrn.php +++ b/include/jrn.php @@ -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) { diff --git a/sql/journal.sql b/sql/journal.sql index 7aa81b1fc..08aad1970 100644 --- a/sql/journal.sql +++ b/sql/journal.sql @@ -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,