Graph and debit/credit report can be used with no account parameter (calculation is made on all accounts)
This commit is contained in:
parent
de3e605871
commit
db5fb4788a
@ -53,7 +53,7 @@ llxHeader();
|
|||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
// R<EFBFBD>cup<EFBFBD>re info du compte
|
// Get account informations
|
||||||
$acct = new Account($db);
|
$acct = new Account($db);
|
||||||
if ($_GET["account"])
|
if ($_GET["account"])
|
||||||
{
|
{
|
||||||
@ -127,12 +127,28 @@ print '<table class="border" width="100%">';
|
|||||||
// 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">';
|
||||||
|
if ($_GET["account"])
|
||||||
|
{
|
||||||
print $form->showrefnav($acct,'ref','',1,'ref');
|
print $form->showrefnav($acct,'ref','',1,'ref');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $langs->trans("ALL");
|
||||||
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
|
print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
|
||||||
print '<td colspan="3">'.$acct->label.'</td></tr>';
|
print '<td colspan="3">';
|
||||||
|
if ($_GET["account"])
|
||||||
|
{
|
||||||
|
print $acct->label;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $langs->trans("AllAccounts");
|
||||||
|
}
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|||||||
@ -44,11 +44,10 @@ llxHeader();
|
|||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
if ($_GET["account"] || $_GET["ref"])
|
|
||||||
{
|
|
||||||
// If lib forced
|
// If lib forced
|
||||||
if (! empty($_GET["lib"])) $conf->global->MAIN_GRAPH_LIBRARY=$_GET["lib"];
|
if (! empty($_GET["lib"])) $conf->global->MAIN_GRAPH_LIBRARY=$_GET["lib"];
|
||||||
|
|
||||||
|
|
||||||
$datetime = time();
|
$datetime = time();
|
||||||
$year = dolibarr_print_date($datetime, "%Y");
|
$year = dolibarr_print_date($datetime, "%Y");
|
||||||
$month = dolibarr_print_date($datetime, "%m");
|
$month = dolibarr_print_date($datetime, "%m");
|
||||||
@ -78,7 +77,6 @@ if ($_GET["account"] || $_GET["ref"])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
// Definition de $width et $height
|
// Definition de $width et $height
|
||||||
$width = 768;
|
$width = 768;
|
||||||
$height = 200;
|
$height = 200;
|
||||||
@ -86,7 +84,7 @@ if ($_GET["account"] || $_GET["ref"])
|
|||||||
// Calcul de $min et $max
|
// Calcul de $min et $max
|
||||||
$sql = "SELECT min(".$db->pdate("datev")."), max(".$db->pdate("datev").")";
|
$sql = "SELECT min(".$db->pdate("datev")."), max(".$db->pdate("datev").")";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank";
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank";
|
||||||
$sql.= " WHERE fk_account = ".$account;
|
if ($account) $sql.= " WHERE fk_account = ".$account;
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -112,8 +110,8 @@ if ($_GET["account"] || $_GET["ref"])
|
|||||||
$amounts = array();
|
$amounts = array();
|
||||||
$sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)";
|
$sql = "SELECT date_format(datev,'%Y%m%d'), 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 date_format(datev,'%Y%m') = '".$year.$month."'";
|
if ($account) $sql .= " AND fk_account = ".$account;
|
||||||
$sql .= " GROUP BY date_format(datev,'%Y%m%d')";
|
$sql .= " GROUP BY date_format(datev,'%Y%m%d')";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -135,10 +133,10 @@ if ($_GET["account"] || $_GET["ref"])
|
|||||||
|
|
||||||
// Calcul de $solde avant le debut du graphe
|
// Calcul de $solde avant le debut du graphe
|
||||||
$solde = 0;
|
$solde = 0;
|
||||||
$sql = "SELECT sum(amount)";
|
$sql = "SELECT SUM(amount)";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||||
$sql .= " WHERE fk_account = ".$account;
|
$sql .= " WHERE datev < '".$year."-".sprintf("%02s",$month)."-01'";
|
||||||
$sql .= " AND datev < '".$year."-".sprintf("%02s",$month)."-01'";
|
if ($account) $sql .= " AND fk_account = ".$account;
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -238,8 +236,8 @@ if ($_GET["account"] || $_GET["ref"])
|
|||||||
$amounts = array();
|
$amounts = array();
|
||||||
$sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)";
|
$sql = "SELECT date_format(datev,'%Y%m%d'), 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') = '".$year."'";
|
||||||
$sql .= " AND date_format(datev,'%Y') = '".$year."'";
|
if ($account) $sql .= " AND fk_account = ".$account;
|
||||||
$sql .= " GROUP BY date_format(datev,'%Y%m%d')";
|
$sql .= " GROUP BY date_format(datev,'%Y%m%d')";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -263,8 +261,8 @@ if ($_GET["account"] || $_GET["ref"])
|
|||||||
$solde = 0;
|
$solde = 0;
|
||||||
$sql = "SELECT sum(amount)";
|
$sql = "SELECT sum(amount)";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||||
$sql .= " WHERE fk_account = ".$account;
|
$sql .= " WHERE datev < '".$year."-01-01'";
|
||||||
$sql .= " AND datev < '".$year."-01-01'";
|
if ($account) $sql .= " AND fk_account = ".$account;
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -357,7 +355,7 @@ if ($_GET["account"] || $_GET["ref"])
|
|||||||
$amounts = array();
|
$amounts = array();
|
||||||
$sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)";
|
$sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||||
$sql .= " WHERE fk_account = ".$account;
|
if ($account) $sql .= " WHERE fk_account = ".$account;
|
||||||
$sql .= " GROUP BY date_format(datev,'%Y%m%d')";
|
$sql .= " GROUP BY date_format(datev,'%Y%m%d')";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -455,12 +453,12 @@ if ($_GET["account"] || $_GET["ref"])
|
|||||||
$debits = array();
|
$debits = array();
|
||||||
$sql = "SELECT date_format(datev,'%d'), sum(amount)";
|
$sql = "SELECT date_format(datev,'%d'), sum(amount)";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||||
$sql .= " WHERE fk_account = ".$account;
|
|
||||||
$monthnext=$month+1; $yearnext=$year;
|
$monthnext=$month+1; $yearnext=$year;
|
||||||
if ($monthnext > 12) { $monthnext=1; $yearnext++; }
|
if ($monthnext > 12) { $monthnext=1; $yearnext++; }
|
||||||
$sql .= " AND datev >= '".$year."-".$month."-01 00:00:00'";
|
$sql .= " WHERE datev >= '".$year."-".$month."-01 00:00:00'";
|
||||||
$sql .= " AND datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
|
$sql .= " AND datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
|
||||||
$sql .= " AND amount > 0";
|
$sql .= " AND amount > 0";
|
||||||
|
if ($account) $sql .= " AND fk_account = ".$account;
|
||||||
$sql .= " GROUP BY date_format(datev,'%d')";
|
$sql .= " GROUP BY date_format(datev,'%d')";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -481,12 +479,12 @@ if ($_GET["account"] || $_GET["ref"])
|
|||||||
}
|
}
|
||||||
$sql = "SELECT date_format(datev,'%d'), sum(amount)";
|
$sql = "SELECT date_format(datev,'%d'), sum(amount)";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||||
$sql .= " WHERE fk_account = ".$account;
|
|
||||||
$monthnext=$month+1; $yearnext=$year;
|
$monthnext=$month+1; $yearnext=$year;
|
||||||
if ($monthnext > 12) { $monthnext=1; $yearnext++; }
|
if ($monthnext > 12) { $monthnext=1; $yearnext++; }
|
||||||
$sql .= " AND datev >= '".$year."-".$month."-01 00:00:00'";
|
$sql .= " WHERE datev >= '".$year."-".$month."-01 00:00:00'";
|
||||||
$sql .= " AND datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
|
$sql .= " AND datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
|
||||||
$sql .= " AND amount < 0";
|
$sql .= " AND amount < 0";
|
||||||
|
if ($account) $sql .= " AND fk_account = ".$account;
|
||||||
$sql .= " GROUP BY date_format(datev,'%d')";
|
$sql .= " GROUP BY date_format(datev,'%d')";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -555,10 +553,10 @@ if ($_GET["account"] || $_GET["ref"])
|
|||||||
$debits = array();
|
$debits = array();
|
||||||
$sql = "SELECT date_format(datev,'%m'), sum(amount)";
|
$sql = "SELECT date_format(datev,'%m'), sum(amount)";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||||
$sql .= " WHERE fk_account = ".$account;
|
$sql .= " WHERE datev >= '".$year."-01-01 00:00:00'";
|
||||||
$sql .= " AND datev >= '".$year."-01-01 00:00:00'";
|
|
||||||
$sql .= " AND datev <= '".$year."-12-31 23:59:59'";
|
$sql .= " AND datev <= '".$year."-12-31 23:59:59'";
|
||||||
$sql .= " AND amount > 0";
|
$sql .= " AND amount > 0";
|
||||||
|
if ($account) $sql .= " AND fk_account = ".$account;
|
||||||
$sql .= " GROUP BY date_format(datev,'%m');";
|
$sql .= " GROUP BY date_format(datev,'%m');";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -579,10 +577,10 @@ if ($_GET["account"] || $_GET["ref"])
|
|||||||
}
|
}
|
||||||
$sql = "SELECT date_format(datev,'%m'), sum(amount)";
|
$sql = "SELECT date_format(datev,'%m'), sum(amount)";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
$sql .= " FROM ".MAIN_DB_PREFIX."bank";
|
||||||
$sql .= " WHERE fk_account = ".$account;
|
$sql .= " WHERE datev >= '".$year."-01-01 00:00:00'";
|
||||||
$sql .= " AND datev >= '".$year."-01-01 00:00:00'";
|
|
||||||
$sql .= " AND datev <= '".$year."-12-31 23:59:59'";
|
$sql .= " AND datev <= '".$year."-12-31 23:59:59'";
|
||||||
$sql .= " AND amount < 0";
|
$sql .= " AND amount < 0";
|
||||||
|
if ($account) $sql .= " AND fk_account = ".$account;
|
||||||
$sql .= " GROUP BY date_format(datev,'%m');";
|
$sql .= " GROUP BY date_format(datev,'%m');";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -655,13 +653,29 @@ 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">';
|
||||||
|
if ($account)
|
||||||
|
{
|
||||||
$moreparam='&month='.$month.'&year='.$year.($mode=='showalltime'?'&mode=showalltime':'');
|
$moreparam='&month='.$month.'&year='.$year.($mode=='showalltime'?'&mode=showalltime':'');
|
||||||
print $form->showrefnav($acct,'ref','',1,'ref','ref','',$moreparam);
|
print $form->showrefnav($acct,'ref','',1,'ref','ref','',$moreparam);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $langs->trans("ALL");
|
||||||
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
|
print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
|
||||||
print '<td colspan="3">'.$acct->label.'</td></tr>';
|
print '<td colspan="3">';
|
||||||
|
if ($account)
|
||||||
|
{
|
||||||
|
print $acct->label;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $langs->trans("AllAccounts");
|
||||||
|
}
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
@ -736,7 +750,6 @@ if ($_GET["account"] || $_GET["ref"])
|
|||||||
|
|
||||||
print "\n</div>\n";
|
print "\n</div>\n";
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user