2
0
forked from Wavyzz/dolibarr

Can switch between graph on account or all acounts.

This commit is contained in:
Laurent Destailleur
2009-01-12 19:36:40 +00:00
parent 7ecc9c1d48
commit 4d7e695d86
6 changed files with 81 additions and 64 deletions

View File

@@ -89,7 +89,7 @@ else
// 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";
if ($account) $sql.= " WHERE fk_account in (".$account.")"; if ($account && $_GET["option"]!='all') $sql.= " WHERE fk_account in (".$account.")";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
@@ -111,12 +111,14 @@ else
if ($mode == 'standard') if ($mode == 'standard')
{ {
// Chargement du tableau $amounts // Chargement du tableau $amounts
// \todo peut etre optimise en virant les date_format
$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 date_format(datev,'%Y%m') = '".$year.$month."'"; $monthnext=$month+1; $yearnext=$year;
if ($account) $sql .= " AND fk_account in (".$account.")"; if ($monthnext > 12) { $monthnext=1; $yearnext++; }
$sql .= " WHERE datev >= '".$year."-".$month."-01 00:00:00'";
$sql .= " AND datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
if ($account && $_GET["option"]!='all') $sql .= " AND fk_account in (".$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)
@@ -141,7 +143,7 @@ else
$sql = "SELECT SUM(amount)"; $sql = "SELECT SUM(amount)";
$sql .= " FROM ".MAIN_DB_PREFIX."bank"; $sql .= " FROM ".MAIN_DB_PREFIX."bank";
$sql .= " WHERE datev < '".$year."-".sprintf("%02s",$month)."-01'"; $sql .= " WHERE datev < '".$year."-".sprintf("%02s",$month)."-01'";
if ($account) $sql .= " AND fk_account in (".$account.")"; if ($account && $_GET["option"]!='all') $sql .= " AND fk_account in (".$account.")";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
@@ -237,12 +239,12 @@ else
if ($mode == 'standard') if ($mode == 'standard')
{ {
// Chargement du tableau $amounts // Chargement du tableau $amounts
// \todo peut etre optimise en virant les date_format
$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 date_format(datev,'%Y') = '".$year."'"; $sql .= " WHERE datev >= '".$year."-01-01 00:00:00'";
if ($account) $sql .= " AND fk_account in (".$account.")"; $sql .= " AND datev <= '".$year."-12-31 23:59:59'";
if ($account && $_GET["option"]!='all') $sql .= " AND fk_account in (".$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)
@@ -267,7 +269,7 @@ else
$sql = "SELECT sum(amount)"; $sql = "SELECT sum(amount)";
$sql .= " FROM ".MAIN_DB_PREFIX."bank"; $sql .= " FROM ".MAIN_DB_PREFIX."bank";
$sql .= " WHERE datev < '".$year."-01-01'"; $sql .= " WHERE datev < '".$year."-01-01'";
if ($account) $sql .= " AND fk_account in (".$account.")"; if ($account && $_GET["option"]!='all') $sql .= " AND fk_account in (".$account.")";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
@@ -356,11 +358,10 @@ else
if ($mode == 'showalltime') if ($mode == 'showalltime')
{ {
// Chargement du tableau $amounts // Chargement du tableau $amounts
// \todo peut etre optimise en virant les date_format
$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";
if ($account) $sql .= " WHERE fk_account in (".$account.")"; if ($account && $_GET["option"]!='all') $sql .= " WHERE fk_account in (".$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)
@@ -463,7 +464,7 @@ else
$sql .= " WHERE 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 in (".$account.")"; if ($account && $_GET["option"]!='all') $sql .= " AND fk_account in (".$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)
@@ -489,7 +490,7 @@ else
$sql .= " WHERE 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 in (".$account.")"; if ($account && $_GET["option"]!='all') $sql .= " AND fk_account in (".$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)
@@ -561,7 +562,7 @@ else
$sql .= " WHERE datev >= '".$year."-01-01 00:00:00'"; $sql .= " WHERE 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 in (".$account.")"; if ($account && $_GET["option"]!='all') $sql .= " AND fk_account in (".$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)
@@ -585,7 +586,7 @@ else
$sql .= " WHERE datev >= '".$year."-01-01 00:00:00'"; $sql .= " WHERE 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 in (".$account.")"; if ($account && $_GET["option"]!='all') $sql .= " AND fk_account in (".$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)
@@ -663,9 +664,19 @@ if ($account)
if (! eregi(',',$account)) if (! eregi(',',$account))
{ {
$moreparam='&month='.$month.'&year='.$year.($mode=='showalltime'?'&mode=showalltime':''); $moreparam='&month='.$month.'&year='.$year.($mode=='showalltime'?'&mode=showalltime':'');
if ($_GET["option"]!='all')
{
$morehtml='<a href="'.$_SERVER["PHP_SELF"].'?account='.$account.'&option=all'.$moreparam.'">'.$langs->trans("ShowAllAccounts").'</a>';
print $form->showrefnav($acct,'ref','',1,'ref','ref','',$moreparam); print $form->showrefnav($acct,'ref','',1,'ref','ref','',$moreparam);
} }
else else
{
$morehtml='<a href="'.$_SERVER["PHP_SELF"].'?account='.$account.$moreparam.'">'.$langs->trans("BackToAccount").'</a>';
print $langs->trans("All");
//print $morehtml;
}
}
else
{ {
$bankaccount=new Account($db); $bankaccount=new Account($db);
$listid=split(',',$account); $listid=split(',',$account);
@@ -680,14 +691,14 @@ if ($account)
} }
else else
{ {
print $langs->trans("ALL"); 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">'; print '<td colspan="3">';
if ($account) if ($account && $_GET["option"]!='all')
{ {
print $acct->label; print $acct->label;
} }
@@ -699,11 +710,25 @@ print '</td></tr>';
print '</table>'; print '</table>';
print '<br>';
print '<table class="notopnoleftnoright" width="100%">'; print '<table class="notopnoleftnoright" width="100%">';
// Navigation links
print '<tr><td align="right">'.$morehtml.' &nbsp; &nbsp; ';
if ($mode == 'showalltime')
{
print '<a href="'.$_SERVER["PHP_SELF"].'?account='.$account.'">';
print $langs->trans("GoBack");
print '</a>';
}
else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?mode=showalltime&account='.$account.'">';
print $langs->trans("ShowAllTimeBalance");
print '</a>';
}
print '<br><br></td></tr>';
if ($mode == 'standard') if ($mode == 'standard')
{ {
$prevyear=$year;$nextyear=$year; $prevyear=$year;$nextyear=$year;
@@ -748,24 +773,6 @@ if ($mode == 'showalltime')
print '</td></tr>'; 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 '<a href="'.$_SERVER["PHP_SELF"].'?mode=showalltime&account='.$account.'">';
print $langs->trans("ShowAllTimeBalance");
print '</a>';
print '</td></tr>';
}
print '</table>'; print '</table>';
print "\n</div>\n"; print "\n</div>\n";
@@ -774,5 +781,4 @@ print "\n</div>\n";
$db->close(); $db->close();
llxFooter('$Date$ - $Revision$'); llxFooter('$Date$ - $Revision$');
?> ?>

View File

@@ -32,8 +32,8 @@ require_once('../lib/admin.lib.php');
// DOL_DOCUMENT_ROOT has been defined in function.inc.php to '..' // DOL_DOCUMENT_ROOT has been defined in function.inc.php to '..'
// Define REQUEST["logtohtml"] // Define $_REQUEST["logtohtml"]
$REQUEST["logtohtml"]=1; $_REQUEST["logtohtml"]=1;
// Correction PHP_SELF (ex pour apache via caudium) car PHP_SELF doit valoir URL relative // Correction PHP_SELF (ex pour apache via caudium) car PHP_SELF doit valoir URL relative
// et non path absolu. // et non path absolu.

View File

@@ -85,12 +85,9 @@ class DoliDb
{ {
global $conf,$langs; global $conf,$langs;
if (isset($conf->db->character_set) && $conf->db->character_set) { if (! empty($conf->db->character_set)) $this->forcecharset=$conf->db->character_set;
$this->forcecharset=$conf->db->character_set; if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation;
}
if (isset($conf->db->dolibarr_main_db_collation) && $conf->db->dolibarr_main_db_collation) {
$this->forcecollate=$conf->db->dolibarr_main_db_collation;
}
$this->database_user=$user; $this->database_user=$user;
$this->transaction_opened=0; $this->transaction_opened=0;
@@ -199,6 +196,7 @@ class DoliDb
*/ */
function select_db($database) function select_db($database)
{ {
dolibarr_syslog("DoliDB::select_db database=".$database, LOG_DEBUG);
return mysql_select_db($database, $this->db); return mysql_select_db($database, $this->db);
} }

View File

@@ -85,12 +85,9 @@ class DoliDb
{ {
global $conf,$langs; global $conf,$langs;
if (isset($conf->db->character_set) && $conf->db->character_set) { if (! empty($conf->db->character_set)) $this->forcecharset=$conf->db->character_set;
$this->forcecharset=$conf->db->character_set; if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation;
}
if (isset($conf->db->dolibarr_main_db_collation) && $conf->db->dolibarr_main_db_collation) {
$this->forcecollate=$conf->db->dolibarr_main_db_collation;
}
$this->database_user=$user; $this->database_user=$user;
$this->transaction_opened=0; $this->transaction_opened=0;
@@ -201,6 +198,7 @@ class DoliDb
*/ */
function select_db($database) function select_db($database)
{ {
dolibarr_syslog("DoliDB::select_db database=".$database, LOG_DEBUG);
return mysqli_select_db($this->db,$database); return mysqli_select_db($this->db,$database);
} }

View File

@@ -180,14 +180,15 @@ function dolibarr_syslog($message, $level=LOG_INFO)
*/ */
function dol_syslog($message, $level=LOG_INFO) function dol_syslog($message, $level=LOG_INFO)
{ {
global $conf,$user,$langs,$REQUEST; global $conf,$user,$langs,$_REQUEST;
// If adding log inside HTML page is required // If adding log inside HTML page is required
if (! empty($REQUEST['logtohtml'])) /* Disabled because this is a security hole
if (! empty($_REQUEST['logtohtml']))
{ {
$conf->logbuffer[]=strftime("%Y-%m-%d %H:%M:%S",time())." ".$message; $conf->logbuffer[]=strftime("%Y-%m-%d %H:%M:%S",time())." ".$message;
} }
*/
// If syslog module enabled // If syslog module enabled
if (! empty($conf->syslog->enabled)) if (! empty($conf->syslog->enabled))

View File

@@ -979,11 +979,11 @@ function printSearchForm($urlaction,$urlobject,$title,$htmlmodesearch='search',$
/** /**
* \brief Impression du pied de page DIV + BODY + HTML * \brief Show HTML footer DIV + BODY + HTML
* \remarks Ferme 2 div * \remarks Close 2 div
* \param foot Non utilise * \param foot Not used
* \param limitIEbug Not used
*/ */
function llxFooter($foot='',$limitIEbug=1) function llxFooter($foot='',$limitIEbug=1)
{ {
global $conf, $dolibarr_auto_user, $micro_start_time; global $conf, $dolibarr_auto_user, $micro_start_time;
@@ -1005,8 +1005,7 @@ function llxFooter($foot='',$limitIEbug=1)
{ {
print ' - Zend encoded file: '.(zend_loader_file_encoded()?'yes':'no'); print ' - Zend encoded file: '.(zend_loader_file_encoded()?'yes':'no');
} }
print '"</script>'; print '"</script>'."\n";
print "\n";
} }
if ($conf->use_javascript_ajax) if ($conf->use_javascript_ajax)
@@ -1017,6 +1016,21 @@ function llxFooter($foot='',$limitIEbug=1)
// Juste pour eviter bug IE qui reorganise mal div precedents si celui-ci absent // Juste pour eviter bug IE qui reorganise mal div precedents si celui-ci absent
if ($limitIEbug && ! $conf->browser->firefox) print "\n".'<div class="tabsAction">&nbsp;</div>'."\n"; if ($limitIEbug && ! $conf->browser->firefox) print "\n".'<div class="tabsAction">&nbsp;</div>'."\n";
// If there is some logs in buffer to show
if (sizeof($conf->logbuffer))
{
print "\n";
print "<!-- Start of log output\n";
//print '<div class="hidden">'."\n";
foreach($conf->logbuffer as $logline)
{
print $logline."<br>\n";
}
//print '</div>'."\n";
print "End of log output -->\n";
}
print "\n";
print "</body>\n"; print "</body>\n";
print "</html>\n"; print "</html>\n";
} }