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

<p align="center"><strong>Professional Tax  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%">State</th>
    <td width="14%"><select name="state" id="state" style="width:107px">
     <option value="">Select </option>
     <?php $state=DB_query("select * from state_master",$db);
	 while($statedata=DB_fetch_array($state))
	 {
	 ?>
	 <option value="<?php echo $statedata['id']; ?>"><?php echo $statedata['state']; ?></option>	
	<?php  } ?>
      
    </select></td>
    <th width="21%">Country </th>
    <td width="16%"><select name="country" id="country" style="width:107px">
          <option value="">Select </option>
         <?php $country=DB_query("select * from country_master",$db);
	 while($countryedata=DB_fetch_array($country))
	 {
	 ?>
	 <option value="<?php echo $countryedata['id']; ?>"><?php echo $countryedata['country']; ?></option>	
	<?php  } ?>
        </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>P. Tax Amount </th>
    <td><input type="text" name="p_tax_amt" id='p_tax_amt' /></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>State</th>
    <th>Country</th>
    <th>Salary Range From </th>
    <th>Salary Range To </th>
    <th>P. Tax Amount </th>
    
  </tr>
 


<?php
$i=1;
$sql1=DB_query("select * from hrpayroll_professional_tax ",$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 $s->getField('state_master','id',$row['state'],'state'); ?></td>
   <td><?php echo $s->getField('country_master','id',$row['country'],'country') ?></td>
    <td><?php echo $row['salary_range_from']; ?></td>
      <td><?php echo $row['salary_range_to']; ?></td>
      <td><?php echo $row['p_tax_amount']; ?></td>
   
  </tr>

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