<?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/view_gl_batch_ui.inc");
include_once($path_to_root . "/gl/includes/ui/gl_trans_view_ui.inc");
include_once($path_to_root . "/gl/includes/ui/delete_gl_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");
include_once($path_to_root . "/gl/includes/db/print_cheques_db.inc");
include_once($path_to_root . "/gl/includes/fi/db/post_fi_accounting_entries_db.inc");




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

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

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


$batch_no = -1;

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

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

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

    $message = "GL Batch $trans_no has been deleted and all it's FI Batches have been reopened.";
	
    display_notification_centered($message);
        
    display_footer_exit();
}

if(isset($_POST['Delete_GL_Batch'])){
    process_delete_gl_batch($_POST['gl_batch_number']);
}

start_form();

$_POST['gl_batch_number'] = $batch_no;
hidden('gl_batch_number', $batch_no);
$has_records = display_gl_batch_header_view($batch_no);

//$gl_batch = get_gl_batch_record($batch_no);
//$gl_batch_type = $gl_batch['gl_batch_type'];
//$_GET['type_id'] = $gl_batch_type;
//$_GET['trans_no'] = $batch_no;
//display_gl_view_transactions($gl_batch_type, $batch_no);

br(1);

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

br(1);

end_form(1);

end_page();



?>
