Graph and debit/credit report can be used with no account parameter (calculation is made on all accounts)
This commit is contained in:
parent
bc00a6bdbc
commit
584c22f1d1
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-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
|
||||
@ -26,6 +26,7 @@
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php");
|
||||
|
||||
if (!$user->rights->banque->lire) accessforbidden();
|
||||
|
||||
@ -55,7 +56,7 @@ $form = new Form($db);
|
||||
|
||||
// Get account informations
|
||||
$acct = new Account($db);
|
||||
if ($_GET["account"])
|
||||
if ($_GET["account"] && ! eregi(',',$_GET["account"])) // if for a particular account and not a list
|
||||
{
|
||||
$result=$acct->fetch($_GET["account"]);
|
||||
}
|
||||
@ -72,7 +73,7 @@ if ($_GET["ref"])
|
||||
$sql = "SELECT sum(f.amount), date_format(f.dateo,'%Y-%m') as dm";
|
||||
$sql .= " FROM llx_bank as f";
|
||||
$sql .= " WHERE f.amount >= 0";
|
||||
if ($_GET["account"]) { $sql .= " AND fk_account = ".$_GET["account"]; }
|
||||
if ($_GET["account"]) { $sql .= " AND fk_account in (".$_GET["account"].")"; }
|
||||
$sql .= " GROUP BY dm";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
@ -95,7 +96,7 @@ else
|
||||
$sql = "SELECT sum(f.amount), date_format(f.dateo,'%Y-%m') as dm";
|
||||
$sql .= " FROM llx_bank as f";
|
||||
$sql .= " WHERE f.amount <= 0";
|
||||
if ($_GET["account"]) { $sql .= " AND fk_account = ".$_GET["account"]; }
|
||||
if ($_GET["account"]) { $sql .= " AND fk_account in (".$_GET["account"].")"; }
|
||||
$sql .= " GROUP BY dm";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
@ -129,7 +130,22 @@ print '<tr><td valign="top" width="25%">'.$langs->trans("Ref").'</td>';
|
||||
print '<td colspan="3">';
|
||||
if ($_GET["account"])
|
||||
{
|
||||
print $form->showrefnav($acct,'ref','',1,'ref');
|
||||
if (! eregi(',',$_GET["account"]))
|
||||
{
|
||||
print $form->showrefnav($acct,'ref','',1,'ref');
|
||||
}
|
||||
else
|
||||
{
|
||||
$bankaccount=new Account($db);
|
||||
$listid=split(',',$_GET["account"]);
|
||||
foreach($listid as $key => $id)
|
||||
{
|
||||
$bankaccount->fetch($id);
|
||||
$bankaccount->label=$bankaccount->ref;
|
||||
print $bankaccount->getNomUrl(1);
|
||||
if ($key < (sizeof($listid)-1)) print ', ';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -221,7 +237,7 @@ print "</tr>\n";
|
||||
$balance=0;
|
||||
$sql = "SELECT sum(f.amount) as total";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as f";
|
||||
if ($_GET["account"]) { $sql .= " WHERE fk_account = ".$_GET["account"]; }
|
||||
if ($_GET["account"]) { $sql .= " WHERE fk_account in (".$_GET["account"].")"; }
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
|
||||
@ -18,14 +18,15 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/bank/graph.php
|
||||
\ingroup banque
|
||||
\brief Page graph des transactions bancaires
|
||||
\version $Id$
|
||||
* \file htdocs/compta/bank/graph.php
|
||||
* \ingroup banque
|
||||
* \brief Page graph des transactions bancaires
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/core/dolgraph.class.php");
|
||||
|
||||
$langs->load("banks");
|
||||
@ -33,13 +34,17 @@ $langs->load("banks");
|
||||
if (!$user->rights->banque->lire)
|
||||
accessforbidden();
|
||||
|
||||
$account = $_GET["account"];
|
||||
$account=$_GET["account"];
|
||||
$mode='standard';
|
||||
if (isset($_GET["mode"]) && $_GET["mode"] == 'showalltime') $mode='showalltime';
|
||||
$mesg = '';
|
||||
$error=0;
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$form = new Form($db);
|
||||
@ -57,7 +62,7 @@ if (! empty($_GET["month"])) $month=sprintf("%02d",$_GET["month"]);
|
||||
|
||||
|
||||
$acct = new Account($db);
|
||||
if ($_GET["account"])
|
||||
if ($_GET["account"] && ! eregi(',',$_GET["account"])) // if for a particular account and not a list
|
||||
{
|
||||
$result=$acct->fetch($_GET["account"]);
|
||||
}
|
||||
@ -84,7 +89,7 @@ else
|
||||
// Calcul de $min et $max
|
||||
$sql = "SELECT min(".$db->pdate("datev")."), max(".$db->pdate("datev").")";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
if ($account) $sql.= " WHERE fk_account = ".$account;
|
||||
if ($account) $sql.= " WHERE fk_account in (".$account.")";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -111,7 +116,7 @@ else
|
||||
$sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql .= " WHERE date_format(datev,'%Y%m') = '".$year.$month."'";
|
||||
if ($account) $sql .= " AND fk_account = ".$account;
|
||||
if ($account) $sql .= " AND fk_account in (".$account.")";
|
||||
$sql .= " GROUP BY date_format(datev,'%Y%m%d')";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
@ -136,7 +141,7 @@ else
|
||||
$sql = "SELECT SUM(amount)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql .= " WHERE datev < '".$year."-".sprintf("%02s",$month)."-01'";
|
||||
if ($account) $sql .= " AND fk_account = ".$account;
|
||||
if ($account) $sql .= " AND fk_account in (".$account.")";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -237,7 +242,7 @@ else
|
||||
$sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql .= " WHERE date_format(datev,'%Y') = '".$year."'";
|
||||
if ($account) $sql .= " AND fk_account = ".$account;
|
||||
if ($account) $sql .= " AND fk_account in (".$account.")";
|
||||
$sql .= " GROUP BY date_format(datev,'%Y%m%d')";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
@ -262,7 +267,7 @@ else
|
||||
$sql = "SELECT sum(amount)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
$sql .= " WHERE datev < '".$year."-01-01'";
|
||||
if ($account) $sql .= " AND fk_account = ".$account;
|
||||
if ($account) $sql .= " AND fk_account in (".$account.")";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -355,7 +360,7 @@ else
|
||||
$amounts = array();
|
||||
$sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||
if ($account) $sql .= " WHERE fk_account = ".$account;
|
||||
if ($account) $sql .= " WHERE fk_account in (".$account.")";
|
||||
$sql .= " GROUP BY date_format(datev,'%Y%m%d')";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
@ -458,7 +463,7 @@ else
|
||||
$sql .= " WHERE datev >= '".$year."-".$month."-01 00:00:00'";
|
||||
$sql .= " AND datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
|
||||
$sql .= " AND amount > 0";
|
||||
if ($account) $sql .= " AND fk_account = ".$account;
|
||||
if ($account) $sql .= " AND fk_account in (".$account.")";
|
||||
$sql .= " GROUP BY date_format(datev,'%d')";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
@ -484,7 +489,7 @@ else
|
||||
$sql .= " WHERE datev >= '".$year."-".$month."-01 00:00:00'";
|
||||
$sql .= " AND datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
|
||||
$sql .= " AND amount < 0";
|
||||
if ($account) $sql .= " AND fk_account = ".$account;
|
||||
if ($account) $sql .= " AND fk_account in (".$account.")";
|
||||
$sql .= " GROUP BY date_format(datev,'%d')";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
@ -556,7 +561,7 @@ else
|
||||
$sql .= " WHERE datev >= '".$year."-01-01 00:00:00'";
|
||||
$sql .= " AND datev <= '".$year."-12-31 23:59:59'";
|
||||
$sql .= " AND amount > 0";
|
||||
if ($account) $sql .= " AND fk_account = ".$account;
|
||||
if ($account) $sql .= " AND fk_account in (".$account.")";
|
||||
$sql .= " GROUP BY date_format(datev,'%m');";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
@ -580,8 +585,8 @@ else
|
||||
$sql .= " WHERE datev >= '".$year."-01-01 00:00:00'";
|
||||
$sql .= " AND datev <= '".$year."-12-31 23:59:59'";
|
||||
$sql .= " AND amount < 0";
|
||||
if ($account) $sql .= " AND fk_account = ".$account;
|
||||
$sql .= " GROUP BY date_format(datev,'%m');";
|
||||
if ($account) $sql .= " AND fk_account in (".$account.")";
|
||||
$sql .= " GROUP BY date_format(datev,'%m')";
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@ -655,8 +660,23 @@ print '<tr><td valign="top" width="25%">'.$langs->trans("Ref").'</td>';
|
||||
print '<td colspan="3">';
|
||||
if ($account)
|
||||
{
|
||||
$moreparam='&month='.$month.'&year='.$year.($mode=='showalltime'?'&mode=showalltime':'');
|
||||
print $form->showrefnav($acct,'ref','',1,'ref','ref','',$moreparam);
|
||||
if (! eregi(',',$account))
|
||||
{
|
||||
$moreparam='&month='.$month.'&year='.$year.($mode=='showalltime'?'&mode=showalltime':'');
|
||||
print $form->showrefnav($acct,'ref','',1,'ref','ref','',$moreparam);
|
||||
}
|
||||
else
|
||||
{
|
||||
$bankaccount=new Account($db);
|
||||
$listid=split(',',$account);
|
||||
foreach($listid as $key => $id)
|
||||
{
|
||||
$bankaccount->fetch($id);
|
||||
$bankaccount->label=$bankaccount->ref;
|
||||
print $bankaccount->getNomUrl(1);
|
||||
if ($key < (sizeof($listid)-1)) print ', ';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -18,11 +18,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/compta/bank/index.php
|
||||
\ingroup banque
|
||||
\brief Page accueil banque
|
||||
\version $Id$
|
||||
*/
|
||||
* \file htdocs/compta/bank/index.php
|
||||
* \ingroup banque
|
||||
* \brief Page accueil banque
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
require("./pre.inc.php");
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php");
|
||||
@ -32,7 +32,7 @@ require_once(DOL_DOCUMENT_ROOT."/chargesociales.class.php");
|
||||
$langs->load("banks");
|
||||
|
||||
if (!$user->rights->banque->lire)
|
||||
accessforbidden();
|
||||
accessforbidden();
|
||||
|
||||
$statut=isset($_GET["statut"])?$_GET["statut"]:'';
|
||||
|
||||
@ -58,27 +58,27 @@ $accounts = array();
|
||||
$sql = "SELECT rowid, courant, rappro";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
|
||||
if ($statut != 'all') {
|
||||
$sql .= " WHERE clos = 0";
|
||||
$sql .= " WHERE clos = 0";
|
||||
}
|
||||
$sql .= " ORDER BY label";
|
||||
$sql .= $db->order('label', 'ASC');
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$accounts[$objp->rowid] = $objp->courant;
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$accounts[$objp->rowid] = $objp->courant;
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Comptes courants
|
||||
* Comptes courants (courant = 1)
|
||||
*/
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre"><td width="30%">'.$langs->trans("CurrentAccounts").'</td>';
|
||||
@ -106,7 +106,7 @@ foreach ($accounts as $key=>$type)
|
||||
print '<td>'.$acc->bank.'</td>';
|
||||
print '<td>'.$acc->number.'</td>';
|
||||
print '<td align="center">';
|
||||
if ($acc->rappro)
|
||||
if ($acc->rappro)
|
||||
{
|
||||
$result=$acc->load_board($user,$acc->id);
|
||||
print $acc->nbtodo;
|
||||
@ -132,7 +132,52 @@ print '<tr><td colspan="5"> </td></tr>';
|
||||
|
||||
|
||||
/*
|
||||
* Comptes placements
|
||||
* Comptes caisse/liquide (courant = 2)
|
||||
*/
|
||||
print '<tr class="liste_titre"><td width="30%">'.$langs->trans("CashAccounts").'</td><td width="20%"> </td>';
|
||||
print '<td align="left"> </td>';
|
||||
print '<td align="left" width="100"> </td>';
|
||||
print '<td align="center" width="70">'.$langs->trans("Status").'</td>';
|
||||
print '<td align="right" width="100">'.$langs->trans("BankBalance").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$total = 0;
|
||||
$var=true;
|
||||
foreach ($accounts as $key=>$type)
|
||||
{
|
||||
if ($type == 2)
|
||||
{
|
||||
$acc = new Account($db);
|
||||
$acc->fetch($key);
|
||||
|
||||
$var = !$var;
|
||||
$solde = $acc->solde(1);
|
||||
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td width="30%">'.$acc->getNomUrl(1).'</td>';
|
||||
print '<td>'.$acc->bank.'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="center">'.$acc->getLibStatut(2).'</td>';
|
||||
print '<td align="right">';
|
||||
print '<a href="account.php?account='.$acc->id.'">'.price($solde).'</a>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$total += $solde;
|
||||
}
|
||||
}
|
||||
|
||||
// Total
|
||||
print '<tr class="liste_total"><td colspan="4"> </td><td align="center"><b>'.$langs->trans("Total").'</b></td><td align="right"><b>'.price($total).'</b></td></tr>';
|
||||
|
||||
|
||||
|
||||
print '<tr><td colspan="5"> </td></tr>';
|
||||
|
||||
|
||||
/*
|
||||
* Comptes placements (courant = 0)
|
||||
*/
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="30%">'.$langs->trans("SavingAccounts").'</td>';
|
||||
@ -160,7 +205,7 @@ foreach ($accounts as $key=>$type)
|
||||
print '<td>'.$acc->bank.'</td>';
|
||||
print '<td>'.$acc->number.'</td>';
|
||||
print '<td align="center">';
|
||||
if ($acc->rappro)
|
||||
if ($acc->rappro)
|
||||
{
|
||||
$result=$acc->load_board($user,$acc->id);
|
||||
print $acc->nbtodo;
|
||||
@ -182,49 +227,6 @@ foreach ($accounts as $key=>$type)
|
||||
print '<tr class="liste_total"><td colspan="4"> </td><td align="center"><b>'.$langs->trans("Total").'</b></td><td align="right"><b>'.price($total).'</b></td></tr>';
|
||||
|
||||
|
||||
print '<tr><td colspan="5"> </td></tr>';
|
||||
|
||||
|
||||
/*
|
||||
* Comptes caisse/liquide
|
||||
*/
|
||||
print '<tr class="liste_titre"><td width="30%">'.$langs->trans("CashAccounts").'</td><td width="20%"> </td>';
|
||||
print '<td align="left"> </td>';
|
||||
print '<td align="left" width="100"> </td>';
|
||||
print '<td align="center" width="70">'.$langs->trans("Status").'</td>';
|
||||
print '<td align="right" width="100">'.$langs->trans("BankBalance").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$total = 0;
|
||||
$var=true;
|
||||
foreach ($accounts as $key=>$type)
|
||||
{
|
||||
if ($type == 2)
|
||||
{
|
||||
$acc = new Account($db);
|
||||
$acc->fetch($key);
|
||||
|
||||
$var = !$var;
|
||||
$solde = $acc->solde(1);
|
||||
|
||||
print "<tr ".$bc[$var].">";
|
||||
print '<td width="30%">'.$acc->getNomUrl(1).'</td>';
|
||||
print '<td>'.$acc->bank.'</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="center">'.$acc->getLibStatut(2).'</td>';
|
||||
print '<td align="right">';
|
||||
print '<a href="account.php?account='.$acc->id.'">'.price($solde).'</a>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$total += $solde;
|
||||
}
|
||||
}
|
||||
|
||||
// Total
|
||||
print '<tr class="liste_total"><td colspan="4"> </td><td align="center"><b>'.$langs->trans("Total").'</b></td><td align="right"><b>'.price($total).'</b></td></tr>';
|
||||
|
||||
|
||||
print "</table>";
|
||||
|
||||
|
||||
@ -147,7 +147,7 @@ if ($resql)
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre">';
|
||||
print '<input type="text" class="flat" name="description" size="32" value="'.$description.'">';
|
||||
print '<input type="text" class="flat" name="description" size="28" value="'.$description.'">';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre"> </td>';
|
||||
print '<td class="liste_titre" align="right">';
|
||||
@ -218,7 +218,7 @@ if ($resql)
|
||||
print "<td align=\"center\">".$langs->getLabelFromKey($db,$objp->fk_type,'c_paiement','code','libelle')."</td>\n";
|
||||
|
||||
// Bank account
|
||||
print "<td align=\"left\">";
|
||||
print '<td align="left" nowrap="nowrap">';
|
||||
$bankaccountstatic->id=$objp->url_id;
|
||||
$bankaccountstatic->label=$objp->bankref;
|
||||
print $bankaccountstatic->getNomUrl(1);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user