<?php
include("../connect.php"); 
$response = array();
if(isset($_POST['admin_id']))
{
	$ver = $_POST['admin_id'];
	date_default_timezone_set('Asia/Calcutta');
    $scro = date("h:i:sa");
    $da  = date("Y-m-d");
    $scri =$da.' '.$scro;
	
	$status=$_POST["status"];
	$month=$_POST["month"];
	$recharge_amount=$_POST["amount"];
	$txnid=$_POST["txnid"];
	$payment_plan=$_POST["payment_plan"];
	$payment_type=$_POST["payment_type"];

	$fetchwpq=mysqli_query($con,"SELECT  * from tbl_admin_panel WHERE admin_id='$ver'");
    
    if($fetchwpq)
	{
		while($fetchrow=mysqli_fetch_assoc($fetchwpq))
		{
			extract($fetchrow);
			$flag=0;
			$uname=ucwords($admin_name);
			$luemail=$admin_email;
			$mob=$admin_phone;
			$id=$admin_id;
			$add=$address;
            $regtime=$next_renew_date;
            $date = strtotime($registration_datetime);
            $h=date('h', $date);
			date_default_timezone_set('Asia/Calcutta');
			$scro = date("h:i:sa");
            $da  = date("Y-m-d");
            $scri =$da.' '.$scro;
			$month_days=$month*30;
            $r=strtotime($next_renew_date);
            $r2= strtotime("+".$month_days." days ", $r);
            $aftmonths=date('Y-m-d h:i:sa', $r2);

			include("sendmail_recharge.php");
			require '../../bthawk/PHPMailer-master/PHPMailerAutoload.php';
            $d_link="http://www.bthawk.appexperts.net/";
            $prod_name="BTCover";
            $m_type='recharge';
			$sendmail=new SendMail();

			$res=$sendmail->rechargepayment($luemail,$m_type,$uname,$prod_name,$aftmonths,$scri,$id,$d_link,$txnid,$recharge_amount,$payment_plan,$month,$mob,$payment_type);
			$senderemail="btcover@appexperts.net";
			//$senderemail="shilpa.khandelwal@belltechnology.in";
			$sendmail=new SendMail();
			$result_admin=$sendmail->rechargepaymentadmin($senderemail,$luemail,$m_type,$uname,$prod_name,$aftmonths,$scri,$id,$d_link,$txnid,$recharge_amount,$mob,$payment_type);
		} 
	}
	
	if($res==1 and $result_admin==1)
	{
		include("../connect.php");
		$uq=mysqli_query($con,"UPDATE tbl_admin_panel SET next_renew_date='$aftmonths' WHERE admin_id='$ver'");
		$response['success']='1';
		$response['message']="Mail send successfully";
	}
	else
	{
		$response['success']='0';
		$response['message']="Mail not send";

	}
}
else
{
	$response['success']='0';
	$response['details']="Required field missing";
}	
echo json_encode($response);

?>