
<h3><?php echo $page_title;?></h3>
<?php $table="tpl_materialdefinition";
if($_REQUEST['Save'] && isset($_REQUEST['action']))
{
  $data['assetgroup']=$_REQUEST['assetgroup']; 
  $data['deprec_mst_name']=$_REQUEST['deprec_mst_name']; 
  $data['deprec_companyact']=$_REQUEST['deprec_companyact']; 
 $data['deprec_incomeact']=$_REQUEST['deprec_incomeact']; 
 $data['deprec_companyper']=$_REQUEST['deprec_companyper']; 
 $data['deprec_incomeper']=$_REQUEST['deprec_incomeper']; 
 $data['deprec_residual']=$_REQUEST['deprec_residual']; 
 $data['remark']=$_REQUEST['remark']; 
      	if($_REQUEST['action']=='AddNew'){
     $r=$s->RecordInsert($table, $data);
	 if($r)
	    $s->pageLocation($redirect_page.'&daction=Insert');
	 }
	 elseif($_REQUEST['action']=='Edit')
	 {
	 	$cond="id='".$_REQUEST['Vid']."'";
		  $r=$s->RecordEdit($table, $data, $cond);
		  $s->pageLocation($redirect_page.'&daction=Updated');

	 }
	 
}

if($_REQUEST['action']=='Delete')
{	 $condition="id='".$_REQUEST['Vid']."'";
	 $r=$s->DeleteRecord($table,  $condition);
	  $s->pageLocation($redirect_page.'&daction=Deleted');
}
if($_REQUEST['action']=='Edit')
{
	$condition="id='".$_REQUEST['Vid']."'";
   $result= $s->GetRecordById($table,  $condition);
   while($rowdata=DB_fetch_array( $result))
   {
		$remark=$rowdata['remark']; 
		$assetgroup=$rowdata['assetgroup']; 
		$deprec_mst_name=$rowdata['deprec_mst_name']; 
		$deprec_companyact=$rowdata['deprec_companyact']; 
		$deprec_incomeact=$rowdata['deprec_incomeact']; 
		$deprec_companyper=$rowdata['deprec_companyper']; 
		$deprec_incomeper=$rowdata['deprec_incomeper']; 
		$deprec_residual=$rowdata['deprec_residual']; 
     }
}
?>

<?php 
if($_REQUEST['daction'])
{
  echo "<div class='success'>Record ".$_REQUEST['daction']." Successfully</div>";
}
  if(isset($_REQUEST['action']) &&($_REQUEST['action']=='AddNew' || $_REQUEST['action']=='Edit'))
  {
?>
<form action="" method="post">
<table width="100%" border="0" cellpadding="4" cellspacing="4" class="font_bold" >
  <tr  valign="top">
    <td width="31%">Asset Group </td>
      <td width="69%">: 
	  
	  <?php  echo $ClassMaterial->Material($assetgroup);?>
	  </td>
    </tr>
	<tr  valign="top">
    <td width="31%">Depreciation Master Name </td>
      <td width="69%">: <input type="text" name="deprec_mst_name" class="col_230" value="<?php  echo $deprec_mst_name;?>" size="50"></td>
    </tr>
	<tr  valign="top">
    <td width="31%">Depreciation Method(Company Act) </td>
      <td width="69%"><span class="top_blt">: </span>  
<input type="radio" name="deprec_companyact" value="StraightLine" class="col_20" <?php  echo ($deprec_companyact=='StraightLine'?'checked':'')?>>StraightLine	  
<input type="radio" name="deprec_companyact" value="Diminishing" class="col_20"  <?php  echo ($deprec_companyact=='Diminishing'?'checked':'')?>> Diminishing	  </td>
    </tr>
	<tr  valign="top">
    <td width="31%">Depreciation Method(Income Tax Act) </td>
      <td width="69%"><span class="top_blt">: </span> 
	  <input type="radio" name="deprec_incomeact" value="StraightLine"  class="col_20" <?php  echo ($deprec_incomeact=='StraightLine'?'checked':'')?>>StraightLine	  
<input type="radio" name="deprec_incomeact" value="Diminishing"  class="col_20"  <?php  echo ($deprec_incomeact=='Diminishing'?'checked':'')?>> Diminishing	
	  
	  </td>
    </tr>
	<tr  valign="top">
    <td width="31%">Depreciation Percentage(Company Act) </td>
      <td width="69%">: <input type="text" name="deprec_companyper" value="<?php  echo $deprec_companyper;?>" size="50"></td>
    </tr>
	<tr  valign="top">
    <td width="31%">Depreciation Percentage(Income Tax Act)  </td>
      <td width="69%">: <input type="text" name="deprec_incomeper" value="<?php  echo $deprec_incomeper;?>" size="50"></td>
    </tr>
	
   <tr  valign="top">
    <td>Residual value </td>
    <td>: <input type="text" name="deprec_residual" value="<?php  echo $deprec_residual;?>" size="50"></td>
    </tr>
   <tr  valign="top">
    <td>Remark</td>
    <td><span class="top_blt">: </span><textarea name="remark" rows="2" cols="21" class="col_230"><?php echo $remark?></textarea> </td>
    </tr>
   <tr  valign="top">
    <td>&nbsp;</td>
    <td><input type="submit" name="Save" value="Save" class="pointer"></td>
    </tr>
</table>
</form>
<?php } 
else
{?>
<a href="<?php echo $redirect_page?>&action=AddNew">Addnew</a>
<table width="100%" border="1" cellpadding="2" cellspacing="2">
  <tr>
  <th>Depreciation Group</th>
    <th>Depreciation Master Name</th>
    <th>Remark</th>     <th> Status</th>
    <th>Edit</th>
    <th>Delete</th>
  </tr>
<?php 
  	$condition="1=1";
   $result= $s->GetRecordById($table,  $condition);
   while($rowdata=DB_fetch_array( $result))
   {
?>
  <tr>
   <td><?php echo  	$s->GetFieldValue('tpl_materialcategorydefinition',"id='".$rowdata['assetgroup']."'" ,'asset_capitalisation');
 ?></td>
    <td><?php echo $rowdata['deprec_mst_name'] ;
	
	?></td>
    <td><?php echo $rowdata['remark'] ?></td>
	 <td><?php echo ($rowdata['material_status']=='Y'?'Active':'Inactive'); ?></td>
    <td><a href="<?php echo $redirect_page?>&action=Edit&Vid=<?php echo  $rowdata['id'] ?>"><img src="images/icon-edit.png" width="10" height="10"></a></td>
   <td> <a href="<?php echo $redirect_page?>&action=Delete&Vid=<?php echo  $rowdata['id'] ?>"><img src="images/Icon_Delete.png" width="10" height="10"></a></td>
  </tr>
<?php } ?>  
</table>
 <?php } ?>