<?php
if(isset($_POST['Save']))
{

 if($_REQUEST['schedule']!='') 
 $data['schedule']=$_REQUEST['schedule'];
 else
 $data['schedule']=$_REQUEST['appendex']; 
 if($_REQUEST['section']!='') 
 $data['section']=$_REQUEST['section'];
 else
 $data['section']=$_REQUEST['rules']; 

 if($_REQUEST['com_effective_from']!='')
 $data['effective_from']=FormatDateForSQL($_REQUEST['com_effective_from']);
 else
 $data['effective_from']=FormatDateForSQL($_REQUEST['income_effective_from']);
if($_REQUEST['com_effective_to']!='')
 $data['effective_to']=FormatDateForSQL($_REQUEST['com_effective_to']);
 else
 $data['effective_to']=FormatDateForSQL($_REQUEST['income_effective_to']);

 $data['act']=$_REQUEST['Act'];
 $data['created_by']=$_SESSION['UserID'];
 $data['created_date']=date('Y-m-d');
 $data['company_id']=$_SESSION['ACGCompanyId'];
 $s->RecordInsert('tpl_rate_deprications',$data);
 $Lastreq_id=DB_Last_Insert_ID($db,'tpl_rate_deprications',$ErrMsg);

for($t=0;$t<count($_REQUEST['code']);$t++)
{
 if($_REQUEST['code'][$t]!='')
 {
 $data1['parent_id']=$Lastreq_id;
 $data1['code']=$_REQUEST['code'][$t];
 $data1['asset_name']=$_REQUEST['asset_name'][$t];
 $data1['sng_wdv']=$_REQUEST['sng_wdv'][$t];
 $data1['sng_slm']=$_REQUEST['sng_slm'][$t];
 $data1['dbl_wdv']=$_REQUEST['dbl_wdv'][$t];
 $data1['dbl_slm']=$_REQUEST['dbl_slm'][$t];
 $data1['tpl_wdv']=$_REQUEST['tpl_wdv'][$t];
 $data1['tpl_slm']=$_REQUEST['tpl_slm'][$t];
 $data1['rate']=$_REQUEST['rate'][$t];
 $data1['group_id']=$_REQUEST['group'];
 $s->RecordInsert('tpl_rate_deprications_details',$data1);
 }

}
$s->pageLocation("index.php?route=ToolPlants/maintenance/act_index".$rurl);
}

if($_REQUEST['subid']!='')
{
 
 $del=DB_query("delete from tpl_rate_deprications_details where id='".$_REQUEST['subid']."'",$db); 
  $check=$s->GetFieldValue("tpl_rate_deprications_details","parent_id='".$_REQUEST['mid']."'","count(*)");
 
 if($check==0)
 $del=DB_query("delete from tpl_rate_deprications where id='".$_REQUEST['mid']."'",$db); 
 $s->pageLocation("index.php?route=ToolPlants/maintenance/act_index".$rurl);
}
?>

<style type="text/css">
.company_act{width:100%;}
.income_act{width:100%;}
</style>
<link href="css/new_mxerp.css" rel="stylesheet" />
<div class="body_contain">
<div class="tab_div">
<h1><strong><?php echo $s->GetFieldValue("modules_form","id='".$_REQUEST['frmid']."' and moduleid='".$_REQUEST['modid']."'","frm_name"); ?></strong></h1>
<div class="new_tab">
<div class="inside_tab">
  <ul>
    <li><a href="index.php?route=ToolPlants/maintenance/act&modid=<?php echo $_REQUEST['modid']; ?>&frmid=<?php echo $_REQUEST['frmid']; ?>">Add New</a></li>
    <li><a href="index.php?route=ToolPlants/maintenance/act_index&modid=<?php echo  $_REQUEST['modid']?>&frmid=<?php echo $_REQUEST['frmid']?>&tab=1&type=company_act">Company Act</a></li>
    <li><a href="index.php?route=ToolPlants/maintenance/act_index&modid=<?php  echo $_REQUEST['modid']?>&frmid=<?php echo $_REQUEST['frmid']?>&tab=2&type=income_act">Income Act</a></li>
  </ul>
</div>
</div>
<div style="width:100%; float:left;">
  <?php    
      if($_REQUEST['route']!='' && $_REQUEST['type']!='')
      {
        include($_REQUEST['type'].".php");
      } 
  else{
  include("company_act.php");
  }
  ?>
</div>
</div>
</div>
