<?php
	session_start();
include "../class/class.MySQL.php";
require '../class/resizeImage.php';
$db=new MySQL();

$from_date1='';
$to_date1='';

if(!empty($_REQUEST['from_date'])){
$from_date=$_REQUEST['from_date'];
$from_date1 = date('Y-m-d', strtotime($from_date));
}

if(!empty($_REQUEST['to_date'])){
$to_date=$_REQUEST['to_date'];
$to_date1 = date('Y-m-d', strtotime($to_date));
}

$query = "SELECT selected_list.*,DATE_FORMAT(sel_doj,'%d-%m-%Y') as sel_date,designation.desig_name FROM `selected_list` LEFT JOIN designation ON designation.desig_id=selected_list.sel_desg WHERE   selected_list.sel_id not in(SELECT sel_candidate_id from employee)";

if($from_date1!="" && $to_date1!=""){
$query.=" and sel_doj between '$from_date1' and '$to_date1'";
}
include "pagingserch.php";

$query.=" LIMIT $start, $limit";
//echo $sq_arr;
if(isset($_REQUEST['page'])){
$page=$_REQUEST['page'];
}else{
$page=15;
}

$pagecnt=$start;
$getselectedlist = $db->fetchQuery($query);
	
	//echo $count = count($getrecruitment);
	
	//echo $getrecruitment[] = $pagination;
	
	$count = count($getselectedlist);
	$getselectedlist[$count-1]['totalrows'] = $total_pages;
	//$getrecruitment[$count-1]['items_per_page'] = $page;
	
	
				$sub_rights=mysql_fetch_array(mysql_query("select * from menu as m,menu_sub as s where  s.s_menu_name='Selected List' and m.menu_id=s.menu_id "));
	
	$userid=$_SESSION['admin_id'];

	$where['user_id']	= $userid;
	$where['s_submenu_id']	= $sub_rights['s_id'];
	if($userid==1)
	{
	$getselectedlist[count($getselectedlist)-1]['permissions'][0] = array("user_id"=>$userid);
	}
	else
	{
	$getselectedlist[count($getselectedlist)-1]['permissions'] =  $db->fetchAll("tbl_user_rights",$where);
	}
	
	
	
	echo '{"getselectedlist":'.json_encode($getselectedlist).'}';

?>

	
    
    
