[UPDATE] updated query and template
This commit is contained in:
parent
74ac29efc8
commit
1960df0d91
@ -106,22 +106,51 @@ class Transaction extends Base {
|
||||
* @param account_id int Account ID, NULL for all
|
||||
* @return data array type and total
|
||||
**/
|
||||
public function getTransactionTypebyTime($account_id=NULL, $type=NULL) {
|
||||
public function getTransactionTypebyTime($account_id=NULL) {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT
|
||||
IFNULL(SUM(IF(t.type = '" . $type ."' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS HourlyTrans,
|
||||
IFNULL(SUM(IF(t.type = '" . $type ."' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 * 24 SECOND), t.amount, 0)), 0) AS DailyTrans,
|
||||
IFNULL(SUM(IF(t.type = '" . $type ."' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 * 24 * 7 SECOND), t.amount, 0)), 0) AS WeeklyTrans,
|
||||
IFNULL(SUM(IF(t.type = '" . $type ."' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 * 24 * 30 SECOND), t.amount, 0)), 0) AS MonthlyTrans,
|
||||
IFNULL(SUM(IF(t.type = '" . $type ."' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 * 24 * 30 * 12 SECOND), t.amount, 0)), 0) AS YearlyTrans
|
||||
IFNULL(SUM(IF(t.type = 'Credit' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourCredit,
|
||||
IFNULL(SUM(IF(t.type = 'Debit_MP' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourDebitMP,
|
||||
IFNULL(SUM(IF(t.type = 'Debit_AP' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourDebitAP,
|
||||
IFNULL(SUM(IF(t.type = 'TXFee' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourTXFee,
|
||||
IFNULL(SUM(IF(t.type = 'Fee' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourFee,
|
||||
IFNULL(SUM(IF(t.type = 'Donation' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourDonation,
|
||||
|
||||
IFNULL(SUM(IF(t.type = 'Credit' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourCredit,
|
||||
IFNULL(SUM(IF(t.type = 'Debit_MP' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourDebitMP,
|
||||
IFNULL(SUM(IF(t.type = 'Debit_AP' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourDebitAP,
|
||||
IFNULL(SUM(IF(t.type = 'TXFee' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourTXFee,
|
||||
IFNULL(SUM(IF(t.type = 'Fee' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourFee,
|
||||
IFNULL(SUM(IF(t.type = 'Donation' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourDonation,
|
||||
|
||||
IFNULL(SUM(IF(t.type = 'Credit' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekCredit,
|
||||
IFNULL(SUM(IF(t.type = 'Debit_MP' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekDebitMP,
|
||||
IFNULL(SUM(IF(t.type = 'Debit_AP' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekDebitAP,
|
||||
IFNULL(SUM(IF(t.type = 'TXFee' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekTXFee,
|
||||
IFNULL(SUM(IF(t.type = 'Fee' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekFee,
|
||||
IFNULL(SUM(IF(t.type = 'Donation' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekDonation,
|
||||
|
||||
IFNULL(SUM(IF(t.type = 'Credit' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthCredit,
|
||||
IFNULL(SUM(IF(t.type = 'Debit_MP' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthDebitMP,
|
||||
IFNULL(SUM(IF(t.type = 'Debit_AP' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthDebitAP,
|
||||
IFNULL(SUM(IF(t.type = 'TXFee' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthTXFee,
|
||||
IFNULL(SUM(IF(t.type = 'Fee' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthFee,
|
||||
IFNULL(SUM(IF(t.type = 'Donation' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthDonation,
|
||||
|
||||
IFNULL(SUM(IF(t.type = 'Credit' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearCredit,
|
||||
IFNULL(SUM(IF(t.type = 'Debit_MP' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearDebitMP,
|
||||
IFNULL(SUM(IF(t.type = 'Debit_AP' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearDebitAP,
|
||||
IFNULL(SUM(IF(t.type = 'TXFee' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearTXFee,
|
||||
IFNULL(SUM(IF(t.type = 'Fee' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearFee,
|
||||
IFNULL(SUM(IF(t.type = 'Donation' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearDonation
|
||||
FROM transactions AS t
|
||||
LEFT OUTER JOIN blocks AS b ON b.id = t.block_id
|
||||
WHERE
|
||||
t.account_id = ? AND (b.confirmations > 120 OR b.id IS NULL)");
|
||||
t.account_id = ? AND (b.confirmations > 0 OR b.id IS NULL)");
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param("i", $account_id) && $stmt->execute() && $result = $stmt->get_result())
|
||||
return $this->memcache->setCache(__FUNCTION__, $result->fetch_assoc());
|
||||
return $this->memcache->setCache(__FUNCTION__ . $account_id, $result->fetch_assoc(), 60);
|
||||
return $this->sqlError();
|
||||
}
|
||||
|
||||
|
||||
@ -12,21 +12,9 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
|
||||
$debug->append('No cached version available, fetching from backend', 3);
|
||||
if (!$setting->getValue('disable_transactionsummary')) {
|
||||
$aTransactionSummary = $transaction->getTransactionSummary($_SESSION['USERDATA']['id']);
|
||||
|
||||
$aCredit = $transaction->getTransactionTypebyTime($_SESSION['USERDATA']['id'], 'CREDIT');
|
||||
$aDebitAP = $transaction->getTransactionTypebyTime($_SESSION['USERDATA']['id'], 'DEBIT_AP');
|
||||
$aDebitMP = $transaction->getTransactionTypebyTime($_SESSION['USERDATA']['id'], 'DEBIT_MP');
|
||||
$aTXFee = $transaction->getTransactionTypebyTime($_SESSION['USERDATA']['id'], 'TXFee');
|
||||
$aFee = $transaction->getTransactionTypebyTime($_SESSION['USERDATA']['id'], 'Fee');
|
||||
$aDonation = $transaction->getTransactionTypebyTime($_SESSION['USERDATA']['id'], 'Donation');
|
||||
|
||||
$aTransactionSummaryByTime = $transaction->getTransactionTypebyTime($_SESSION['USERDATA']['id']);
|
||||
$smarty->assign('SUMMARY', $aTransactionSummary);
|
||||
$smarty->assign('CREDIT', $aCredit);
|
||||
$smarty->assign('DEBITAP', $aDebitAP);
|
||||
$smarty->assign('DEBITMP', $aDebitMP);
|
||||
$smarty->assign('TXFEE', $aTXFee);
|
||||
$smarty->assign('FEE', $aFee);
|
||||
$smarty->assign('DONATION', $aDonation);
|
||||
$smarty->assign('BYTIME', $aTransactionSummaryByTime);
|
||||
}
|
||||
} else {
|
||||
$debug->append('Using cached page', 3);
|
||||
|
||||
@ -48,68 +48,68 @@
|
||||
<th>Credit</th>
|
||||
<th>Debit AP</th>
|
||||
<th>Debit MP</th>
|
||||
<th>TXFee</th>
|
||||
<th>Donation</th>
|
||||
{if $GLOBAL.fees > 0}
|
||||
<th>Fee</th>
|
||||
{/if}
|
||||
<th>Donation</th>
|
||||
<th>TXFee</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Last Hour</th>
|
||||
<td>{$CREDIT.HourlyTrans|number_format:"8"}</td>
|
||||
<td>{$DEBITAP.HourlyTrans|number_format:"8"}</td>
|
||||
<td>{$DEBITMP.HourlyTrans|number_format:"8"}</td>
|
||||
<td>{$TXFEE.HourlyTrans|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1HourCredit|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1HourDebitAP|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1HourDebitMP|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1HourDonation|number_format:"8"}</td>
|
||||
{if $GLOBAL.fees|default:"0" > 0}
|
||||
<td>{$FEE.HourlyTrans|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1HourFee|number_format:"8"}</td>
|
||||
{/if}
|
||||
<td>{$DONATION.HourlyTrans|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1HourTXFee|number_format:"8"}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Last Day</th>
|
||||
<td>{$CREDIT.DailyTrans|number_format:"8"}</td>
|
||||
<td>{$DEBITAP.DailyTrans|number_format:"8"}</td>
|
||||
<td>{$DEBITMP.DailyTrans|number_format:"8"}</td>
|
||||
<td>{$TXFEE.DailyTrans|number_format:"8"}</td>
|
||||
<td>{$BYTIME.24HourCredit|number_format:"8"}</td>
|
||||
<td>{$BYTIME.24HourDebitAP|number_format:"8"}</td>
|
||||
<td>{$BYTIME.24HourDebitMP|number_format:"8"}</td>
|
||||
<td>{$BYTIME.24HourDonation|number_format:"8"}</td>
|
||||
{if $GLOBAL.fees|default:"0" > 0}
|
||||
<td>{$FEE.DailyTrans|number_format:"8"}</td>
|
||||
<td>{$BYTIME.24HourFee|number_format:"8"}</td>
|
||||
{/if}
|
||||
<td>{$DONATION.DailyTrans|number_format:"8"}</td>
|
||||
<td>{$BYTIME.24HourTXFee|number_format:"8"}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Last Week</th>
|
||||
<td>{$CREDIT.WeeklyTrans|number_format:"8"}</td>
|
||||
<td>{$DEBITAP.WeeklyTrans|number_format:"8"}</td>
|
||||
<td>{$DEBITMP.WeeklyTrans|number_format:"8"}</td>
|
||||
<td>{$TXFEE.WeeklyTrans|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1WeekCredit|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1WeekDebitAP|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1WeekDebitMP|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1WeekDonation|number_format:"8"}</td>
|
||||
{if $GLOBAL.fees|default:"0" > 0}
|
||||
<td>{$FEE.WeeklyTrans|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1WeekFee|number_format:"8"}</td>
|
||||
{/if}
|
||||
<td>{$DONATION.WeeklyTrans|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1WeekTXFee|number_format:"8"}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Last Month</th>
|
||||
<td>{$CREDIT.MonthlyTrans|number_format:"8"}</td>
|
||||
<td>{$DEBITAP.MonthlyTrans|number_format:"8"}</td>
|
||||
<td>{$DEBITMP.MonthlyTrans|number_format:"8"}</td>
|
||||
<td>{$TXFEE.MonthlyTrans|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1MonthCredit|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1MonthDebitAP|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1MonthDebitMP|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1MonthDonation|number_format:"8"}</td>
|
||||
{if $GLOBAL.fees|default:"0" > 0}
|
||||
<td>{$FEE.MonthlyTrans|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1MonthFee|number_format:"8"}</td>
|
||||
{/if}
|
||||
<td>{$DONATION.MonthlyTrans|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1MonthTXFee|number_format:"8"}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Last Year</th>
|
||||
<td>{$CREDIT.YearlyTrans|number_format:"8"}</td>
|
||||
<td>{$DEBITAP.YearlyTrans|number_format:"8"}</td>
|
||||
<td>{$DEBITMP.YearlyTrans|number_format:"8"}</td>
|
||||
<td>{$TXFEE.YearlyTrans|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1YearCredit|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1YearDebitAP|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1YearDebitMP|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1YearDonation|number_format:"8"}</td>
|
||||
{if $GLOBAL.fees|default:"0" > 0}
|
||||
<td>{$FEE.YearlyTrans|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1YearFee|number_format:"8"}</td>
|
||||
{/if}
|
||||
<td>{$DONATION.YearlyTrans|number_format:"8"}</td>
|
||||
<td>{$BYTIME.1YearTXFee|number_format:"8"}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -117,6 +117,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -124,7 +125,3 @@
|
||||
{/if}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user