<?php
if($_REQUEST['Save'])
{
  
  $data['ledger_id']      =$_REQUEST['nature_service'];
  $data['abt']            =$_REQUEST['abt'];
  $data['service_id']     =$_REQUEST['service_tax']; 
  $data['ecess_id']       =$_REQUEST['ecess_tax'];
  $data['she_cess_id']    =$_REQUEST['she_cess'];
  $data['tax_exemption']  =$_REQUEST['tax_exemption'];
  $data['credit_type']    =$_REQUEST['type'];
  $data['status']         =$_REQUEST['status'];
  $data['created_by']     =$_SESSION['ACGCompanyId'];
  $data['created_date']   =date('Y-m-d');
  $data['Company_id']     =$_SESSION['ACGCompanyId'];
 $s->RecordInsert('servise_tax_ledger_map',$data);
 $s->pageLocation("index.php?route=Account/serviceTax_ledger_mapping_index&daction=Updated".$rurl);  
}

if($_REQUEST['Update'])
{
  
  $data['ledger_id']      =$_REQUEST['nature_service'];
  $data['abt']            =$_REQUEST['abt'];
  $data['service_id']     =$_REQUEST['service_tax']; 
  $data['ecess_id']       =$_REQUEST['ecess_tax'];
  $data['she_cess_id']    =$_REQUEST['she_cess'];
  $data['tax_exemption']  =$_REQUEST['tax_exemption'];
  $data['credit_type']    =$_REQUEST['type'];
  $data['status']         =$_REQUEST['status'];
  $data['modified_by']     =$_SESSION['ACGCompanyId'];
  $data['modified_date']   =date('Y-m-d');
  $cond="id='".$_REQUEST['id']."'";
 $s->RecordEdit('servise_tax_ledger_map',$data,$cond);
 $s->pageLocation("index.php?route=Account/serviceTax_ledger_mapping_index&daction=Updated".$rurl);  
}

 
if($_REQUEST['action']=='Edit') 
{
$sql_fetch=DB_query("select * from servise_tax_ledger_map where id='".$_REQUEST['id']."'",$db);
$row_fetch=DB_fetch_array($sql_fetch);
extract($row_fetch);

}	

?>

<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
  <td><div align="right"><A HREF="javascript:history.go(-1)"> [Go Back]</A> </div></td>
  </tr>
</table>
<h3><?php echo $s->GetFieldValue("modules_form","id='".$_REQUEST['frmid']."' and moduleid='".$_REQUEST['modid']."'","frm_name"); ?> </h3>
<form action="" method="post">
<table width="100%" border="0" cellspacing="2" cellpadding="2" style="border:solid 1px #999999">
 <tr class="row1">
<?php 
$grpid='';
 //$groupid=$s->GetFieldValue("accountgroupmaster","GroupName LIKE '%EXPENSE%' || '%INCOME%' " ,"GroupId");

$sql_group=DB_query("SELECT GroupId FROM accountgroupmaster WHERE NatureOfGroup IN (SELECT GroupId FROM accountgroupmaster WHERE GroupName IN('INCOME','EXPENSE') )",$db);
while($r=DB_fetch_array($sql_group))
{
  $grpid[]=$r['GroupId'];
}
$grpid2=implode("','",$grpid);
if(count($grpid)>0)
{
$sql_group=DB_query("SELECT GroupId FROM accountgroupmaster WHERE MainGroupId IN ('".$grpid2."')",$db);
while($r=DB_fetch_array($sql_group))
{
  $grpid12[]=$r['GroupId'];
}
}
$grpid13=array_merge($grpid,$grpid12);

$grpid1=implode("','",$grpid13);
?>
 <td class="tabledata1" >Nature Of Service:</td>
 <td class="tabledata1" ><select name="nature_service" id="nature_service" style="width:100%;">
<option value="0">Select</option>
<?php 

$sel_ledg=DB_query("select * from accountledger where UnderGroup in('".$grpid1."')",$db); 
while($sel_ledgRow=DB_fetch_array($sel_ledg))
{

$p12='';
if($ledger_id==$sel_ledgRow['AccountsID'])
$p12="selected";

?>
<option value="<?php echo $sel_ledgRow['AccountsID']; ?>" <?php echo $p12; ?> ><?php echo $sel_ledgRow['AccountName']; ?></option>
<?php   }?>
</select></td>
	
    <td class="tabledata1" >Abtment{%)</td>
    <td><input type="text" name="abt"  value="<?php echo $abt; ?>" id="abt" />
     </td>	
     <td class="tabledata1" >Service Tax</td>
     <td>
		<?php
  	    $result_ledger = DB_query("SELECT *  FROM service_tax_master WHERE type='ST' ",$db);
  			?>
  			<select name="service_tax" id="service_tax">
			<?php 			
 			while($myrow_ledger = DB_fetch_array($result_ledger))
			{
			  $p='';
			  if($myrow_ledger['id']==$service_tax || $myrow_ledger['id']==$service_id)
			  $p="selected";
			?>
			<option value="<?php echo $myrow_ledger['id']; ?>"<?php echo $p; ?>><?php echo $myrow_ledger['tax_code']; ?></option>
			<?php }?>
			</select> </td>
			</tr>
	<tr Class="row1">
    <td class="tabledata1" >E. Cess </td>
    <td>
	<select name="ecess_tax" id="ecess_tax" style="width:100%">
	<option value="0">Select</option>
	<?php
  	    $result_ledger1= DB_query("SELECT *  FROM service_tax_master WHERE type='E' ",$db);
  			?>
  			
			<?php 			
 			while($myrow_ledger1 = DB_fetch_array($result_ledger1))
			{
			  $p2='';
			  if($myrow_ledger1['id']==$ecess_tax || $myrow_ledger1['id']==$ecess_id)
			  $p2="selected";
			?>
			<option value="<?php echo $myrow_ledger1['id']; ?>"<?php echo $p2; ?>><?php echo $myrow_ledger1['tax_code']; ?></option>
			<?php }?>
	
	</select>
	</td>   
 
    <td class="tabledata1" >SHE.Cess</td>
    <td><select name="she_cess" id="she_cess" >
	<option value="0" >Select</option>
	<?php
  	    $result_ledger2= DB_query("SELECT *  FROM service_tax_master WHERE type='S' ",$db);
  			?>
  			
			<?php 			
 			while($myrow_ledger2 = DB_fetch_array($result_ledger2))
			{
			  $p3='';
			  if($myrow_ledger2['id']==$she_cess || $myrow_ledger2['id']==$she_cess_id)
			  $p3="selected";
			?>
			<option value="<?php echo $myrow_ledger2['id']; ?>"<?php echo $p3; ?>><?php echo $myrow_ledger2['tax_code']; ?></option>
			<?php }?>
	
	</select>
	</select></td>

	<td class="tabledata1" >Tax  Exemption </td>
	<td><input type="text" name="tax_exemption"   value="<?php echo $tax_exemption; ?>"/></td>
  </tr>
 <tr class="row1">
	<td class="tabledata1" >Credit Type </td>
	<td><select name="type" id="type" style="width:100%">
	<option value="0" >Select</option>
	<option value="F" <?php if($type=='F' || $credit_type=='F')echo "selected";?>>100 %</option>
	<option value="H" <?php if($type=='H' || $credit_type=='H')echo "selected";?>>50 %</option>
	</select></td>
<td class="tabledata1">Active</td>
<td><input type="radio" name="status" value="Y" <?php if($status=='Y') { ?> checked="checked" <?php }?> >Active &nbsp; 
<input type="radio" name="status" value="N" <?php if($status=='N') { ?> checked="checked" <?php }?>>InActive</td>
<td colspan="2">&nbsp; </td>
  </tr>
  <?php if($_REQUEST['action']!='Edit')  {?>
 <tr class="row1">
  <td colspan="6" style="text-align:center"><input type="submit" name="Save" value="Save" class="search" /></td>
  </tr>
  <?php } else { ?>
 <tr class="row1">
  <td colspan="6" style="text-align:center"><input type="submit" name="Update" value="Update" class="search" /></td>
  </tr>
  <?php } ?>
  
</table>

</form>
 

</div></div>
 
 
