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
* \brief Page reporting mensuel Entr<EFBFBD>es/Sorties d'un compte bancaire
* \version $Id$
*/
*/
require("./pre.inc.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());
if (! $year_start)
{
$year_start = $year_current - 2;
$year_end = $year_current;
$year_start = $year_current - 2;
$year_end = $year_current;
}
else
{
$year_end=$year_start+2;
$year_end=$year_start+2;
}
// 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;
}
@ -55,11 +55,11 @@ $form = new Form($db);
// R<>cup<75>re info du compte
$acct = new Account($db);
if ($_GET["account"])
if ($_GET["account"])
{
$result=$acct->fetch($_GET["account"]);
}
if ($_GET["ref"])
if ($_GET["ref"])
{
$result=$acct->fetch(0,$_GET["ref"]);
$_GET["account"]=$acct->id;
@ -120,7 +120,7 @@ $head=bank_prepare_head($acct);
dolibarr_fiche_head($head,'annual',$langs->trans("FinancialAccount"),0);
$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%">';
@ -145,50 +145,50 @@ print '<tr class="liste_titre"><td rowspan=2>'.$langs->trans("Month").'</td>';
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 class="liste_titre">';
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>';
$var=true;
for ($mois = 1 ; $mois < 13 ; $mois++)
{
$var=!$var;
print '<tr '.$bc[$var].'>';
print "<td>".dolibarr_print_date(dolibarr_mktime(1,1,1,$mois,1,2000),"%B")."</td>";
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{
$case = sprintf("%04s-%02s",$annee,$mois);
print '<td align="right" width="10%">&nbsp;';
if ($decaiss[$case]>0)
{
print price($decaiss[$case]);
$totsorties[$annee]+=$decaiss[$case];
}
print "</td>";
$var=!$var;
print '<tr '.$bc[$var].'>';
print "<td>".dolibarr_print_date(dolibarr_mktime(1,1,1,$mois,1,2000),"%B")."</td>";
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{
$case = sprintf("%04s-%02s",$annee,$mois);
print '<td align="right" width="10%">&nbsp;';
if ($decaiss[$case]>0)
{
print price($decaiss[$case]);
$totsorties[$annee]+=$decaiss[$case];
}
print "</td>";
print '<td align="right" width="10%">&nbsp;';
if ($encaiss[$case]>0)
{
print price($encaiss[$case]);
$totentrees[$annee]+=$encaiss[$case];
}
print "</td>";
}
print '</tr>';
print '<td align="right" width="10%">&nbsp;';
if ($encaiss[$case]>0)
{
print price($encaiss[$case]);
$totentrees[$annee]+=$encaiss[$case];
}
print "</td>";
}
print '</tr>';
}
// Total debit-credit
print '<tr class="liste_total"><td><b>'.$langs->trans("Total")."</b></td>";
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";
@ -197,7 +197,7 @@ print '<tr><td>&nbsp;</td>';
$nbcol=0;
for ($annee = $year_start ; $annee <= $year_end ; $annee++)
{
$nbcol+=2;
$nbcol+=2;
}
print "</tr>\n";
@ -209,11 +209,11 @@ if ($_GET["account"]) { $sql .= " WHERE fk_account = ".$_GET["account"]; }
$resql=$db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj) $balance=$obj->total;
$obj = $db->fetch_object($resql);
if ($obj) $balance=$obj->total;
}
else {
dolibarr_print_error($db);
dolibarr_print_error($db);
}
print '<tr class="liste_total"><td><b>'.$langs->trans("CurrentBalance")."</b></td>";
print '<td colspan="'.($nbcol).'" align="right">'.price($balance).'</td>';

View File

@ -1,6 +1,6 @@
<?php
/* 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
* it under the terms of the GNU General Public License as published by
@ -187,7 +187,13 @@ if ($_GET["account"] || $_GET["ref"])
$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
$file= $conf->banque->dir_temp."/balance".$account."-".$year.$month.".png";
$title=$langs->transnoentities("Balance").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year;
@ -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]);
else $graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]);
}
$px = new DolGraph();
$px->SetData($graph_datas);
if ($acct->min_desired) $px->SetLegend(array($langs->transnoentities("Balance"),$langs->transnoentities("BalanceMinimalDesired")));
@ -212,8 +219,8 @@ if ($_GET["account"] || $_GET["ref"])
$px->setBgColorGrid(array(255,255,255));
$px->SetHorizTickIncrement(1);
$px->SetPrecisionY(0);
$px->draw($file);
$px->draw($file);
unset($graph_datas);
unset($px);
unset($datas);
@ -636,6 +643,7 @@ if ($_GET["account"] || $_GET["ref"])
}
}
// Onglets
$head=bank_prepare_head($acct);
dolibarr_fiche_head($head,'graph',$langs->trans("FinancialAccount"),0);
@ -647,7 +655,8 @@ if ($_GET["account"] || $_GET["ref"])
// Ref
print '<tr><td valign="top" width="25%">'.$langs->trans("Ref").'</td>';
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>';
// Label
@ -663,6 +672,15 @@ if ($_GET["account"] || $_GET["ref"])
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">';
$file = "movement".$account."-".$year.$month.".png";
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 '</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">';
$file = "movement".$account."-".$year.".png";
print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=bank&file='.$file.'" alt="" title="">';
@ -681,30 +704,35 @@ if ($_GET["account"] || $_GET["ref"])
$file = "balance".$account."-".$year.".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"].'?mode=showalltime&account='.$account.'">';
print $langs->trans("ShowAllTimeBalance");
print '</a>';
print '</td></tr>';
}
// All time
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>';
}
print '</table>';
else
{
print '<tr><td align="center"><br>';
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=showalltime&account='.$account.'">';
print $langs->trans("ShowAllTimeBalance");
print '</a>';
print '</td></tr>';
}
print '</table>';
print "\n</div>\n";