<?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>Town</td>
    <td align="center">Edit</td>
    <td align="center">Delete</td>
  </tr>
  
  <?php

$district_id ='';
$client_code='';

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

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

$i=1;

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

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_district where dist_clientcode = $clientsubid "; 	
}

if($district_id!=''){
$sq_arr.=" and district_id = '$district_id' ";
}

if($client_code!=''){
$sq_arr.=" and dist_clientcode = '$client_code' ";
}


/*if($sdate_12!=''){
$sq_arr.=" and date='".$sdate."' ";
}*/
$sq_arr.=" order by district_id desc ";
$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){
while($res=mysql_fetch_array($array))
{
  ?> 
  <tr>
    <td><?php echo $res['district_id'];?></td>
    <td><a href="#login-box" class="login-window"><?php echo $res['district'];?></a></td>
    <td align="center" class="tr_td_b"><a href="add-town.php?page=<?php echo $page; ?>&districtid=<?php echo $res['district_id']; ?>&ab=<?php echo $i;?>"><img src="images/edit.png" title="edit"></a></td> 
   
    <td align="center" class="tr_td_r" ><a href="view-town.php?del=delete&id=<?php echo $res['district_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>