  
 
<div style="background-color:#FFF; height:auto;" align="center">
 
   <img id="loder" style="visibility:hidden;"  src="images/ajax-loader.gif" align="middle" alt="Loder" />
 
 
     <table style='width:90%; height:auto;' cellpadding='0' cellspacing='0' border='0' align="center" >
     
     <thead  style="color:#060;" >
						<th align="left" style='border-bottom:1px solid #000;width:5%; '>&nbsp;SL</th> 
                        <th align="left" style='border-bottom:1px solid #000;width:5%;'>Pin</th>
						<th align="left" style='border-bottom:1px solid #000;width:25%;'>Name</th>
						<th align="left" style='border-bottom:1px solid #000;width:30%;'>Department</th>
                        
						<th align="left" style='border-bottom:1px solid #000;width:25%;'>Designation</th>
                        <th align="center" style='border-bottom:1px solid #000;width:5%;color:#039'>Point</th>
                        <th align="center" style='border-bottom:1px solid #000;width:5%;color:#F00'>Rank</th>
                        
 
			 
					</thead> 
 
 
 <?php 	include('config/database_connection.php'); 
 
 
 	$display = "";
	$connecttion = getSQLConection();
	
	$query = " Select Emp_Id,Emp_Name,Dept_Name,Desig_Name, sum(point_10 + point_5) as point FROM dbo.viewResult WHERE  Emp_Id in (select emp_id from dbo.tbl_jackpot)
group by Emp_Id, Emp_Name,Dept_Name,Desig_Name order by point desc, Emp_Id asc  ";
	/*
$query = " SELECT  
 Emp_Master.Emp_Id,
(select Emp_Name from dbo.Emp_Master m WHERE m.Emp_Id = Emp_Master.Emp_Id) as Emp_Name,
(select DepName from dbo.tblDepartment Where DepID = (SElECT DepID FROM dbo.Emp_Master m WHERE m.Emp_Id = Emp_Master.Emp_Id)) as [Dept_Name], 
(select DesName from dbo.tblDesignation Where DesId  = (SElECT DesID FROM dbo.Emp_Master m WHERE m.Emp_Id = Emp_Master.Emp_Id)) as [Desig_Name],
(select sum(x.point)
from
(
SELECT  
 (case isnull(goal_left, 0) When 0 then 0 else (case
isnull((select pk_id  from dbo.tbl_jackpot  p WHERE p.emp_id = Emp_Master.Emp_Id and p.group_id = [tbl_fixture_result].pk_id and p.bit_left = [tbl_fixture_result].goal_left and   p.bit_right = [tbl_fixture_result].goal_right ), 0)
when 0 then(case
isnull((select pk_id  from dbo.tbl_jackpot  p WHERE p.emp_id = Emp_Master.Emp_Id and p.group_id = [tbl_fixture_result].pk_id and (p.bit_left > p.bit_right) and ([tbl_fixture_result].goal_left > [tbl_fixture_result].goal_right)), 0)
When 0 then (case 
isnull((select pk_id  from dbo.tbl_jackpot  p WHERE p.emp_id = Emp_Master.Emp_Id and p.group_id = [tbl_fixture_result].pk_id and (p.bit_left < p.bit_right) and ([tbl_fixture_result].goal_left < [tbl_fixture_result].goal_right)), 0)
When 0 then 0 else 5 end) else 5 end) else 10 end)end)  as point

FROM [db_fifa].[dbo].[tbl_fixture_result] 
)x) as point
FROM 
dbo.Emp_Master WHERE Emp_Status = 1 and Emp_Id in (select emp_id from dbo.tbl_jackpot) order by point desc ";
*/
 
 
 
 
		$result = sqlsrv_query($connecttion, $query);

		$point = '';
 		$i = 1;
		$rank = 0;
		
		while($row = sqlsrv_fetch_array($result))
		{
			if(trim($row['point']) != $point)
				$rank++;
			
			
			$display .= "<tr style='height:35px;color:#060;' >
				<td style='border-bottom:1px solid #000; ' align='left' >
			 	&nbsp;$i.
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			 	$row[Emp_Id]
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			    $row[Emp_Name]
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			    $row[Dept_Name]
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >$row[Desig_Name]
	 
				</td>
				 
				<td style='border-bottom:1px solid #000;  color:#900;' align='center' >
				<a target='_blank' href='index.php?page_id=result_employee&emp_id=$row[Emp_Id]'>$row[point]</a>
			    
				</td>
				 
				 <td style='border-bottom:1px solid #000; ' align='center' >
				 <a style='color:#F00;' target='_blank' href='index.php?page_id=result_employee&emp_id=$row[Emp_Id]'>$rank</a>
	 
				</td>
				
			 
			</tr> ";
			
			$point = trim($row['point']);
			
			$i++;
			
		} 
	
 echo $display;
 
 ?>

     <tr> <td colspan="6">&nbsp;</td></tr>
						 

</table>
 

	 