<?php
session_start();
include_once("../class/class.MySQL.php");
$db	=new MySQL();


if($_GET['action'] == 'load'){
	
if($_SESSION['usertype'] == 'Subadmin')
{
	if($_SESSION['branchadmin'] == 'Y')
	{
		if($_GET['dept'])
		{
			$designation = $db->fetchQuery('select * from designation  where  departs_id="'.$_GET['dept'].'" group by desig_id');
		}
		else
		{
			$designation = $db->fetchAll('designation');
		}
	}
	else
	{
		$userid = $_SESSION['admin_id'];
	
		if($_GET['dept'])
		{
			$designation = $db->fetchQuery('select * from designation inner join employee on employee.e_post=designation.desig_id where imd_supervisor_id="'.$userid.'" and departs_id="'.$_GET['dept'].'" group by designation.desig_id');
		}
		else
		{
			$designation = $db->fetchQuery('select * from designation inner join employee on employee.e_post=designation.desig_id where imd_supervisor_id="'.$userid.'" group by designation.desig_id');
		}
	}
}
else
{	
	$company = $db->fetchQuery('select * from addhrm_company_master ');   
}	
echo '{"companyList":'.json_encode($company).'}';
}

?>