<?php
   if(isset($_POST['save']))
   {
   
 
           
               $k=1;
	    for($i=0;$i<count($_REQUEST['emp_id']);$i++)
	    {
        $empid=$_REQUEST['emp_id'][$i];
      
         for($t=0;$t<count($_REQUEST['leave'][$empid]);$t++)
           {      
              $leavetype=$_REQUEST['leave'][$empid][$t];   
            
             
		           if($_REQUEST['leave_opening'][$leavetype][$empid][$t]!='')
		           {
               
		           	$data['site']=$_REQUEST['site'];
		           	$data['opening_year']=$_REQUEST['opening_year'];
		           	$data['empid']= $empid;
		           	$data['opening']=$_REQUEST['leave_opening'][$leavetype][$empid][$t];
                $data['leave_type']= $leavetype;         
              
		          $s->RecordInsert('hr_leave_opening',$data); 
             }


	    }
     $k++;}

	 $s->pageLocation("index.php?route=HRModule/employee_opening_index".$rurl);
   
}



  


?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div"> <h1><?php echo $s->GetFieldValue("modules_form","moduleid='".$_REQUEST['modid']."' and id='".$_REQUEST['frmid']."'","frm_name"); ?></h1>
<form method="post" action="">
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="0">
<tr class="row1">
 <td width="20%" align="right">Branch</td>
 <td width="30%"><select name="site" id="site"  onchange="showEmployee(this.value)" >
	  <option value="0">---Select---</option>
	  <?php 
		$site_sql=DB_query("Select loccode,locationname from locations",$db);
		while($site_row=DB_fetch_array($site_sql))
		{
		?>
	   <option value="<?php echo $site_row['loccode'];?>"<?php echo ($emp_site==$site_row['loccode']?'selected':'')?>><?php echo $site_row['locationname'];?></option>
			<?php } ?>
		  </select></td>
     
  <td width="20%" align="right">Opening Year</td>
  <td width="30%"><select name="opening_year" id="opening_year">
  <option value="0">Select</option>
  <?php for($t=date("Y");$t>=2000;$t--)
  {
  ?>
  <option value="<?php echo $t; ?>"><?php echo $t; ?> </option>
  <?php } ?>
   </td>
</tr>
</table>
<br>

<div id="show1"></div>
</form>
<!-- <div class="modal1" ></div> -->

<style type="text/css" >
.button{ background-color:#666666;
color: #FFFFFF;
height:25px;
margin:0px 5px 0px 5px;
border:1px solid #359CA2;
}
.link{ color:#9900CC; font-family:"Comic Sans MS"; letter-spacing:1px
}
</style>

<script>
function showEmployee(str)
{

 $.ajax({
            url : "ajax_employee_show.php",
            type : "POST",
            data : {             
            site:str
            },
            success : function(data) {//alert(data);
              
             $('#show1').html(data); 
 
                          }
          });

}
</script>

<style>
  .modal1 { 
    visibility:hidden;   
    position:   fixed;
    z-index:    99999;
    top:        0;
    left:       0;
    height:     100%;
    width:      100%;
     background: rgba( 105, 105, 105, .4 ) 
                url('images/loading.gif') 
                50% 50% 
                no-repeat;
}
body.loading .modal1 {
    visibility: visible;
}
  </style>
  <script type="text/javascript">
$( document ).ajaxStart(function() {
  
     $(".modal1").css("visibility", "visible");
});
$(document).ready(function(){
  $("body").ajaxStop(function(){
     $(".modal1").css("visibility", "hidden");
   });
});

function validate()
{

if(document.getElementById("opening_year").value=='0')
{
 alert("Must Select Opening Year") ;
 return false; 
}
if(document.getElementById("site").value=='0')
{
 alert("Must Select Site") ;
 return false; 
}
return true;

}

</script>
