<?php
/**********************************************************************
***********************************************************************/
$page_security = 'SA_PETTY_CASH_FLOAT_ADJUSTMENTS';

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 . "/petty_cash/includes/ui/float_transfer_ui.inc");
include_once($path_to_root . "/petty_cash/includes/db/i_owe_you_db.inc");
include_once($path_to_root . "/petty_cash/includes/db/petty_cash_float_adjustments_db.inc");

$trans_type = ST_FLOAT_TRANSFER;

$js = '';
$js .= get_js_open_window(900, 500);
$js .= get_js_date_picker();

global $systypes_array;

page(_($help_context = $systypes_array[$trans_type]), false, false, "", $js);

simple_page_mode(true);

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

if (! (isset($trans_no) && $trans_no > 0)) {
    $trans_no = -1;
}

if (isset($_GET['Added_ID'])) {
    $trans_no = $_GET['Added_ID'];
    
	display_notification_centered($systypes_array[$trans_type]." ".$trans_no." has been created.");
         
	hyperlink_no_params($_SERVER['PHP_SELF'], _("Create another ".$systypes_array[$trans_type]));
        
	display_footer_exit();
}

if (isset($_GET['Updated_ID'])) {
    $trans_no = $_GET['Updated_ID'];
    
	display_notification_centered($systypes_array[$trans_type]." ".$trans_no." has been updated.");
        
	hyperlink_no_params($_SERVER['PHP_SELF'], _("Create another ".$systypes_array[$trans_type]));
        
        hyperlink_no_params("$path_to_root/petty_cash/inquiry/petty_cash_adjustments_inquiry.php", _("Update another ".$systypes_array[$trans_type])); 

	display_footer_exit();
}

if (isset($_GET['Processed_Id'])) {
    $trans_no = $_GET['Processed_Id'];
    
	display_notification_centered($systypes_array[$trans_type]." ".$trans_no." has been approved.");
        
	hyperlink_no_params($_SERVER['PHP_SELF'], _("Create another ".$systypes_array[$trans_type]));

	hyperlink_no_params("$path_to_root/petty_cash/inquiry/petty_cash_adjustments_inquiry.php", _("Process another ".$systypes_array[$trans_type])); 

	display_footer_exit();
}

if (isset($_POST['SAVE_ST_FLOAT_TRANSFER'])) {
    save_float_transfer($trans_type, $trans_no, false);
}

if (isset($_POST['PROCESS_ST_FLOAT_TRANSFER'])) {
    save_float_transfer($trans_type, $trans_no, true);
}

$Ajax->activate('_page_body');
start_form();

    br(1);

    display_float_transfer($trans_type, $trans_no);
    
    br(1);
//    br(1);
    
    display_float_transfer_details($trans_type, $trans_no);
    
    div_start('Buttons');
    
    br(1);
    
    submit_center_first('Calculate_PCFP', "Calculate", '', 'default', '');
    
    br(2);

        submit_center_first('SAVE_ST_FLOAT_TRANSFER', _("Save"), false, false, ICON_SUBMIT);
        submit_center_last('PROCESS_ST_FLOAT_TRANSFER', 'Process', false, false, ICON_SUBMIT);   

    div_end();
    
end_form(2);
end_page(@$_GET['popup'], false, false);

?>