<?php
session_start();
$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>Vendor Code</td>
    <td>Vendor Name</td>
    <td>Address</td>
    <td>Phone No</td>
    <td>Contact Person</td> 
    <td>Tin No</td> 
    <td>Edit</td>
    <td>Delete</td>
  </tr>
  
<?php
$dealer_name ='';
$con_person ='';
$client_code='';
$fromdate='';
$todate='';

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



$i=1;
if(($_SESSION['typename'] == 'SuperAdmin')) {
	$sq_arr="select * from cf_reseller where re_type = 2 ";	
}

if(($_SESSION['typename'] == 'SubAdmin')) {	
	$userids = $_SESSION['admin_id'];
	
	$sq_user1 = mysql_query("select cf_client.client_sub_id from cf_user_clientid join cf_client on cf_user_clientid.client_code = cf_client.client_newcode where cf_user_clientid.user_id = '$userids' ");
	$rw1=mysql_fetch_array($sq_user1);
	$clientsubid = $rw1['client_sub_id'];
	$sq_arr="select * from cf_reseller where client_subid = $clientsubid "; 	
}

if($dealer_name!=''){
$sq_arr.=" and res_name like '%".$dealer_name."%' ";
}


$sq_arr.=" order by reseller_id desc ";
$query=$sq_arr;
//echo $query;
$function="Searchdate";
include("../pagingserch.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['re_code'];?></td>
    <td><?php if($res['res_name']!='')echo $res['res_name'];else echo '--'; ?></td>
    <td><?php if($res['re_address']!='')echo $res['re_address'];else echo '--'; ?></td>
    <td><?php if($res['re_contactno']!='')echo $res['re_contactno'];else echo '--'; ?></td>
    <td><?php if($res['re_consperson']!='')echo $res['re_consperson'];else echo '--'; ?></td>
    <td><?php if($res['re_tino']!='')echo $res['re_tino'];else echo '--'; ?></td>
   <td align="center" class="tr_td_b"><a href="add-reseller.php?resellerid=<?php echo $res['reseller_id']; ?>&ab=<?php echo $i;?>"><img src="images/edit.png" title="edit"></a></td>
   <td align="center" class="tr_td_r" ><a href="reseller-list.php?del=delete&id=<?php echo $res['reseller_id']; ?>" onClick="return confirm('Do you really want to delete this field?');"><img src="images/delete.png" title="delete"></a></td>
    
   
  </tr>
  <?php 
    }}
  ?>
 
  <!--<tr>
    <td><input type="checkbox">2</td>
    <td>2323d</td>
    <td>jinesh</td>
    <td>jose</td>
    <td>9443274636</td>
    <td>email@gmail.com</td>
    <td>design</td>
    <td>designer</td>
    <td>23/4/11</td>
    <td><div class="deletedStat"></div></td>
    <td><a href="#">
      <div class="actEdit"></div><div class="actDelete"></div>
    </a></td>
  </tr>-->

   
</table>
  
   <div align="right" style="padding-top:10px;"><?=$pagination?></div>