<?php session_start();  //Developed by ITechScripts
    require 'include/announcements.php'; // ITECHBIDS Configuration File
    require 'include/options.php'; // ITECHBIDS Configuration File
    require 'include/itechbids.php'; // ITECHBIDS Configuration File
	$amount=$_SESSION['amount'];
	if( $_SESSION['amount']!='') 
	{
		$amount=$_SESSION['amount'];
		$mem_plans=$_SESSION['mem_plans'];
		$payment_gateway=$_SESSION['regpay'];
		$productid=$_SESSION['productid'];
		$userid=$_SESSION['regmem'];
        $checkpay=$_SESSION['checkpay'];
        $txn_id=$_SESSION['txn_id'];
        $trn_id=$_SESSION['trn_id'];
		$trans_date=date('Y-m-d');

$duration = site_plans($mem_plans, 'duration');
function addDay($date,$interval) 
  { 
  if (!isset($date)) 
  $date = date("Y-m-d"); 
  $elts = explode("-", $date); 
  $inter=$interval*24*3600; 
  $dcour=mktime(1,0,0,$elts[1],$elts[2],$elts[0]); 
  $dres=$dcour+$inter; 
  $date1=date("Y-m-d",$dres);
  $sec=date("G:i:s");
  $ret_date="$date1"." "."$sec";
  return $ret_date; 
}
if($duration!=0)
{
$start_date=date("y-m-d");
$expir_date= addDay($trans_date,$dur);  
}
if($duration==0)
{
$expir_date = "";
}
	
if($checkpay=="yes")
{
$up_sql="update member_details set payment_status='yes' where user_id=$userid";	
mysql_query($up_sql);
$query="update f_members set status='Active', start_date=now(), exp_date='$expir_date', fee_id=$mem_plans where user_id=$userid";
mysql_query($query);

if(site_plans($mem_plans, 'shop_free')=="yes"){
      $query="insert into shopfronts (user_id,shop_name,status,start_date,expir_date,scheme)values('$userid','My Shop','enable',now(),'$expir_date',99)";
       mysql_query($query);
}

$insert_query="insert into usertransaction(trans_amount,itemid,user_id,trans_batchnumber,trans_date, trans_details, txn_id, type, currency, typeofpay) values($amount,'$productid','$userid','$trn_id','$trans_date', 'Registration Fee', '$txn_id', 'Debit', '$pay_currency', 'regsuccess')";	
$insert_result=mysql_query($insert_query);
$sucess_flag=1;
		}
		else
		{
			 $failureflag=1;
		}
		$_SESSION['amount']='';
		$_SESSION['productid']='';
		$_SESSION['regpay']='';
	}
	else $failureflag=1;
	require 'themes/regsuccess.tpl';
	require 'templates/'.$tfold.'/footer.php';
?>
