<?php
	session_start();
	if($_SESSION['rid'])
	{
		$userid= $_SESSION['rid'];
	}
	else
	{
		header('location:../login.php');
	}
?>
<?php
	include'connection.php';
	include'time.php';
	include'update_bal_wallet_id.php';
	
	$quGetEwalletId="select * from RetBal where Userid='$userid'";
    $reGetEwalletId=mysqli_query($con,$quGetEwalletId);
    $dataGetEwalletId=mysqli_fetch_array($reGetEwalletId);
    $EwalletId=$dataGetEwalletId['Walletid'];
    
	
		$query2="select * from retailer where Userid='$userid'";
		$result2=mysqli_query($con,$query2);
		$databal=mysqli_fetch_array($result2);
		$username=$databal['Name'];
		$parentid=$databal['Parentid'];
		$ApiActive=$databal['ApiActive'];
		
		// Get Diffrance Value //
		
		$quAdminBal="select * from wallet where Userid='1111' order by Id desc";
		$reAdminBal=mysqli_query($con,$quAdminBal);
		$dataAdminBal=mysqli_fetch_array($reAdminBal);
		$currentAdminbal= $dataAdminBal['Balance'];
		
		$TotalIdeaBal=0;
		$TotalJioBal=0;
		$TotalVodaBal=0;
		$TotalAirtelBal=0;
		$TotalTataBal=0;
		
		$quMyAPI="select * from myapi where Operator='Idea'";
		$reMyAPI=mysqli_query($con,$quMyAPI);
		while($dataMyAPI=mysqli_fetch_array($reMyAPI))
		{
		    $LapuIdeaBal=$dataMyAPI['LapuBal'];
		    $TotalIdeaBal=$TotalIdeaBal+$LapuIdeaBal;
		}
		
		$quMyApiJio="select * from myapi where Operator='JIO'";
		$reMyApiJio=mysqli_query($con,$quMyApiJio);
		while($dataMyApiJio=mysqli_fetch_array($reMyApiJio))
		{
		    $LapuJioBal=$dataMyApiJio['LapuBal'];
		    $TotalJioBal=$TotalJioBal+$LapuJioBal;
		}
		
		$quMyApiVoda1="select * from myapi where Operator='Voda'";
		$reMyApiVoda1=mysqli_query($con,$quMyApiVoda1);
		while($dataMyApiVoda1=mysqli_fetch_array($reMyApiVoda1))
		{
		    $LapuVoda1Bal=$dataMyApiVoda1['LapuBal'];
		    $TotalVodaBal=$TotalVodaBal+$LapuVoda1Bal;
		}
		
		$quMyApiAirtel="select * from myapi where Operator='Airtel'";
		$reMyApiAirtel=mysqli_query($con,$quMyApiAirtel);
		while($dataMyApiAirtel=mysqli_fetch_array($reMyApiAirtel))
		{
		    $LapuAirtelBal=$dataMyApiAirtel['LapuBal'];
		    $TotalAirtelBal=$TotalAirtelBal+$LapuAirtelBal;
		}
		
		$quMyApiTata="select * from myapi where Operator='Tata'";
		$reMyApiTata=mysqli_query($con,$quMyApiTata);
		while($dataMyApiTata=mysqli_fetch_array($reMyApiTata))
		{
		    $LapuTataBal=$dataMyApiTata['LapuBal'];
		    $TotalTataBal=$TotalTataBal+$LapuTataBal;
		}
		
    	$ActualIdeaBal=$TotalIdeaBal*100/104;
	    $ActualJioBal=$TotalJioBal*100/106;
	    $ActualVodaBal=$TotalVodaBal*100/104;
	    $ActualAirtelBal=$TotalAirtelBal*100/103;
	    $ActualTataBal=$TotalTataBal*100/103;
	
		$UniqueAPIBal=0;
		
		
    $rechApiBal=0;
        //DIZI_PAY API BALANCE//
		$GetLapuOldBal1="select * from myapi where LapuNumber='DiziPay_Api'";
        $reGetLapuOldBal1=mysqli_query($con,$GetLapuOldBal1);
        $dataGetLapuOldBal1=mysqli_fetch_array($reGetLapuOldBal1);
        $LapuOldBal1=$dataGetLapuOldBal1['LapuBal'];
		$DiziPayApiBal=$LapuOldBal1;
		
		  
    //Ozzy_PAY API BALANCE//
		$GetLapuOldBal2="select * from myapi where LapuNumber='Ozzy_Api'";
        $reGetLapuOldBal2=mysqli_query($con,$GetLapuOldBal2);
        $dataGetLapuOldBal2=mysqli_fetch_array($reGetLapuOldBal2);
        $LapuOldBal2=$dataGetLapuOldBal2['LapuBal'];
		$OzzyApiBal=$LapuOldBal2;
		
		
	//Perfect Paisa API Balance //
		$GetLapuOldBal3="select * from myapi where LapuNumber='PP_Api'";
        $reGetLapuOldBal3=mysqli_query($con,$GetLapuOldBal3);
        $dataGetLapuOldBal3=mysqli_fetch_array($reGetLapuOldBal3);
        $LapuOldBal3=$dataGetLapuOldBal3['LapuBal'];
		$PP_ApiBal=$LapuOldBal3;
		
		
    //KWIK_API BALANCE CODE//
		$GetLapuOldBal4="select * from myapi where LapuNumber='Kwik_API'";
        $reGetLapuOldBal4=mysqli_query($con,$GetLapuOldBal4);
        $dataGetLapuOldBal4=mysqli_fetch_array($reGetLapuOldBal4);
        $LapuOldBal4=$dataGetLapuOldBal4['LapuBal'];
		$KwikApiBal=$LapuOldBal4;
	
		$queryMd="select * from masterdis";
		$resultMd=mysqli_query($con,$queryMd);
		$rowMd=mysqli_num_rows($resultMd);
		$sumMdBal=0;
		while($mdData=mysqli_fetch_array($resultMd))
		{
			$totalMdBal=$mdData['Balance'];
			$sumMdBal=$sumMdBal+$totalMdBal;
		}
		
		$querydis="select * from distributer";
		$resultdis=mysqli_query($con,$querydis);
		$rowdis=mysqli_num_rows($resultdis);
		$sumDisBal=0;
		while($disData=mysqli_fetch_array($resultdis))
		{
			$totalDisBal=$disData['Balance'];
	    	$sumDisBal=$sumDisBal+$totalDisBal;
		}
		
		$query1="select * from retailer";
		$result1=mysqli_query($con,$query1);
		$row1=mysqli_num_rows($result1);
		$sumRet=0;
		while($row11=mysqli_fetch_array($result1))
		{
			$retalrBal=$row11['Balance'];
			$sumRet=$sumRet+$retalrBal;
		}
		
		$query4="select * from commwallet where Active='0'";
		$result4=mysqli_query($con,$query4);
		$sum4=0;
		while($row4=mysqli_fetch_array($result4))
		{
			$data4=$row4['Balance'];
			$sum4=$sum4+$data4;
		}
		$TotUsrBal=$sumMdBal+$sumDisBal+$sumRet+$sum4;
		$totalWalletBal=$currentAdminbal+$TotUsrBal;
	    
	    $TotalApiBal=$ActualIdeaBal+$ActualJioBal+$ActualVodaBal+$ActualAirtelBal+$ActualTataBal+$rechApiBal+$KwikApiBal+$UniqueAPIBal+$DiziPayApiBal+$PP_ApiBal+$OzzyApiBal;
    	$Managebal=$totalWalletBal-$TotalApiBal;
    	$BenefitBal=2000000-$Managebal;
?>
<html>
<title>HOME</title>
<head>
     <script type='text/javascript' src='//platform-api.sharethis.com/js/sharethis.js#property=5c01770ef30c5a001138cb08&product=social-ab' async='async'></script>
    

<style>
body{background:url('bg.jpg'); background-size:cover; width:100%; margin:0px;}

.head{background:; width:1500px; height:80px; margin:0px;}
#p1{font-size:34px; float:left; Margin:10 0 0 45px; color:#996420; font-weight:bold;}
#p2{font-size:20px; float:left; margin:28 0 0 -8px; color:#eaa040; font-family:Courier;}
#p3{font-size:15px; font-family:Comic Sans MS; float:left; color:#996420; margin-top:48px; margin-left:-153px;}
.h2{background:white; width:400px; height:70px; margin:10 200px;}
#link1{float:right; margin:10 30 0 0px; font-size:20px; text-decoration:none;
 color:white; background:red; padding:5px; border-radius:4px;}
 #link2{float:right; margin:10 30 0 0px; font-size:20px; background:white;color:Green; padding:5px; border-radius:4px;}
 #linkApi{float:right; margin:5 140 0 0px; font-size:20px; background:#191970;color:white; padding:5 20px; border-radius:4px; text-decoration:none;}
 #linkApi:hover{background:#556b2f;}
 #link3{float:right; margin:25 40 0 0px;}
#link1:hover{ padding:5px; border-radius:4px; color:black;}
	
.menu{background:#996420; height:50px; width:1400px; margin-left:10px; padding:0; line-height:40px;}
.menu ul{padding:0; margin:0; position:relative; display:inline-block;}
.menu ul li{list-style:none; float:left; width:220px; line-height:50px; text-align:center; font-size:20px; margin:0px; padding:0; color:white;}
.menu ul li ul {display:none;}
.menu ul li:hover{background:#d1994a; cursor:pointer;}
.menu ul li:hover ul {display:block; z-index:2;}
.menu ul li:hover ul li{background:#d1994a; border-top:solid white 0.1px;}
.menu ul li ul li:hover{background:#996420; color:white;}
.menu ul li ul li:hover a{ color:white;}
.menu ul li a{ text-decoration:none; color:white;}
 #a1{border:none; color:white;}
 .menu{letter-spacing:1px;}
 #bal:hover{background:#996420; cursor:text;}
 

.dmorq{background:#565450; color:white; width:1200px; margin:10 0 0 50px; line-height:40px; z-index:0; border-radius:18px; font-size:24px; font-family:sans-serif;}
.rech{width:550px; margin:10 0 0 80px;}
table{width:550px; font-size:20px;}
#tdfl{float:right; margin-right:15px;}
#greenbal{background:; color:white; font-size:22px; border-radius:5px; text-align:center; height:30px; width:180px; line-height:30px; border:2px solid white;}
#redbal{background:red; color:white; font-size:22px; border-radius:5px; text-align:center; height:30px; width:180px; line-height:30px; border:2px solid white;}
#inpset{width:180px; border-radius:2px; border:1px solid #996420; padding:4px; font-size:20px;}
#inpset1{width:180px; border-radius:2px; border:1px solid #996420; padding:4px; font-size:16px;}
::-webkit-input-placeholder{font-size:15px; padding-left:5px; }
#rechbtn{background:green; border:none; color:white; font-size:20px; border-radius:5px; cursor:pointer;
 padding:6px 10px; border:2px solid white; width:180px;}
#rechbtn:focus{outline:none;}
#rechbtn:hover{ background:#c7fac8; color:black; border:2px solid black; width:180px;}
.trarepo{height:30px; background:#996420; width:1450px; margin:0 0 0 20px; padding:0px;  line-height:30px;}
.trarepo p{font-size:20px; margin-left:20px; color:white;}
#dnldLink{text-decoration:none; font-size:22px;}
.addiv1{background:; width:400px; height:200px; float:left; position:absolute; top:320px; left:800px; text-align:center;
    border-radius:20px;}
#addmsg{font-size:22px;}
#rechreport{width:1450px; margin:0 0 0 20px; padding:0px;}

#t1{ width:1450px; text-align:center; border-collapse:collapse; border-color:black; }
#t1 th{font-family:calibri; background:#94928f; color:white; }
#t1 td{font-family:calibri;}
#t1 tr:nth-child(odd){background:#f6f0e8;}
#t1 tr:nth-child(even){background:white; }
#RechIdColor{color:blue; font-size:22px;}
#green{background:green; color:white; font-size:18px; padding:2 5px; border-radius:4px; font-weight:bold;}
#red{background:red; color:white; font-size:18px; padding:2 5px; border-radius:4px; font-weight:bold;}
#blue{background:blue; color:white; font-size:18px; padding:2 5px; border-radius:4px; font-weight:bold;}
#disId{display:none;}
#disDiv{position:absolute; width:500px; height:250px; margin:100 0 0 700px; z-index:3; display:none;}
#radiobutton{width:20px; height:20px;}
 #tbl{ margin:0px; border-collapse:collapse; z-index:4;}
 #tbl th{background:#687388; color:white; font-size:20px; font-family:sans-serif;}
 #tbl td{background:#f3f4f5; color:black; font-size:20px; font-family:sans-serif;}
</style>

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "ca-pub-8510562507020545",
    enable_page_level_ads: true
  });
</script>

    <script>
        function GetDisDetail()
        {
            var DisId = document.getElementById("disId").value;
            var xmlhttpDis = new XMLHttpRequest();
            xmlhttpDis.open("GET","my_distributer.php?disId="+DisId, false)
            xmlhttpDis.send(null);
            document.getElementById("disDiv").innerHTML = xmlhttpDis.responseText;
            document.getElementById("disDiv").style.display="block";
            document.getElementById("addiv").style.display="none";
        }
        function GetBal()
        {
            var usrid = document.getElementById("user").value;
            var xmlhttp2 = new XMLHttpRequest();
            xmlhttp2.open("GET", "get_bal_ajax.php?usr="+usrid, false);
            xmlhttp2.send(null);
            var bal = xmlhttp2.responseText;
        
            var txtClr = document.getElementById("greenbal");
            
            if(bal>500)
            {
                txtClr.style.background = "green";
            }
            else
            {
                txtClr.style.background ="red";
            }
            document.getElementById("greenbal").innerHTML = xmlhttp2.responseText;
            
            setTimeout("GetBal()",10000)
        }
    </script>
</head>
<body onload="GetRechReport(), GetBal(), MyBlink()">
	<div class="head">
		<p id="p1">LLP</p>
		<p id="p2">Recharge</p>
		<p id="p3">The Complete Solution</p>
		<a id="link1" href="logout.php">Log Out</a>
		<p id="link2"><?php echo "Welcome Dear- ".$username." [ ".$userid." ]";  ?></p>
		<p id="link3">
		  <iframe src="http://free.timeanddate.com/clock/i6g7kcjv/n44/fs24/fc077104/tct/pct/ftbi/tt0/th2" frameborder="0" width="568" height="30" allowTransparency="true"></iframe>
		</p>
	</div>
	<input type="text" id="disId" value="<?php echo $parentid ;?>">
	<div class="menu">
		<ul>
			<li><a href="recharge_home.php" id="a1">Home</a></li>
			<li>Reports
				<ul>
					<li><a href="recharge_history.php">Recharge History</a></li>
					<li><a href="account_reports.php">Account Reports</a></li>
					<li><a href="check_status.php">Check Status</a></li>
				</ul>
			</li>
			<li>Documents
				<ul>
					<li><a href="api_documents.php" target="_blank">API Documents</a></li>
					<li><a href="my_commission.php">My Commission</a></li>
					<li><a href="commision.php">Get Commission</a></li>
					<li><a href="complain.php">Complain</a></li>
					<li><a href="Download_GST_Invoice.php">GST Invoice</a></li>
					<li><a href="../LlpRecharge.apk" download="LlpRecharge" id="dnldLink">Download App</a></li>
				</ul>
			</li>
			<li>Profile
				<ul>
					<li><a href="change_profile.php">Change Profile</a></li>
					<li><a href="change_pwd.php">Change Password</a></li>
				</ul>
			</li>
			<li>Payment Request
				<ul>
					<li><a href="payment_request.php">Update Payment</a></li>
					<li><a href="TopUpReport.php">TopUp Report</a></li>
					<li><a href="bank_list.php">Bank List</a></li>
				</ul>
			</li>
			<?php if($ApiActive==0){ echo "<li onclick='GetDisDetail()' >My Distributer</li>"; } ?>
		</ul>
	</div >
	
	<div class="dmorq">
		<marquee scrollamount="4" onmouseover="stop()" onmouseout="start()">
		<?php
		    $dateformat = Date("d/M/Y");
			
			$AcOp="select * from operator where Active='1'";
			$reAcOp=mysqli_query($con,$AcOp);
			$CountRowsAcOp=mysqli_num_rows($reAcOp);
			while($dataAcOp=mysqli_fetch_array($reAcOp))
			{
			    echo $dataAcOp['Operator']." Down, ";
			}
			if($CountRowsAcOp==0)
			{
			    echo "ALL OPERATORS ARE WORKING FINE, ";
			}
			
		    $querymsg="select * from messege where Users='ALL' or Users='RET' order by Id desc";
			$resultmsg=mysqli_query($con,$querymsg);
			while($datamsg=mysqli_fetch_array($resultmsg))
			{
			    echo $datamsg['Messege']." ";
			}
			
		?>
		</marquee>
	</div>
    <div id="disDiv">
    
    </div>
	<?php
	include'connection.php';
	
	ini_set('memory_limit', '-1');
    if($_SESSION['rid'])
    {	
    	$query2="select * from distributer where Userid='$parentid'";
    	$result2=mysqli_query($con,$query2);
    	$datad=mysqli_fetch_array($result2);
    	$username=$datad['Name'];
    	$grandparentid=$datad['Parentid'];
    	$ReferId=$datad['ReferId'];
    	
    	$quGetAutoFailedStatus="select * from Auto_Failed where Id='1'";
		$reGetAutoFailedStatus=mysqli_query($con,$quGetAutoFailedStatus);
		$dataGetAutoFailedStatus=mysqli_fetch_array($reGetAutoFailedStatus);
		$AutoFailedStatus=$dataGetAutoFailedStatus['Status'];
		
            date_default_timezone_set("asia/Kolkata");
			$datetime= Date("Y-m-d - h:i:s A");
			$time= Date("h:i:s A");
			$date= Date("Y-m-d");
			
			$date1 = date("Y-m-d h:i:s A");
            $time1 = strtotime($date1);
            $time2 = $time1 - (30 * 60);
            $date2 = date("h:i:s A", $time2);
        
		if(isset($_POST['submit']))
		{
		    $service=$_POST['gen'];
			$operator=$_POST['operator'];
			$mnum=$_POST['mnum'];
			$cmnum=$_POST['cmnum'];
			$amount=$_POST['amount'];
			
			$postpaidOperator=substr($operator, -8);
			
			$opcodequery="select * from operator where Operator='$operator'";
			$opcoderesult=mysqli_query($con,$opcodequery);
			$opcodedata=mysqli_fetch_array($opcoderesult);
			$opcode=$opcodedata['Value'];
			$myApiOpCode=$opcodedata['MyApiValue'];
			$MyApi2OpCode=$opcodedata['My_API2'];
			$KwikApiOpCode=$opcodedata['KwikAPI'];
			$UniqueApiOpCode=$opcodedata['UniqueAPI'];
			$DiziPayOpCode=$opcodedata['DiziPayApi'];
			$OzzyOpCode=$opcodedata['Ozzy_Api'];
			$PP_ApiOpCode=$opcodedata['PP_Api'];
			$columName=$opcodedata['Commision_Column'];
			
			
			$querygetcom="select * from commision where Userid='$userid'";
			$rsultgetcom=mysqli_query($con,$querygetcom);
			$data=mysqli_fetch_array($rsultgetcom);
			$usercommvalue=$data[$columName];
			
			$parentq="select * from commision where Userid='$parentid'";
			$parentcomm=mysqli_query($con,$parentq);
			$dataparcomm=mysqli_fetch_array($parentcomm);
			$parcommvalue=$dataparcomm[$columName];
			$parbalcomm= $parcommvalue-$usercommvalue;
			
			$gparentq="select * from commision where Userid='$grandparentid'";
			$gparentcomm=mysqli_query($con,$gparentq);
			$gdataparcomm=mysqli_fetch_array($gparentcomm);
			$gparcommvalue=$gdataparcomm[$columName];
			$gparbalcomm= $gparcommvalue-$parcommvalue;
	
			if($operator=="--Select Operator--")	
			{
				echo "<h1 align='center'><font color='#ff0000'> &#x2716; You Did Not Select Any Operator !</font></h1>";
			}
			elseif($usercommvalue>$parcommvalue || $parcommvalue>$gparcommvalue)
			{
				echo "<h1 align='center'><font color='#ff0000'> &#x2716; Invalid Commission Value !</font></h1>";
			}
			elseif($amount<6)
			{
				echo "<h1 align='center'><font color='#ff0000'> &#x2716; Amount Is Less Than 6 !</font></h1>";
			}
			else
			{
				if(empty($operator) || empty($mnum) || empty($cmnum) || empty($amount))
				{
					echo "<h1 align='center'><font color='#ff0000'> &#x2716; Please Fill All Field !</font></h1>";
				}
				else
				{
					
					if($mnum==$cmnum)
					{
						$numLength = strlen($mnum);
						$startNum = substr($mnum,0,1);
						
						if($service=="Mobile" || $service=="Postpaid")
						{
							if($numLength!==10)
							{
								$passNum  = 0;
								$msgPass  = "MOBILE NUMBER MUST BE 10 DIGIT ONLY !";
							}
							else
							{
								$passNum  = 1;
							}
						}
						elseif($operator=="TATA SKY DTH")
						{
							if($numLength==10)
							{
								$passNum  = 1;
							}
							else
							{
								$passNum  = 0;
								$msgPass  = "TATA SKY DTH NUMBER MUST BE 10 DIGIT ONLY !";
							}
						}
						elseif($operator=="DISH TV DTH")
						{
							if($numLength==11 && $startNum==0)
							{
								$passNum  = 1;
							}
							else
							{
								$passNum  = 0;
								$msgPass  = "DISH TV DTH NUMBER MUST BE 11 DIGIT AND START FROM 0 ONLY !";
							}
						}
						elseif($operator=="AIRTEL DTH")
						{
							if($numLength==10 && $startNum==3)
							{
								$passNum  = 1;
							}
							else
							{
								$passNum  = 0;
								$msgPass  = "AIRTEL DTH	NUMBER MUST BE 10 DIGIT AND START FROM 3 ONLY !";
							}
						}
						else
						{
						    $passNum  = 1;
						}
						
						
						if($passNum==1)
						{
						    $quGetBal1="select * from wallet where Userid='$userid' and Id>=$EwalletId";
	                        $reGetBal1=mysqli_query($con,$quGetBal1);
	                        $CureentBal1=0;
	                        while($dataGetBal1=mysqli_fetch_array($reGetBal1))
	                        {
	                            $OldTxn1= $dataGetBal1['Txn'];
	                            $CureentBal1=$CureentBal1+$OldTxn1;
	                        }
							if($amount<=$CureentBal1)
							{
								$quGetSameRech="select * from recharge where Companyname='$operator' and Mobile='$mnum' and Amount='$amount' and Status='PENDING' and Rechargedate='$date'";
								$reGetsameRech=mysqli_query($con,$quGetSameRech);
								$dataGetSameRech=mysqli_num_rows($reGetsameRech);
								
								$quGetSameRech1="select * from recharge where Companyname='$operator' and Mobile='$mnum' and Amount='$amount' and Status='SUCCESS' and Rechargedate='$date'";
								$reGetsameRech1=mysqli_query($con,$quGetSameRech1);
								$dataGetSameRech1=mysqli_num_rows($reGetsameRech1);
								
								$quGetSameRech2="select * from recharge where Companyname='$operator' and Mobile='$mnum' and Amount='$amount' and Status='' and Rechargedate='$date'";
								$reGetsameRech2=mysqli_query($con,$quGetSameRech2);
								$dataGetSameRech2=mysqli_num_rows($reGetsameRech2);
								
								if($dataGetSameRech>=1 || $dataGetSameRech1>=1 || $dataGetSameRech2>=1)
								{
									echo "<h1 align='center'><font color='#ff0000'> &#x2716; Same Recharge Not Allowed At Same Day !</font></h1>";
								}
								else
								{
									$commision=$amount*$usercommvalue/100;
									$actual=$amount-$commision;
										
										$insertq="insert into recharge(Userid,RetComm,Parentid,DisComm,Grandparentid,MdComm,ReferalId,Rechargedate,Time,PTime,Agentname,Companyname,Mobile,Amount,Debitamount,Status,AdminDiffValue)
										values('$userid','$usercommvalue','$parentid','$parcommvalue','$grandparentid','$gparcommvalue','$ReferId','$date','$time','$PTime','$username','$operator','$mnum','$amount','$actual','PENDING','$BenefitBal')";
										if(mysqli_query($con,$insertq))
										{   
											$newrechid=mysqli_insert_id($con);
										
    	                                    $TotalApiBal=$TotalAirtelBal+$TotalIdeaBal+$TotalJioBal+$TotalVodaBal+$rechApiBal+$UniqueAPIBal+$KwikApiBal;
                                    	    $insrtDiff="insert into Diff(Rechid,Date,Time,AdminBal,MdBal,DisBal,RetBal,CommBal,TotUsrBal,AirtelBal,IdeaBal,VodaBal,JioBal,UniqBal,KwikBal,RechBal,DiziApi,PpApi,OzzyApi,TotApiBal,Diff)
    	                                    values('$newrechid','$date','$time','$currentAdminbal','$sumMdBal','$sumDisBal','$sumRet','$sum4','$TotUsrBal','$ActualAirtelBal','$ActualIdeaBal','$ActualVodaBal','$ActualJioBal','$UniqueAPIBal','$KwikApiBal','$rechApiBal','$DiziPayApiBal','$PP_ApiBal','$OzzyApiBal','$TotalApiBal','$BenefitBal')";
    	                                    mysqli_query($con,$insrtDiff);
											
										    $query5="insert into wallet(Userid,Txn,Debit,Remarks,Date,Time,Transactiontype,Paynrechid,Operator,Mobile,Amount)
										    values('$userid','-$actual','$actual','Recharge','$date','$time','Recharge','$newrechid','$operator','$mnum','$amount')";
											
											if(mysqli_query($con,$query5))
											{
												$ewalletid=mysqli_insert_id($con);
    											$quGetBal2="select * from wallet where Userid='$userid' and Id>=$EwalletId";
	                                            $reGetBal2=mysqli_query($con,$quGetBal2);
	                                            $CureentBal2=0;
	                                            while($dataGetBal2=mysqli_fetch_array($reGetBal2))
	                                            {
	                                                $OldTxn2= $dataGetBal2['Txn'];
	                                                $CureentBal2=$CureentBal2+$OldTxn2;
	                                            }
	                                            $OpeningBal=$CureentBal2+$actual;
	                                            $queryW="update wallet set Openingbalance='$OpeningBal', Balance='$CureentBal2' where Id='$ewalletid'";
									    		mysqli_query($con,$queryW);
											
										    	$query7="update recharge set Balance='$CureentBal2', Ewalletid='$ewalletid' where Id='$newrechid'";
											    mysqli_query($con,$query7);
											    
											    $quUpdateBal="update retailer set Balance='$CureentBal2' where Userid='$userid'";
											    mysqli_query($con,$quUpdateBal);
											    
												$parcommbal=$amount*$parbalcomm/100;
												$gparcommbal=$amount*$gparbalcomm/100;
												
												$insertparcomm="insert into commwallet(Userid,Balance,Date,Time,Rechargeid,Mobile,Amount,Operator,Retailer,Retailername)
												values('$parentid','$parcommbal','$date','$time','$newrechid','$mnum','$amount','$operator','$userid','$username')";
												mysqli_query($con,$insertparcomm);
												
												$insertgparcomm="insert into commwallet(Userid,Balance,Date,Time,Rechargeid,Mobile,Amount,Operator,Retailer,Retailername)
												values('$grandparentid','$gparcommbal','$date','$time','$newrechid','$mnum','$amount','$operator','$userid','$username')";
												mysqli_query($con,$insertgparcomm);
												
												$query10="update retailer set Lastrechdate='$date' where Userid='$userid'";
												mysqli_query($con,$query10);
												
												$quGetUseApi="select * from operator where Operator='$operator'";
												$reGetUseApi=mysqli_query($con,$quGetUseApi);
												$dataGetUseApi=mysqli_fetch_array($reGetUseApi);
												$UseApi=$dataGetUseApi['UseAPI'];
												
												if($UseApi=="My_API" && $operator=="Airtel" && $amount=="35" || $UseApi=="My_API" && $operator=="Airtel" && $amount=="65")
												{
												    $quGetTopupapi="select * from topupapi where Id='1'";
												    $reGetTopupApu=mysqli_query($con,$quGetTopupapi);
												    $dataGetTopupApi=mysqli_fetch_array($reGetTopupApu);
												    $TopupApi=$dataGetTopupApi['TopupApi'];
												    $UseApi2=$TopupApi;
												}
												else
												{
												    $UseApi2=$UseApi;
												}
												
												if($UseApi2=="My_API")
												{
												    	
												}
												elseif($UseApi2=="My_API2")
												{   
											        $UpdateRechApibal="update recharge set API='My_API2' where Id='$newrechid'";
											    	mysqli_query($con,$UpdateRechApibal);
											    		
											    		$ch = curl_init();

                                                                  if (!$ch) {
                                                            die("Couldn't initialize a cURL handle");
                                                                }
                                                              curl_setopt($ch, CURLOPT_URL,'https://mrobotics.in/api/recharge?'); // Target URL
                                                            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
                                                            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
                                                            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
                                                            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

                                                             curl_setopt($ch, CURLOPT_POST, 1);
                                                            curl_setopt($ch, CURLOPT_POSTFIELDS,"api_token=37a1e7bd-3d24-4d73-8c17-ecd76d5a847e&mobile_no=$mnum&amount=$amount&company_id=$MyApi2OpCode&order_id=$newrechid&is_stv=false");

                                                            $result = curl_exec ($ch); 

                                                            $result = (array)json_decode($result);
                                                               // print_r($result);
                                                               // echo "<br>";
                                                                 $status1 = $result['status'];
                                                                 $errorMsg = $result['errorMessage'];   
                                                                 $msg = $result['response'];   
                                                                 $txnId = $result['tnx_id'];   
                                                                 $LapuNo = $result['lapu_no'];   
                                                                 $LapuBal = $result['balance'];   
												                $roffer = $result['roffer'];   
												
												                    $updateLapu="update recharge set LapuNo='$LapuNo', ApiBal='$LapuBal' where Id='$newrechid'";
												                    mysqli_query($con,$updateLapu);
                                                                
														    if($status1=="SUCCESS" || $status1=="success")
														    {
														        $GetLapuOldBal="select * from recharge where LapuNo='$LapuNo' and status='SUCCESS' order by Id desc";
                                                                $reGetLapuOldBal=mysqli_query($con,$GetLapuOldBal);
                                                        	    $dataGetLapuOldBal=mysqli_fetch_array($reGetLapuOldBal);
                                                               	$LapuOldBal=$dataGetLapuOldBal['ApiBal'];
                                                        	    $remaiBal=$LapuOldBal-$amount;
                                                        	    $LapuDiff = $LapuBal-$remaiBal;
														        $queryUpadateOrderId="update recharge set Transactionid='$orderId', Status='SUCCESS', R_Offer='$roffer', Operatorid='$txnId', LapuOldBal='$LapuOldBal', Diff='$LapuDiff', API='My_API2', LapuNo='$LapuNo', ApiBal='$LapuBal' where Id='$newrechid'";
																mysqli_query($con,$queryUpadateOrderId);
																
																$quUpdatebal="UPDATE myapi SET LapuBal='$LapuBal', LastUpdate='$date', OrderId='$newrechid' WHERE LapuNumber='$LapuNo'";
														        mysqli_query($con,$quUpdatebal);
			                                                    
																echo "<h1 align='center'><font color='#008000'> &#x2714; Your Request Submit Successfully !</font></h1><br>";
																		
														    }
														    elseif($status1=="FAILED" || $status1=="failure")
														    {
														        
														        if($msg=="No records found" || $msg=="IN Bad MSISDN" || $msg=="Subscriber Not Found")
														        {
														            $Printmsg ="Invalid Number Or Operator !";
														        }
														        elseif($msg=="No Plans Found with this Amount	" || $msg=="Transaction Failed" || $msg=="Card gorup set ID not found.")
														        {
														            $Printmsg ="Invalid Amount !";
														        }
														        else
														        {
														            $Printmsg =$msg;
														        }
														      
														        if($msg=="No Plans Found with this Amount	" || $msg=="You can only select other than prime plan for recharge.	" || $msg=="No records found" || $msg=="You can only select other than prime plan for recharge." || $msg=="IN Bad MSISDN" || $msg=="Transaction Failed" || $msg=="Subscriber Not Found" || $msg=="Card gorup set ID not found.")
														        {
														            
			            								            $queryRefund="insert into wallet(Userid,Txn,Credit,Remarks,Date,Time,Transactiontype,Paynrechid,Operator,Mobile,Amount)
						            				                values('$userid','$actual','$actual','Recharge_Refund','$date','$time','Recharge_Refund','$newrechid','$operator','$mnum','$amount')";
									            	                if(mysqli_query($con,$queryRefund))
										                            {
															            $refundewalletid=mysqli_insert_id($con);


															            $queryNewBal3="select * from wallet where Userid='$userid' and Id>=$EwalletId";
            	                                                        $resultNewBal3=mysqli_query($con,$queryNewBal3);
	                                                                    $newbal3=0;
	                                                                    while($dataNewBal3=mysqli_fetch_array($resultNewBal3))
	                                                                    {
	                                                                        $Retbal3= $dataNewBal3['Txn'];
	                                                                        $newbal3=$newbal3+$Retbal3;
            	                                                        }
            	                                                        $OpeningBal=$newbal3-$actual;
	                                                                    $queryW="update wallet set Openingbalance='$OpeningBal', Balance='$newbal3' where Id='$refundewalletid'";
									    		                        mysqli_query($con,$queryW);
									    		                        $query9="update retailer set Balance='$newbal3' where Userid='$userid'";
							                							mysqli_query($con,$query9);
            															$failedquery="update recharge set Creditewalletid='$refundewalletid', Status='FAILED', Transactionid='$orderId', Operatorid='$Printmsg', Responsetxt='$resText', API='My_API2' where Id='$newrechid'";
			            												mysqli_query($con,$failedquery);
						    									
							            								$deletecomm="delete from commwallet where Rechargeid='$newrechid'";
										            					mysqli_query($con,$deletecomm);
										            					
												                		echo "<h1 align='center'><font color='#ff0000'> &#x2716; Your Recharge Request Has Been Failed Now !</font></h1>";
																    }
																    else
																    {
																        echo "Error-Refund_Query";
																        
																    }
														          
														      }
														      elseif($AutoFailedStatus=="Deactive")
														      {
														    		$UpdateRechApibal="update recharge set ReHit='1', AdminOpId='$msg', API='My_API2' where Id='$newrechid'";
															    	mysqli_query($con,$UpdateRechApibal);
														      }
														      else
														      {
			            								            $queryRefund="insert into wallet(Userid,Txn,Credit,Remarks,Date,Time,Transactiontype,Paynrechid,Operator,Mobile,Amount)
						            				                values('$userid','$actual','$actual','Recharge_Refund','$date','$time','Recharge_Refund','$newrechid','$operator','$mnum','$amount')";
									            	                if(mysqli_query($con,$queryRefund))
										                            {
															            $refundewalletid=mysqli_insert_id($con);
															            
															            $queryNewBal3="select * from wallet where Userid='$userid' and Id>=$EwalletId";
            	                                                        $resultNewBal3=mysqli_query($con,$queryNewBal3);
	                                                                    $newbal3=0;
	                                                                    while($dataNewBal3=mysqli_fetch_array($resultNewBal3))
	                                                                    {
	                                                                        $Retbal3= $dataNewBal3['Txn'];
	                                                                        $newbal3=$newbal3+$Retbal3;
            	                                                        }
            	                                                        $OpeningBal=$newbal3-$actual;
	                                                                    $queryW="update wallet set Openingbalance='$OpeningBal', Balance='$newbal3' where Id='$refundewalletid'";
									    		                        mysqli_query($con,$queryW);
            															$failedquery="update recharge set Creditewalletid='$refundewalletid', Status='FAILED', Transactionid='$orderId', Operatorid='$Printmsg', Responsetxt='$resText', API='My_API2' where Id='$newrechid'";
			            												mysqli_query($con,$failedquery);
						    									
							            								$deletecomm="delete from commwallet where Rechargeid='$newrechid'";
										            					mysqli_query($con,$deletecomm);
											
			                												$query9="update retailer set Balance='$newbal3' where Userid='$userid'";
							                								mysqli_query($con,$query9);
											    				
												                			 echo "<h1 align='center'><font color='#ff0000'> &#x2716; Your Recharge Request Has Been Failed Now !</font></h1>";
																    }
														      }
														  }
												}
												elseif($UseApi2=="Kwik_API")
												{
												    $UpdateRechApibal="update recharge set API='Kwik_API' where Id='$newrechid'";
													mysqli_query($con,$UpdateRechApibal);
														
													$apikey="8tyeubd-prieyeiw-854125-75yhr-8454adz";
													if($postpaidOperator=="Postpaid")
													{
														$url="https://www.kwikapi.com/api/v2/bills/recharge.php?api_key=$apikey&number=$mnum&amount=$amount&opid=$KwikApiOpCode&state_code=0&order_id=$newrechid";
															
														$curl = curl_init();
														curl_setopt_array($curl, array(
														CURLOPT_URL => $url,
														CURLOPT_RETURNTRANSFER => true,
														CURLOPT_ENCODING => "",
														CURLOPT_MAXREDIRS => 10,
														CURLOPT_TIMEOUT => 0,
														CURLOPT_FOLLOWLOCATION => false,
														CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
														CURLOPT_CUSTOMREQUEST => "GET",
														));
		
														$response = curl_exec($curl);
														$err = curl_error($curl);
		
														curl_close($curl);
		
														if ($err)
														{
															echo "cURL Error #:" . $err;
															$errData=json_decode($err);
															$status1 = $errData->status;
															$resText = $errData->message;
															if($status1=="FAILED")
															{
															    $UpdateRechApibal="update recharge set ReHit='1', AdminOpId='$resText', API='Kwik_API' where Id='$newrechid'";
														    	mysqli_query($con,$UpdateRechApibal);
															}
														}
														else
														{
															$data2=json_decode($response);
													
															$status1 = $data2->status;
															$resText = $data2->message;
															$txnId = $data2->opr_id;
															$kwikApiBal = $data2->balance;
													
															if($status1=="PENDING" || $status1=="SUCCESS")
															{
																$queryUpadateOrderId="update recharge set Transactionid='$orderId', Status='$status1', Operatorid='$txnId', API='Kwik_API', ApiBal='$kwikApiBal' where Id='$newrechid'";
																mysqli_query($con,$queryUpadateOrderId);
																
																$quUpdatebal="UPDATE myapi SET LapuBal='$kwikApiBal', LastUpdate='$date', OrderId='$newrechid' WHERE LapuNumber='Kwik_Api'";
														        mysqli_query($con,$quUpdatebal);
                                                        			
																echo "<h1 align='center'><font color='#008000'> &#x2714; Your Request Submit Successfull !</font></h1><br>";
															}
															
															elseif($postpaidOperator=="Postpaid")
															{
					
															}
															elseif($AutoFailedStatus=="Deactive")
															{
																$UpdateRechApibal="update recharge set ReHit='1', AdminOpId='$resText', API='Kwik_API' where Id='$newrechid'";
																mysqli_query($con,$UpdateRechApibal);
															
															}
															else
															{
															        
			            								            $queryRefund="insert into wallet(Userid,Txn,Credit,Remarks,Date,Time,Transactiontype,Paynrechid,Operator,Mobile,Amount)
						            				                values('$userid','$actual','$actual','Recharge_Refund','$date','$time','Recharge_Refund','$newrechid','$operator','$mnum','$amount')";
									            	                if(mysqli_query($con,$queryRefund))
										                            {
															            $refundewalletid=mysqli_insert_id($con);
															
            															$failedquery="update recharge set Creditewalletid='$refundewalletid', Status='FAILED', Transactionid='$orderId', Operatorid='$Printmsg', Responsetxt='$resText', API='My_API2' where Id='$newrechid'";
			            												mysqli_query($con,$failedquery);
						    									
							            								$deletecomm="delete from commwallet where Rechargeid='$newrechid'";
										            					mysqli_query($con,$deletecomm);
															
													            		$queryNewBal="select * from wallet where Userid='$userid' and Id>=$EwalletId";
            	                                                        $resultNewBal=mysqli_query($con,$queryNewBal);
	                                                                    $newbal3=0;
	                                                                    while($dataNewBal=mysqli_fetch_array($resultNewBal))
	                                                                    {
	                                                                        $Retbal= $dataNewBal['Txn'];
	                                                                        $newbal3=$newbal3+$Retbal;
            	                                                        }
            	                                                        $OpeningBal=$newbal3-$actual;
	                                                                    $queryW="update wallet set Openingbalance='$OpeningBal', Balance='$newbal3' where Id='$refundewalletid'";
									    		                        mysqli_query($con,$queryW);
			                												$query9="update retailer set Balance='$newbal3' where Userid='$userid'";
							                								mysqli_query($con,$query9);
											    				
												                			 echo "<h1 align='center'><font color='#ff0000'> &#x2716; Your Recharge Request Has Been Failed Now !</font></h1>";
																    }
															}
														}
													}
													else
													{
														$url="https://www.kwikapi.com/api/v2/recharge.php?api_key=$apikey&number=$mnum&amount=$amount&opid=$KwikApiOpCode&state_code=0&order_id=$newrechid";
															
														$curl = curl_init();
														curl_setopt_array($curl, array(
														CURLOPT_URL => $url,
														CURLOPT_RETURNTRANSFER => true,
														CURLOPT_ENCODING => "",
														CURLOPT_MAXREDIRS => 10,
														CURLOPT_TIMEOUT => 0,
														CURLOPT_FOLLOWLOCATION => false,
														CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
														CURLOPT_CUSTOMREQUEST => "GET",
														));
		
														$response = curl_exec($curl);
														$err = curl_error($curl);
		
														curl_close($curl);
		
														if ($err)
														{
															echo "cURL Error #:" . $err;
														}
														else
														{
															$data2=json_decode($response);
													
															$status1 = $data2->status;
															$resText = $data2->message;
															$txnId = $data2->opr_id;
															$kwikApiBal = $data2->balance;
													
															if($status1=="PENDING")
															{
															    $queryUpadateOrderId="update recharge set Transactionid='$orderId', Status='$status1', Operatorid='$txnId', API='Kwik_API' where Id='$newrechid'";
																mysqli_query($con,$queryUpadateOrderId);
															    echo "<h1 align='center'><font color='#008000'> &#x2714; Your Request Submit Successfull !</font></h1><br>";
															}
															elseif($status1=="SUCCESS")
															{
															    $GetLapuOldBal="select * from recharge where LapuNo='Kwik_Api' and status='SUCCESS' order by Id desc";
                                                               	$reGetLapuOldBal=mysqli_query($con,$GetLapuOldBal);
                                                        	    $dataGetLapuOldBal=mysqli_fetch_array($reGetLapuOldBal);
                                                            	$LapuOldBal=$dataGetLapuOldBal['ApiBal'];
                                                            	$remaiBal=$LapuOldBal-$amount;
                                                            	
																$queryUpadateOrderId="update recharge set Transactionid='$orderId', Status='$status1', Operatorid='$txnId', API='Kwik_API' where Id='$newrechid'";
																mysqli_query($con,$queryUpadateOrderId);
																
																$curl = curl_init();

                                                                    curl_setopt_array($curl, array(
                                                                  CURLOPT_URL => "https://www.kwikapi.com/api/v2/balance.php?api_key=8tyeubd-prieyeiw-854125-75yhr-8454adz",
                                                                  CURLOPT_RETURNTRANSFER => true,
                                                                  CURLOPT_ENCODING => "",
                                                                  CURLOPT_MAXREDIRS => 10,
                                                                  CURLOPT_TIMEOUT => 0,
                                                                  CURLOPT_FOLLOWLOCATION => false,
                                                                  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                                                                  CURLOPT_CUSTOMREQUEST => "GET",
                                                                                ));

                                                                $response = curl_exec($curl);
                                                                $err = curl_error($curl);

                                                                        curl_close($curl);

                                                                    if ($err) {
                                                                  echo "cURL Error #:" . $err;
                                                                    }
                                                                   else
                                                                   {
                                                                       $data2=json_decode($response);
											
                                                        			    $KwikApiBal = $data2->response->balance;;
                                                                   }
            
                                                        		    $LapuDiff=$KwikApiBal-$remaiBal;
                                                        		    $UpdateRechApibal="update recharge set ApiBal='$KwikApiBal', LapuNo='Kwik_Api', Diff='$LapuDiff' where Id='$newrechid'";
                                                        			mysqli_query($con,$UpdateRechApibal);
                                                        			
                                                        			$quUpdatebal="UPDATE myapi SET LapuBal='$KwikApiBal', LastUpdate='$date', OrderId='$newrechid' WHERE LapuNumber='Kwik_Api'";
														            mysqli_query($con,$quUpdatebal);
                                                        			
																echo "<h1 align='center'><font color='#008000'> &#x2714; Your Request Submit Successfull !</font></h1><br>";
															}
															elseif($postpaidOperator=="Postpaid")
															{
					
															}
															elseif($AutoFailedStatus=="Deactive")
															{
																$UpdateRechApibal="update recharge set ReHit='1', AdminOpId='$resText', API='Kwik_API' where Id='$newrechid'";
																mysqli_query($con,$UpdateRechApibal);
															
															}
															else
															{
																    
			            								            $queryRefund="insert into wallet(Userid,Txn,Credit,Remarks,Date,Time,Transactiontype,Paynrechid,Operator,Mobile,Amount)
						            				                values('$userid','$actual','$actual','Recharge_Refund','$date','$time','Recharge_Refund','$newrechid','$operator','$mnum','$amount')";
									            	                if(mysqli_query($con,$queryRefund))
										                            {
															            $refundewalletid=mysqli_insert_id($con);
															
            															$failedquery="update recharge set Creditewalletid='$refundewalletid', Status='FAILED', Transactionid='$orderId', Operatorid='$Printmsg', Responsetxt='$resText', API='My_API2' where Id='$newrechid'";
			            												mysqli_query($con,$failedquery);
						    									
							            								$deletecomm="delete from commwallet where Rechargeid='$newrechid'";
										            					mysqli_query($con,$deletecomm);
															
													            		$queryNewBal="select * from wallet where Userid='$userid' and Id>=$EwalletId";
            	                                                        $resultNewBal=mysqli_query($con,$queryNewBal);
	                                                                    $newbal3=0;
	                                                                    while($dataNewBal=mysqli_fetch_array($resultNewBal))
	                                                                    {
	                                                                        $Retbal= $dataNewBal['Txn'];
	                                                                        $newbal3=$newbal3+$Retbal;
            	                                                        }
            	                                                        $OpeningBal=$newbal3-$actual;
	                                                                    $queryW="update wallet set Openingbalance='$OpeningBal', Balance='$newbal3' where Id='$refundewalletid'";
									    		                        mysqli_query($con,$queryW);
			                												$query9="update retailer set Balance='$newbal3' where Userid='$userid'";
							                								mysqli_query($con,$query9);
											    				
												                			 echo "<h1 align='center'><font color='#ff0000'> &#x2716; Your Recharge Request Has Been Failed Now !</font></h1>";
																    }
															}
														}
													}
												}
												elseif($UseApi2=="DiziPay_Api")
												{   
											        $UpdateRechApibal="update recharge set API='DiziPay_Api' where Id='$newrechid'";
											    	mysqli_query($con,$UpdateRechApibal);
											    	
                                                    $apiUsrId="6";
                                                    $apiToken="e0330b377da0041bf360f65f150cd41d";
                                                    $url="http://dizipayapi.com/API/TransactionAPI?UserID=$apiUsrId&Token=$apiToken&Account=$mnum&Amount=$amount&SPKey=$DiziPayOpCode&APIRequestID=$newrechid"; 
		                                            $request_timeout = 60; // 60 seconds timeout
		                                            $ch = curl_init();
		                                            curl_setopt($ch, CURLOPT_URL, $url);
		                                            curl_setopt($ch, CURLOPT_TIMEOUT, $request_timeout);
		                                            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $request_timeout);
		                                            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	                                            	$output = curl_exec($ch);
		                                            $curl_error = curl_errno($ch);
		                                            $getserver= curl_getinfo($ch);
		                                            curl_close($ch);
		                                            $data2=json_decode($output);
		                                            $DiziPayApiBal=$data2->bal;
                                                    $status1 = $data2->status;   
                                                    $msg = $data2->msg;   
                                                    $txnId = $data2->opid;   
                                                    $OrderID = $data2->rpid;    
                                                                
														  if($status1=="SUCCESS" || $status1=="2")
														  {
														      $GetLapuOldBal="select * from recharge where LapuNo='DiziPay_Api' and status='SUCCESS' order by Id desc";
                                                              $reGetLapuOldBal=mysqli_query($con,$GetLapuOldBal);
                                                        	  $dataGetLapuOldBal=mysqli_fetch_array($reGetLapuOldBal);
                                                              $LapuOldBal=$dataGetLapuOldBal['ApiBal'];
                                                        	  $remaiBal=$LapuOldBal-$amount;
                                                        	  $LapuDiff = $DiziPayApiBal-$remaiBal;
                                                        	  
														      $queryUpadateOrderId="update recharge set LapuNo='DiziPay_Api', Transactionid='$orderId', Status='SUCCESS', Operatorid='$txnId', LapuOldBal='$LapuOldBal', Diff='$LapuDiff', API='DiziPay_Api', LapuNo='DiziPay_Api', ApiBal='$DiziPayApiBal' where Id='$newrechid'";
															  mysqli_query($con,$queryUpadateOrderId);
															  
															  $quUpdatebal="UPDATE myapi SET LapuBal='$DiziPayApiBal', LastUpdate='$date', OrderId='$newrechid' WHERE LapuNumber='DiziPay_Api'";
														      mysqli_query($con,$quUpdatebal);
															  
															  echo "<h1 align='center'><font color='#008000'> &#x2714; Your Request Submit Successfully !</font></h1><br>";
																		
														  }
														  elseif($status1=="PENDING" || $status1=="1")
														  {   
														      $queryUpadateOrderId="update recharge set Transactionid='$OrderID', Status='PENDING', Operatorid='$txnId', LapuOldBal='$LapuOldBal', Diff='$LapuDiff', API='DiziPay_Api', LapuNo='DiziPay_Api', ApiBal='$LapuBal' where Id='$newrechid'";
															  mysqli_query($con,$queryUpadateOrderId);
																
															  echo "<h1 align='center'><font color='#008000'> &#x2714; Your Request Submit Successfully !</font></h1><br>";
														  }
														  elseif($status1=="FAILED" || $status1=="3"  || $status1=="4")
														  {
														      
														          $Printmsg =$msg;
														      
														      
														      if($msg=="No Plans Found with this Amount	" || $msg=="You can only select other than prime plan for recharge.	" || $msg=="No records found" || $msg=="You can only select other than prime plan for recharge." || $msg=="IN Bad MSISDN" || $msg=="Transaction Failed" || $msg=="Subscriber Not Found" || $msg=="Card gorup set ID not found.")
														      {
														          
														            
			            								            $queryRefund="insert into wallet(Userid,Txn,Credit,Remarks,Date,Time,Transactiontype,Paynrechid,Operator,Mobile,Amount)
						            				                values('$userid','$actual','$actual','Recharge_Refund','$date','$time','Recharge_Refund','$newrechid','$operator','$mnum','$amount')";
									            	                if(mysqli_query($con,$queryRefund))
										                            {
															            $refundewalletid=mysqli_insert_id($con);
															
            															$failedquery="update recharge set Creditewalletid='$refundewalletid', Status='FAILED', Transactionid='$orderId', Operatorid='$Printmsg', Responsetxt='$resText', API='DiziPay_Api' where Id='$newrechid'";
			            												mysqli_query($con,$failedquery);
						    									
							            								$deletecomm="delete from commwallet where Rechargeid='$newrechid'";
										            					mysqli_query($con,$deletecomm);
															
													            		$queryNewBal="select * from wallet where Userid='$userid' and Id>=$EwalletId";
            	                                                        $resultNewBal=mysqli_query($con,$queryNewBal);
	                                                                    $newbal3=0;
	                                                                    while($dataNewBal=mysqli_fetch_array($resultNewBal))
	                                                                    {
	                                                                        $Retbal= $dataNewBal['Txn'];
	                                                                        $newbal3=$newbal3+$Retbal;
            	                                                        }
            	                                                        $OpeningBal=$newbal3-$actual;
	                                                                    $queryW="update wallet set Openingbalance='$OpeningBal', Balance='$newbal3' where Id='$refundewalletid'";
									    		                        mysqli_query($con,$queryW);
			                												$query9="update retailer set Balance='$newbal3' where Userid='$userid'";
							                								mysqli_query($con,$query9);
											    				
												                			 echo "<h1 align='center'><font color='#ff0000'> &#x2716; Your Recharge Request Has Been Failed Now !</font></h1>";
																    }
														          
														      }
														      elseif($AutoFailedStatus=="Deactive")
														      {
														    		$UpdateRechApibal="update recharge set ReHit='1', AdminOpId='$msg', API='DiziPay_Api' where Id='$newrechid'";
															    	mysqli_query($con,$UpdateRechApibal);
															    	echo "<h1 align='center'><font color='#008000'> &#x2714; Your Request Submit Successfully !</font></h1><br>";
														      }
														      else
														      {
															        
			            								            $queryRefund="insert into wallet(Userid,Txn,Credit,Remarks,Date,Time,Transactiontype,Paynrechid,Operator,Mobile,Amount)
						            				                values('$userid','$actual','$actual','Recharge_Refund','$date','$time','Recharge_Refund','$newrechid','$operator','$mnum','$amount')";
									            	                if(mysqli_query($con,$queryRefund))
										                            {
															            $refundewalletid=mysqli_insert_id($con);
															
            															$failedquery="update recharge set Creditewalletid='$refundewalletid', Status='FAILED', Transactionid='$orderId', Operatorid='$Printmsg', Responsetxt='$resText', API='DiziPay_Api' where Id='$newrechid'";
			            												mysqli_query($con,$failedquery);
						    									
							            								$deletecomm="delete from commwallet where Rechargeid='$newrechid'";
										            					mysqli_query($con,$deletecomm);
															
													            		$queryNewBal="select * from wallet where Userid='$userid' and Id>=$EwalletId";
            	                                                        $resultNewBal=mysqli_query($con,$queryNewBal);
	                                                                    $newbal3=0;
	                                                                    while($dataNewBal=mysqli_fetch_array($resultNewBal))
	                                                                    {
	                                                                        $Retbal= $dataNewBal['Txn'];
	                                                                        $newbal3=$newbal3+$Retbal;
            	                                                        }
            	                                                        $OpeningBal=$newbal3-$actual;
	                                                                    $queryW="update wallet set Openingbalance='$OpeningBal', Balance='$newbal3' where Id='$refundewalletid'";
									    		                        mysqli_query($con,$queryW);
			                												$query9="update retailer set Balance='$newbal3' where Userid='$userid'";
							                								mysqli_query($con,$query9);
											    				
												                			 echo "<h1 align='center'><font color='#ff0000'> &#x2716; Your Recharge Request Has Been Failed Now !</font></h1>";
																    }
														      }
														  }
												}
												elseif($UseApi2=="Ozzy_Api")
												{   
											        $UpdateRechApibal="update recharge set API='Ozzy_Api' where Id='$newrechid'";
											    	mysqli_query($con,$UpdateRechApibal);
											    	
                                                    $apiUsrId=170;
                                                    $apiToken="2bc8fc628274544b5ba8445989e865ec";
                                                    $url="http://ozzyrecharge.com/API/TransactionAPI?UserID=$apiUsrId&Token=$apiToken&Account=$mnum&Amount=$amount&SPKey=$OzzyOpCode&APIRequestID=$newrechid"; 
		                                            $request_timeout = 60; // 60 seconds timeout
		                                            $ch = curl_init();
		                                            curl_setopt($ch, CURLOPT_URL, $url);
		                                            curl_setopt($ch, CURLOPT_TIMEOUT, $request_timeout);
		                                            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $request_timeout);
		                                            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	                                            	$output = curl_exec($ch);
		                                            $curl_error = curl_errno($ch);
		                                            $getserver= curl_getinfo($ch);
		                                            curl_close($ch);
		                                            $data2=json_decode($output);
		                                            
		                                            $Ozzy_ApiBal=$data2->bal;
                                                    $status1 = $data2->status;   
                                                    $msg = $data2->msg;   
                                                    $txnId = $data2->opid;   
                                                    $OrderID = $data2->rpid;    
                                                                
														  if($status1=="SUCCESS" || $status1=="2")
														  {
														      $GetLapuOldBal="select * from recharge where LapuNo='Ozzy_Api' and status='SUCCESS' order by Id desc";
                                                              $reGetLapuOldBal=mysqli_query($con,$GetLapuOldBal);
                                                        	  $dataGetLapuOldBal=mysqli_fetch_array($reGetLapuOldBal);
                                                              $LapuOldBal=$dataGetLapuOldBal['ApiBal'];
                                                        	  $remaiBal=$LapuOldBal-$amount;
                                                        	  $LapuDiff = $OzzyApiBal-$remaiBal;
                                                        	  
														      $queryUpadateOrderId="update recharge set LapuNo='Ozzy_Api', Transactionid='$orderId', Status='SUCCESS', Operatorid='$txnId', LapuOldBal='$LapuOldBal', Diff='$LapuDiff', API='Ozzy_Api', LapuNo='Ozzy_Api', ApiBal='$OzzyApiBal' where Id='$newrechid'";
															  mysqli_query($con,$queryUpadateOrderId);
															  
															  $quUpdatebal="UPDATE myapi SET LapuBal='$Ozzy_ApiBal', LastUpdate='$date', OrderId='$newrechid' WHERE LapuNumber='Ozzy_Api'";
														      mysqli_query($con,$quUpdatebal);
																
															  echo "<h1 align='center'><font color='#008000'> &#x2714; Your Request Submit Successfully !</font></h1><br>";
																		
														  }
														  elseif($status1=="PENDING" || $status1=="1")
														  {   
														      $queryUpadateOrderId="update recharge set Transactionid='$OrderID', Status='PENDING', Operatorid='$txnId', LapuOldBal='$LapuOldBal', Diff='$LapuDiff', API='Ozzy_Api', LapuNo='Ozzy_Api', ApiBal='$LapuBal' where Id='$newrechid'";
															  mysqli_query($con,$queryUpadateOrderId);
																
															  echo "<h1 align='center'><font color='#008000'> &#x2714; Your Request Submit Successfully !</font></h1><br>";
														  }
														  elseif($status1=="FAILED" || $status1=="3"  || $status1=="4")
														  {
														      
														          $Printmsg =$msg;
														      
														      
														      if($msg=="No Plans Found with this Amount	" || $msg=="You can only select other than prime plan for recharge.	" || $msg=="No records found" || $msg=="You can only select other than prime plan for recharge." || $msg=="IN Bad MSISDN" || $msg=="Transaction Failed" || $msg=="Subscriber Not Found" || $msg=="Card gorup set ID not found.")
														      {
														          
														            
			            								            $queryRefund="insert into wallet(Userid,Txn,Credit,Remarks,Date,Time,Transactiontype,Paynrechid,Operator,Mobile,Amount)
						            				                values('$userid','$actual','$actual','Recharge_Refund','$date','$time','Recharge_Refund','$newrechid','$operator','$mnum','$amount')";
									            	                if(mysqli_query($con,$queryRefund))
										                            {
															            $refundewalletid=mysqli_insert_id($con);
															
            															$failedquery="update recharge set Creditewalletid='$refundewalletid', Status='FAILED', Transactionid='$orderId', Operatorid='$Printmsg', Responsetxt='$resText', API='Ozzy_Api' where Id='$newrechid'";
			            												mysqli_query($con,$failedquery);
						    									
							            								$deletecomm="delete from commwallet where Rechargeid='$newrechid'";
										            					mysqli_query($con,$deletecomm);
															
													            		$queryNewBal="select * from wallet where Userid='$userid' and Id>=$EwalletId";
            	                                                        $resultNewBal=mysqli_query($con,$queryNewBal);
	                                                                    $newbal3=0;
	                                                                    while($dataNewBal=mysqli_fetch_array($resultNewBal))
	                                                                    {
	                                                                        $Retbal= $dataNewBal['Txn'];
	                                                                        $newbal3=$newbal3+$Retbal;
            	                                                        }
            	                                                        $OpeningBal=$newbal3-$actual;
	                                                                    $queryW="update wallet set Openingbalance='$OpeningBal', Balance='$newbal3' where Id='$refundewalletid'";
									    		                        mysqli_query($con,$queryW);
			                												$query9="update retailer set Balance='$newbal3' where Userid='$userid'";
							                								mysqli_query($con,$query9);
											    				
												                			 echo "<h1 align='center'><font color='#ff0000'> &#x2716; Your Recharge Request Has Been Failed Now !</font></h1>";
																    }
														          
														      }
														      elseif($AutoFailedStatus=="Deactive")
														      {
														    		$UpdateRechApibal="update recharge set ReHit='1', AdminOpId='$msg', API='Ozzy_Api' where Id='$newrechid'";
															    	mysqli_query($con,$UpdateRechApibal);
															    	echo "<h1 align='center'><font color='#008000'> &#x2714; Your Request Submit Successfully !</font></h1><br>";
														      }
														      else
														      {
															        
			            								            $queryRefund="insert into wallet(Userid,Txn,Credit,Remarks,Date,Time,Transactiontype,Paynrechid,Operator,Mobile,Amount)
						            				                values('$userid','$actual','$actual','Recharge_Refund','$date','$time','Recharge_Refund','$newrechid','$operator','$mnum','$amount')";
									            	                if(mysqli_query($con,$queryRefund))
										                            {
															            $refundewalletid=mysqli_insert_id($con);
															
            															$failedquery="update recharge set Creditewalletid='$refundewalletid', Status='FAILED', Transactionid='$orderId', Operatorid='$Printmsg', Responsetxt='$resText', API='Ozzy_Api' where Id='$newrechid'";
			            												mysqli_query($con,$failedquery);
						    									
							            								$deletecomm="delete from commwallet where Rechargeid='$newrechid'";
										            					mysqli_query($con,$deletecomm);
															
													            		$queryNewBal="select * from wallet where Userid='$userid' and Id>=$EwalletId";
            	                                                        $resultNewBal=mysqli_query($con,$queryNewBal);
	                                                                    $newbal3=0;
	                                                                    while($dataNewBal=mysqli_fetch_array($resultNewBal))
	                                                                    {
	                                                                        $Retbal= $dataNewBal['Txn'];
	                                                                        $newbal3=$newbal3+$Retbal;
            	                                                        }
            	                                                        $OpeningBal=$newbal3-$actual;
	                                                                    $queryW="update wallet set Openingbalance='$OpeningBal', Balance='$newbal3' where Id='$refundewalletid'";
									    		                        mysqli_query($con,$queryW);
			                												$query9="update retailer set Balance='$newbal3' where Userid='$userid'";
							                								mysqli_query($con,$query9);
											    				
												                			 echo "<h1 align='center'><font color='#ff0000'> &#x2716; Your Recharge Request Has Been Failed Now !</font></h1>";
																    }
														      }
														  }
												}
												elseif($UseApi2=="PP_Api")
												{
												    $UpdateRechApibal="update recharge set API='PP_API' where Id='$newrechid'";
													mysqli_query($con,$UpdateRechApibal);
													
													//Perfect Paisa API Balance //
	
                                                        $token2="b968b63cabae4d9aa26b4c252e13be11";
                                                    	$url2="https://www.perfectpaisa.in/apiservice.asmx/GetBalance?apiToken=$token2";
                                                    	$request_timeout = 60; // 60 seconds timeout
                                                    	$ch2 = curl_init();
                                                    	curl_setopt($ch2, CURLOPT_URL, $url2);
                                                    	curl_setopt($ch2, CURLOPT_TIMEOUT, $request_timeout);
                                                    	curl_setopt($ch2, CURLOPT_CONNECTTIMEOUT, $request_timeout);
                                                    	curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
                                                        $output2 = curl_exec($ch2);
                                                    	$curl_error = curl_errno($ch2);
                                                    	$getserver= curl_getinfo($ch2);
                                                    	curl_close($ch2);
                                                        $xml2 = simplexml_load_string($output2);
                                                    	$PP_API_Bal=floor($xml2);
	
													$token="b968b63cabae4d9aa26b4c252e13be11";
													$url="https://www.perfectpaisa.in/apiservice.asmx/Recharge?apiToken=$token&mn=$mnum&op=$PP_ApiOpCode&amt=$amount&reqid=$newrechid&field1=''&field2=''";

													$request_timeout = 60; // 60 seconds timeout
													$ch = curl_init();
													curl_setopt($ch, CURLOPT_URL, $url);
													curl_setopt($ch, CURLOPT_TIMEOUT, $request_timeout);
													curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $request_timeout);
													curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
													$output = curl_exec($ch);
													$curl_error = curl_errno($ch);
													$getserver= curl_getinfo($ch);
													curl_close($ch);
													
														
														$UpdatePPApi="update recharge set Operatorid='$operatorId', AdminOpId='$output', API='PP_Api' where Id='$newrechid'";
														mysqli_query($con,$UpdatePPApi);
													
														$xml = simplexml_load_string($output);
														
														$error_code=$xml->ec;
														if($error_code=="1010")
														{
														    $status1=="PENDING";
														}
														elseif($error_code=="1000")
														{
														    $status1=="SUCCESS";
														}
														elseif($error_code=="1010" || $error_code=="1005" || $error_code=="1015")
														{
														    $status1=="FAILED";
														    
														    $queryRefund="insert into wallet(Userid,Txn,Credit,Remarks,Date,Time,Transactiontype,Paynrechid,Operator,Mobile,Amount)
						            				                values('$userid','$actual','$actual','Recharge_Refund','$date','$time','Recharge_Refund','$newrechid','$operator','$mnum','$amount')";
									            	                if(mysqli_query($con,$queryRefund))
										                            {
															            $refundewalletid=mysqli_insert_id($con);
															
            															$failedquery="update recharge set Creditewalletid='$refundewalletid', Status='FAILED', Transactionid='$orderId', Operatorid='$error_code', Responsetxt='$resText', API='PP_Api' where Id='$newrechid'";
			            												mysqli_query($con,$failedquery);
						    									
							            								$deletecomm="delete from commwallet where Rechargeid='$newrechid'";
										            					mysqli_query($con,$deletecomm);
															
													            		$queryNewBal="select * from wallet where Userid='$userid' and Id>=$EwalletId";
            	                                                        $resultNewBal=mysqli_query($con,$queryNewBal);
	                                                                    $newbal3=0;
	                                                                    while($dataNewBal=mysqli_fetch_array($resultNewBal))
	                                                                    {
	                                                                        $Retbal= $dataNewBal['Txn'];
	                                                                        $newbal3=$newbal3+$Retbal;
            	                                                        }
            	                                                        $OpeningBal=$newbal3-$actual;
	                                                                    $queryW="update wallet set Openingbalance='$OpeningBal', Balance='$newbal3' where Id='$refundewalletid'";
									    		                        mysqli_query($con,$queryW);
									    		                        
			                											$query9="update retailer set Balance='$newbal3' where Userid='$userid'";
							                							mysqli_query($con,$query9);
											    				
												                		echo "<h1 align='center'><font color='#ff0000'> &#x2716; Your Recharge Request Has Been Failed Now !</font></h1>";
																    }
														}
														$orderId=$xml->orderId;
														$status1=$xml->status;
														$mobile=$xml->mn;
														$operatorId=$xml->field1;
														$balance=$xml->balance;
														if($status1=="PENDING")
														{
															$queryUpadateOrderId="update recharge set Transactionid='$orderId', API='PP_Api' where Id='$newrechid'";
															mysqli_query($con,$queryUpadateOrderId);
															echo "<h1 align='center'><font color='#008000'> &#x2714; Your Request Submit Successfull !</font></h1><br>";
														}
														elseif($status1=="SUCCESS")
														{
														    $GetLapuOldBal="select * from recharge where LapuNo='PP_Api' and status='SUCCESS' order by Id desc";
                                                        	$reGetLapuOldBal=mysqli_query($con,$GetLapuOldBal);
                                                    	    $dataGetLapuOldBal=mysqli_fetch_array($reGetLapuOldBal);
                                                        	$LapuOldBal=$dataGetLapuOldBal['ApiBal'];
                                                        	$remaiBal=$LapuOldBal-$amount;
	                                                        $LapuDiff=$balance-$remaiBal;
	                                                        
															$UpdatePPApibal="update recharge set LapuNo='PP_Api', ApiBal='$balance', Diff='$LapuDiff', Operatorid='$operatorId', Status='SUCCESS', AdminOpId='S', API='PP_Api' where Id='$newrechid'";
															mysqli_query($con,$UpdatePPApibal);
															
															$quUpdatebal="UPDATE myapi SET LapuBal='$PP_API_Bal', LastUpdate='$date', OrderId='$newrechid' WHERE LapuNumber='PP_Api'";
														    mysqli_query($con,$quUpdatebal);
															
															echo "<h1 align='center'><font color='#008000'> &#x2714; Your Request Submit Successfull !</font></h1><br>";
														}
														elseif($status1=="FAILED" || $status1=="REFUND")
														{
															    
														    if($AutoFailedStatus=="Deactive")
														    {
		    													$UpdateRechApibal="update recharge set ReHit='1', AdminOpId='$output', API='PP_Api' where Id='$newrechid'";
			    												mysqli_query($con,$UpdateRechApibal);
															
				    										}
				    										else
				    										{
			            								            $queryRefund="insert into wallet(Userid,Txn,Credit,Remarks,Date,Time,Transactiontype,Paynrechid,Operator,Mobile,Amount)
						            				                values('$userid','$actual','$actual','Recharge_Refund','$date','$time','Recharge_Refund','$newrechid','$operator','$mnum','$amount')";
									            	                if(mysqli_query($con,$queryRefund))
										                            {
															            $refundewalletid=mysqli_insert_id($con);
															
            															$failedquery="update recharge set Creditewalletid='$refundewalletid', Status='FAILED', Transactionid='$orderId', Operatorid='$error_code', Responsetxt='$resText', API='PP_Api' where Id='$newrechid'";
			            												mysqli_query($con,$failedquery);
						    									
							            								$deletecomm="delete from commwallet where Rechargeid='$newrechid'";
										            					mysqli_query($con,$deletecomm);
															
													            		$queryNewBal="select * from wallet where Userid='$userid' and Id>=$EwalletId";
            	                                                        $resultNewBal=mysqli_query($con,$queryNewBal);
	                                                                    $newbal3=0;
	                                                                    while($dataNewBal=mysqli_fetch_array($resultNewBal))
	                                                                    {
	                                                                        $Retbal= $dataNewBal['Txn'];
	                                                                        $newbal3=$newbal3+$Retbal;
            	                                                        }
            	                                                        $OpeningBal=$newbal3-$actual;
	                                                                    $queryW="update wallet set Openingbalance='$OpeningBal', Balance='$newbal3' where Id='$refundewalletid'";
									    		                        mysqli_query($con,$queryW);
									    		                        
			                											$query9="update retailer set Balance='$newbal3' where Userid='$userid'";
							                							mysqli_query($con,$query9);
											    				
												                		echo "<h1 align='center'><font color='#ff0000'> &#x2716; Your Recharge Request Has Been Failed Now !</font></h1>";
																    }
				    										}
														}
												
												}
											}
											else
											{
												echo "<h1 align='center'><font color='#ff0000'> &#x2716; Error 5 !</font></h1>";
											}
										
										}
										else
										{
											echo "<h1 align='center'><font color='#ff0000'> &#x2716; Error For Insert Data !</font></h1>";
										}
								}	
							}	
							else	
							{
								echo "<h1 align='center'><font color='#ff0000'> &#x2716; Your Balance Is Low !</font></h1>";
							}
						}
						else
						{
						    echo "<h1 align='center'><font color='#ff0000'> &#x2716; ".$msgPass."</font></h1>";
						}
					}
					else
					{
						echo "<h1 align='center'><font color='#ff0000'> &#x2716; Mobile Number And Confirm Number Does Not Match !</font></h1>";
					}
				}
			}		
			echo "<meta http-equiv='refresh' content='5' />";		
			
		}
    }
    else
    {
    	header('location:../login.php');
    }
       
    
?>
<div class="rech">
    <input type="number" id="user" value="<?php echo $userid; ?>" style="display:none;">
<form method='post'>
	<table border="0" cellpadding="10">
	    <tr>
	        <td id="tdfl">Balance : </td>
	        <?php
	        if($currentbal>=500)
	        {
	            $colorBal="greenbal";
	        }
	        else
	        {
	            $colorBal="redbal";
	        }
	        ?>
	        <td ><p id="greenbal"></p></td>
	   </tr>
		<tr>
			<td id="tdfl">Recharge: </td>
			<td >
			<?php
			include'connection.php';
			$querygetservic="select * from service";
			$resultgetservic=mysqli_query($con,$querygetservic);
			?>
			<script>
				function onchange_event(arg)
				{
					var xmlhttp = new XMLHttpRequest();
					xmlhttp.open("GET","ajax.php?sid="+arg,false);
					xmlhttp.send(null);
					document.getElementById("divop").innerHTML=xmlhttp.responseText;
				
				}
			</script>
			
			<input type='radio' id="radiobutton" name='gen' value='Mobile' onchange='onchange_event(1)' required/>Mobile
			<input type='radio' id="radiobutton" name='gen' value='DTH' onchange='onchange_event(2)' required/>DTH
			<input type='radio' id="radiobutton" name='gen' value='Postpaid' onchange='onchange_event(3)' required/>Postpaid
				
			</td>
		</tr>


			<tr>
				<td id="tdfl">Operator: </td> 
				
				<td>
				<div id="divop">
				<select name="operator"  id="inpset1" required>
						<option id="opfont">--Select Operator--</option>
					</select>
				</div></td>
			</tr>
			
			<tr>
				<td id="tdfl">DTH / Mobile No:</td>
				<td><input type="number" name="mnum" placeholder="Enter Number.." id="inpset" required></td>
			<tr>
				<td id="tdfl">Confirm No:</td>
				<td><input type="number" name="cmnum" placeholder="Re-Enter Number.." id="inpset" required></td>
			</tr>	
			<tr>
				<td id="tdfl">Amount:</td>
				<td><input type="number" name="amount" placeholder="Enter Amount.." id="inpset" required></td>
			</tr>
			<tr>
				<td></td>
				<td><input type="submit" name="submit" id="rechbtn" value="Recharge Now" onclick="show()"></td>
			</tr>
			
			</form>
		</table>
	</div>
<script>
	function MyBlink()
	{
		var r = document.getElementById("txt");
		if(r.style.color=='blue')
		{
			r.style.color ='red';
		}
		else
		{
			r.style.color ='blue';
		}
		setTimeout('MyBlink()',500)
	}
</script>
	    <div class="addiv1" id="addiv">
	        <a href="LlpRecharge.apk" download="LlpRecharge" id="dnldLink">Click Hear To Download LLP Recharge Mobile Application</a>
	    </div>
	<div class="trarepo">
		<p>Transaction Reports ( Live )</p>
	</div>
	<input type="text" id="uid" value="<?php echo $userid; ?>" style="display:none;">
		<script>
	    function GetRechReport()
	    {
	        
	        var usrid = document.getElementById("uid").value;
	        
	        var xmlhttp = new XMLHttpRequest();
	        xmlhttp.open("GET","getrechreport.php?uid="+usrid,false);
	        xmlhttp.send(null);
	        
	        document.getElementById("rechreport").innerHTML = xmlhttp.responseText;
	        
	        setTimeout("GetRechReport()", 10000);
	    }
	</script>
	<div id="rechreport">
	</div>
	<div class="foot" >
		<p >Copyright &copy; 2018 -2019 Long Life Product Pvt. Ltd.</p>
	</div>
	
</body>
</html>