<?php
include("../include/config.php");
//require_once "../include/Database_functions.php";
//$sqlObj=new sqlclass();

$ledger_start_dt='';
if(isset($_GET['editid']) && $_GET['editid']!='')
{

$editid=$_GET['editid'];
$edit_drop=mysql_query("select * from cf_ledger where status=1 and ledgerid='$editid'");
if($edit_drop && mysql_num_rows($edit_drop)>0){

while($edit_res=mysql_fetch_array($edit_drop))
{
$ledgername=$edit_res['ledgername'];
$groupid=$edit_res['groupid'];
$opening_balance=$edit_res['opening_balance'];
$cr_dt=$edit_res['cr_dt'];
$ledger_start_dt=date(('d-m-Y'),strtotime($edit_res['ledger_start_date']));
}
}
?>

<?php /*?><link type="text/css" href="../css_date/ui-lightness/jquery-ui-1.7.2.custom.css" rel="stylesheet" />
<script type='text/javascript' src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>



<script type='text/javascript' src="../js/jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="../js/jquery.autocomplete.css" />

<script type="text/javascript" src="../scripts_date/jquery-calendar-1.7.2.js"></script>
<script language="javascript">

$(document).ready(function(){
$('#pay_date').datepicker({
showOn: 'both',
buttonImage: 'icons_date/calendar.gif',
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: 'yy-mm-dd'
});
});<?php */?>

</script>
<form name="frm" method="post">
<table width="67%" border="0" cellspacing="0" cellpadding="0" align="center" style="margin-top:25px;">
<tr><input type="hidden" name="hid_id" id="hid_id" value="<?=$editid?>" />
<td width="300px;">Ledger Name</td><td width="100px;"><input type="text" name="addledger_name" id="addledger_name" value="<?=$ledgername?>" class="input1"></td>
</tr><tr>
<td width="400px;">Parent Group</td><td width="100px;"> <select name="addparent_name" id="addparent_name" class="input1" >
	 <option value="">Select one</option>
	 <?php
	 	$cf_drop="select * from cf_account_groups where status=1 ";
$cf_array=mysql_query($cf_drop);
if($cf_array && mysql_num_rows($cf_array)>0){

while($cf_res=mysql_fetch_array($cf_array))
{

?>
<option <?php if($cf_res['id']==$groupid){?> selected="selected" <?php } ?> value="<?=$cf_res['id']?>"><?=$cf_res['category']?></option>

<?php
}
	} 
	 ?>
	 </select></td>
</tr>
<tr><td width="300px;">Opening Balance</td><input type="hidden" name="oldopeningbal" id="oldopeningbal" value="<?=$opening_balance?>" class="input1">
<td width="100px;"><input type="text" name="addopeningbal" id="addopeningbal" value="<?=$opening_balance?>" class="input1"></td></tr>

<tr><td width="300px;">Ledger Type</td><td width="100px;">
<input type="radio" name="crdt" value="1" <?php if($cr_dt == 1){?> checked <?php }?>> Credit<br>
<input type="radio" name="crdt" value="2" <?php if($cr_dt == 2){?> checked <?php }?>> Debit<br></td></tr>

<tr><td width="300px;">Date</td><td width="100px;">
<input type="text" name="pay_date" id="pay_date"  class="slabinput input1" style="width:70px;" value="<?=$ledger_start_dt?>" />
</td></tr>

<tr><td><input type="submit" name="editledger" value="Update" class="input1"></td>

</tr>
  </table></form>
<?php
}
else
{?>
<form name="frm" method="post">
<table width="67%" border="0" cellspacing="0" cellpadding="0" align="center" style="margin-top:25px;">
<tr>
<td width="300px;">Ledger Name</td><td width="100px;"><input type="text" name="addledger_name" id="addledger_name" value="" class="input1"></td>
</tr><tr>
<td width="400px;">Parent Group</td><td width="100px;"> <select name="addparent_name" id="addparent_name" class="input1" >
	 <option value="">Select one</option>
	 <?php
	 	$cf_drop="select * from cf_account_groups where status=1 ";
$cf_array=mysql_query($cf_drop);
if($cf_array && mysql_num_rows($cf_array)>0){

while($cf_res=mysql_fetch_array($cf_array))
{

?>
<option value="<?=$cf_res['id']?>"><?=$cf_res['category']?></option>

<?php
}
	} 
	 ?>
	 </select></td>
</tr>
<tr><td width="300px;">Opening Balance</td><td width="100px;"><input type="text" name="addopeningbal" id="addopeningbal" value="" class="input1"></td></tr>

<tr><td width="300px;">Ledger Type</td><td width="100px;">
<input type="radio" name="crdt" value="1"> Credit<br>
<input type="radio" name="crdt" value="2"> Debit<br></td></tr>

<tr><td width="300px;">Date</td><td width="100px;">
<input type="text" name="pay_date" id="pay_date"  class="slabinput input1" style="width:70px;" value="<?=$ledger_start_dt?>" />
</td></tr>

<tr><td><input type="submit" name="addledger" value="Submit" class="input1"></td>

</tr>


  </table></form>
  <?php
}  ?>