From 7474eebbe73e71706a9f7cfa0185068ca351a28d Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 13 Oct 2007 14:35:42 +0000 Subject: [PATCH] Ajout debit / credit dans rapport --- doc/manuel-fr.sgml | 4 +- include/impress_inc.php | 245 ++++------------------------------------ 2 files changed, 23 insertions(+), 226 deletions(-) diff --git a/doc/manuel-fr.sgml b/doc/manuel-fr.sgml index 395229205..ffd73c559 100644 --- a/doc/manuel-fr.sgml +++ b/doc/manuel-fr.sgml @@ -1217,12 +1217,12 @@ r les postes sont toujours écrits entre crochets; pour avoir la somme du poste et des sous-poste, il faut utiliser le %; -Les soldes sont toujours positifs et vous ne savez pas -s'ils sont au débit ou au crédit. Si vous souhaitez commencer à une autre période pour certains compte et donc avoir plusieurs intervalles pour un rapport, vous devez utiliser l'option FROM=MM.YYYY (voir exemple). Ce genre d'option est très utile pour par exemple les déclarations de TVA. +Si vous souhaitez n'avoir que le crédit ou le débit, utilisez le + D ou le C avant la fermeture du crochet

cas particulier : FROM=00.0000 pour indiquer le début de l'exercice diff --git a/include/impress_inc.php b/include/impress_inc.php index 7bc5aa1a0..79e9b7beb 100644 --- a/include/impress_inc.php +++ b/include/impress_inc.php @@ -20,227 +20,6 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr // $Revision$ -/*! - * \brief Create the form where the period - * is asked - * - * \param array (type,action,central,filter...) - * \param connection - * \return none - *\todo it seems not to be used ==> to clean - */ - /* -function ViewImp($p_array,$p_cn) { - include_once("preference.php"); - require_once("class_user.php"); - - $periode=FormPeriodeMult($p_cn); - foreach ( $p_array as $key=>$element) { - echo_debug('impress_inc.php',__LINE__,"VIEWIMP $key $element"); - ${"$key"}=$element; - } - if ( ! isset($type) ) return; - $centr=""; - if ( $action=="viewhtml") { - echo '

'; - if ( $type=="jrn") - $centr='
Centralisé : -
'; - } - else { - if ( $type=="jrn") { - echo ''; - $centr='
Centralisé : -
'; - } - if ( $type=="poste") - echo ''; - } - echo $periode; - echo ''; - echo ''; - - echo $centr; - - if ( isset($filter)) - echo ''; - if ( isset ($p_id)) { - echo ''; - } else { - include_once("poste.php"); - echo "
"; - echo PosteForm($p_cn); - echo '
Tous les postes '; - echo '
'; - } - echo ''; - - echo '
'; - echo ""; -} -*/ -/*! - * \brief Show the html printing result - * \param array - * \param db connection - * \return ImpHtml - * - * \todo not used ==> to clean -function Imp($p_array,$p_cn) { - if ( ! isset($p_array['action'])) { - echo_error ("IMP no action specified"); return; - } - if ( $p_array['action']=="viewhtml") { - return ImpHtml($p_array,$p_cn); - } - echo_error ("IMP no action specified"); return; -} -*/ -/*! - * \brief Show the html result - * \param array (type,periode, - * \param connection - * \return error if something goes wrong or - * the page result - * \todo not used ==> to clean - * - * -function ImpHtml($p_array,$p_cn) -{ - foreach($p_array as $key=>$element) { - ${"$key"}=$element; - echo_debug('impress_inc.php',__LINE__,"ImpHtml $key => $element"); - } - - - $colvide=""; - // formulaire - if ( $type == "form" ) { - if ( !isset ($periode)) return NO_PERIOD_SELECTED; - $cond=CreatePeriodeCond($periode); - $Res=ExecSql($p_cn,"select fo_id , - fo_fr_id, - fo_pos, - fo_label, - fo_formula, - fr_label from form - inner join formdef on fr_id=fo_fr_id - where fo_fr_id=$p_id - order by fo_pos"); - $Max=pg_NumRows($Res); - if ($Max==0) return $ret=""; - for ($i=0;$i<$Max;$i++) { - $l_line=pg_fetch_array($Res,$i); - $col=GetFormulaValue($p_cn, - $l_line['fo_label'], - $l_line['fo_formula'],$cond); - echo "
"; - foreach ($col as $key=> $element) { - echo "$element "; - } - echo "
"; - } //for ($i - - }//form - if ($type=="poste") { - if ( ! isset ( $all_poste) && ! isset ( $poste )) return NO_POST_SELECTED; - if ( !isset ($periode)) return NO_PERIOD_SELECTED; - include_once("poste.php"); - $cond=CreatePeriodeCond($periode); - $ret="" ; - if ( isset ( $all_poste) ){ //choisit de voir tous les postes - $r_poste=ExecSql($p_cn,"select pcm_val from tmp_pcmn"); - $nPoste=pg_numRows($r_poste); - for ( $i=0;$i<$nPoste;$i++) { - $t_poste=pg_fetch_array($r_poste,$i); - $poste[]=$t_poste['pcm_val']; - } - } - for ( $i =0;$i%d %s", - $poste[$i],GetPosteLibelle($p_cn,$poste[$i],1)); - $ret.=""; - $i=0; - foreach ($array as $col=>$element) { - $i++; - if ( $i %2 == 0) - $ret.=""; - else - $ret.=""; - $ret.=sprintf("",$element['j_date']); - $ret.=sprintf("",$element['jr_internal']); - // $ret.=sprintf("",$element['jrn_name']); - $ret.=sprintf("",$element['description']); - if ( $element['j_debit']=='t') { - $ret.=sprintf(" $colvide", - $element['deb_montant']); - } else { - $ret.=sprintf(" $colvide ", - $element['cred_montant']); - - } - $ret.=""; - }//foreach - - $ret.=sprintf("$colvide $colvide $colvide $colvide ". - "". - "", - $tot_deb, - $tot_cred); - $ret.="
%s%sjrn:%s%s debit % 8.2fcredit % 8.2f
% 8.2f% 8.2f
"; - $ret.="

Total débit :".$tot_deb." Total Crédit:".$tot_cred."

"; - if ( $tot_deb > $tot_cred ) { - $solde_t="D"; - $solde=$tot_deb-$tot_cred; - }else { - $solde_t="C"; - $solde=$tot_cred-$tot_deb; - } - $ret.="

Solde $solde_t = ".$solde."

"; - }// for i - return $ret; - }//poste - if ($type=="jrn") { - if ( !isset ($periode)) return NO_PERIOD_SELECTED; - - echo_debug('impress_inc.php',__LINE__,"imp html journaux"); - $ret=""; - if (isset($filter)) { - $array=GetDataJrn($p_cn,$p_array,$filter); - } - $cass=""; - $c=0; - - foreach ($array as $a=>$e2) { - // echo_debug($ret); - - //cassure entre op - if ( $cass!=$e2['grp'] ) { - $cass=$e2['grp']; - $ret.=''.$e2['j_date'].""; - $ret.="".$e2['jr_internal']." ".$e2['comment'].""; - } - $ret.=""; - $ret.=$colvide; - - if ($e2['debit']=='f') $ret.=$colvide; - $ret.="".$e2['poste'].""; - if ($e2['debit']=='t') $ret.=$colvide; - $ret.="".$e2['description'].""; - if ($e2['debit']=='f') $ret.=$colvide; - $ret.="".$e2['montant'].""; - if ($e2['debit']=='t') $ret.=$colvide; - $ret.=""; - } - echo_debug($ret); - - return $ret ; - }//jrn - -} -*/ /*! * \brief Get dat for poste @@ -770,12 +549,20 @@ function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true,$p_ $cond="( j_date >= to_date('$p_start','DD.MM.YYYY') and j_date <= to_date('$p_end','DD.MM.YYYY'))"; include_once("class_poste.php"); - while (ereg("(\[[0-9]*%*\])",$p_formula,$e) == true) { + while (ereg("(\[[0-9]*%*D*C*\])",$p_formula,$e) == true) { // remove the [ ] $x=$e; + $compute='all'; + if ( strpos($e[0],'D') != 0 ) + $compute='deb'; + if ( strpos($e[0],'C') != 0 ) + $compute='cred'; + echo_debug(__FILE__,__LINE__,' $e = '.$e[0]); $e[0]=str_replace ("[","",$e[0]); $e[0]=str_replace ("]","",$e[0]); + $e[0]=str_replace ("D","",$e[0]); + $e[0]=str_replace ("C","",$e[0]); echo_debug('impress_inc',__LINE__,"p_formula is $p_formula"); // If there is a FROM clause we must recompute // the time cond @@ -813,7 +600,15 @@ function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true,$p_ // Get sum of account $P=new poste($p_cn,$e[0]); echo_debug(__FILE__.":".__LINE__." condition is $cond"); - $i=$P->GetSolde($cond); + + $detail=$P->GetSoldeDetail($cond); + if ( $compute=='all') + $i=$detail['solde']; + if ( $compute=='deb') + $i=$detail['debit']; + if ( $compute=='cred') + $i=$detail['credit']; + $p_formula=str_replace($x,$i,$p_formula); } @@ -909,7 +704,9 @@ function CheckFormula($p_string) { $p_string=str_replace("<","+",$p_string); // eat Space $p_string=str_replace(" ","",$p_string); - + // Remove D/C + $p_string=str_replace("C","",$p_string); + $p_string=str_replace("D","",$p_string); if ( ereg ("^(\\$[a-zA-Z]*[0-9]*=){0,1}((\[{0,1}[0-9]+\.*[0-9]*%{0,1}\]{0,1})+ *([+-\*/])* *(\[{0,1}[0-9]+\.*[0-9]*%{0,1}\]{0,1})*)*(([+-\*/])*\\$([a-zA-Z])+[0-9]*([+-\*/])*)* *( *FROM=[0-9][0-0].20[0-9][0-9]){0,1}$",$p_string) == false) { return false;