	<?php if(isset($_SESSION['msg']) ){?>
	<div class="alert alert-info">                
	<h4>Info!</h4>
	<?php echo $_SESSION['msg']; unset($_SESSION['msg']); ?>
	</div> <?php }  ?> 
<div class="row-fluid" >
    <div class="span12">    
	<div class="head clearfix">
        <div class="isw-ok"></div>
        <h1>View Employee List</h1> 
     </div>   
    <div class="block-fluid">
        <form class="form-horizontal" onsubmit="return get_validation();" action="" method="post" enctype="multipart/form-data">
        <div class="row-form clearfix">
           <div class="span3">
                        <label>State</label>
                        <select name="state" required>
                        <option value="ALL">ALL</option>
                        <?php
                        if($_SESSION['userid']==4)
                        {
                            $st		= array();
                            $sql_st	= mysql_query("SELECT distinct `state` FROM `tbl_emp_records` ORDER BY `state` ASC ")or die(mysql_error());
                            while($row_st= mysql_fetch_array($sql_st))
                            {
                                array_push($st,$row_st['state']);
                            }
                        }
                        else
                        {
                            $st	  = explode('&',$_SESSION['post']);
                        }
                        foreach($st as $key)
                        {
                            $type = '';
                            if(isset($_SESSION['list_st'])&&($_SESSION['list_st']==$key)){ $type ='selected';}
                            echo "<option value='$key' $type>$key</option>";
                        }
                        ?>
                        </select>
                    </div>
           <div class="span2">
           	<label>&nbsp;</label>
            <input type="submit" name="Search" class="btn btn-block" value="Search"/>
           </div>         
        </div>     
        </form>           
    </div>
    </div>
    </div>
<?php
if(isset($_POST['Search']))
{
	unset($_SESSION['list_st']);unset($_SESSION['list_qry']);
	$_SESSION['list_st']        = $_POST['state'];	
	$list_st  = $_SESSION['list_st'];
	if($list_st=='ALL')
	{
		if($_SESSION['userid']==4)
		{
			$st_qry = " ";
		}
		else
		{
			$st	  = implode("','",explode('&',$_SESSION['post']));
			$st_qry = " and `state` in ('$st') ";
		}
	}
	else
	{
		$st_qry = " and `state`='$list_st' ";
	}
    $user_qry   = mysql_query(" SELECT * FROM `tbl_admin` WHERE `id`='".$_SESSION['userid']."' ") or die(mysql_error());
    $user_data  = mysql_fetch_array($user_qry);
    if($user_data['zone'] !="")
    {
        $zone    = explode("&",$user_data['zone']);
        $st_qry .= " and `emp_zone` IN ('".implode("','",$zone)."')";
    }
$_SESSION['list_qry'] = ("SELECT * FROM `tbl_emp_records` where `status`='0'  $st_qry order by `emp_name` asc ");
header("location:home.php?page=page");
}
?>   
<?php
if(isset($_SESSION['list_qry']))
{
?>     
    <div class="row-fluid" >
    <div class="span12">    
    	<div class="head clearfix">
        <div class="isw-ok"></div>
        <h1>View Employee List</h1>
     </div>   
   		<div class="block-fluid">
        	<table cellpadding="0" cellspacing="0" width="100%" class="table" id="example">
                <thead>
                    <tr>
                        <th>S.No.</th>
                        <th>Emp Code</th>
                       	<th>Emp Name</th>
                       	<th>Fat. Name</th>
                        <th>Designation</th>
                        <th>State</th>
                        <th>DOB</th>
                        <th>Aadhar No.</th>
                        <th>A/c No.</th>
                        <th>IFSC Code</th>
                        <th>Payment Status</th>
                        <th>UAN Status</th>
                        <th>Modify</th>
                        <th>Delete</th>
                    </tr>
                </thead>                 
                <tbody>
					<?php
					$i=1;
					$menu		= mysql_query($_SESSION['list_qry'])or die(mysql_error());
                    while($show_menu = mysql_fetch_array($menu)) 
                    {
						$a			 = "<img height='20' width='20' src='images/right.png'/>";
						$b			 = "<img height='20' width='20' src='images/wrong.png'/>";
						$payment_status	 = $b;
						if($show_menu['payment_status']=='Complete')
						{
							$payment_status	= $a;
						}
						$uan_status	 = $b;
						if($show_menu['uan_status']=='Done')
						{
							$uan_status	= $a;
						}
						$url    = "home.php?page=add_page&page_id=".$show_menu['id'];
						if($show_menu['state']=='Andhra Pradesh')
						$url    = "home.php?page=add_page_2&page_id=".$show_menu['id'];
                    ?>	
                    	<tr id="tr_num_<?php echo $i;?>">
                        <td><?php echo $i++; ?></td>
                        <td ><?php echo ucwords($show_menu['emp_code']); ?></td>
                        <td><?php echo ucwords($show_menu['emp_name']); ?></td>
                        <td><?php echo ucwords($show_menu['fname']); ?></td>
                        <td><?php echo ucwords($show_menu['desiganation']); ?></td>
                        <td><?php echo ucwords($show_menu['state']); ?></td>
                        <td><?php echo date("d-M-Y",strtotime($show_menu['dob'])); ?></td>
                        <td><?php echo ucwords($show_menu['aadhar_no']); ?></td>
                        <td><?php echo $show_menu['account_no']; ?></td>
                        <td><?php echo $show_menu['branch_ifsc']; ?></td>
                        <td style="text-align:center !important;"><?php echo $payment_status; ?></td>
                        <td style="text-align:center !important;"><?php echo $uan_status; ?></td>
                        <td class="center" style="text-align:center">
                        	<a href="<?php echo $url; ?>"><img src="images/edit_new.png"  border="0" style="width: 20px;"/></a>
                        </td>     
                        <td class="center" style="text-align:center">
                        <a onclick="return confirm_delete(<?php echo $i;?>,<?php echo $show_menu['id']; ?>);" href="javascript:void(0);"><img src="images/delete.png" style="width:30px;height:30px;"/></a></td> 
                    </tr>
               	   <?php } ?>                
                </tbody>            
            </table> 
        </div>    
   </div>
   </div>            
	<script>
	function confirm_delete(row_num,delete_id)
	{
		if (confirm("Delete Account?"))
		{
			showModal(row_num,delete_id);
			  return true;
    	}
		else
		{
		   return false;
		}
	}  
function showModal(row_num,str)
{
	$('#myModal').modal();	
	document.getElementById("row_num").value = row_num;
	document.getElementById("str").value = str;
	$('#submit_sabe').prop("disabled", false);
	$("#narr_model").val("");
	$('#load_img').attr('src','images/loader.gif');
	$("#load_img").css("display", "none");
	$('.datetimepicker2').datetimepicker({ timepicker:false, format:'d-m-Y', scrollInput:false});
	return false
}
function onsubmit_data()
{
	$('#load_img').attr('src','images/right.png');
	$("#load_img").css("display", "block");
	var narr_model = $("#narr_model").val();
	var str		   = $("#str").val();
	var row_num	   = $("#row_num").val();	
	var r_date     = $("#r_date").val();
	if (narr_model == "")
	{ alert("Please Enter Some Content !!!!!!!!")
		return false;
	}
	else
	{
		var xmlhttp = new XMLHttpRequest();
		xmlhttp.onreadystatechange = function() {
		if (this.readyState == 4 && this.status == 200)
			{
				$('#load_img').attr('src','images/right.png');
				$("#load_img").css("display", "block");
				$("#submit_sabe").attr('disabled','disabled');
				$('#tr_num_'+row_num).remove();
			}
		};
		xmlhttp.open("GET", "pages/page/get_update_st.php?str="+str+"&narr_model="+narr_model+"&r_date="+r_date, true);
		xmlhttp.send();
		return false;	
	}

}
$(document).ready(function() {
    var table = $('#example').DataTable( {
		"order": [[ 2, "asc" ]],
		"pageLength": 50,stateSave: true,
        fixedHeader: {
            header: true,
            footer: true
        }
    } );
	 table.on( 'order.dt search.dt', function () {
        table.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
            cell.innerHTML = i+1;
        } );
    } ).draw(); } );
	</script>
<?php } ?>    
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" data-keyboard="false" data-backdrop="static">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="exampleModalLabel" style="color:#fff;">Employee Delete !!</h4>
      </div>
      
      <form id="data" onsubmit="return onsubmit_data();">
        <div class="modal-body">
        <input type="hidden" id="str" name="str" />
        <input type="hidden" id="row_num" name="row_num" />
        Seprated Date : <textarea name="r_date" required="" class="datetimepicker2" id="r_date" style="width:400px; height:25px;"></textarea> <br />        
        Why do you delete : <textarea required="" name="narr_model" id="narr_model" style="width:400px;"></textarea><br />        
        <img src="images/loader.gif" id="load_img" style="display:none;" height="30" width="30"/>
      </div>
      <div class="modal-footer" style="text-align:center;">
        <button type="submit" id="submit_sabe" class="btn btn-default">Save</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>      
      </form>      
    </div>
  </div>
</div>