<?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>Group Name</td>    
    <td>Parent Group</td>
    <td>Edit</td>
    <td>Delete</td>
  </tr>
  
<?php

$group_name ='';
$parent_name='';


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

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


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

if(isset($_REQUEST['group_name']) && $_REQUEST['group_name']!=''){
$group_name=$_REQUEST['group_name'];
$sq_arr.="and   a.category like '%".$group_name."%'";
}
if(isset($_REQUEST['parent_name']) && $_REQUEST['parent_name']!=''){
$parent_name=$_REQUEST['parent_name'];
$sq_arr.="and   a.mainid='$parent_name'";
}
$sq_arr.=" order by a.category 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['category'];?></td>
    <td><?php echo $res['parent'];?></td>
    
   <td class="tr_td_b"> <a href="#login-box" class="login-update" style="font-weight:bold;" data-type=<?php echo $res['id'];?>><img src="images/edit.png" title="edit"><input type="hidden" name="acc_id" id="acc_id<?php echo $res['id'];?>" value="<?php echo $res['id'];?>" /></a></td>
   
   <td class="tr_td_r" ><a href="account-groups.php?del=delete&id=<?php echo $res['id']; ?>" onClick="return confirm('Do you really want to delete this field?');"><img src="images/delete.png" title="delete"></a></td>
   
  </tr>
  <?php 
    }}
  ?>
 
  
   
</table>
  
   <div align="right" style="padding-top:10px;"><?=$pagination?></div>