<?php
/**********************************************************************
***********************************************************************/
$page_security = 'SA_DELETE_FI_BATCH';
$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 . "/gl/includes/db/financial_integration_inquiry_db.inc");
include_once($path_to_root . "/gl/includes/ui/view_fi_batch_ui.inc");
include_once($path_to_root . "/gl/includes/ui/delete_fi_batch_ui.inc");
include_once($path_to_root . "/gl/includes/fi/db/generate_fi_accounting_entries_db.inc");
include_once($path_to_root . "/includes/db/group_companies_db.inc");


$js = "";
if ($SysPrefs->use_popup_windows)
	$js .= get_js_open_window(800, 500);

page(_($help_context = "Delete FI Batch"), false, false, "", $js);

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


$batch_no = -1;

if(isset($_GET['batch_no']) && $_GET['batch_no'] > 0){
    $batch_no = $_GET['batch_no'];
}

if(isset($_POST['fi_batch_number']) && $_POST['fi_batch_number'] > 0){
    $batch_no = $_POST['fi_batch_number'];
}

if (isset($_GET['did'])) 
{
	//return;
        
    $trans_no = $_GET['did'];

    $message = "All accounting entries of FI Batch $trans_no have been deleted.";
	
    display_notification_centered($message);
        
    display_footer_exit();
}

if(isset($_POST['Delete_FI_Batch'])){
    process_delete_fi_batch($_POST['fi_batch_number']);
}

start_form();

$has_records = display_fi_batch_header_view($batch_no);

display_fi_batch_transactions_view($batch_no);

br(1);

if($has_records){
    submit_center_first('Delete_FI_Batch', _("Delete FI Batch"), '', 'default');
}
else{
    display_note("No details found for FI Batch #$batch_no.");
}

br(1);

end_form(1);

end_page();



?>
