/*
* This file is part of PhpCompta.
*
* 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.
*
* 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 PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/* $Revision$ */
/* function RecordJrn
* Purpose : Record an entry in the selected journal
*
* parm :
* - p_dossier dossier id
* - p_user user id
* - p_jrn selected journal
* gen :
* - none
* return:
* - none
*
*/
function RecordJrn($p_dossier,$p_user,$p_jrn,$p_MaxDeb,$p_MaxCred,$p_array = null,$p_update=0)
{
include_once("postgres.php");
include_once("preference.php");
echo_debug("RecordJrn($p_dossier,$p_user,$p_jrn,$p_MaxDeb,$p_MaxCred,$p_array,$p_update)");
for ( $i = 0; $i < $p_MaxDeb; $i++) {
${"e_class_deb$i"}=0;
${"e_mont_deb$i"}=0;
}
for ( $i = 0; $i < $p_MaxCred; $i++) {
${"e_class_cred$i"}=0;
${"e_mont_cred$i"}=0;
}
$l_dossier=sprintf("dossier%d",$p_dossier);
$cn=DbConnect($l_dossier);
// userPref contient la periode par default
$userPref=GetUserPeriode($cn,$p_user);
list ($l_date_start,$l_date_end)=GetPeriode($cn,$userPref);
$e_op_rem=substr($l_date_start,2,8);
if ( $p_array == null ) {
$e_op_date="01";
$e_comment="";
$e_rapt="";
$e_ech="";
$e_sum_deb=0;
$e_sum_cred=0;
} else {
foreach ( $p_array as $n=>$e) {
${"e_$n"}= $e;
}
}
/* Get Jrn's properties */
$l_line=GetJrnProperty($cn,$p_jrn);
if ( $l_line == null ) return;
echo '
';
echo '";
echo '
';
}
/* function UpdateJrn
* Purpose : Display the form to UPDATE account operation
*
* parm :
* - p_dossier
* - p_jrn
* - p_MaxDeb number of debit line
* - p_MaxCred " " credit "
*" - p_array array containing the others datas
* gen :
* - none
* return:
* - none
*
*/
function UpdateJrn($p_cn,$p_jr_id)
{
echo_debug("function UpdateJrn");
$l_array=GetDataJrnJrId($p_cn,$p_jr_id);
if ( $l_array == null ) {
echo_error ("Not data found for UpdateJrn p_jr_id = $p_jr_id");
return ;
}
// Javascript
$r=JS_VIEW_JRN_MODIFY;
// Build the form
$col_vide="
";
for ( $i =0 ; $i < sizeof($l_array); $i++) {
$content=$l_array[$i] ;
// for the first line
if ( $i == 0 ) {
$r.="
";
$r.="
";
// Date
$r.="
";
$r.=$content['jr_date'];
$r.="
";
// comment can be changed
$r.="
";
$r.='';
$r.="
";
// Internal
$r.="
";
$r.=$content['jr_internal'];
$r.="
";
if ( $content['jrn_def_type'] == 'ACH' or
$content['jrn_def_type'] == 'VEN' )
{
// Is Paid
$r.="
';
}
/* function GetJrnProperty ($p_cn,$p_jrn)
* Purpose : Get the properties of a journal
*
* parm :
* - p_cn database connection
* - p_jrn the jrn id
* gen :
* - none
* return:
* - an array containing properties
*
*/
function GetJrnProperty($p_cn,$p_jrn)
{
$Res=ExecSql($p_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_def_fiche_deb,jrn_def_fiche_deb
from jrn_Def
where jrn_def_id=$p_jrn");
$Count=pg_NumRows($Res);
if ( $Count == 0 ) {
echo '
Paramètres journaux non trouvés
';
return null;
}
return pg_fetch_array($Res,0);
}
/* function GetJrnProp
* Purpose : Get the properties of a journal
*
* parm :
* - p_dossier the folder id
* - p_jrn the jrn id
* gen :
* - none
* return:
* - an array containing properties
*
*/
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_def_fiche_deb,jrn_def_fiche_deb
from jrn_Def
where jrn_def_id=$p_jrn");
$Count=pg_NumRows($Res);
if ( $Count == 0 ) {
echo '
Paramètres journaux non trouvés
';
return null;
}
return pg_fetch_array($Res,0);
}
/* function GetNextId($p_cn,$p_name)
* Purpose :
*
* parm :
* -
* gen :
* -
* return:
* -
*
*/
function GetNextId($p_cn,$p_name) {
include_once("postgres.php");
$Res=ExecSql($p_cn,"select max($p_name) as result from jrnx");
echo_debug("$Res=ExecSql($p_cn,"."select max($p_name) as result from jrnx");
if (pg_NumRows($Res) == 0 )
return 0;
$l_res=pg_fetch_array($Res,0);
return $l_res['result'];
}
/* function GetNextJrnId($p_cn,$p_name)
* Purpose :
*
* parm :
* -
* gen :
* -
* return:
* -
*
*/
function GetNextJrnId($p_cn,$p_name) {
include_once("postgres.php");
$Res=ExecSql($p_cn,"select max($p_name) as result from jrn ");
echo_debug("$Res=ExecSql($p_cn,"."select max($p_name) as result from jrn ");
if (pg_NumRows($Res) == 0 )
return 0;
$l_res=pg_fetch_array($Res,0);
return $l_res['result'];
}
/* function ViewJrn
* Purpose : Vue des écritures comptables
*
* parm :
* - p_dossier,
* - p_user,
* - p_jrn
* - p_url for modif
* - array
* gen :
* -
* return:
* -
*
*/
function ViewJrn($p_dossier,$p_user,$p_jrn,$p_url,$p_array=null) {
echo_debug("function ViewJrn($p_dossier,$p_user,$p_jrn,$p_array=null) ");
echo JS_VIEW_JRN_DETAIL;
$db=sprintf("dossier%d",$p_dossier);
$l_prop=GetJrnProp($p_dossier,$p_jrn);
echo "