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


$page_security = 'SA_GRUOP_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('salary_group_id')=='' || get_post('cancel') || get_post('clone'); 


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

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

$salary_group_id = get_post('salary_group_id');

if (list_updated('salary_group_id')) {
	$_POST['NewEmployeeCode'] = $salary_group_id = get_post('salary_group_id');
    //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:"), 'salary_group_id', null,
//	  false, true, check_value('show_inactive'));
//    
//	$new_item = get_post('salary_group_id')=='';
//	check_cells(_("Show inactive:"), 'show_inactive', null, true);
//	end_row();
//	end_table();
//
//	if (get_post('_show_inactive_update')) {
//		$Ajax->activate('salary_group_id');
//		set_focus('salary_group_id');
//	}
//}
//else
//{
//	hidden('salary_group_id', get_post('salary_group_id'));
//}
start_table(TABLESTYLE_NOBORDER);
start_row();
value_list_cells("Salary Component:", "salary_group_id", "SALARY_GROUPS", null, false, true);
start_row();
end_table();

div_start('details');

$salary_group_id = get_post('salary_group_id');

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

tabbed_content_start('tabs', array(
		'group_salary_additions' => array(_('&Additions'), $salary_group_id),
		'group_salary_deductions' => array(_('&Deductions'), $salary_group_id),
	));
	
	switch (get_post('_tabs_sel')) {
		default:
		case 'group_salary_additions':
			$_GET['employee_code'] = $salary_group_id;
			$_GET['popup'] = 1;
                        $_GET['type'] = SCC_ALL_GROUP_ADDITIONS;
                        $_GET['clear_data'] = 1;
			include_once($path_to_root."/payroll/salary_components.php");
			break;
        case 'group_salary_deductions':
			$_GET['employee_code'] = $salary_group_id;
			$_GET['popup'] = 1;
                        $_GET['type'] = SCC_ALL_GROUP_DEDUCTIONS;
                        $_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']);
?>
