<?php
$PageSecurity = 15;
$title = _('Professional Tax Slab Master') ;

				if(isset($_POST['update']))
				{
                 $data['site']=$_REQUEST['site'];
				 $data['grade']=$_REQUEST['grade'];
				 $data['state']=$_REQUEST['state'];
				 $data['effective_date']=FormatDateForSQL($_REQUEST['effective_date']);
				 $data['modified_by']=$_SESSION['UserID'];
				 $data['modified_date']=date('Y-m-d');				
				$cond="id='".$_REQUEST['id']."'";
				$s->RecordEdit('professional_tax',$data,$cond);
				
				
			$last_id=$_REQUEST['id'];
            $del=DB_query("delete from professional_tax_details where parentid='".$_REQUEST['id']."' ",$db);
            for($i=0;$i<count($_REQUEST['amount']);$i++)
			{
			
                 if($_REQUEST['amount'][$i]!='' && $_REQUEST['to_range'][$i]!='' && $_REQUEST['to_range'][$i]!='')	
			    {		
						$dataArr['parentid']=$last_id;
						$dataArr['from_rage']=$_REQUEST['from_rage'][$i];
						$dataArr['to_range']=$_REQUEST['to_range'][$i];
						$dataArr['amount']=$_REQUEST['amount'][$i];
						
						$s->RecordInsert('professional_tax_details',$dataArr);
				}		
			}	
			$s->pageLocation("index.php?route=HRModule/view_rofessional_tax_indes".$rurl);

				}



if($_REQUEST['id']!='')
{
$sql_edit=DB_query("select * from professional_tax where id='".$_REQUEST['id']."'",$db);
$row_edit=DB_fetch_array($sql_edit);
extract($row_edit);

}


?>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div"> 
<h1>Professional Tax Slab  Master</h1>
<form method="post" action="">
<table width="70%" border="0" align="center" cellpadding="3" cellspacing="0">
<tr class="row1">
    <td width="20%" class="tabledata1"><strong>Branch</strong></td>
    <td width="18%"><select  name="site" id="site" style="width:100%;" onchange="show_state(this.value)">
	<option value="0">Select</option>
	<?php 
	$sql_site=DB_query("select * from locations where CompanyId='".$_SESSION['ACGCompanyId']."'",$db);
	while($row=DB_fetch_array($sql_site))
	{
	$s1='';
	if($site==$row['loccode'])
	$s1="selected";
	?>
	<option value="<?php echo $row['loccode']; ?>" <?php echo $s1; ?>><?php echo $row['locationname']; ?></option>
	<?php } ?>
	</select></td>
    <td width="11%">&nbsp;</td>
    <td width="18%"><strong>Grade</strong></td>
    <td width="16%"><select  name="grade" id="grade" style="width:100%;" 
      <option value="0">Select</option>
      <?php 
	$sql_grade=DB_query("select * from emp_grade ",$db);
	while($row_grade=DB_fetch_array($sql_grade))
	{
	$s2='';
	if($grade==$row_grade['id'])
	$s2="selected";
	?>
      <option value="<?php echo $row_grade['id']; ?>" <?php echo $s2; ?>><?php echo $row_grade['grade_name']; ?></option>
      <?php } ?>
    </select></td>
    <td width="17%">&nbsp;</td>
</tr>
<tr class="row1">
    <td class="tabledata1"><strong>State</strong></td>
<td id="state"><input type='text' name='' id='' value="<?php echo $statename=$s->getField('state_master','id',$state,'state'); ?>" readonly='true'>
<input type='hidden' name='state' id='state1' value="<?php echo $state; ?>"></td>
<td>&nbsp;</td>
<td><strong>Effective Date</strong> </td>
<td><input type="text" name="effective_date" id="effective_date" class="datepicker" 
 value="<?php echo ConvertSQLDate($effective_date); ?>"/></td>
<td>&nbsp;</td>
</tr>
</table>

<table width="100%" border="1" cellspacing="2" cellpadding="2" style="border-collapse:collapse;">
  <tr>
    <td  colspan="3"><input type="button" onClick="addRow('dataTable')" value="Add Rows" class="search" /></td>
	   
    </tr>
  <tr >
    <td width="25%" align="left" valign="top" class="tabledata">From Range</td>
    <td width="25%" align="left" valign="top" class="tabledata">To Range</td>
    <td width="25%" align="left" valign="top" class="tabledata">Amount</td>
	
     </tr>
   <tbody id="dataTable">
   <?php 
   $i=1;
   $sql_parent=DB_query("select * from professional_tax_details where parentid='".$_REQUEST['id']."'",$db);
   while($row_parent=DB_fetch_array($sql_parent))
   {
   
     ?>
  <tr>
    <td align="left" valign="top" class="tabledata"><input type="text" style="width:100%;" name="from_rage[]" id="bvfm_<?php echo $i; ?>"  value="<?php echo $row_parent['from_rage']; ?>"   /></td>
    <td align="left" valign="top" class="tabledata"><input type="text" style="width:100%;" name="to_range[]" id="bvto_<?php echo $i; ?>"   value="<?php echo $row_parent['to_range']; ?>" /></td>
    <td align="left" valign="top" class="tabledata"><input type="text" style="width:100%;" name="amount[]" id="bvcharge_<?php echo $i; ?>" onkeypress="return isNumberKey(event)"   value="<?php echo $row_parent['amount']; ?>" /></td>
  
  </tr>
  <?php $i++; } ?>
  </tbody>
</table>
<input type="hidden" name="hiditemcount" id="hiditemcount" value="<?php echo $i; ?>" />
  <input type="hidden"  value="" id="edit_cnt" />
<p align="center" style="text-align:center"><input type="submit" name="update" value="Update" class="search" /></p>

</form>

<script>
function isNumberKey(evt){
    var charCode = (evt.which) ? evt.which : event.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
	{
	alert("Only Numeric Value Allowed");
    return false;
	}
    return true;
}

function show_state(str)
{
if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	if (xmlhttp.readyState==4 && xmlhttp.status==200)
	{
	document.getElementById("state").innerHTML=xmlhttp.responseText;
	}
	}
	xmlhttp.open("GET","ajax_getbranchstate.php?str="+str,true);
	xmlhttp.send();






}
</script>