From b1d823fabbe89db4c7f734c7e1b5d55dede59bb1 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Wed, 27 Jul 2005 11:15:09 +0000 Subject: [PATCH] task #4499 : balance pour les fiches --- doc/manuel-fr.sgml | 16 ++++-- html/fiche_csv.php | 33 ++++++++++-- html/user_impress.php | 2 +- include/class_fiche.php | 15 ++++++ include/class_poste.php | 30 ++++++++++- include/impress_fiche.php | 103 +++++++++++++++++++++++++++++++------- 6 files changed, 169 insertions(+), 30 deletions(-) diff --git a/doc/manuel-fr.sgml b/doc/manuel-fr.sgml index 79f3eee4d..48d22b7e0 100644 --- a/doc/manuel-fr.sgml +++ b/doc/manuel-fr.sgml @@ -489,7 +489,7 @@ C'est l'unique journal qui n'utilise pas les fiches. Pourquoi ? Tout simplement parce que s'il utilisait lui-aussi les fiches, il faudrait faire une fiche par poste comptable, -ce qui serait rapidement ingérable. De plus, es fiches sont là pour +ce qui serait rapidement ingérable. De plus, les fiches sont là pour les opérations courantes (vente/Achat/banque). Puisque ce journal n'utilise pas les fiches, le filtre est @@ -511,7 +511,8 @@ Pour cr création. Vous devez donner le nom de la catégorie et le type de fiche que vous voulez. -La classe de base est le poste comptable parent de vos fiche, ce poste doit exister, il faut alors +La classe de base est le poste comptable parent de vos fiche, ce poste +doit exister, il faut alors cliquer aussi sur "create account for each" qui permet de générer automatiquement le poste comptable voulu, ce poste sera automatiquement ajouté dans le Plan Comptable. Si cette option n'est @@ -524,8 +525,11 @@ classe par d Pour simplifier : -Vous voulez que chaque fiche aie son propre poste comptable et vous souhaitez que ce poste soit crée automatiquement : cochez la case 'Create account for each' -Vous souhaitez qu'il n'y a pas de poste comptable attaché à chaque fiche: ne la cochez pas +Vous voulez que chaque fiche aie son propre poste comptable et +vous souhaitez que ce poste soit crée automatiquement : cochez la case +'Create account for each' +Vous souhaitez qu'il n'y a pas de poste comptable attaché à +chaque fiche: ne la cochez pas Vous souhaitez qu'il y aie un poste comptable attaché à chaque fiche mais pas généré automatiquement: ne cochez pas. Par la suite, ajoutez @@ -537,6 +541,8 @@ vous devrez mettre manuellement le poste comptable par défaut qui sera utilisé. +

Cas spécial: la classe de base "Autre" permet de créer des fiches +sur mesure, par exemple: liste des employés, Création d'une fiche @@ -549,7 +555,9 @@ et unique fiche appel

Autre : comme plusieur fiches peuvent utiliser le même poste comptable, si on modifie le nom d'une fiche cela ne modifiera pas son nom dans le Plan Comptable + + Encodage d'opération Remarques générales

La tva est automatiquement mise, on prend celle de la fiche, il n'est diff --git a/html/fiche_csv.php b/html/fiche_csv.php index 2b2088999..a0fd04f97 100644 --- a/html/fiche_csv.php +++ b/html/fiche_csv.php @@ -24,7 +24,7 @@ include_once ("ac_common.php"); include_once('class_fiche.php'); include_once ("postgres.php"); include_once("check_priv.php"); - +if ( isset ($_REQUEST['with_amount'])) include_once("class_poste.php"); $cn=DbConnect($_SESSION['g_dossier']); $rep=DbConnect(); @@ -49,19 +49,42 @@ if ( isset ($_POST['fd_id'])) { if ( $o == 0 ) { printf("%s",$attribut->ad_text); $o=1; - }else - printf(";%s",$attribut->ad_text); + }else { + printf(";%s",$attribut->ad_text); + if ( $attribut->ad_id == ATTR_DEF_ACCOUNT + && isset ($_REQUEST['with_amount'])) + echo ";debit;credit;solde"; + } } printf("\n"); $o=0; // Details + // Save the accounting foreach ($e as $detail) { foreach ( $detail->attribut as $dattribut ) { if ( $o == 0 ) { printf("%s",$dattribut->av_text); $o=1; - } else - printf (";%s",$dattribut->av_text); + } else { + printf (";%s",$dattribut->av_text); + // if solde resquested + //-- + if ( $dattribut->ad_id == ATTR_DEF_ACCOUNT + && isset ($_REQUEST['with_amount'])) { + $account=new poste ($cn,$dattribut->av_text); + $solde=$account->GetSoldeDetail("j_tech_per between ".$_REQUEST['from_periode']. + " and ". + $_REQUEST['to_periode']); + + printf(";% 10.2f;% 10.2f;% 10.2f", + $solde['debit'], + $solde['credit'], + $solde['solde'] + ); + + + } + } } printf("\n"); $o=0; diff --git a/html/user_impress.php b/html/user_impress.php index db43506d3..572edd4cc 100644 --- a/html/user_impress.php +++ b/html/user_impress.php @@ -67,7 +67,7 @@ if ( $User->admin == 0 ) { } // something is choosen -$default=( isset ($_GET['type']))?$_GET['type']:""; +$default=( isset ($_REQUEST['type']))?$_REQUEST['type']:""; switch ($default) { case "jrn": include ("impress_jrn.php"); diff --git a/include/class_fiche.php b/include/class_fiche.php index c262a2056..f14cab014 100644 --- a/include/class_fiche.php +++ b/include/class_fiche.php @@ -113,6 +113,21 @@ class fiche_def { $this->all[$i]->create_account=$row['fd_create_account']; } } +/* function HasAttribute + ************************************************** + * Purpose : Check in vw_fiche_def if a fiche has + * a attribut X + * + * parm : + * - attribut to check + * gen : + * - none + * return: true or false + */ + function HasAttribute($p_attr) { + return (CountSql($this->cn,"select * from vw_fiche_def where ad_id=$p_attr and fd_id=".$this->id)>0)?true:false; + + } } diff --git a/include/class_poste.php b/include/class_poste.php index 9533997b9..17a99549c 100644 --- a/include/class_poste.php +++ b/include/class_poste.php @@ -111,5 +111,33 @@ function GetSolde($p_cond="") { return abs($r['sum_deb']-$r['sum_cred']); } - + /* function GetSoldeDetail + * Purpose : give the balance of an account + * + * parm : + * - cond + * gen : + * - none + * return: + * - balance of the account + * + */ +function GetSoldeDetail($p_cond="") { + $Res=ExecSql($this->db,"select sum(deb) as sum_deb, sum(cred) as sum_cred from + ( select j_poste, + case when j_debit='t' then j_montant else 0 end as deb, + case when j_debit='f' then j_montant else 0 end as cred + from jrnx join tmp_pcmn on j_poste=pcm_val + where + j_poste like ('$this->id'::text) and + $p_cond + ) as m "); + $Max=pg_NumRows($Res); + if ($Max==0) return 0; + $r=pg_fetch_array($Res,0); + + return array('debit'=>$r['sum_deb'], + 'credit'=>$r['sum_cred'], + 'solde'=>abs($r['sum_deb']-$r['sum_cred'])); +} } \ No newline at end of file diff --git a/include/impress_fiche.php b/include/impress_fiche.php index 66281b48b..fbc8f5fd8 100644 --- a/include/impress_fiche.php +++ b/include/impress_fiche.php @@ -24,53 +24,118 @@ include_once('class_fiche.php'); include_once("class_widget.php"); $cn=DbConnect($_SESSION['g_dossier']); -$fiche_def=new fiche_def($cn); - -$fiche_def->GetAll(); - -$i=0; -foreach ($fiche_def->all as $l_fiche) { - $a[$i]=array("user_impress.php?type=fiche&fd_id=".$l_fiche->id,$l_fiche->label); - $i++; -} -echo ShowItem($a,'V'); //////////////////////////////////////////////////////////////////////////////// -if ( isset ($_GET['fd_id'])) { - echo '

'; +if ( isset ($_REQUEST['fd_id'])) { + // if amount requested + $with_amount= (isset($_REQUEST['with_amount']))?true:false; + if ($with_amount) + include_once("class_poste.php"); + //echo '
'; + echo "
"; $submit=new widget(); $hid=new widget("hidden"); $fiche_id=new widget("hidden"); - + $w=new widget("select"); + $fiche_def=new fiche_def($cn); + echo '
'. $submit->Submit('bt_csv',"Export CSV"). $hid->IOValue("type","fiche"). - $fiche_id->IOValue("fd_id",$_GET['fd_id']); - + $fiche_id->IOValue("fd_id",$_REQUEST['fd_id']); + if ($with_amount) { + echo $hid->IOValue("with_amount"); + echo $hid->IOValue("from_periode",$_REQUEST['from_periode']); + echo $hid->IOValue("to_periode",$_REQUEST['to_periode']); + } echo "
"; + echo '
'.$submit->Submit("bt_submit","Autres fiches")."
"; + + $fiche_def->id=$_REQUEST['fd_id']; + + // Si les fiches ont un poste comptable + // propose de calculer aussi le solde + //-- + if ( $fiche_def->HasAttribute(ATTR_DEF_ACCOUNT) == true ) { + echo '
'; + $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode order by p_id"); + + $w->selected=(isset($_POST['from_periode']))?$_POST['from_periode']:""; + print "Depuis ".$w->IOValue('from_periode',$periode_start); + $periode_end=make_array($cn,"select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode order by p_id"); + $w->selected=(isset($_POST['to_periode']))?$_POST['to_periode']:""; + print " Jusque ".$w->IOValue('to_periode',$periode_end); + + + print $submit->Submit('bt_solde',"Avec solde"). + $hid->IOValue("type","fiche"). + $fiche_id->IOValue("fd_id",$_REQUEST['fd_id']). + $hid->IOValue("with_amount"); + + echo "
"; + } - $fiche_def->id=$_GET['fd_id']; $fiche=new fiche($cn); $e=$fiche->GetByType($fiche_def->id); $l=var_export($e,true); echo_debug(__FILE__,__LINE__,$l); $old=-1; - echo ""; + echo "
"; echo ""; $fiche_def->GetAttribut(); - foreach ($fiche_def->attribut as $attribut) + foreach ($fiche_def->attribut as $attribut) { echo ""; + // si solde demandé affiche la col + //-- + if ($attribut->ad_id==ATTR_DEF_ACCOUNT + && $with_amount==true) { + echo ""; + echo ""; + echo ""; + } + } + echo ""; if ( count($e) != 0 ) { foreach ($e as $detail) { echo ""; foreach ( $detail->attribut as $dattribut ) { echo ""; + // if amount requested + //--- + if ( $dattribut->ad_id == ATTR_DEF_ACCOUNT && + $with_amount) { + + $account=new poste ($cn,$dattribut->av_text); + $solde= $account->GetSoldeDetail("j_tech_per between ".$_REQUEST['from_periode']. + " and ". + $_REQUEST['to_periode']); + printf ("",$solde['debit']); + printf ("",$solde['credit']); + printf ("",$solde['solde']); + + } } - echo ""; } + echo ""; } + echo "
".$attribut->ad_text."DébitCréditSolde
".$dattribut->av_text."% 10.2f% 10.2f% 10.2f
"; echo "
"; } + else { + // only the menu + $fiche_def=new fiche_def($cn); + + + $fiche_def->GetAll(); + + $i=0; + foreach ($fiche_def->all as $l_fiche) { + $a[$i]=array("user_impress.php?type=fiche&fd_id=".$l_fiche->id,$l_fiche->label); + $i++; + } + echo ShowItem($a,'V'); + } + ?> \ No newline at end of file