<?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/date_functions.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/inventory.inc");
include_once($path_to_root . "/includes/data_checks.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");
include_once($path_to_root . "/petty_cash/includes/ui/float_payment_ui.inc");
//include_once($path_to_root . "/petty_cash/includes/db/float_payment_db.inc");
include_once($path_to_root . "/includes/approval_functions.inc");

include_once($path_to_root . "/reporting/includes/reporting.inc");


$trans_type = ST_FLOAT_PAYMENT;

$js = '';

if ($SysPrefs->use_popup_windows) {
	$js .= get_js_open_window(900, 500);
}

if (user_use_date_picker()) {
	$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'])){
    $trans_no = $_GET['trans_no'];
}

if (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'])) 
{
	//return;
        
        $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]));
        
        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['Updated_ID'])) 
{
	//return;
        
        $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'])) 
{
	//return;
        
        $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 &Float Adjustment"));  

	display_footer_exit();
}



//--------------------------------------------------------------------------------------------------
//$Mode = 'ADD_ITEM';
if (isset($_POST['SAVE_ST_FLOAT_PAYMENT']) )
{
    save_petty_cash_float_payment($trans_type, $trans_no, false);
}

//--------------------------------------------------------------------------------------------------
//$Mode = 'ADD_ITEM';
if (isset($_POST['PROCESS_ST_FLOAT_PAYMENT']) )
{
    save_petty_cash_float_payment($trans_type, $trans_no, true);
}

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

if ($Mode == 'RESET')
{
   $selected_id = -1;
}

if (isset($_POST['_selected_id_update']) )
{
    $selected_id = $_POST['selected_id'];
    //$Ajax->activate('_page_body');
}
//if (list_updated('employee_code')) 
	$Ajax->activate('_page_body');
//--------------------------------------------------------------------------------------------------
if (!@$_GET['popup'])
	start_form();

//$i_owe_you = display_i_owe_you_header($iou_id);
br();

//display_petty_cash_float_adjustments();
//-----------------------------------------------------------------------------------------------

    display_petty_cash_float_payment_header($trans_type, $trans_no);
    
    br(1);
    
    display_petty_cash_float_payment_details($trans_type, $trans_no);
    
    br(1);
    
    
    submit_center_first('Calculate_PCFP', "Calculate", '', 'default', '');
    
    br(2);
    
div_start('Buttons');

submit_center_first('PROCESS_ST_FLOAT_PAYMENT',_("Process"), false, false, ICON_SUBMIT);
submit_center_last('SAVE_ST_FLOAT_PAYMENT', 'Save', false, false, ICON_SUBMIT);   

div_end();
    
//    br();
//    submit_center_first('Add_Make_Payment', _("Save and Make Payment"), '', 'default');


br();

if (!@$_GET['popup'])
{
    end_form();
    end_page(@$_GET['popup'], false, false);
}


?>
