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


if($_GET['action'] == 'load'){

	//$branchid = $_GET['branch_id'];
	
		//echo "SELECT department.depart_id,department.depart_name from employee join department on employee.departid = department.depart_id  where employee.branchid = '$branchid' group by employee.departid";
		//echo "SELECT department.depart_id,department.depart_name from employee join department on employee.departid = department.depart_id  where employee.branchid = '$branchid' group by employee.departid";
		//echo 'SELECT department.depart_id,department.depart_name from employee join department on employee.departid = department.depart_id  group by employee.departid limit 5';
		$department = $db->fetchQuery("SELECT department.depart_id,department.depart_name from employee join department on employee.departid = department.depart_id  group by employee.departid limit 5");
		
		echo '{"department":'.json_encode($department).'}';

}elseif($_GET['action'] == 'emplist'){
    
	$branchid = $_GET['branch_id'];
	$condition=1;
	if($branchid){
		$condition .=" and branchid = '$branchid' ";
	}
	
	$department = $db->fetchQuery("SELECT * from employee join file on employee.e_id = file.e_id join department on department.depart_id = employee.departid where  $condition ");
	echo '{"name":'.json_encode($department).'}';
	
	
	
}

?>