<?php include("header.php");
if(!isset($_SESSION['cid']))
{
	?>
		<script>
        	window.location="<?php echo $actual_link?>index";
        </script>
	<?php
}


//echo'<pre>';print_r($_POST);exit;
$msg="";
if(isset($_POST['submit']))
{
	$adsid=$_POST['adsid'];
	$amount=$_POST['amount'];
	$packid=$_POST['packid'];
	
	$update=mysql_query("update tbl_ads set admin_status='Approved' and package='$packid' and postdate=now() where ads_id='$adsid'");
	
	
	$msg="Ad renew successfully";
	
	
}

?>
 
<div class="main-container">
<div class="container">
<div class="row">
<?php include("profileside.php");?>
 
<div class="col-sm-9 page-content">
<div class="inner-box">
<h2 class="title-2"><i class="icon-hourglass"></i> My Pending Ads </h2>
<div class="table-responsive">
<?php if($msg!=="")
{
	?>
		<div class="alert alert-success">
          <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
		  <?php echo $msg;?>
        </div>
	<?php
}
?>

<div class="table-action">
<label for="checkAll">
<input type="checkbox" onclick="checkAll(this)" id="checkAll">
Select: All | <a  class="btn btn-xs btn-danger deleteAll">Delete <i class="glyphicon glyphicon-remove "></i></a> </label>
<div class="table-search pull-right col-xs-7">
<div class="form-group">
<label class="col-xs-5 control-label text-right">Search <br>
<a title="clear filter" class="clear-filter" href="#clear">[clear]</a> </label>
<div class="col-xs-7 searchpan">
<input type="text" class="form-control" id="filter">
</div>
</div>
</div>
</div>
<table id="addManageTable" class="table table-striped table-bordered add-manage-table table demo" data-filter="#filter" data-filter-text-only="true">
<thead>
<tr>
<th data-type="numeric" data-sort-initial="true"> </th>
<th> Photo </th>
<th data-sort-ignore="true"> Adds Details </th>
<th data-type="numeric"> Price </th>
<th> Option </th>
</tr>
</thead>
<tbody>
<?php $sqlads=mysql_query("select * from tbl_ads where posted_userid='".$_SESSION['cid']."' and admin_status='Renew'");
if(mysql_num_rows($sqlads)>0)
{

while($resads=mysql_fetch_assoc($sqlads))
{
$title = str_replace(' ', '-', $resadd['title']);
?>
<tr>
<td style="width:2%" class="add-img-selector"><div class="checkbox">
<label>
<input type="checkbox" name="adsDetails" class="adsDetails" id="<?php echo $resads['ads_id'];?>">
</label>
</div></td>
<td style="width:14%" class="add-img-td">
<a href="<?php echo $actual_link;?>ads_details/<?php echo $title;?>/<?php echo $resads['ads_id'];?>">
	<img class="thumbnail  img-responsive" src="<?php echo $actual_link."postedfile/".$resads['file1']?>" alt="img"></a></td>
<td style="width:58%" class="ads-details-td">
    <div>
        <p><strong> <a href="<?php echo $actual_link;?>ads_details/<?php echo $title;?>/<?php echo $resads['ads_id'];?>" title="<?php echo $resads['title'];?>"><?php echo ucfirst($resads['title']);?></a> </strong></p>
        <p> <strong> Posted On </strong>:
        <?php echo date('d M Y',strtotime($resads['postdate']));?> </p>
        <?php $sqllocat=mysql_query("select * from tbl_users where userid='".$_SESSION['cid']."'");
			  $reslocat=mysql_fetch_assoc($sqllocat);
			  
			  
			  $sqllcits=mysql_query("select * from tbl_cities where city_id='".$reslocat['city']."'");
			  $reslcits=mysql_fetch_assoc($sqllcits);
			  
			  
		?>
        <p> <!--<strong>Visitors </strong>: 221--> <strong>Located In:</strong> <?php echo $reslcits['cityname']?> </p>
    </div>
</td>
<td style="width:16%" class="price-td"><div><strong> <i class="fa fa-inr"></i>&nbsp; <?php echo $resads['price'];?></strong></div></td>
<td style="width:10%" class="action-td"><div>
<p><a class="btn btn-primary btn-xs" href="<?php echo $actual_link;?>post_ads/<?php echo $resads['ads_id'];?>"> <i class="fa fa-edit"></i> Edit </a></p>
<!--<p> <a class="btn btn-info btn-xs"> <i class="fa fa-mail-forward"></i> Share </a></p>-->
<p> <a class="btn btn-danger btn-xs deleteAd" id="<?php echo $resads['ads_id'];?>"> <i class=" fa fa-trash"></i> Delete </a></p>

<p> <a class="btn btn-default btn-xs Renew" value="<?php echo $resads['ads_id'];?>" href="#selectRegion" id="dropdownMenu1" data-toggle="modal"> <i class="fa fa-refresh" aria-hidden="true"></i>
 Renew </a></p>

</div></td>
</tr>

<?php }
}
else
{
	?>
		<tr align="center">
          <td colspan="5"><?php echo "No records available";?></td>
        </tr>
	<?php 
}
 ?>
</tbody>
</table>
</div>
 
</div>
</div>
 
</div>
 
</div>
 
</div>
 
<?php include("footer.php");?>

<div class="modal fade" id="selectRegion" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<div class="well">
<h3><i class=" icon-certificate icon-color-1"></i> Make your Ad Premium </h3>
<p>Premium ads help sellers promote their product or service by getting their ads more visibility with more
buyers and sell what they want faster. <a href="help.html">Learn more</a></p>
<div class="form-group">
<table class="table table-hover checkboxtable">
<?php $sqlpackage=mysql_query("select * from tbl_package where status='Enable'");
      while($respackage=mysql_fetch_assoc($sqlpackage))
	  {
?>

<tr>
	<td>
    	<div class="radio">
			<label>
				<input type="radio" name="package" class="package" id="<?php echo $respackage['pid']?>" value="<?php echo $respackage['pid'];?>">
				<strong><?php echo $respackage['name'];?></strong> 
            </label>
		</div>
    </td>
	<td>
    	<p><i class="fa fa-inr"></i> <b id="pack<?php echo $respackage['pid'];?>"><?php echo $respackage['amount'];?></b> for <?php echo $respackage['dnumber']." ".$respackage['duration'];?>	
        </p>
    </td>
</tr>

<?php } ?>



<tr>
<!--<td><div class="form-group">
<div class="col-md-8">
<select class="form-control" name="Method" id="PaymentMethod">
<option value="2">Select Payment Method</option>
<option value="3">Credit / Debit Card </option>
<option value="5">Paypal</option>
</select>
</div>
</div></td>-->
  

<td id="pay"></td>
</tr>
</table>
<form method="post">
<input type='hidden'  name='adsid' id="adsid">
<input type='hidden'  name='amount' id="payment">
<input type='hidden'  name='packid' id="packid">
<button type="submit" name="submit" class="btn btn-primary">Pay</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</form>


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



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

<script>
$(".Renew").click(function(){
	$("#adsid").val($(this).attr('value'));

});

$(".package").change(function(){
	
	var val=$(this).val();
	
	$("#packid").val($(this).attr('id'));
	
	var amnt=$("#pack"+val).html();
	$("#pay").html("<p> <strong>Payable Amount : <i class='fa fa-inr'></i> "+amnt+"</strong></p>");
	$("#payment").val(amnt);

});
</script>
 

