<?php include('includes/Class_Branch.php');
  
if(isset($_POST['Save']))
{
$check=DB_query("select * from hrpayroll_esicalculation where site='".$_REQUEST['site']."' and emp_type='".$_REQUEST['employment_type']."' and  employee_type='".$_REQUEST['employee_type']."'",$db);
$numrow=DB_num_rows($check);
if($numrow<=0)
{	
$sql=DB_query("insert into hrpayroll_esicalculation set site='".$_REQUEST['site']."',emp_type='".$_REQUEST['employment_type']."',employee_type='".$_REQUEST['employee_type']."',
               salary_range_frm='".$_REQUEST['frm_range']."',salary_range_to='".$_REQUEST['to_range']."',esi_per='".$_REQUEST['esi_per']."'",$db);	
}
else
{
?>
<script> alert("Duplicate Entry");</script>
<?php
}
	
	
}  
  
?>

<p align="center"><strong>ESI Calculations</strong></p>
<br>
<br>
<form action="" method="post">
<table width="85%" border="0" align="center">
  <tr>
    <th width="17%">Branch</th>
    <td width="12%"><select name="site" id="site" style=" width: 100%">
    <option value="0">Select Site</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 ($_REQUEST['site']==$site_row['loccode']?'selected':'');?>><?php echo $site_row['locationname'];?></option>
          <?php } ?>
        </select>	
   
    	
    	
    </td>
    <th width="20%">Employment Type </th>
    <td width="14%"><select name="employment_type" id="employment_type" style="width:107px">
     <option value="">Select </option>
      <option value="Permanent"<?php echo($employment_type=='Permanent'?'selected':'')?>>Permanent</option>
      <option value="Temporary"<?php echo($employment_type=='Temporary'?'selected':'')?>>Temporary</option>
    </select></td>
    <th width="21%">Employee Type </th>
    <td width="16%"><select name="employee_type" id="employee_type" style="width:107px">
          <option value="">Select </option>
         <option value="Staff"<?php echo($employee_type=='Staff'?'selected':'')?>>Staff</option>
      <option value="Worker"<?php echo($employee_type=='Worker'?'selected':'')?>>Worker</option>
        </select></td>
  </tr>
  <tr>
    <th>Salary Range : From </th>
    <td><input type="text" name="frm_range" id='frm_range' /></td>
    <th>Salary Range : TO</th>
    <td><input type="text" name="to_range" id='to_range' /></td>
    <th>ESI % </th>
    <td><input type="text" name="esi_per" id='esi_per' /></td>
  </tr>
  <tr>
    <td colspan="6">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="6"><p align="center"><input type="submit" name="Save" value="Save" /></p></td>
  </tr>
</table>
</form>
<hr>
<p align="center"><strong>View Details</strong></p>
<table width="100%" border="1">
  <tr>
    <th>Sr.No</th>
    <th>Branch</th>
    <th>Employment Type</th>
    <th>Employee Type</th>
    <th>Salary Range : From </th>
    <th>Salary Range : To </th>
    <th>ESI %</th>
  </tr>
 


<?php
$i=1;
$sql1=DB_query("select * from hrpayroll_esicalculation ",$db);
$records=DB_num_rows($sql1);
if($records>=1)
{
while($row=DB_fetch_array($sql1))
{
?>
<tr>
    <td><?php echo $i; ?></td>
    <td><?php echo $row['site']; ?></td>
     <td><?php echo $row['emp_type']; ?></td>
   <td><?php echo $row['employee_type']; ?></td>
    <td><?php echo $row['salary_range_frm']; ?></td>
      <td><?php echo $row['salary_range_to']; ?></td>
     <td><?php echo $row['esi_per']; ?></td>
  </tr>

<?php	
$i++; } } else {?>
	
<tr><td colspan="7">No Records</td></tr>	
	<?php } ?>
</table>
