<?php
/**********************************************************************
***********************************************************************/


$page_security = 'SA_SALARIES';
$path_to_root = "../..";
include($path_to_root . "/includes/session.inc");
include_once ($path_to_root . "/trace.php");
$js = "";
if ($SysPrefs->use_popup_windows)
	$js .= get_js_open_window(900, 500);
if (user_use_date_picker())
	$js .= get_js_date_picker();
	
page(_($help_context = "Salaries"), @$_REQUEST['popup'], false, "", $js);

include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/data_checks.inc");

include_once($path_to_root . "/payroll/includes/payroll_db.inc");
include_once($path_to_root . "/includes/ui/ui_lists_custom.inc");

$user_comp = user_company();
$new_item = get_post('employee_code')=='' || get_post('cancel') || get_post('clone'); 


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

if (isset($_GET['employee_code']))
{
	$_POST['employee_code'] = $_GET['employee_code'];
}

$employee_code = get_post('employee_code');

if (list_updated('employee_code')) {
	$_POST['NewEmployeeCode'] = $employee_code = get_post('employee_code');
    //clear_data();
	$Ajax->activate('details');
	$Ajax->activate('controls');
}

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

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

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

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

start_form(true);

//if (db_has_stock_items()) 
{
	start_table(TABLESTYLE_NOBORDER);
	start_row();
        emoplyees_list_cells(_("Select an Employee:"), 'employee_code', null, "Select an employee", true, check_value('show_inactive'));
    
	$new_item = get_post('employee_code')=='';
	check_cells(_("Show inactive:"), 'show_inactive', null, true);
	end_row();
	end_table();

	if (get_post('_show_inactive_update')) {
		$Ajax->activate('employee_code');
		set_focus('employee_code');
	}
}
//else
//{
//	hidden('employee_code', get_post('employee_code'));
//}



div_start('details');

$employee_code = get_post('employee_code');

if (!$employee_code)
	unset($_POST['_tabs_sel']); // force settings tab for new customer

tabbed_content_start('tabs', array(
		'employee_salary_additions' => array(_('&Additions'), $employee_code),
		'employee_salary_deductions' => array(_('&Deductions'), $employee_code),
//        'work_time_deficits' => array(_('&Worktime Deficits'), $employee_code),
//        'mobile_allowances' => array(_('&Mobile_allowances'), $employee_code),
	));
	
	switch (get_post('_tabs_sel')) {
		default:
		case 'employee_salary_additions':
			$_GET['employee_code'] = $employee_code;
			$_GET['popup'] = 1;
                        $_GET['type'] = SCC_ALL_EMPLOYEE_ADDITIONS;
                        $_GET['clear_data'] = 1;
			include_once($path_to_root."/payroll/salary_components.php");
			break;
        case 'employee_salary_deductions':
			$_GET['employee_code'] = $employee_code;
			$_GET['popup'] = 1;
                        $_GET['type'] = SCC_ALL_EMPLOYEE_DEDUCTIONS;
                        $_GET['clear_data'] = 1;
			include_once($path_to_root."/payroll/salary_components.php");
			break;
//        case 'employee_salary_deductions':
//			$_GET['employee_code'] = $employee_code;
//			$_GET['popup'] = 1;
//                        $_GET['type'] = "A";
//                        $_GET['clear_data'] = 1;
//			include_once($path_to_root."/payroll/salary_components.php");
//			break;
//        case 'work_time_deficits':
//			$_GET['employee_code'] = $employee_code;
//			$_GET['popup'] = 1;
//                        $_GET['type'] = "W";
//                        $_GET['clear_data'] = 1;
//			include_once($path_to_root."/payroll/salary_components.php");
//			break;
//        case 'mobile_allowances':
//			$_GET['employee_code'] = $employee_code;
//			$_GET['popup'] = 1;
//                        $_GET['type'] = "M";
//                        $_GET['clear_data'] = 1;
//			include_once($path_to_root."/payroll/salary_components.php");
//			break;

	};
br();
tabbed_content_end();

div_end();


hidden('popup', @$_REQUEST['popup']);

end_form();

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

end_page(@$_REQUEST['popup']);
?>
