<?php
/**********************************************************************
***********************************************************************/
$page_security = 'SA_RECONCILE';
$path_to_root="../..";
include_once($path_to_root . "/includes/session.inc");

include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/data_checks.inc");

include_once($path_to_root . "/gl/includes/gl_db.inc");
include_once($path_to_root . "/gl/includes/ui/bank_reconciliation_inquiry_ui.inc");
include_once($path_to_root . "/gl/includes/db/gl_bank_reconciliation_inquiry_db.inc");
include_once($path_to_root . "/includes/banking.inc");

$js = "";
if ($SysPrefs->use_popup_windows)
	$js .= get_js_open_window(800, 500);
if (user_use_date_picker())
	$js .= get_js_date_picker();
page(_($help_context = "Bank Account Recomciliations Inquiry"), isset($_GET['bank_account']), false, "", $js);

check_db_has_bank_accounts(_("There are no bank accounts defined in the system."));

//-----------------------------------------------------------------------------------
// Ajax updates
//

global $Ajax;

//if (get_post('Show'))
//{
	$Ajax->activate('trans_tbl');
//}
//------------------------------------------------------------------------------------------------

if (isset($_GET['bank_account']))
	$_POST['bank_account'] = $_GET['bank_account'];

start_form();

display_bank_account_reconciliation_filtering_controls();

end_form();

//------------------------------------------------------------------------------------------------

if (!isset($_POST['bank_account']))
	$_POST['bank_account'] = "";

div_start('trans_tbl');

br(1);

display_heading("Summary");
display_bank_account_reconciliation_header(get_post('bank_account'), get_post('filtering_reconciled_date'));

br(1);
display_heading("Reconciled Transactions");
display_bank_account_reconciliation_details(get_post('bank_account'), get_post('filtering_reconciled_date'));
br(1);

display_heading("Unreconciled Debits");
display_bank_account_unreconciled_details(get_post('bank_account'), get_post('filtering_reconciled_date'), true);

display_heading("Unreconciled Credits");
display_bank_account_unreconciled_details(get_post('bank_account'), get_post('filtering_reconciled_date'), false);

div_end();
//------------------------------------------------------------------------------------------------

end_page();

?>
