<?php
session_start();
include("../../config/database.php");
include("../../config/function.php");
$conct  = new connectionCreat();
$conct->connectToDB();
$conct->selectDB();
$date				= date("Y-m-d",strtotime($_GET['date']));
$state				= $_GET['state'];
$state_id			= state_id($state);


$user_qry   = mysql_query(" SELECT * FROM `tbl_admin` WHERE `id`='".$_SESSION['userid']."' ") or die(mysql_error());
$user_data  = mysql_fetch_array($user_qry);
$st_qry     = "";
if($user_data['zone'] !="")
{
    $zone    = explode("&",$user_data['zone']);
    $st_qry .= " and `emp_zone` IN ('".implode("','",$zone)."')";
}


$attand_typ['id']	= array();
$user_list			= array();
$attand_typ['sym']	= array();
////Town Master
$town_master        = "";
/*$sql_town           = mysql_query( " SELECT * FROM `tbl_town` WHERE `state_id`='".$state_id."' " );
while($row_town     = mysql_fetch_array($sql_town))
{
	$town_master    .= '<option value="'.$row_town['id'].'">'.$row_town['town_name'].'</option>';
}
*/

$sql				= mysql_query("SELECT * FROM `tbl_attend_type` where `status`='1' order by `sort_order` ASC")or die(mysql_error());
while($row			= mysql_fetch_array($sql))
{
	array_push($attand_typ['id'],$row['id']);array_push($attand_typ['sym'],$row['details']);
}
///echo $sql_sub  			=  ("select * from `tbl_emp_records` where `state`='$state' and `status`='0' $st_qry order by `emp_name` ASC") ;///or die(mysql_error());
$sql_sub  			=  mysql_query("select * from `tbl_emp_driver` where `state`='$state' and `status`='0' $st_qry order by `emp_name` ASC") or die(mysql_error());
?>
<?php
if(mysql_num_rows($sql_sub)>0)
{
	$j				= 0;
	while($sql_row  = mysql_fetch_array($sql_sub))
	{
		$j++;
		$sql_attt	= mysql_query("SELECT * FROM `tbl_attendence_driver_team` where `emp_id`='".$sql_row['id']."' and `date`='$date' ")or die(mysql_error());	
		$row_attt   = mysql_fetch_array($sql_attt);
		$sql_attt_2	= mysql_query("SELECT * FROM `tbl_attendence_driver_team` where `emp_id`='".$sql_row['id']."' and `mark`='7' ")or die(mysql_error());	
		$row_attt_2 = mysql_fetch_array($sql_attt_2);
		array_push($user_list,$sql_row['id']);
?>
	<div class="row-form clearfix">
        <div class="span4"><?php echo $j.". ".ucwords(strtolower($sql_row['emp_name']));?> F/H/o <?php echo ucwords(strtolower($sql_row['fname']));?>
        	<input type="hidden" name="emp_id_<?php echo $sql_row['id'];?>" value="<?php echo $sql_row['id'];?>" />
        </div>
		<?php
		$i			= 0;
		if((mysql_num_rows($sql_attt_2)>0)&&($row_attt_2['date']<$date))
		{?>
			<div class="span3"><p style="width:100% !important;color:red;">This User Seprated From <?php echo date("d-m-Y",strtotime($row_attt_2['date']));?> </p></div>	
		<?php }
		else
		{
        foreach($attand_typ['sym'] as $key)
        { ?>   
        <div class="span1">
			<label><?php echo $key;?></label>
            <input type="radio" <?php
			if(isset($row_attt['mark']))
			{
				if($attand_typ['id'][$i]==$row_attt['mark'])
				{
					echo "checked";
				}
				/*else
				{
					echo "disabled";	
				}*/
			}
			?> value="<?php echo $attand_typ['id'][$i];?>" name="att_type_<?php echo $sql_row['id'];?>" />
        </div>
        <?php $i++;} 
        ?>        
        <?php 
		}
		?>     
    </div>
<?php
	}
	
?>
	<input type="hidden" id="user_list" name="user_list" value="<?php echo implode('&',$user_list);?>" />
<?php	
}
else
{
	echo "0";
}
mysql_close();
?>