-
Notifications
You must be signed in to change notification settings - Fork 3
/
DailyBankTransactions.php
142 lines (123 loc) · 6.17 KB
/
DailyBankTransactions.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
include ('includes/session.inc');
$title = _('Bank Transactions Inquiry');
include('includes/header.inc');
echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/money_add.png" title="' . _('Search') . '" alt="" />' . ' ' . $title.'</p>';
if (!isset($_POST['Show'])) {
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
echo '<table class="selection">';
$SQL = "SELECT bankaccountname,
bankaccounts.accountcode,
bankaccounts.currcode
FROM bankaccounts,
chartmaster
WHERE bankaccounts.accountcode=chartmaster.accountcode";
$ErrMsg = _('The bank accounts could not be retrieved because');
$DbgMsg = _('The SQL used to retrieve the bank accounts was');
$AccountsResults = DB_query($SQL,$db,$ErrMsg,$DbgMsg);
echo '<tr><td>' . _('Bank Account') . ':</td><td><select name="BankAccount">';
if (DB_num_rows($AccountsResults)==0){
echo '</select></td></tr></table><br />';
prnMsg( _('Bank Accounts have not yet been defined. You must first') . ' <a href="' . $rootpath . '/BankAccounts.php">' . _('define the bank accounts') . '</a> ' . _('and general ledger accounts to be affected'),'warn');
include('includes/footer.inc');
exit;
} else {
while ($myrow=DB_fetch_array($AccountsResults)){
/*list the bank account names */
if (!isset($_POST['BankAccount']) AND $myrow['currcode']==$_SESSION['CompanyRecord']['currencydefault']){
$_POST['BankAccount']=$myrow['accountcode'];
}
if ($_POST['BankAccount']==$myrow['accountcode']){
echo '<option selected="True" value="' . $myrow['accountcode'] . '">' . $myrow['bankaccountname'] . ' - ' . $myrow['currcode'] . '</option>';
} else {
echo '<option value="' . $myrow['accountcode'] . '">' . $myrow['bankaccountname'] . ' - ' . $myrow['currcode'] . '</option>';
}
}
echo '</select></td></tr>';
}
echo '<tr><td>' . _('Transactions Dated From') . ':</td>
<td><input type="text" name="FromTransDate" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" maxlength="10" size="11" onChange="isDate(this, this.value, '."'".$_SESSION['DefaultDateFormat']."'".')" value="' . date($_SESSION['DefaultDateFormat']) . '" /></td></tr>
<tr><td>' . _('Transactions Dated To') . ':</td>
<td><input type="text" name="ToTransDate" class="date" alt="'.$_SESSION['DefaultDateFormat'].'" maxlength="10" size="11" onChange="isDate(this, this.value, '."'".$_SESSION['DefaultDateFormat']."'".')" value="' . date($_SESSION['DefaultDateFormat']) . '" /></td>
</tr>';
echo '</table>';
echo '<br /><div class="centre"><button type="submit" name="Show">' . _('Show transactions'). '</button></div><br />';
echo '</form>';
} else {
$SQL = "SELECT bankaccountname,
bankaccounts.currcode
FROM bankaccounts
WHERE bankaccounts.accountcode='" . $_POST['BankAccount'] . "'";
$BankResult = DB_query($SQL,$db,_('Could not retrieve the bank account details'));
$sql="SELECT banktrans.currcode,
banktrans.amount,
banktrans.functionalexrate,
banktrans.exrate,
banktrans.banktranstype,
banktrans.transdate,
banktrans.ref,
banktrans.chequeno,
bankaccounts.bankaccountname,
banktrans.userid,
banktrans.ref,
systypes.typename,
systypes.typeid
FROM banktrans
INNER JOIN bankaccounts
ON banktrans.bankact=bankaccounts.accountcode
INNER JOIN systypes
ON banktrans.type=systypes.typeid
WHERE bankact='".$_POST['BankAccount']."'
AND transdate>='" . FormatDateForSQL($_POST['FromTransDate']) . "'
AND transdate<='" . FormatDateForSQL($_POST['ToTransDate']) . "'
ORDER BY banktrans.transdate, banktransid";
$result = DB_query($sql, $db);
if (DB_num_rows($result)==0) {
prnMsg(_('There are no transactions for this account in the date range selected'), 'info');
} else {
$BankDetailRow = DB_fetch_array($BankResult);
echo '<table class="selection">
<tr>
<th colspan="10"><font size="3" color="blue">' . _('Account Transactions For').' '.$BankDetailRow['bankaccountname'].' '._('Between').' '.$_POST['FromTransDate'] . ' ' . _('and') . ' ' . $_POST['ToTransDate'] . '</font></th>
</tr>';
echo '<tr>
<th>' . ('Date') . '</th>
<th>' . ('Input By') . '</th>
<th>'._('Transaction type').'</th>
<th>'._('Type').'</th>
<th>'._('Cheque/Voucher No').'</th>
<th>'._('Reference').'</th>
<th>'._('Amount in').' '.$BankDetailRow['currcode'].'</th>
<th>'._('Running Total').' '.$BankDetailRow['currcode'].'</th>
<th>'._('Amount in').' '.$_SESSION['CompanyRecord']['currencydefault'].'</th>
<th>'._('Running Total').' '.$_SESSION['CompanyRecord']['currencydefault'].'</th>
</tr>';
$AccountCurrTotal=0;
$LocalCurrTotal =0;
while ($myrow = DB_fetch_array($result)){
$AccountCurrTotal += $myrow['amount'];
$LocalCurrTotal += $myrow['amount']/$myrow['functionalexrate']/$myrow['exrate'];
echo '<tr>
<td>'. ConvertSQLDate($myrow['transdate']) . '</td>
<td>'. $myrow['userid'] . '</td>
<td>'.$myrow['typename'].'</td>
<td>'.$myrow['banktranstype'].'</td>
<td>'.$myrow['chequeno'].'</td>
<td>'.$myrow['ref'].'</td>
<td class="number">'.locale_money_format($myrow['amount'],$myrow['currcode']).'</td>
<td class="number">'.locale_money_format($AccountCurrTotal,$myrow['currcode']).'</td>
<td class="number">'.locale_money_format($myrow['amount']/$myrow['functionalexrate']/$myrow['exrate'],$_SESSION['CompanyRecord']['currencydefault']).'</td>
<td class="number">'.locale_money_format($LocalCurrTotal,$_SESSION['CompanyRecord']['currencydefault']).'</td>
</tr>';
}
echo '<tr><th colspan=10>' . _('Total number of receipts') . ' - ' . DB_num_rows($result) . '</th></tr>';
echo '</table>';
} //end if no bank trans in the range to show
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
echo '<br /><div class="centre"><button type="submit" name="Return">' . _('Select Another Date'). '</button></div><br />';
echo '</form>';
}
include('includes/footer.inc');
?>