7 include ('includes/session.inc');
9 $title = _('Bank Reconciliation');
11 include('includes/header.inc');
13 echo '<FORM METHOD="POST" ACTION="' . $_SERVER["PHP_SELF"] . '?' . SID
. '">';
15 echo '<CENTER><TABLE>';
17 $SQL = 'SELECT bankaccountname, accountcode FROM bankaccounts';
21 $ErrMsg = _('The bank accounts could not be retrieved by the SQL because');
22 $DbgMsg = _('The SQL used to retrieve the bank acconts was');
23 $AccountsResults = DB_query($SQL,$db,$ErrMsg,$DbgMsg);
25 echo '<TR><TD>' . _('Bank Account') . ':</TD><TD><SELECT name="BankAccount">';
27 if (DB_num_rows($AccountsResults)==0){
28 echo '</SELECT></TD></TR></TABLE><P>' . _('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') . '.';
29 include('includes/footer.inc');
32 while ($myrow=DB_fetch_array($AccountsResults)){
33 /*list the bank account names */
34 if ($_POST["BankAccount"]==$myrow["accountcode"]){
35 echo '<OPTION SELECTED VALUE="' . $myrow["accountcode"] . '">' . $myrow["bankaccountname"];
37 echo '<OPTION VALUE="' . $myrow["accountcode"] . '">' . $myrow["bankaccountname"];
40 echo '</SELECT></TD></TR>';
43 /*Now do the posting while the user is thinking about the bank account to select */
45 include ('includes/GLPostings.inc');
47 echo '</TABLE><P><INPUT TYPE=SUBMIT Name="ShowRec" Value="' . _('Show bank reconciliation statement') . '"></CENTER>';
50 if (isset($_POST['ShowRec']) AND $_POST['ShowRec']!=''){
52 /*Get the balance of the bank account concerned */
54 $sql = "SELECT MAX(period) FROM chartdetails WHERE accountcode=" . $_POST['BankAccount'];
55 $PrdResult = DB_query($sql, $db);
56 $myrow = DB_fetch_row($PrdResult);
57 $LastPeriod = $myrow[0];
60 $SQL = "SELECT bfwd+actual AS balance FROM chartdetails WHERE period=$LastPeriod AND accountcode=" . $_POST["BankAccount"];
62 $ErrMsg = _('The bank account balance could not be returned by the SQL because');
63 $BalanceResult = DB_query($SQL,$db,$ErrMsg);
65 $myrow = DB_fetch_row($BalanceResult);
68 echo '<CENTER><TABLE><TR><TD COLSPAN=6><B>' . _('Current bank account balance as at') . ' ' . Date($_SESSION['DefaultDateFormat']) . '</B></TD><TD VALIGN=BOTTOM ALIGN=RIGHT><B>' . number_format($Balance,2) . '</B></TD></TR>';
70 $SQL = "SELECT amount/exrate AS amt,
72 (amount/exrate)-amountcleared as outstanding,
79 WHERE banktrans.type = systypes.typeid
80 AND banktrans.bankact=" . $_POST["BankAccount"] . "
82 AND ABS((amount/exrate)-amountcleared)>0.009";
84 echo '<TR></TR>'; /*Bang in a blank line */
86 $ErrMsg = _('The unpresented cheques could not be retrieved by the SQL because');
87 $UPChequesResult = DB_query($SQL, $db, $ErrMsg);
89 echo '<TR><TD COLSPAN=6><B>' . _('Add back unpresented cheques') . ':</B></TD></TR>';
92 <TD class="tableheader">' . _('Date') . '</TD>
93 <TD class="tableheader">' . _('Type') . '</TD>
94 <TD class="tableheader">' . _('Number') . '</TD>
95 <TD class="tableheader">' . _('Reference') . '</TD>
96 <TD class="tableheader">' . _('Orig Amount') . '</TD>
97 <TD class="tableheader">' . _('Outstanding') . '</TD>
103 $k=0; //row colour counter
104 $TotalUnpresentedCheques =0;
106 while ($myrow=DB_fetch_array($UPChequesResult)) {
108 echo "<tr bgcolor='#CCCCCC'>";
111 echo "<tr bgcolor='#EEEEEE'>";
119 <td ALIGN=RIGHT>%01.2f</td>
120 <td ALIGN=RIGHT>%01.2f</td>
122 ConvertSQLDate($myrow['transdate']),
127 $myrow['outstanding']);
129 $TotalUnpresentedCheques +
=$myrow['outstanding'];
138 echo '<TR></TR><TR><TD COLSPAN=6>' . _('Total of all unpresented cheques') . '</TD><TD ALIGN=RIGHT>' . number_format($TotalUnpresentedCheques,2) . '</TD></TR>';
140 $SQL = "SELECT amount/exrate AS amt,
142 (amount/exrate)-amountcleared as outstanding,
149 WHERE banktrans.type = systypes.typeid
150 AND banktrans.bankact=" . $_POST["BankAccount"] . "
152 AND ABS((amount/exrate)-amountcleared)>0.009";
154 echo '<TR></TR>'; /*Bang in a blank line */
156 $ErrMsg = _('The uncleared deposits could not be retrieved by the SQL because');
158 $UPChequesResult = DB_query($SQL,$db,$ErrMsg);
160 echo '<TR><TD COLSPAN=6><B>' . _('Less deposits not cleared') . ':</B></TD></TR>';
163 <TD class="tableheader">' . _('Date') . '</TD>
164 <TD class="tableheader">' . _('Type') . '</TD>
165 <TD class="tableheader">' . _('Number') . '</TD>
166 <TD class="tableheader">' . _('Reference') . '</TD>
167 <TD class="tableheader">' . _('Orig Amount') . '</TD>
168 <TD class="tableheader">' . _('Outstanding') . '</TD>
171 echo '<TR>' . $TableHeader;
174 $k=0; //row colour counter
175 $TotalUnclearedDeposits =0;
177 while ($myrow=DB_fetch_array($UPChequesResult)) {
179 echo "<tr bgcolor='#CCCCCC'>";
182 echo "<tr bgcolor='#EEEEEE'>";
190 <td ALIGN=RIGHT>%01.2f</td>
191 <td ALIGN=RIGHT>%01.2f</td>
193 ConvertSQLDate($myrow['transdate']),
198 $myrow['outstanding']
201 $TotalUnclearedDeposits +
=$myrow['outstanding'];
210 echo '<TR></TR><TR><TD COLSPAN=6>' . _('Total of all uncleared deposits') . '</TD><TD ALIGN=RIGHT>' . number_format($TotalUnclearedDeposits,2) . '</TD></TR>';
212 echo '<TR></TR><TR><TD COLSPAN=6><B>' . _('Bank statement balance should be') . '</B></TD><TD ALIGN=RIGHT>' . number_format(($Balance - $TotalUnpresentedCheques -$TotalUnclearedDeposits),2) . '</TD></TR>';
216 echo '<P><A HREF="' . $rootpath . '/BankMatching.php?' . SID
. '&Type=Payments">' . _('Match off cleared payments') . '</A>';
217 echo '<BR><A HREF="' . $rootpath . '/BankMatching.php?' . SID
. '&Type=Receipts">' . _('Match off cleared deposits') . '</A>';
219 include('includes/footer.inc');