<?
ob_start();
session_start();
if(isset($_SESSION['ses_name']))
{
$user=$_SESSION['ses_name'];
}else{
header("location:index.php");
}


$veh_num='';
$sdate_12 ='';
$page='1';
include("include/config.php");
require_once "include/Database_functions.php";
$sqlObj=new sqlclass();
$msg = '';

if(isset($_REQUEST['del']) && $_REQUEST['del']=='delete')
{
	$id = $_REQUEST['id'];
	$sql=mysql_query("delete from cf_reseller where reseller_id='$id'");
	header("location:reseller-list.php?msg=You Have Successfully Deleted");
}

?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>OIL FILL</title>
<link href="css/styles.css" rel="stylesheet"  />
<link href="css/menu.css" rel="stylesheet" type="text/css" />
<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 src="js/trippopup.js" type="text/javascript"></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(){
$('#fromdate').datepicker({
showOn: 'both',
buttonImage: 'icons_date/calendar.gif',
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
dateFormat: 'yy-mm-dd'
});
});

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

function getXMLHTTP()
	 { //fuction to return the xml http object
	var xmlhttp=false;	
		try
		{
		xmlhttp=new XMLHttpRequest();
		}
		catch(e)	
		{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
				}
			catch(e)
			{
				try
				{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1)
				{
				xmlhttp=false;
				}
			}
		}
	return xmlhttp;
	}   


function Searchdate(val)
{ 
 	
	 var page=val;	
	 var dealer_name='';
	 var con_person='';
	 var client_code='';
	 	
	 if(document.client_frm.dealer_name){
	 dealer_name= document.client_frm.dealer_name.value;
	 }
	 
	 
	 
	var strURL="ajax/reseller_data.php?&page="+page;
	if(dealer_name!=''){
	strURL+="&dealer_name="+dealer_name;
	}
	
	
	
	//alert(strURL);
		
	var req = getXMLHTTP();
   if (req)
   {
     req.onreadystatechange = function()
     {
		 
			if ((req.readyState == 0)||(req.readyState == 1)||(req.readyState == 2)||(req.readyState == 3))
      		{
			//document.getElementById('order').innerHTML='<div align="center"><img src="'+path+'images/ajax_loader.gif"/></div>';
			//document.getElementById('Cakeorder').innerHTML='<div align="center"><img src="'+path+'images/ajax_loader.gif"/></div>';
			}
		 
		 
      if (req.readyState == 4)
      {
	 // only if "OK"
	 	if (req.status == 200)
	 	{ 
	   document.getElementById('list').innerHTML=req.responseText;
	//	document.getElementById('Cakeorder').innerHTML=req.responseText;
	 	}
	  else 
	 	{
   	   alert("There was a problem while using XMLHTTP:\n" + req.statusText);

	 }
     }
     }
   req.open("GET", strURL, true);
   req.send(null);
   }
 
   
}
</script>
</head>

<body>
<!------------------popup area (view, edit)--------------->



<!---------------popup area ends------------------>
<div class="wrapper">
   <div>
<?php 
	include("header.php");
?>
 
</div>
 
 <div class="tabbedArea">
 
  
  <div class="tabBody">
   <h1>Vendor List</h1>
   <form name="client_frm" id="client_frm" method="post"  >
   <div class="searchBox" style="width:93%; margin-right:0px;  padding:0px; ">
   <div style="padding:20px;">
   <div class="searchField" style="padding-left:20px;">
     <p class="input1">Vendorr Name</p>
     <input type="text" name="dealer_name" id="dealer_name" class="input1" />
    </div>
   
    
       
    <div class="searchField">
     <input name="button" type="button" class="input1" onClick="Searchdate(1);" value="search" />
    </div>
  
   </div>
   </div>
   </form>
   <div id="list">
   <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


/*
if(isset($_REQUEST['typename'])){
$typenames=$_REQUEST['typename'];
}*/

$i=1;

if(($_SESSION['typename'] == 'SuperAdmin')) {
	$sq_arr="select * from cf_reseller where re_type = 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_reseller where client_subid = $clientsubid "; 	
}

//$sq_arr="select * from cf_reseller where 1 ";
/*if($veh_num!=''){
$sq_arr.=" and client_name like '%".$veh_num."%' ";
}

if($veh_num!=''){
$sq_arr.=" and client_conper like '%".$veh_num."%' ";
}*/


$sq_arr.=" order by reseller_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){
$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> 
  </div>
  </div>
 </div>
 <div class="footer"><p>Powered by <a href="http://www.aadhocc.co.uk/" target="_blank">Aadhocc</a></p></div>
 
</div>
<div class="quicLInksCover">
 <?php 
	include("leftlink.php");
?>

</div>
</body>
</html>
