Graph tous les comptes

This commit is contained in:
Rodolphe Quiedeville 2005-07-31 18:33:29 +00:00
parent 69e9e7d443
commit 0d3445b83c

View File

@ -38,8 +38,6 @@ $datetime = time();
$month = strftime("%m", $datetime); $month = strftime("%m", $datetime);
$year = strftime("%Y", $datetime); $year = strftime("%Y", $datetime);
$account = 1;
if ($month == 1) if ($month == 1)
{ {
$monthprev = "12"; $monthprev = "12";
@ -60,22 +58,51 @@ else
$monthnext = substr("00".($month + 1), -2) ; $monthnext = substr("00".($month + 1), -2) ;
} }
$sql = "SELECT distinct(fk_account)";
$sql = "SELECT sum(amount)";
$sql .= " FROM ".MAIN_DB_PREFIX."bank"; $sql .= " FROM ".MAIN_DB_PREFIX."bank";
$sql .= " WHERE fk_account = ".$account; $sql .= " WHERE date_format(datev,'%Y%m') = '".$year.$month."'";
$sql .= " AND datev < '".$year."-".$month."-01';";
$resql = $db->query($sql); $resql = $db->query($sql);
$amounts = array();
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
array_push($accounts, $row[0]);
$i++;
}
}
$account = 1;
foreach ($accounts as $account)
{
$sql = "SELECT sum(amount)";
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
$sql .= " WHERE fk_account = ".$account;
$sql .= " AND datev < '".$year."-".$month."-01';";
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
$solde = $row[0]; $solde = $row[0];
} }
else else
{ {
print $sql ; print $sql ;
} }
$sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)"; $sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)";
@ -154,6 +181,6 @@ $graph->img->SetImgFormat("png");
$file= DOL_DATA_ROOT."/graph/banque/solde.$account.png"; $file= DOL_DATA_ROOT."/graph/banque/solde.$account.png";
$graph->Stroke($file); $graph->Stroke($file);
}
?> ?>