<?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);
 }


}
if($_REQUEST['Act']='Company Act')
$s->pageLocation("index.php?route=ToolPlants/maintenance/act_index&tab=1&type=company_act".$rurl);
else
 $s->pageLocation("index.php?route=ToolPlants/maintenance/act_index&tab=2&type=income_act".$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">
<form method="post" action="" name="frm">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr class="row1">
    <td><h3><strong><?php echo $s->GetFieldValue("modules_form","id='".$_REQUEST['frmid']."' and moduleid='".$_REQUEST['modid']."'","frm_name"); ?></strong></h3></td>
  </tr>
  <tr class="row1">
    <td><input type="radio" name="Act" id="act" onclick="show(this.value)" value="Company Act" checked="checked" />
     <strong>As Per Company Act</strong> 
     <input type="radio" name="Act" id="act" onclick="show(this.value)" value="Income Act"  /> 
     <strong>As Per Income Act</strong></td>
  </tr>
  <tr>
    <td>
<div  id="companyact">
<table width="100%" cellspacing="0" cellpadding="3" border="0">
  <tbody><tr class="row1">
    <td width="10%" valign="top" align="left"><strong>Schedule</strong></td>
    <td width="15%" valign="top" align="left"><input type="text" name="schedule" style="width:90%;"></td>
    <td width="10%" valign="top" align="left"><strong>Section</strong></td>
    <td width="15%" valign="top" align="left"><input type="text" name="section" style="width:90%;"></td>
    <td width="10%" valign="top" align="left"><strong>Effective From</strong> </td>
    <td width="15%" valign="top" align="left"><input type="text" name="com_effective_from" style="width:90%;" class="datepicker"></td>
    <td width="10%" valign="top" align="left"><strong>Effective To</strong></td>
    <td valign="top" align="left"><input type="text" name="com_effective_to" style="width:90%;" class="datepicker"></td>
  </tr>
  <tr>
    <td style="padding:0px;" colspan="8">
	<table width="100%" cellspacing="0" cellpadding="3" border="1" style="border:#666666 1px solid;">
  <tbody><tr bgcolor="#CCCCCC">
    <td><strong>Code</strong></td>
    <td><strong>Nature &amp; Asset </strong></td>
    <td style="text-align:center;" colspan="2"><strong>Single Shift </strong></td>
    <td style="text-align:center;" colspan="2"><strong>Double Shift </strong></td>
    <td style="text-align:center;" colspan="2"><strong>Triple Shift </strong></td>
    </tr>
  <tr>
    <td bgcolor="#CCC">&nbsp;</td>
    <td bgcolor="#CCC">&nbsp;</td>
    <td bgcolor="#CCC"><strong>WDV</strong></td>
    <td bgcolor="#CCC"><strong>SLM</strong></td>
    <td bgcolor="#CCC"><strong>WDV</strong></td>
    <td bgcolor="#CCC"><strong>SLM</strong></td>
    <td bgcolor="#CCC"><strong>WDV</strong></td>
    <td bgcolor="#CCC"><strong>SLM</strong></td>
  </tr>
  <?php for($k=1;$k<=10;$k++)
  {
    ?>
  
  <tr>
     <td><input type="text" name="code[]" id="code" style="width:100%;"></td>
    <td><input type="text" name="asset_name[]" id="asset" style="width:100%;"></td>
    <td><input type="text" name="sng_wdv[]"  id="sngwdv" style="width:100%;"></td>
    <td><input type="text" name="sng_slm[]" id="sngslm" style="width:100%;"></td>
    <td><input type="text" name="dbl_wdv[]" id="dblwdv" style="width:100%;"></td>
    <td><input type="text" name="dbl_slm[]" id="dblslm" style="width:100%;"></td>
    <td><input type="text" name="tpl_wdv[]" id="tplwdv" style="width:100%;"></td>
    <td><input type="text" name="tpl_slm[]"  id= "tplslm" style="width:100%;"></td>
  </tr>
 <?php } ?>
  
</tbody></table>

	</td>
    </tr>
</tbody></table>

</div>

<div class="income_act"  id="incomeact" style="display:none;">
<table width="100%" cellspacing="0" cellpadding="3" border="0">
  <tbody>
  <tr class="row1">
    <td width="10%" valign="top" align="left"><strong>Appendex</strong></td>
    <td width="15%" valign="top" align="left"><input type="text" name="appendex" style="width:90%;"></td>
    <td width="10%" valign="top" align="left"><strong>See Rules	</strong></td>
    <td width="15%" valign="top" align="left"><input type="text" name="rules" style="width:90%;"></td>
    <td width="10%" valign="top" align="left"><strong>Effective From</strong> </td>
    <td width="15%" valign="top" align="left"><input type="text" name="income_effective_from" style="width:90%;" class="datepicker"></td>
    <td width="10%" valign="top" align="left"><strong>Effective To</strong></td>
    <td valign="top" align="left"><input type="text" name="income_effective_to" style="width:90%;" class="datepicker"></td>
  </tr>

  <tr class="row1">
  <td colspan="2">&nbsp;</td>
  <td ><strong>Under Group</strong></td>
  <td style="padding:0px;" colspan="2"><select name="group" style="width:70%">
    <option select="0">Root</option>
  <?php
  $sql=DB_query("select asset_name,tpl_rate_deprications_details.id as id from tpl_rate_deprications_details
    inner join tpl_rate_deprications on tpl_rate_deprications.id=tpl_rate_deprications_details.parent_id where tpl_rate_deprications.act='Income Act'
    and tpl_rate_deprications_details.group_id=0 order by tpl_rate_deprications.id ",$db);
  while($row1=DB_fetch_array($sql))
  {
  ?>
  <option value="<?php echo $row1['id']; ?>"><?php echo $row1['asset_name']; ?> </option>
  <?php } ?>
  </select></td>
  <td colspan="3">&nbsp;</td>
  </tr>
  
  <tr>
    <td style="padding:0px;" colspan="8" >
	<table width="100%" border="1" align="center" cellpadding="3" cellspacing="0" style="border:#666666 1px solid;">
  <tbody><tr bgcolor="#CCCCCC">
    <td><strong>Code</strong></td>
    <td><strong>Nature &amp; Asset </strong></td>
    <td style="text-align:center;"><strong>Rate</strong></td>
    </tr>
    <?php
   for($k=1;$k<=10;$k++)
    {
    ?>
  <tr>
    <td><input type="text" name="code[]" id="code1" style="width:100%;"></td>
    <td><input type="text" name="asset_name[]" id="asset1" style="width:100%;"></td>
    <td><input type="text" name="rate[]" id="rate" style="width:100%;"></td>
    </tr>
  <?php } ?>
</tbody></table>

	</td>
    </tr>
</tbody></table>

</div>
</td>
  </tr>
  <tr class="row1">
  <td style="text-align:center;"><input type="submit" name="Save" value="Save" class="search" /><a href="index.php?route=ToolPlants/maintenance/act_index&modid=<?php echo $_REQUEST['modid']; ?>&frmid=<?php echo $_REQUEST['frmid']; ?>"> <input type="button" name="Save" value="Cancel" class="search" /></a></td>
  
  </tr>
</table>
</form>
</div>
</div>
<script>
function show(val)
{
  
if(val=='Company Act')
{
  
document.getElementById("companyact").style.display='block';
document.getElementById("incomeact").style.display='none';

document.getElementById("code1").disabled='true';
document.getElementById("asset1").disabled='true';

document.getElementById("code1").disabled='false';
document.getElementById("asset1").disabled='false';
document.getElementById("sngwdv").disabled='false';
document.getElementById("sngslm").disabled='false';
document.getElementById("dblwdv").disabled='false';
document.getElementById("dblslm").disabled='false';
document.getElementById("tplwdv").disabled='false';
document.getElementById("tplslm").disabled='false';

}
else
{
  
document.getElementById("incomeact").style.display='block';
document.getElementById("companyact").style.display='none';
document.getElementById("code1").disabled='false';
document.getElementById("asset1").disabled='false';

document.getElementById("code1").disabled='true';
document.getElementById("asset1").disabled='true';
document.getElementById("sngwdv").disabled='true';
document.getElementById("sngslm").disabled='true';
document.getElementById("dblwdv").disabled='true';
document.getElementById("dblslm").disabled='true';
document.getElementById("tplwdv").disabled='true';
document.getElementById("tplslm").disabled='true';
}

}
</script>