[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 05/12: Task #1057 - Impression poste sur plus
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 05/12: Task #1057 - Impression poste sur plusieurs exercices Impression poste et fiche sur plusieurs exercices (PDF & CSV) |
Date: |
Sat, 29 Nov 2014 16:15:35 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 189c9f2777e0ec8d757b7ed463de53fcf5b9b97e
Author: Dany De Bontridder <address@hidden>
Date: Sat Nov 29 14:01:48 2014 +0100
Task #1057 - Impression poste sur plusieurs exercices
Impression poste et fiche sur plusieurs exercices (PDF & CSV)
---
include/export_fiche_detail_csv.php | 52 +++++++++++++++++++++++++++----
include/export_fiche_detail_pdf.php | 58 +++++++++++++++++++++++++++++------
include/export_poste_detail_csv.php | 44 ++++++++++++++++++++++++--
include/export_poste_detail_pdf.php | 53 +++++++++++++++++++++++++++----
4 files changed, 179 insertions(+), 28 deletions(-)
diff --git a/include/export_fiche_detail_csv.php
b/include/export_fiche_detail_csv.php
index d35d62c..7ef345e 100644
--- a/include/export_fiche_detail_csv.php
+++ b/include/export_fiche_detail_csv.php
@@ -24,10 +24,10 @@ if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas
permis');
include_once("ac_common.php");
require_once('class_database.php');
require_once("class_fiche.php");
-header('Content-type: application/csv');
-
-header('Pragma: public');
-header('Content-Disposition: attachment;filename="poste.csv"',FALSE);
+$f_id=HtmlInput::default_value_request("f_id", "-");
+if ( $f_id == "-") {
+ throw new Exception ('Invalid parameter');
+}
require_once('class_dossier.php');
$gDossier=dossier::id();
@@ -35,7 +35,13 @@ $gDossier=dossier::id();
$cn=new Database($gDossier);
-$Fiche=new Fiche($cn,$_REQUEST['f_id']);
+$Fiche=new Fiche($cn,$f_id);
+$qcode=$Fiche->get_quick_code();
+
+header('Content-type: application/csv');
+
+header('Pragma: public');
+header('Content-Disposition:
attachment;filename="fiche-'.$qcode.'.csv"',FALSE);
$Fiche->getName();
list($array,$tot_deb,$tot_cred)=$Fiche->get_row_date(
$_GET['from_periode'],
@@ -55,6 +61,8 @@ if ( ! isset ($_REQUEST['oper_detail']))
"\"Date\";".
"\"n° pièce\";".
"\"Code interne\";".
+ '"Code journal";'.
+ '"Nom journal";'.
"\"Description\";".
"\"Débit\";".
"\"Crédit\";".
@@ -62,14 +70,44 @@ if ( ! isset ($_REQUEST['oper_detail']))
"\"Let.\"" ;
printf("\n");
$progress=0;
+ $current_exercice="";
+ $tot_deb=0;$tot_cred=0;
+ bcscale(2);
foreach ( $Fiche->row as $op )
{
- $progress+=$op['deb_montant']-$op['cred_montant'];
-
+ /*
+ * separation per exercice
+ */
+ if ( $current_exercice == "") $current_exercice=$op['p_exercice'];
+
+ if ( $current_exercice != $op['p_exercice']) {
+ $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde
créditeur";
+ $diff=abs($tot_deb-$tot_cred);
+ printf(
+ ";;;".
+ '"'._('total').'";'.
+ '"'.$current_exercice.'";;'.
+ '"'."$solde_type".'"'.";".
+ nb($tot_deb).";".
+ nb($tot_cred).";".
+ nb($diff).";"."\n");
+ /*
+ * reset total and current_exercice
+ */
+ $progress=0;
+ $current_exercice=$op['p_exercice'];
+ $tot_deb=0;$tot_cred=0;
+ }
+ $diff=bcsub($op['deb_montant'],$op['cred_montant']);
+ $progress=bcadd($progress,$diff);
+ $tot_deb=bcadd($tot_deb,$op['deb_montant']);
+ $tot_cred=bcadd($tot_cred,$op['cred_montant']);
echo '"'.$op['j_qcode'].'";'.
'"'.$op['j_date_fmt'].'"'.";".
'"'.$op['jr_pj_number'].'"'.";".
'"'.$op['jr_internal'].'"'.";".
+ '"'.$op['jrn_def_code'].'"'.";".
+ '"'.$op['jrn_def_name'].'"'.";".
'"'.$op['description'].'"'.";".
nb($op['deb_montant']).";".
nb($op['cred_montant']).";".
diff --git a/include/export_fiche_detail_pdf.php
b/include/export_fiche_detail_pdf.php
index 6207f95..41ca868 100644
--- a/include/export_fiche_detail_pdf.php
+++ b/include/export_fiche_detail_pdf.php
@@ -86,15 +86,53 @@ $pdf->ln();
$tot_deb=0;
$tot_cred=0;
$progress=0;
+$current_exercice="";
+bcscale(2);
for ($e=0;$e<count($array);$e++)
{
- $l=0;
$row=$array[$e];
- $progress+=$row['deb_montant']-$row['cred_montant'];
+ /*
+ * separation per exercice
+ */
+ if ( $current_exercice == "") $current_exercice=$row['p_exercice'];
+
+ if ( $current_exercice != $row['p_exercice']) {
+ $str_debit=sprintf("% 12.2f €",$tot_deb);
+ $str_credit=sprintf("% 12.2f €",$tot_cred);
+ $diff_solde=bcsub($tot_deb,$tot_cred);
+ if ( $diff_solde < 0 )
+ {
+ $solde=" créditeur ";
+ $diff_solde=bcmul($diff_solde,-1);
+ }
+ else
+ {
+ $solde=" débiteur ";
+ }
+ $str_diff_solde=sprintf("%12.2f €",$diff_solde);
+
+ $pdf->SetFont('DejaVu','B',8);
+ $pdf->LongLine(15,6,_('totaux'),0,'L');
+ $pdf->Cell(15,6,$current_exercice,0,0,'L');
+ $pdf->LongLine(40,6,$solde,0,'L');
+ $pdf->Cell(40,6,$str_debit,0,0,'R');
+ $pdf->Cell(40,6,$str_credit,0,0,'R');
+ $pdf->Cell(40,6,$str_diff_solde,0,0,'R');
+ $pdf->Ln();
+ /*
+ * reset total and current_exercice
+ */
+ $prog=0;
+ $current_exercice=$row['p_exercice'];
+ $tot_deb=0;$tot_cred=0;
+ $pdf->SetFont('DejaVuCond','',8);
+ }
+ $l=0;
+ $progress=bcsub($row['deb_montant'],$row['cred_montant']);
$date=shrink_date($row['j_date_fmt']);
- $pdf->Cell($size[$l],6,$date,0,0,$align[$l]);
+ $pdf->LongLine($size[$l],6,$date,0,$align[$l]);
$l++;
if ( $row['jr_pj_number'] == '')
$pdf->Cell($size[$l],6,"",0,0,$align[$l]);
@@ -102,22 +140,22 @@ for ($e=0;$e<count($array);$e++)
$pdf->Cell($size[$l],6,$row['jr_pj_number'],0,0,$align[$l]);
$l++;
- $pdf->Cell($size[$l],6,mb_substr($row['jrn_name'],0,14),0,0,$align[$l]);
+
$pdf->LongLine($size[$l],6,mb_substr($row['jrn_def_code'],0,14),0,$align[$l]);
$l++;
$pdf->LongLine($size[$l],6,($row['description'].'('.$row['jr_internal'].")"),0,$align[$l]);
$l++;
-
$pdf->Cell($size[$l],6,(($row['letter']!=-1)?strtoupper(base_convert($row['letter'],10,36)):''),0,0,$align[$l]);
+
$pdf->LongLine($size[$l],6,(($row['letter']!=-1)?strtoupper(base_convert($row['letter'],10,36)):''),0,$align[$l]);
$l++;
- $pdf->Cell($size[$l],6,(sprintf('%
12.2f',$row['deb_montant'])),0,0,$align[$l]);
+ $pdf->LongLine($size[$l],6,(sprintf('%
12.2f',$row['deb_montant'])),0,$align[$l]);
$l++;
- $pdf->Cell($size[$l],6,(sprintf('%
12.2f',$row['cred_montant'])),0,0,$align[$l]);
+ $pdf->LongLine($size[$l],6,(sprintf('%
12.2f',$row['cred_montant'])),0,$align[$l]);
$l++;
- $pdf->Cell($size[$l],6,(sprintf('% 12.2f',abs($progress))),0,0,$align[$l]);
+ $pdf->LongLine($size[$l],6,(sprintf('%
12.2f',abs($progress))),0,$align[$l]);
$l++;
$pdf->ln();
- $tot_deb+=$row['deb_montant'];
- $tot_cred+=$row['cred_montant'];
+ $tot_deb=bcadd($tot_deb,$row['deb_montant']);
+ $tot_cred=bcadd($tot_cred,$row['cred_montant']);
/* -------------------------------------- */
/* if details are asked we show them here */
/* -------------------------------------- */
diff --git a/include/export_poste_detail_csv.php
b/include/export_poste_detail_csv.php
index 09b8ade..b1ea1d9 100644
--- a/include/export_poste_detail_csv.php
+++ b/include/export_poste_detail_csv.php
@@ -43,7 +43,7 @@ else
{
$a_poste=$cn->get_array("select pcm_val from tmp_pcmn where pcm_val =
$1",array($_REQUEST['poste_id']));
}
-
+bcscale(2);
if ( ! isset ($_REQUEST['oper_detail']))
{
if ( count($a_poste) == 0 )
@@ -62,6 +62,8 @@ if ( ! isset ($_REQUEST['oper_detail']))
echo '"Poste";'.
'"n° pièce";'.
+ '"Code journal";'.
+ '"Nom journal";'.
'"Lib.";'.
"\"Code interne\";".
"\"Date\";".
@@ -73,12 +75,43 @@ if ( ! isset ($_REQUEST['oper_detail']))
printf("\n");
$prog=0;
+ $current_exercice="";
+ $tot_cred=0;
+ $tot_deb=0;
+ $diff=0;
foreach ( $Poste->row as $op )
{
+ /*
+ * separation per exercice
+ */
+ if ( $current_exercice == "") $current_exercice=$op['p_exercice'];
+
+ if ( $current_exercice != $op['p_exercice']) {
+ $solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde
créditeur";
+ $diff=abs($tot_deb-$tot_cred);
+ printf(
+ ";;;".
+ '"'._('total').'";'.
+ '"'.$current_exercice.'";'.
+ '"'."$solde_type".'"'.";".
+ nb($tot_deb).";".
+ nb($tot_cred).";".
+ nb($diff).";"."\n");
+ /*
+ * reset total and current_exercice
+ */
+ $prog=0;
+ $current_exercice=$op['p_exercice'];
+ $tot_deb=0;$tot_cred=0;
+ }
+ $tot_deb=bcadd($tot_deb,$op['deb_montant']);
+ $tot_cred=bcadd($tot_cred,$op['cred_montant']);
$diff=bcsub($op['deb_montant'],$op['cred_montant']);
$prog=bcadd($prog,$diff);
echo '"'.$pos['pcm_val'].'";'.
'"'.$op['jr_pj_number'].'"'.";".
+ '"'.$op['jrn_def_code'].'"'.";".
+ '"'.$op['jrn_def_name'].'"'.";".
'"'.$name.'";'.
'"'.$op['jr_internal'].'"'.";".
'"'.$op['j_date_fmt'].'"'.";".
@@ -93,11 +126,14 @@ if ( ! isset ($_REQUEST['oper_detail']))
}
$solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur";
$diff=abs($tot_deb-$tot_cred);
- printf(
+ printf(
+ ";;;".
+ '"'._('total').'";'.
+ '"'.$current_exercice.'";'.
'"'."$solde_type".'"'.";".
- nb($diff).";".
nb($tot_deb).";".
- nb($tot_cred)."\n");
+ nb($tot_cred).";".
+ nb($diff).";"."\n");
}
}
else
diff --git a/include/export_poste_detail_pdf.php
b/include/export_poste_detail_pdf.php
index 0f6e948..43be893 100644
--- a/include/export_poste_detail_pdf.php
+++ b/include/export_poste_detail_pdf.php
@@ -61,7 +61,7 @@ if ( count($a_poste) == 0 )
$pdf->Output('poste.pdf','D');
exit;
}
-$size=array(13,25,20,60,12,20,20,20);
+$size=array(13,25,13,65,12,20,20,20);
$align=array('L','C','C','L','R','R','R','R');
foreach ($a_poste as $poste)
@@ -100,11 +100,50 @@ foreach ($a_poste as $poste)
$tot_deb=0;
$tot_cred=0;
$prog=0;
+ $current_exercice="";
+ bcscale(2);
for ($e=0;$e<count($array);$e++)
{
- $l=0;
$row=$array[$e];
- $prog+=$row['deb_montant']-$row['cred_montant'];
+ /*
+ * separation per exercice
+ */
+ if ( $current_exercice == "") $current_exercice=$row['p_exercice'];
+
+ if ( $current_exercice != $row['p_exercice']) {
+ $str_debit=sprintf("% 12.2f €",$tot_deb);
+ $str_credit=sprintf("% 12.2f €",$tot_cred);
+ $diff_solde=bcsub($tot_deb,$tot_cred);
+ if ( $diff_solde < 0 )
+ {
+ $solde=" créditeur ";
+ $diff_solde=bcmul($diff_solde,-1);
+ }
+ else
+ {
+ $solde=" débiteur ";
+ }
+ $str_diff_solde=sprintf("%12.2f €",$diff_solde);
+
+ $pdf->SetFont('DejaVu','B',8);
+ $pdf->Cell(15,6,_('totaux'),0,0,'L');
+ $pdf->Cell(15,6,$current_exercice,0,0,'L');
+ $pdf->Cell(40,6,$solde,0,'L');
+ $pdf->Cell(40,6,$str_debit,0,0,'R');
+ $pdf->Cell(40,6,$str_credit,0,0,'R');
+ $pdf->Cell(40,6,$str_diff_solde,0,0,'R');
+ $pdf->Ln();
+ /*
+ * reset total and current_exercice
+ */
+ $prog=0;
+ $current_exercice=$row['p_exercice'];
+ $tot_deb=0;$tot_cred=0;
+ $pdf->SetFont('DejaVuCond','',8);
+ }
+ $l=0;
+ $diff=bcsub($row['deb_montant'],$row['cred_montant']);
+ $prog=bcadd($row['deb_montant'],$row['cred_montant']);
$date=shrink_date($row['j_date_fmt']);
$pdf->Cell($size[$l],6,$date,0,0,$align[$l]);
@@ -114,7 +153,7 @@ foreach ($a_poste as $poste)
else
$pdf->Cell($size[$l],6,$row['jr_pj_number'],0,0,$align[$l]);
$l++;
-
$pdf->Cell($size[$l],6,mb_substr($row['jrn_name'],0,14),0,0,$align[$l]);
+
$pdf->Cell($size[$l],6,mb_substr($row['jrn_def_code'],0,14),0,0,$align[$l]);
$l++;
$pdf->LongLine($size[$l],6, $row['description'],0,$align[$l]);
$l++;
@@ -127,8 +166,8 @@ foreach ($a_poste as $poste)
$pdf->Cell($size[$l],6,(sprintf('% 12.2f',abs($prog))),0,0,$align[$l]);
$l++;
$pdf->ln();
- $tot_deb+=$row['deb_montant'];
- $tot_cred+=$row['cred_montant'];
+ $tot_deb=bcadd($tot_deb,$row['deb_montant']);
+ $tot_cred=bcadd($tot_deb,$row['cred_montant']);
/* -------------------------------------- */
/* if details are asked we show them here */
/* -------------------------------------- */
@@ -176,7 +215,7 @@ foreach ($a_poste as $poste)
if ( $diff_solde < 0 )
{
$solde=" créditeur ";
- $diff_solde*=-1;
+ $diff_solde=bcmul($diff_solde,-1);
}
else
{
- [Noalyss-commit] [noalyss] branch master updated (6ac6388 -> 5f767a4), Dany De Bontridder, 2014/11/29
- [Noalyss-commit] [noalyss] 02/12: Task #1056 - Grand livre et plusieurs exercices comptables, Dany De Bontridder, 2014/11/29
- [Noalyss-commit] [noalyss] 03/12: Task #1056 - Grand livre et plusieurs exercices comptables, Dany De Bontridder, 2014/11/29
- [Noalyss-commit] [noalyss] 09/12: Task #1057 - Impression poste sur plusieurs exercices Utilisation code journal (PDF) et nom journal (CSV), Dany De Bontridder, 2014/11/29
- [Noalyss-commit] [noalyss] 04/12: print font too small, Dany De Bontridder, 2014/11/29
- [Noalyss-commit] [noalyss] 06/12: Task #1057 - Impression poste sur plusieurs exercices Utilisation code journal (PDF) et nom journal (CSV), Dany De Bontridder, 2014/11/29
- [Noalyss-commit] [noalyss] 07/12: Task #1045 - Amélioration apparence : Utiisation icon search, Dany De Bontridder, 2014/11/29
- [Noalyss-commit] [noalyss] 11/12: Ajout fonction logout si déconnecté en ajax, Dany De Bontridder, 2014/11/29
- [Noalyss-commit] [noalyss] 10/12: Bouton tinybutton, Dany De Bontridder, 2014/11/29
- [Noalyss-commit] [noalyss] 05/12: Task #1057 - Impression poste sur plusieurs exercices Impression poste et fiche sur plusieurs exercices (PDF & CSV),
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 12/12: Task #1045 - Amélioration apparence : Bouton tinybutton, Dany De Bontridder, 2014/11/29
- [Noalyss-commit] [noalyss] 08/12: Task #1045 - Amélioration apparence : Bug : classe non utilisée, Dany De Bontridder, 2014/11/29
- [Noalyss-commit] [noalyss] 01/12:, Dany De Bontridder, 2014/11/29