forked from KwaMoja/KwaMoja
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathBankAccountBalances.php
60 lines (48 loc) · 2.48 KB
/
BankAccountBalances.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/* Shows bank accounts authorised for with balances */
include ('includes/session.php');
$Title = _('List of bank account balances');
/* Manual links before header.php */
$ViewTopic = 'GeneralLedger';
$BookMark = 'BankAccountBalances';
include ('includes/header.php');
echo '<p class="page_title_text"><img src="', $RootPath, '/css/', $_SESSION['Theme'], '/images/bank.png" title="', _('Bank Account Balances'), '" alt="" /> ', _('Bank Account Balances'), '
</p>';
echo '<table>
<tr>
<th class="SortedColumn">', _('Bank Account'), '</th>
<th class="SortedColumn">', _('Account Name'), '</th>
<th>', _('Balance in account currency'), '</th>
<th>', _('Balance in functional currency'), '</th>
<th></th>
</tr>';
$SQL = "SELECT bankaccounts.accountcode,
currcode,
bankaccountname
FROM bankaccounts
INNER JOIN bankaccountusers
ON bankaccounts.accountcode=bankaccountusers.accountcode
AND userid='" . $_SESSION['UserID'] . "'
ORDER BY bankaccounts.bankaccountname";
$Result = DB_query($SQL);
while ($MyBankRow = DB_fetch_array($Result)) {
$CurrBalanceSQL = "SELECT SUM(amount) AS balance FROM banktrans WHERE bankact='" . $MyBankRow['accountcode'] . "'";
$CurrBalanceResult = DB_query($CurrBalanceSQL);
$CurrBalanceRow = DB_fetch_array($CurrBalanceResult);
$FuncBalanceSQL = "SELECT SUM(amount) AS balance FROM gltrans WHERE account='" . $MyBankRow['accountcode'] . "'";
$FuncBalanceResult = DB_query($FuncBalanceSQL);
$FuncBalanceRow = DB_fetch_array($FuncBalanceResult);
$DecimalPlacesSQL = "SELECT decimalplaces FROM currencies WHERE currabrev='" . $MyBankRow['currcode'] . "'";
$DecimalPlacesResult = DB_query($DecimalPlacesSQL);
$DecimalPlacesRow = DB_fetch_array($DecimalPlacesResult);
echo '<tr class="striped_row">
<td>', $MyBankRow['accountcode'], '</td>
<td>', $MyBankRow['bankaccountname'], '</td>
<td class="number">', locale_number_format($CurrBalanceRow['balance'], $DecimalPlacesRow['decimalplaces']), ' ', $MyBankRow['currcode'], '</td>
<td class="number">', locale_number_format($FuncBalanceRow['balance'], $_SESSION['CompanyRecord']['decimalplaces']), ' ', $_SESSION['CompanyRecord']['currencydefault'], '</td>
<td><a href="', $RootPath, '/DailyBankTransactions.php?BankAccount=', $MyBankRow['accountcode'], '&FromTransDate=', DateAdd(date($_SESSION['DefaultDateFormat']), 'm', -1), '&ToTransDate=', date($_SESSION['DefaultDateFormat']), '" />', _('Show Transactions'), '</a>
</tr>';
}
echo '</table>';
include ('includes/footer.php');
?>