<?php include("header.php");
//error_reporting(0);

$msg="";
$Gpackage="";
if(!isset($_SESSION['cid']))
{
	?><script>window.location="<?php echo $actual_link;?>post_ads";</script><?php
	
}
//echo'<pre>';print_r($_POST);exit;
$update=false;
if(isset($_POST['post']))
{
	if(isset($_GET['lastid']))
	{
		$lastid=$_GET['lastid'];
		
		$sqlpa=mysql_query("select * from tbl_package where amount<1");
		$respa=mysql_fetch_assoc($sqlpa);
		
		$update=mysql_query("update tbl_ads set package='".$respa['pid']."' where ads_id='$lastid'");

		
	}
	
}


if(isset($_POST['pay']))
{
	if(isset($_GET['lastid']))
	{
		if(isset($_POST['package']))
		{
			$package=$_POST['package'];
		}
		
		$lastid=$_GET['lastid'];
		
		
		$update=mysql_query("update tbl_ads set package='$package' where ads_id='$lastid'");
	}
}

if($update==true)
{
	?>
	<script>
	window.location="<?php echo $actual_link;?>posting-success";
	</script>
	<?php
}

?>

<div class="main-container">
<div class="container">
<div class="row">
<div class="col-md-9 page-content">

<div class="inner-box category-content">

<h2 class="title-2 uppercase"><strong> <i class="icon-docs"></i> Post a Free Classified Ad</strong> </h2>
<div class="row">
<div class="col-sm-12">
<form class="form-horizontal" method="post" enctype="multipart/form-data">
<fieldset>
 
<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.</p>
<div class="form-group">
<table class="table table-hover checkboxtable">
<?php $sqlpackage=mysql_query("select * from tbl_package where status='Enable' order by amount asc");
      while($respackage=mysql_fetch_assoc($sqlpackage))
	  {
		  
		  if($respackage['amount']>1)
		  {
?>

<tr>
	<td>
    	<div class="radio">
			<label>
				<input type="radio" <?php if($Gpackage==$respackage['pid']) { echo "checked";} ?> name="package" class="package" value="<?php echo $respackage['pid'];?>" required="">
				<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>-->
<?php 

	  $sqlspack=mysql_query("select * from tbl_package where pid='".$Gpackage."'");
	  $resspack=mysql_fetch_assoc($sqlspack);
      
	  
?>	  

<td id="pay"><p> <strong>Payable Amount : <i class='fa fa-inr'></i> <?php echo $resspack['amount'];?></strong></p></td>
</tr>
</table>
</div>
</div>
 
<!--<div class="form-group">
<label class="col-md-3 control-label">Terms</label>
<div class="col-md-8">
<label class="checkbox-inline" for="checkboxes-0">
<input name="checkboxes" id="checkboxes-0" value="Remember above contact information." type="checkbox">
Remember above contact information. </label>
</div>
</div>-->

<div class="form-group">

<div class="col-md-4"> <button  id="button1id" name="pay" type="submit" class="btn btn-primary pay">Pay</button> 
<button  id="button1id" name="post" type="submit" class="btn btn-success post">Continue Free Ad</button>
</div>

</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
 
<div class="col-md-3 reg-sidebar">
<div class="reg-sidebar-inner text-center">
<div class="promo-text-box"> <i class=" icon-picture fa fa-4x icon-color-1"></i>
<h3><strong>Post a Free Classified</strong></h3>
<p> Post your free online classified ads with us. Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p>
</div>
<div class="panel sidebar-panel">
<div class="panel-heading uppercase"><small><strong>How to sell quickly?</strong></small></div>
<div class="panel-content">
<div class="panel-body text-left">
<ul class="list-check">
<li> Use a brief title and description of the item </li>
<li> Make sure you post in the correct category</li>
<li> Add nice photos to your ad</li>
<li> Put a reasonable price</li>
<li> Check the item before publish</li>
</ul>
</div>
</div>
</div>
</div>
</div> 
</div>
 
</div>
 
</div>

<?php include("footer.php");?>
<script src="<?php echo $actual_link;?>jquery.min.js" type="text/javascript"></script>




<script>




/*$('input[name="file3"]').click(function(){
	$('input[name="file1"]').attr('required=""',true);
	$('input[name="file2"]').attr('required=""',true);
});
$('input[name="file4"]').click(function(){
	$('input[name="file1"]').attr('required=""',true);
	$('input[name="file2"]').attr('required=""',true);
	$('input[name="file3"]').attr('required=""',true);
});
$('input[name="file5"]').click(function(){
	$('input[name="file1"]').attr('required=""',true);
	$('input[name="file2"]').attr('required=""',true);
	$('input[name="file3"]').attr('required=""',true);
	$('input[name="file4"]').attr('required=""',true);
});
*/

// initialize with defaults



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

});

$(".post").click(function(){
$("input[name='package']").attr("required",false);
});
















</script>

 <style>
 @media only screen and (max-width: 920px) {
	  .more
 {
	 margin-top:2%;
 }
  .more1
 {
	 margin-top:1%;
 }
 .ms
 {
	 margin-top:5%;
 }
	 
 }
 
 
 .more1
 {
	 margin-top:1%;
 }
 .more
 {
	 margin-top:5%;
 }
 
 </style>
 





