<?php include("header.php");
//echo'<pre>';print_r($_GET);

$sqlqueryd=mysql_query("select * from tbl_queries where queryid='".$_GET['queryid']."'");
$resqueryd=mysql_fetch_assoc($sqlqueryd);




$for_adid=$resqueryd['for_adid'];

$querybyid=$resqueryd['querybyid'];

$sqlus=mysql_query("select * from tbl_users where userid='".$querybyid."'");
$resus=mysql_fetch_assoc($sqlus);

$sqladdd=mysql_query("select * from tbl_ads where ads_id='".$for_adid."'");
$resaddd=mysql_fetch_assoc($sqladdd);

$suggested_ads=$resqueryd['suggested_ads'];
 $query=$resqueryd['query'];






?>
 
<div class="main-container">
<div class="container">
<div class="row">

<?php include("profileside.php");?>
<div class="col-sm-9 page-content col-thin-left">
<div class="category-list">

 
<ul class="nav nav-tabs add-tabs" id="ajaxTabs" role="tablist">
<li class="active"><a href="#allAds" data-url="" role="tab" data-toggle="tab" aria-expanded="true">Requests </a></li>


</ul>

</div>
 

 
<div class="adds-wrapper">
<div class="tab-content">
<div class="tab-pane active" id="allAds"><table class="table"><tr>
<th><?php echo $resus['fullname']; ?>&nbsp; Listing</th>
<th>Phone Number</th>
<th>My Listing</th>
<th>Query</th>
<th>Status</th></tr>
<tr>
<td><?php
if($suggested_ads!=="")
{

$exp=explode(",",$suggested_ads); 
foreach($exp as $expr)
{
	$sqladdd1=mysql_query("select * from tbl_ads where ads_id='".$expr."'");
	$resaddd1=mysql_fetch_assoc($sqladdd1);
	
	?>
	<img src="<?php echo $actual_link."postedfile/".$resaddd1['file1']?>" height="60" width="60"><br><?php echo $resaddd1['title']."<br>";
	
	$sqladdd2=mysql_query("select * from tbl_cities where city_id='".$resus['city']."'");
	$resaddd2=mysql_fetch_assoc($sqladdd2);
	
	echo $resus['locality']." ".$resaddd2['cityname']."<br>";
	?>
    
	<?php
}
}
else
{
	echo "No listing found";
}
?></td>

<td><?php if($resus['hidenumber']=="") { echo $resus['number']; }
else
{
	echo "hide";
}
?></td>
<td><img src="<?php echo $actual_link."postedfile/".$resaddd['file1']?>" height="60" width="60"><br><?php echo $resaddd['title']?></td>
<td><?php echo $query;?></td>
<td>
<div id="st"><?php echo "<strong>".$resqueryd['status']."</strong>";?></div>
<?php 

if($resqueryd['status']=="rejected")
{
	?>
    <input type="submit" class="btn btn-success Accept" value="Accept">
    <input type="submit" class="btn btn-danger Reject" value="Reject" style="display:none;">
	<?php
}
else
{
	if($resqueryd['status']=="accepted")
	{
		?>
        <input type="submit" class="btn btn-success Accept" value="Accept" style="display:none;"> 
        <input type="submit" class="btn btn-danger Reject" value="Reject">
		<?php
	}
	else
	{
	?>
	<input type="submit" class="btn btn-success Accept" value="Accept">
	<input type="submit" class="btn btn-danger Reject" value="Reject">
<?php
	}
} ?>    </td>
</table></div>


</div>
</div>
 

</div>

 
<div class="post-promo text-center">

</div>
 
</div>
</div>
 
</aside>
</div>







 
</div>
 
</div>
 
</div>
 
<?php include("footer.php");?>


<script>
$(".Reject").click(function(){
	$(this).hide();
	$("#st").html("<strong>Rejected</strong>");
	$(".Accept").show();
	//$(this).parent('td').html('rejected');
	
$.post("<?php echo $actual_link;?>ajax/ajax_query_status.php",{status:"rejected",ad:<?php echo $for_adid;?>,id:<?php echo $_GET['queryid'];?>},function(data){
/*if($(".envl b").html()>0)
	{
		var ts=$(".envl b").html()+parseInt(1);
		
	    $(".envl b").html(ts);
		
	}
	else
	{
		$(".envl b").html(1);
	}*/

});
});

$(".Accept").click(function(){
	$(this).hide();
	$("#st").html("<strong>Accepted</strong>");
	$(".Reject").show();
$.post("<?php echo $actual_link;?>ajax/ajax_query_status.php",{status:"accepted",ad:<?php echo $for_adid;?>,id:<?php echo $_GET['queryid'];?>},function(data){
	/*if($(".envl b").html()>0)
	{
		var ts=$(".envl b").html()-parseInt(1);
		
		if(ts>0)
		{
			$(".envl b").html(ts);
		}
		else
		{
			$(".envl b").html("");
		}
	}*/
	

});
});
</script>
