<?php
	//Start session
	session_start();
	
	//Check whether the session variable SESS_MEMBER_ID is present or not
	if(!isset($_SESSION['SESS_MEMBER_ID']) || (trim($_SESSION['SESS_MEMBER_ID']) == '')) {
		header("location: index.html");
		exit();
	}
?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Master Edit</title>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<meta http-equiv="Content-Type"
 content="text/html; charset=iso-8859-1"/>
<script type="text/javascript" src="javascript/jquery.js"></script>
<script type="text/javascript" src="javascript/jquery.autocomplete.js"></script>

<link rel="stylesheet" href="css/jquery.autocomplete.css" type="text/css" >
</link>
<link rel="stylesheet" href="css/style.css"  type="text/css">
</link>
<style type="text/css">
input[type=text],textarea{
	width:100%
}
</style>
<script type="text/javascript">
$(document).ready(function(){	
$("#close").click(function(){
						   
window.close();

  });
  
  $("#new").click(function(){
						   
window.location='voucherlededit.php';

  });
  
   $("#update").click(function(){
			$('#transperent').show();			   
$.post("master_led_crud.php?mode=update",$('#form_vehextra').serialize(),function(result){
	
		 $('#message').html(result);
			$('#transperent').hide();		
	 });

  });
  
  $("#save").click(function(){
$('#transperent').show();						   
$.post("master_led_crud.php?mode=insert",$('#form_vehextra').serialize(),function(result){
	var str=result.split('###');
	 $('#ID').val(str[1]);
		 $('#message').html(str[0]);
					
	 });$('#transperent').hide();

  });
  


  
  
});


</script>

</head>

<body>
<div id="transperent" >
</div>
<div class="main">

  <div class="page">
 <div>
      <?php 
	    
		
  include '../db_connect.php';
  
$ledger=$_GET['mode'];
if(($result = mysqli_query($con,"SELECT * FROM ledgerreg  where alias='$ledger'"))&&(!empty($ledger)))
{
$row = mysqli_fetch_array($result);
}

?>

<form  id="form_vehextra" action=""  method="" style="margin:auto" >

 <table  cellspacing="5" align="left" style="border: 1px solid;padding: 5px;border-radius: 5px;" >
		  <tr>
		    <td align="right">LEDGER</td>
		   <td colspan="3" align="center"><input type="text" name="ledger" id="ledger" />
          <input type="hidden" name="ID" id="ID" readonly /></td>
	    </tr>
			  <tr>
			    <td align="right">ALIAS</td>
			    <td colspan="3"><input name="alias" type="text" id="alias"  /></td>
	    </tr>
			  <tr>
			    <td align="right">LEDGER TYPE</td>
			    <td colspan="3" align="center"> <input type="text" name="ledtype" id="ledtype"/></td>
	      </tr>
			  <tr>
			    <td align="right">OPENING BAL.:</td>
			    <td><input type="text" name="openingbal" id="openingbal" /></td>
			    <td align="right">&nbsp;</td>
			    <td>&nbsp;</td>
	    </tr>
			  <tr>
              
			    <td colspan="4">
                <input type="button" class="button" id="update" value="UPDATE" style="display:none" />
                <input type="button" class="button" id="save" value="SAVE" />
			      <input type="button" class="button" id="new"  value="NEW" />
			      <input type="button" class="button" id="close"  value="CLOSE" />
</td>
	      </tr>
			  
	  </table>
    
</form>
 <div id="message" style="width:100%; text-align: left;font-weight: bold;color: #0064D1;"> </div>
    </div>


  </div>
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){
<?php if($ledger!='')
{?>
$('#save').hide();
$('#update').show();
$('#ID').val('<?php echo clean($con,$row['id']); ?>');
$('#ledger').val('<?php echo clean($con,$row['ledger']); ?>');
$('#alias').val('<?php echo clean($con,$row['alias']); ?>');
$('#ledtype').val('<?php echo clean($con,$row['ledtype']); ?>');
$('#openingbal').val('<?php echo clean($con,$row['openingbal']); ?>');


<?php }?>

$("#ledger").autocomplete(
		 "billedto.php?",
	  {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
  			autoFill:false
  		}
    );
	
	$("#city").autocomplete(
      "city.php?",
      {
  			delay:10,
  			minChars:1,
  			matchSubset:1,
  			matchContains:1,
  			cacheLength:10,
			mustMatch:1,
  			autoFill:false
  		}
    );
	});
	  $(window).load(function() {
    $('#transperent').hide();
	  });
</script>


</body>
</html>