<? include("si_confi.php"); ?>
<? include("ad_head.php"); ?>
  <div class="container">

<? 

include("mn_option.php");

if($_REQUEST['action']=='active')
{
	$get_emp_id=$_REQUEST['id2'];
	mysql_query("update `advance` set status='1',req='1' where `id`='$get_emp_id'");
?>
<script>window.location="viwe_advance2.php?act=suc";</script>
<?
}
    if($_REQUEST['action']=='trsh')
	{
	$get_emp_id=base64_decode($_REQUEST['isd']);
	mysql_query("delete from `employee_mng` where `id`='$get_emp_id'");
	
?>
    <script>window.location="viwe_advance2.php?del=suc";</script>
    
    <?
	}
	$get_emp_name12=base64_decode($_REQUEST['seemp']);
	?>
    
<? if($_REQUEST['ed']=='suc'){ ?>
<div class="success" style="width:92%;margin:0 auto;margin-top:9px;"> Employee Advance Details Edited successfully.</div><? } ?>
<? if($_REQUEST['del']=='suc'){ ?>
<div class="error" style="width:92%;margin:0 auto;margin-top:9px;"> Employee Advance Details Deleted successfully.</div><? } ?>
<? if($_REQUEST['act']=='suc'){ ?>
<div class="success" style="width:92%;margin:0 auto;margin-top:9px;"> Employee Advance Details Comfimed successfully.</div><? } ?>

<?

   $mnth=$_REQUEST['month'];
  
   if($get_emp_name12==NULL && $mnth==NULL)
   {
	$select_count_emp=mysql_query("select count(*) as num from `advance` where status='0'");
   }
   elseif($get_emp_name12!=NULL && $mnth!=NULL)
   {
	$select_count_emp=mysql_query("select count(*) as num from `advance` where `month`='$mnth' and name='$get_emp_name12' and status='0'");
   }
   elseif($get_emp_name12!=NULL && $mnth==NULL)
   {
    $select_count_emp=mysql_query("select count(*) as num from `advance` where  name='$get_emp_name12' and status='0'");
   }
   elseif($get_emp_name12==NULL && $mnth!=NULL)
   {
    $select_count_emp=mysql_query("select count(*) as num from `advance` where `month`='$mnth' and status='0'");
   }
 
 
 

if($get_emp_name12==NULL){
 } else {
	
}
$fetch_count_emp=mysql_fetch_array($select_count_emp);
$total_emp_result=$fetch_count_emp['num'];
?>
  <div style="border:groove;margin-top:10px;border-width:thin;padding:20px;border-radius:4px;border-color:#cccccc;box-shadow: 10px 9px 90px #000;">
  <h2>View Advance Details&nbsp;&nbsp;&nbsp;(Total&nbsp;:&nbsp;<? echo $total_emp_result; ?>)</h2>
  <link rel="stylesheet" type="text/css" media="all" href="ad_comple.css">
  <script type="text/javascript" src="jquery-1.9.1.min.js"></script>
  <script type="text/javascript" src="jquery.autocomplete.min.js"></script>  
  <script type="text/javascript">
  $(function(){
  var currencies = [
 <?php $qur="SELECT distinct `name` FROM `employee_mng`"; 
		$result = mysql_query($qur);
		while ($row_section = mysql_fetch_array($result)) {?>	  
    { value:'<?php echo $row_section['name']; ?>' },<?php } ?> ];
  $('#autocomplete').autocomplete({
    lookup: currencies,
  }); });
</script>
   
   <form method="post" enctype="multipart/form-data" action="viwe_advance.php">
   <table>
   <tr>
   <td><input type="text" name="search_employee" id="autocomplete"></td>
   
    <td>
        <select name="month" class="validate-selection" autofocus>
        <option value="" hidden="">Select Month</option>
        <?  for($m=1; $m<=12; ++$m)
		{
        ?>
<option value="<?  echo date('F', mktime(0, 0, 0, $m, 1)); ?>"><? echo  date('F', mktime(0, 0, 0, $m, 1)); ?> </option>
		<? } ?>
        </select>
        </td>
   <td><input type="submit" name="search_emp" value="Search"></td>
   </tr>
   </table>
   </form>
  <br>
    <table width="100%" cellpadding="9" cellspacing="0" border="1">
  <tr bgcolor="#CCCCCC">
  <td>EMP ID</td>
  <td>Name</td>
  <td>Advance </td>
  <td>Month </td>
  <td>Date </td>
  <td>Status </td>
  <td>Edit</td>
   <td>Delete</td>

  </tr>
  <?
   $mnth=$_REQUEST['month'];
   if($get_emp_name12==NULL && $mnth==NULL){
   $select_employee_details=mysql_query("select * from `advance` where status='0'");
   }
   elseif($get_emp_name12!=NULL && $mnth!=NULL)
   {
   $select_employee_details=mysql_query("select * from `advance` where `month`='$mnth' and 	name='$get_emp_name12' and status='0'"); 
   }
   elseif($get_emp_name12!=NULL && $mnth==NULL)
   {
   $select_employee_details=mysql_query("select * from `advance` where 	name='$get_emp_name12' and status='0'"); 
   }
   elseif($get_emp_name12==NULL && $mnth!=NULL)
   {
   $select_employee_details=mysql_query("select * from `advance` where `month`='$mnth'  and status='0'"); 
   }
	   
  while($fetch_employee_details=mysql_fetch_array($select_employee_details)){ ?>
  <tr bgcolor="#FFFFFF">
  <td><? echo ucwords($fetch_employee_details['empid']); ?></td>
  <td><? echo ucwords($fetch_employee_details['name']); ?></td>
  <td>Rs.<? echo $fetch_employee_details['advance']; ?></td>
  <td><? echo $fetch_employee_details['month']; ?></td>
  <td><? echo $fetch_employee_details['date']; ?></td>
  
   <td >
    <a href="viwe_advance2.php?id=<? echo $fetch_employee_details['empid']; ?>&&id2=<? echo $fetch_employee_details['id']; ?>&&m&&action=active" onClick="return confirm('Are you sure you want to confirm?');">
   <div style="background:#09F;color:#FFF;padding:10px;border-radius:9px;font-weight:bold; text-align:center;">UnConfirm</div></a>
   </td>
  
  <td><a href="edit_advance.php?id=<? echo $fetch_employee_details['id']; ?>"><img src="ad_img/edit-male-user-icon.png" width="40"></a></td>
  <td><a href="delete_adv.php?id=<? echo $fetch_employee_details['id']; ?>"><img src="img/PngThumb-red-green-OK-not-OK-Icons-1-14389.png" width="40"></a></td>
 
  </tr>
  <? } ?>
  <script type="text/javascript">
function newPopup(url) {
	popupWindow = window.open(
		url,'popUpWindow','height=580,width=700,left=140,top=60,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
}
</script>
  </table>  
  </div>
</div><!-- container -->
  </body>
</html>