  
 
<div style="background-color:#FFF; height:auto; " align="center">
 
 
  <img id="loder" style="visibility:hidden;"  src="images/ajax-loader.gif" align="middle" alt="Loder" />
 

 
 
 <?php 	include('config/database_connection.php'); 
 
 
 				
 	$display = "";
	$connecttion = getSQLConection();
	
	$query = " SELECT TOP 1000 [pk_id] ";
	$query .= " ,CONVERT(VARCHAR(10), date_time, 7) as [date]   ";
	$query .= " ,right((SELECT convert(varchar, date_time, 100)), 8) as [time]  ";
	$query .= " ,(select country from dbo.tbl_group g WHERE g.pk_id =  [country_id_left]) as left_com ";
	$query .= " ,(select country from dbo.tbl_group g WHERE g.pk_id =  [country_id_right]) as right_com ";
	$query .= " ,Lower(SUBSTRING((select country from dbo.tbl_group g WHERE g.pk_id =  [country_id_left]), 1, 3)) as left_prefix ";
	$query .= " ,Lower(SUBSTRING((select country from dbo.tbl_group g WHERE g.pk_id =  [country_id_right]), 1, 3)) as right_prefix ";
	$query .= " ,[venu],[location], ";
	$query .= " (case isnull(goal_left, -1) When -1 then 'Pending' else 'Complete' end) as status_gol,goal_left, goal_right, ";
	
 
 	$query .= "(case round_id When 0 Then 'Qualify Round' When 1 Then '2nd Round' When 2 Then 'Quarter Final Round' 
When 3 Then 'Semi Final Round' When 4 then 'Play-off for third place' else 'Final Round' end) as round_name, datediff(MINUTE,date_time, (getdate())) as date_tag ";
	
    
	$query .= " FROM [db_fifa].[dbo].[tbl_fixture_result]  order by round_id desc, date_time asc ";
 
 
 
		$result = sqlsrv_query($connecttion, $query);

		$i = 1;
		$round = '';
		
		while($row = sqlsrv_fetch_array($result))
		{
			if($round != trim($row['round_name']))
			{
				if($i != 1)
				{
					$display .= " <tr><td colspan='13'>&nbsp;</td></tr> </table> ";
				}
			
					 		$display .= "<div style='font-weight:bold; font-size:14px;width:95%; background-color:#000; color:#FFF; height:20px;' align='left'>$row[round_name]</div> <br /> ";
							
			     $display .= " <table style='width:95%; height:auto;' cellpadding='0' cellspacing='0' border='0' align='center'>
     
     <thead  style='color:#060;' >
						<th style='border-bottom:1px solid #000;width:3%;'>&nbsp;SL</th> 
						<th style='border-bottom:1px solid #000;width:10%;'>Date</th>
						<th style='border-bottom:1px solid #000;width:10%;'>Time</th>
                        
						<th style='border-bottom:1px solid #000;width:10%;'></th>
                        <th style='border-bottom:1px solid #000;width:4%;'>&nbsp;</th>
                        <th style='border-bottom:1px solid #000;width:2%;'>&nbsp;</th>
                        <th align='left' style='border-bottom:1px solid #000;width:10;'>Competitor</th>
                        <th style='border-bottom:1px solid #000;width:4%;'>&nbsp;</th>
                        
						<th style='border-bottom:1px solid #000;width:10%;'></th>
                        <th style='border-bottom:1px solid #000;width:7%;'>&nbsp;</th>
                        <th style='border-bottom:1px solid #000;width:10%;'>Submit</th>
                        <th style='border-bottom:1px solid #000;width:7%;'>&nbsp;</th>
                        <th style='border-bottom:1px solid #000;width:8%;'>&nbsp;</th>
						 
 
 
			 
					</thead>";
					
					$round = trim($row['round_name']);
			}
			
			
			if($row['status_gol'] != 'Pending')
				$display .= "<tr style='height:35px; color:#060; background-color:#CCC;' >";
			else
				$display .= "<tr style='height:35px; color:#060;background-color:#FFF' >";
				
			$display .= "
				<td style='border-bottom:1px solid #000; ' align='left' >
			 	&nbsp;$i
				</td>
				<td style='border-bottom:1px solid #000;' align='center' >
			 	$row[date]
				</td>
				<td style='border-bottom:1px solid #000;' align='center' >
			    $row[time]
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			    $row[left_com]
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			    <img width='30' height='18'  align='middle' src='images/country/$row[left_prefix].png' />
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			 	VS
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			    $row[right_com]
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			 	  <img width='30' height='18'  align='middle' src='images/country/$row[right_prefix].png' />
				</td>
				<td style='border-bottom:1px solid #000;' align='right' >
			 	$row[left_com] :
				</td>
				<td style='border-bottom:1px solid #000;' align='left' > ";
				
	 
      if($row['date_tag'] > 720)
	 		  $display .= " &nbsp;<input  id='txt_left$i' type='text' disabled='disabled'  class='common_text' value='$row[goal_left]'  style='width:50px;color:#900;  text-align:center' /> ";
      else
        $display .= " &nbsp;<input  id='txt_left$i' type='text' class='common_text' value='$row[goal_left]'  style='width:50px;color:#900;  text-align:center' /> ";

          
 
				$display .= "</td>
				
				<td style='border-bottom:1px solid #000;' align='right' >
			 $row[right_com] :
				</td>
				
				
				<td style='border-bottom:1px solid #000;' align='left' >";
				
    if($row['date_tag'] > 720)
	    $display .= "&nbsp;<input id='txt_right$i' type='text' disabled='disabled' class='common_text' value='$row[goal_right]'  style='width:50px;color:#900;  text-align:center' />";
    else
    	$display .= "&nbsp;<input id='txt_right$i' type='text' class='common_text' value='$row[goal_right]'  style='width:50px;color:#900;  text-align:center' />";

				$display .= "</td>
				
				<td style='border-bottom:1px solid #000;' align='center' > ";
        
    	if($row['date_tag'] > 720)
		    $display .= "<input type='button' disabled='disabled'  style='color:#900; height:25px; width:70px' value='Locked' onclick='insertGoalOpeartion(1, $i, $_SESSION[Emp_Id], $row[pk_id])'  />";
		else
				$display .= "<input type='button'  style='color:#900; height:25px; width:70px' value='Submit' onclick='insertGoalOpeartion(1, $i, $_SESSION[Emp_Id], $row[pk_id])'  />";


 
				
				$display .= " </td>
				
				
 
				
				
				
 
			 
			</tr> ";
			
			$i++;
			
		} 
		
 
 echo $display;
 
 ?>

      <tr> <td colspan="13">&nbsp;</td></tr>
 
</table>
 

	 