<?php

$page_security = 'SA_POST_FI_ENTRIES';
if (!@$_GET['popup'])
	$path_to_root = "..";
else	
	$path_to_root = "..";

include_once($path_to_root . "/includes/session.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/fi/db/post_fi_accounting_entries_db.inc");
include_once($path_to_root . "/gl/includes/fi/db/generate_fi_accounting_entries_db.inc");
include_once($path_to_root . "/gl/includes/fi/ui/post_fi_accounting_entries_ui.inc");

include_once($path_to_root . "/sales/includes/db/customers_db.inc");
include_once($path_to_root . "/purchasing/includes/db/suppliers_db.inc");
include_once($path_to_root . "/payroll/includes/db/employees_db.inc");
include_once($path_to_root . "/petty_cash/includes/db/petty_cash_floats_db.inc");

$js = '';

if (user_use_date_picker()) {
        $js .= get_js_date_picker();
}

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

page(_($help_context = "Post Financial Integration Accounting Entries"),false,false,"",$js);

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

//check_db_has_projects(_("There are no projects defined in the system."));

simple_page_mode(true);
//---------------------------------------------------------------------------------------------------
if (isset($_GET['glb'])) 
{
	//return;
        
    $trans_no = $_GET['glb'];

    $message = "Accounting entries of selected FI Batches have been posted to GL Batch $trans_no.";
    
    hyperlink_no_params($_SERVER['PHP_SELF'], _("Post other remaining ".$systypes_array[ST_FI_BATCH]."es."));
	
    display_notification_centered($message);
        
    display_footer_exit();
}


if(isset($_POST['PostFIAccountingEntries'])){

        post_fi_accounting_entries($_POST['tran_date']); 
    
}

global $Ajax;
$Ajax->activate('confirm_tran_date');
$Ajax->activate('fi_batches_table');

start_form();

br(1);

//$_POST['tran_date'] = '00/00/0000';
//$_POST['confirm_tran_date'] = '00/00/0000';
//    
//if(!(isset($_POST['tran_date']))){
//    $_POST['tran_date'] = '00/00/0000';
//}
//if(!(isset($_POST['confirm_tran_date']))){
//    $_POST['confirm_tran_date'] = '00/00/0000';
//}

unset($_POST['confirm_tran_date']);
$_POST['confirm_tran_date'] = '';
    
start_table(TABLESTYLE);

$gl_batch_date_ = get_global_gl_batch_date();
set_post_not_set_date('tran_date', $gl_batch_date_, $overriding_list='');

date_row("Transaction Date: ", 'tran_date', null, null, 0, 0, 0, null, true);
ref_row("Re-enter Transaction Date: ", 'confirm_tran_date');

end_table(1);

div_start('fi_batches_table');
display_fi_batches($_POST['tran_date']);
div_end();

br(2);

$Ajax->activate('acc_summary');

div_start('acc_summary');

display_fi_batch_accounts_summary($_POST['tran_date']);

div_end();

	
//submit_cells('PostFIAccountingEntries1', _("Post Selected Batches1"));

br(2);



	end_form();
	end_page(false, false, false);
	


?>
