<?php
    if($_REQUEST['act']=='del' && $_REQUEST[Id]!='')
    {
      DB_query("delete from tbl_title_master where id='".$_REQUEST['Id']."'",$db);
    }
 ?>


<div style="display:none" id="div_id"></div>
<link rel="stylesheet" href="css/new_mxerp.css">
<div class="body_contain">
<div class="tab_div">
<h1>Sub Asset Title</h1>
<!--
<p align="left"><a href="index.php?route=ToolPlants/fixed_assets/sub_asset_title_master&modid=<?php echo $_REQUEST['modid']; ?>&frmid=<?php echo $_REQUEST['frmid']; ?>"><input type="button" name="Add Title" value="Add title" class="search"></a></p>	-->
<form action="" method="post">
<div class="overpanel">
<table width="100%" border="0" cellspacing="0" cellpadding="3" align="center" class="thborder">   
  <tr>  
    <th width="6%">S. No.</th> 		
    <th width="35%">Title Code</th>
    <th>Title Name</th>
    <th width="5%" style="text-align:center;">Edit</th>    
</tr>
<?php 
$i=1;
$sql=DB_query("select * from tbl_title_master where companyId='".$_SESSION['ACGCompanyId']."'",$db);
      $numrow=DB_num_rows($sql);
      if($numrow>0)
      {
      	while($row=DB_fetch_array($sql))
      		{
      		?>
<tr>
	<td><?php echo $i; ?></td>
	<td><?php echo $row['title_code']; ?></td>
	<td><?php echo $row['title_name']; ?></td>
	<td style="text-align:center;"><img src="images/icon-edit.png" onclick="createForEdit('<?php echo $row['emp_id']; ?>',this);" style="cursor:pointer;"><span onclick="saveForEdit('<?php echo $row['id']; ?>',this);" style="color:green;display:none;cursor:pointer;">Save</span></td>
	<!--<td><?php if($_SESSION['frmDelete']=='1'){?><a href="index.php?route=ToolPlants/fixed_assets/sub_asset_title_master_index&modid=<?php echo $_REQUEST['modid'];?>&frmid=<?php echo $_REQUEST['frmid'];?>&Id=<?php echo $row['id'];?>&act=del" onclick="return confirm('This record will be deleted. Are you sure?')"><img src="images/Icon_Delete.png" height="15" width="15"></a><?php }else{echo "No Permission";} ?></td>-->
</tr>   
<?php $i++; } } else { ?>
<tr><td colspan="4">No Records</td></tr>
<?php } ?>
</table>
</div>
</form>
</div></div>

<style type="text/css" >
.button{ background-color:#666666;
color: #FFFFFF;
height:25px;
margin:0px 5px 0px 5px;
border:1px solid #359CA2;
}
.link{ color:#9900CC; font-family:"Comic Sans MS"; letter-spacing:1px
}
</style>

<script type="text/javascript">
  function createForEdit(empid,obj)
  {//ajax_emp_loan_edit
  	 $(obj).hide();
  	 $(obj).next().show();
  	var opening=$(obj).closest('tr').find('td:eq(1)').html();
  	var openingYear=$(obj).closest('tr').find('td:eq(2)').html();
  
  	$(obj).closest('tr').find('td:eq(1)').html('<input type="text" value="'+opening+'" style="width:90%;" />');

  	$(obj).closest('tr').find('td:eq(2)').html('<input type="text" value="'+openingYear+'" style="width:90%;" />');
  	  
  	
  }

  function saveForEdit(empId,obj)
  {

  	$(obj).hide();
  	 $(obj).prev().show();
    var currOpening=$(obj).closest('tr').find('td:eq(1)').find('input[type="text"]').val();
    var CurrOpeningYear=$(obj).closest('tr').find('td:eq(2)').find('input[type="text"]').val(); 
     $(obj).closest('tr').find('td:eq(1)').html(currOpening);
     $(obj).closest('tr').find('td:eq(2)').html(CurrOpeningYear);
  // alert(currOpening);

   //alert(CurrOpeningYear);

     $.ajax({
            url : "ajax_sub_title_edit.php",
            type : "POST",
            data : {             
            emp_id:empId,
            opening:currOpening,
            forYear:CurrOpeningYear
         
            },
            success : function(data) {
            	//alert(data);
              
            alert('You have update record successfully !'); 
 
                          }
          });


  }
</script>


