
<?php

$i=1;
include("../include/config.php");
require_once "../include/Database_functions.php";
?>

  <table  border="0" cellspacing="0" cellpadding="0" class="tableList">
  <tr class="heading">
    <td>No</td>    
    <td>Ledger Name</td>    
    <td>Group Name</td>
	<td>Opening Balance</td>
    <td>Edit</td>
    <!--<td>Delete</td>-->  
  </tr>
  
<?php

$ledger_name ='';
$parent_name='';


if(isset($_REQUEST['ledger_name'])){
$ledger_name=$_REQUEST['ledger_name'];
}

if(isset($_REQUEST['parent_name'])){
$parent_name=$_REQUEST['parent_name'];
}


$i=1;
$sq_arr="SELECT a.*,b.category as parent FROM cf_ledger a LEFT JOIN cf_account_groups b ON b.id = a.groupid WHERE a.status = '1' ";

if(isset($_REQUEST['ledger_name']) && $_REQUEST['ledger_name']!=''){
$ledger_name=$_REQUEST['ledger_name'];
$sq_arr.="and   a.ledgername like '%".$ledger_name."%'";
}
if(isset($_REQUEST['parent_name']) && $_REQUEST['parent_name']!=''){
$parent_name=$_REQUEST['parent_name'];
$sq_arr.="and   a.groupid='$parent_name'";
}
$sq_arr.=" order by a.ledgerid asc ";
$query=$sq_arr;
//echo $query;
$function="Searchdate";
include("../paging.php");
$sq_arr.=" LIMIT $start, $limit";

if(isset($_REQUEST['page'])){
$page=$_REQUEST['page'];
}else{
$page=10;
}

$array=mysql_query($sq_arr);
if($array && mysql_num_rows($array)>0){
$pagecnt=$start;
while($res=mysql_fetch_array($array))
{

$pagecnt++;
  ?> 
  <tr>
    <td><?php echo $pagecnt;?></td>
    <td><?php echo $res['ledgername'];?></td>
    <td><?php echo $res['parent'];?></td>
    <td><?php echo $res['opening_balance'];?></td>
   <td class="tr_td_b"> <a href="#login-box" class="login-update" style="font-weight:bold;" data-id=<?php echo $res['ledgerid']?>><img src="images/edit.png" title="edit"><input type="hidden" name="acc_id" id="acc_id<?php echo $res['ledgerid'];?>" value="<?php echo $res['ledgerid'];?>" /></a></td>
   
   <?php /*?><td class="tr_td_r" ><a href="account-ledger.php?del=delete&id=<?php echo $res['ledgerid']; ?>" onClick="return confirm('Do you really want to delete this field?');"><img src="images/delete.png" title="delete"></a></td><?php */?>
   
  </tr>
  <?php 
    }}
  ?>
 
  
   
</table>
  
   <div align="right" style="padding-top:10px;"><?=$pagination?></div>