<?php

include '../includes/connection.php';

if(isset($_GET['bid']) && isset($_GET['bcode'])){
$bid=$_GET['bid'];
$bcode=$_GET['bcode'];

$sql="SELECT * from licences where business_id=$bid AND blicence='$bcode'  ";

$result=mysqli_query($con, $sql);
if(!$result){
	die ('ERROR'.mysqli_error($con));
}else{
$countbusiness=mysqli_num_rows($result);
	if($countbusiness==1){
	    $row=mysqli_fetch_array($result);
	    $startdate=$row['startdate'];
	    $enddate=$row['enddate'];
	     $serial=$row['hdserial'];
	   $nextexpiry= $row['enddate'];
	    $startdate=strtotime($startdate);
	    $enddate=strtotime($enddate);
	   //  $serial=md5($seria);
	    
	    $now=time();
	    if($now>=$enddate){
	   	
	      echo "<script>alert('Sorry Your licence expired.Contact +256777844758 or email info@nugsoft.com');</script>";
          
         echo "<script>window.location='http://127.0.0.1/poscream'</script>";
        
	        
	    }else{
	    
 echo "<script>alert('Congrats! Software activated successfully till $nextexpiry');</script>";
 echo "<script>window.location='http://127.0.0.1/poscream/includes/activate_software.php?key1=$startdate&&key2=$enddate&&bid=$bid&&serial=$serial'</script>";
//header("location:http://127.0.0.1/pos.com/includes/activate_software.php?key1=$startdate&&key2=$enddate&&bid=$bid&&serial=$serial");		
	    }	
		
	}else{
 echo "<script>alert('Sorry Invalid Licence Code.Contact +256777844758 or +256706397621(Whatsapp) or email info@nugsoft.com');</script>";
          
         echo "<script>window.location='http://127.0.0.1/poscream'</script>";
	    
	    
	}
}

}




?>