Add navigation on month/year on bank report

This commit is contained in:
Laurent Destailleur 2009-01-01 16:43:11 +00:00
parent a5a65a1a52
commit 1b6598493a
2 changed files with 84 additions and 56 deletions

View File

@ -22,7 +22,7 @@
* \ingroup banque * \ingroup banque
* \brief Page reporting mensuel Entr<EFBFBD>es/Sorties d'un compte bancaire * \brief Page reporting mensuel Entr<EFBFBD>es/Sorties d'un compte bancaire
* \version $Id$ * \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
@ -33,18 +33,18 @@ $year_start=isset($_GET["year_start"])?$_GET["year_start"]:$_POST["year_start"];
$year_current = strftime("%Y",time()); $year_current = strftime("%Y",time());
if (! $year_start) if (! $year_start)
{ {
$year_start = $year_current - 2; $year_start = $year_current - 2;
$year_end = $year_current; $year_end = $year_current;
} }
else else
{ {
$year_end=$year_start+2; $year_end=$year_start+2;
} }
// S<>curit<69> acc<63>s client // S<>curit<69> acc<63>s client
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$socid = $user->societe_id; $socid = $user->societe_id;
} }
@ -120,7 +120,7 @@ $head=bank_prepare_head($acct);
dolibarr_fiche_head($head,'annual',$langs->trans("FinancialAccount"),0); dolibarr_fiche_head($head,'annual',$langs->trans("FinancialAccount"),0);
$title=$langs->trans("FinancialAccount")." : ".$acct->label; $title=$langs->trans("FinancialAccount")." : ".$acct->label;
$lien=($year_start?"<a href='annuel.php?account=".$acct->id."&year_start=".($year_start-1)."'>".img_previous()."</a> ".$langs->trans("Year")." <a href='annuel.php?account=".$acct->id."&year_start=".($year_start+1)."'>".img_next()."</a>":""); $lien=($year_start?"<a href='".$_SERVER["PHP_SELF"]."?account=".$acct->id."&year_start=".($year_start-1)."'>".img_previous()."</a> ".$langs->trans("Year")." <a href='".$_SERVER["PHP_SELF"]."?account=".$acct->id."&year_start=".($year_start+1)."'>".img_next()."</a>":"");
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -145,50 +145,50 @@ print '<tr class="liste_titre"><td rowspan=2>'.$langs->trans("Month").'</td>';
for ($annee = $year_start ; $annee <= $year_end ; $annee++) for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{ {
print '<td align="center" width="20%" colspan="2">'.$annee.'</td>'; print '<td align="center" width="20%" colspan="2">'.$annee.'</td>';
} }
print '</tr>'; print '</tr>';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
for ($annee = $year_start ; $annee <= $year_end ; $annee++) for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{ {
print '<td align="right">'.$langs->trans("Debit").'</td><td align="right">'.$langs->trans("Credit").'</td>'; print '<td align="right">'.$langs->trans("Debit").'</td><td align="right">'.$langs->trans("Credit").'</td>';
} }
print '</tr>'; print '</tr>';
$var=true; $var=true;
for ($mois = 1 ; $mois < 13 ; $mois++) for ($mois = 1 ; $mois < 13 ; $mois++)
{ {
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print "<td>".dolibarr_print_date(dolibarr_mktime(1,1,1,$mois,1,2000),"%B")."</td>"; print "<td>".dolibarr_print_date(dolibarr_mktime(1,1,1,$mois,1,2000),"%B")."</td>";
for ($annee = $year_start ; $annee <= $year_end ; $annee++) for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{ {
$case = sprintf("%04s-%02s",$annee,$mois); $case = sprintf("%04s-%02s",$annee,$mois);
print '<td align="right" width="10%">&nbsp;'; print '<td align="right" width="10%">&nbsp;';
if ($decaiss[$case]>0) if ($decaiss[$case]>0)
{ {
print price($decaiss[$case]); print price($decaiss[$case]);
$totsorties[$annee]+=$decaiss[$case]; $totsorties[$annee]+=$decaiss[$case];
} }
print "</td>"; print "</td>";
print '<td align="right" width="10%">&nbsp;'; print '<td align="right" width="10%">&nbsp;';
if ($encaiss[$case]>0) if ($encaiss[$case]>0)
{ {
print price($encaiss[$case]); print price($encaiss[$case]);
$totentrees[$annee]+=$encaiss[$case]; $totentrees[$annee]+=$encaiss[$case];
} }
print "</td>"; print "</td>";
} }
print '</tr>'; print '</tr>';
} }
// Total debit-credit // Total debit-credit
print '<tr class="liste_total"><td><b>'.$langs->trans("Total")."</b></td>"; print '<tr class="liste_total"><td><b>'.$langs->trans("Total")."</b></td>";
for ($annee = $year_start ; $annee <= $year_end ; $annee++) for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{ {
print '<td align="right"><b>'.price($totsorties[$annee]).'</b></td><td align="right"><b>'.price($totentrees[$annee]).'</b></td>'; print '<td align="right"><b>'.price($totsorties[$annee]).'</b></td><td align="right"><b>'.price($totentrees[$annee]).'</b></td>';
} }
print "</tr>\n"; print "</tr>\n";
@ -197,7 +197,7 @@ print '<tr><td>&nbsp;</td>';
$nbcol=0; $nbcol=0;
for ($annee = $year_start ; $annee <= $year_end ; $annee++) for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{ {
$nbcol+=2; $nbcol+=2;
} }
print "</tr>\n"; print "</tr>\n";
@ -209,11 +209,11 @@ if ($_GET["account"]) { $sql .= " WHERE fk_account = ".$_GET["account"]; }
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj) $balance=$obj->total; if ($obj) $balance=$obj->total;
} }
else { else {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
print '<tr class="liste_total"><td><b>'.$langs->trans("CurrentBalance")."</b></td>"; print '<tr class="liste_total"><td><b>'.$langs->trans("CurrentBalance")."</b></td>";
print '<td colspan="'.($nbcol).'" align="right">'.price($balance).'</td>'; print '<td colspan="'.($nbcol).'" align="right">'.price($balance).'</td>';

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -187,6 +187,12 @@ if ($_GET["account"] || $_GET["ref"])
$i++; $i++;
} }
// If we are the first of month, only $datas[0] is defined to an int value, others are defined to ""
// and this make artichow report a warning.
//$datas[0]=100; KO
//$datas[0]=100; $datas[1]=90; OK
//var_dump($datas);
//exit;
// Fabrication tableau 1 // Fabrication tableau 1
$file= $conf->banque->dir_temp."/balance".$account."-".$year.$month.".png"; $file= $conf->banque->dir_temp."/balance".$account."-".$year.$month.".png";
@ -197,6 +203,7 @@ if ($_GET["account"] || $_GET["ref"])
if ($acct->min_desired) $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i],$datamin[$i]); if ($acct->min_desired) $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i],$datamin[$i]);
else $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]); else $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]);
} }
$px = new DolGraph(); $px = new DolGraph();
$px->SetData($graph_datas); $px->SetData($graph_datas);
if ($acct->min_desired) $px->SetLegend(array($langs->transnoentities("Balance"),$langs->transnoentities("BalanceMinimalDesired"))); if ($acct->min_desired) $px->SetLegend(array($langs->transnoentities("Balance"),$langs->transnoentities("BalanceMinimalDesired")));
@ -212,7 +219,7 @@ if ($_GET["account"] || $_GET["ref"])
$px->setBgColorGrid(array(255,255,255)); $px->setBgColorGrid(array(255,255,255));
$px->SetHorizTickIncrement(1); $px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0); $px->SetPrecisionY(0);
$px->draw($file); $px->draw($file);
unset($graph_datas); unset($graph_datas);
unset($px); unset($px);
@ -636,6 +643,7 @@ if ($_GET["account"] || $_GET["ref"])
} }
} }
// Onglets // Onglets
$head=bank_prepare_head($acct); $head=bank_prepare_head($acct);
dolibarr_fiche_head($head,'graph',$langs->trans("FinancialAccount"),0); dolibarr_fiche_head($head,'graph',$langs->trans("FinancialAccount"),0);
@ -647,7 +655,8 @@ if ($_GET["account"] || $_GET["ref"])
// Ref // Ref
print '<tr><td valign="top" width="25%">'.$langs->trans("Ref").'</td>'; print '<tr><td valign="top" width="25%">'.$langs->trans("Ref").'</td>';
print '<td colspan="3">'; print '<td colspan="3">';
print $form->showrefnav($acct,'ref','',1,'ref'); $moreparam='&month='.$month.'&year='.$year.($mode=='showalltime'?'&mode=showalltime':'');
print $form->showrefnav($acct,'ref','',1,'ref','ref','',$moreparam);
print '</td></tr>'; print '</td></tr>';
// Label // Label
@ -663,6 +672,15 @@ if ($_GET["account"] || $_GET["ref"])
if ($mode == 'standard') if ($mode == 'standard')
{ {
$prevyear=$year;$nextyear=$year;
$prevmonth=$month-1;$nextmonth=$month+1;
if ($prevmonth < 1) { $prevmonth=12; $prevyear--; }
if ($nextmonth > 12) { $nextmonth=1; $nextyear++; }
// For month
$lien="<a href='".$_SERVER["PHP_SELF"]."?account=".$acct->id."&year=".$prevyear."&month=".$prevmonth."'>".img_previous()."</a> ".$langs->trans("Month")." <a href='".$_SERVER["PHP_SELF"]."?account=".$acct->id."&year=".$nextyear."&month=".$nextmonth."'>".img_next()."</a>";
print '<tr><td align="right">'.$lien.'</td></tr>';
print '<tr><td align="center">'; print '<tr><td align="center">';
$file = "movement".$account."-".$year.$month.".png"; $file = "movement".$account."-".$year.$month.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">'; print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">';
@ -672,6 +690,11 @@ if ($_GET["account"] || $_GET["ref"])
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">'; print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">';
print '</td></tr>'; print '</td></tr>';
// For year
$prevyear=$year-1;$nextyear=$year+1;
$lien="<a href='".$_SERVER["PHP_SELF"]."?account=".$acct->id."&year=".($prevyear)."'>".img_previous()."</a> ".$langs->trans("Year")." <a href='".$_SERVER["PHP_SELF"]."?account=".$acct->id."&year=".($nextyear)."'>".img_next()."</a>";
print '<tr><td align="right">'.$lien.'</td></tr>';
print '<tr><td align="center">'; print '<tr><td align="center">';
$file = "movement".$account."-".$year.".png"; $file = "movement".$account."-".$year.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">'; print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">';
@ -681,7 +704,27 @@ if ($_GET["account"] || $_GET["ref"])
$file = "balance".$account."-".$year.".png"; $file = "balance".$account."-".$year.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">'; print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">';
print '</td></tr>'; print '</td></tr>';
}
if ($mode == 'showalltime')
{
print '<tr><td align="center">';
$file = "balance".$account.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">';
print '</td></tr>';
}
// Switch All time/Not all time
if ($mode == 'showalltime')
{
print '<tr><td align="center"><br>';
print '<a href="'.$_SERVER["PHP_SELF"].'?account='.$account.'">';
print $langs->trans("GoBack");
print '</a>';
print '</td></tr>';
}
else
{
print '<tr><td align="center"><br>'; print '<tr><td align="center"><br>';
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=showalltime&account='.$account.'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?mode=showalltime&account='.$account.'">';
print $langs->trans("ShowAllTimeBalance"); print $langs->trans("ShowAllTimeBalance");
@ -689,22 +732,7 @@ if ($_GET["account"] || $_GET["ref"])
print '</td></tr>'; print '</td></tr>';
} }
// All time print '</table>';
if ($mode == 'showalltime')
{
print '<tr><td align="center">';
$file = "balance".$account.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">';
print '</td></tr>';
print '<tr><td align="center"><br>';
print '<a href="'.$_SERVER["PHP_SELF"].'?account='.$account.'">';
print $langs->trans("GoBack");
print '</a>';
print '</td></tr>';
}
print '</table>';
print "\n</div>\n"; print "\n</div>\n";