
<?php
	include'connection.php';
		$userid=1111;
		date_default_timezone_set("asia/kolkata");
        $date=date("Y-m-d");
        $time=date("h:i:s A");
            
		$query8="select * from wallet where Userid='$userid' order by Id desc";
		$result8=mysqli_query($con,$query8);
		$data8=mysqli_fetch_array($result8);
		$currentbal= $data8['Balance'];
		
		$TotalIdeaBal=0;
		$TotalJioBal=0;
		$TotalVodaBal=0;
		$TotalAirtelBal=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;
		}
		
    	$ActualIdeaBal=$TotalIdeaBal*96.34/100;
	    $ActualJioBal=$TotalJioBal*93.20/100;
	    $ActualVodaBal=$TotalVodaBal*96.34/100;
	    $ActualAirtelBal=$TotalAirtelBal*96.63/100;
	
		$quUniqueAPI="select * from myapi where LapuName='Unique_API'";
		$reUniqueAPI=mysqli_query($con,$quUniqueAPI);
		$dataUniqueAPI=mysqli_fetch_array($reUniqueAPI);
		$UniqueAPIBal=$dataUniqueAPI['LapuBal'];
?>
<html>
<head>

<style>
body{background:url(bg.jpg); background-size:cover; margin:0; padding:0; width:1580px;}
#mydiv {
  position: absolute;
  z-index: 9;
  background-color: #f1f1f1;
  text-align: center;
  border: 1px solid #d3d3d3;
}

#mydivheader {
  padding: 10px;
  cursor: move;
  z-index: 10;
  background-color: #2196F3;
  color: #fff;
}

.head{background:; width:1450px; height:90px; 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; float:left;}
#link0{float:right; margin:10 10 0 0px; font-size:20px; text-decoration:none; color:white; background:red; padding:5px; border-radius:4px;}
 #link1{float:right; margin:10 10 0 0px; font-size:20px; text-decoration:none; color:white; background:green; padding:5px; border-radius:4px;}
 #link2{float:left; margin:10 0 0 20px; font-size:20px; background:white;color:Green; padding:5px; border-radius:4px;}
#link0:hover{ padding:5px; border-radius:4px; color:black;}
#time{float:right;}
.menu{background:#996420; height:40px; width:1450px; 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:170px; line-height:40px; text-align:center; font-size:17px; margin:0; 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;}
#AFLI{background:white; width:200px; height:40px; float:left; margin:15 10 0 10px; text-align:center; line-height:40px; border-radius:5px;}
#anchr{font-size:25px; text-decoration:none; padding:5px; margin:100 10px;}
.notifi{background:#995702; width:840px; height:70px; margin:5 5 5 300px; border-radius:8px;}
.imgdiv{background:; width:60px; height:60px; float:left; margin:0 20px;}
#notifidiv{background:red; width:40px; height:40px; margin:0 0 0 30px; border-radius:50%; text-align:center; line-height:40px;
color:white; font-size:20px; z-index:4; float:left; position:absolute;}
img{width:60px; height:60px; float:left; margin:7px;}
 .content{background:; width:1030px; margin:5px; float:left;}
.content1{background:; width:160px; height:160px; margin:5px; float:left;}
.content1 table{width:160px; height:160px; border-collapse:collapse; text-align:center;}
.content1 table th{height:60px; background:green; color:white; font-size:17px;}
.content1 table td{height:100px; font-size:25px; background:#eafaec;}

#bal1,#bal2,#bal3,#bal4,#bal5,#bal6,#bal7,#bal8{display:none;}
#roy1,#roy2,#roy3,#roy4,#roy5,#roy6,#roy7,#roy8{display:none;}
.ApiBalDiv{width:260px; height:500px; background:; float:left; margin:15 10 10 0px;}
#tableApiBal{text-align:center; width:360px; margin:0px; border-collapse:collapse; background:white; text-decoration:none;}
#tableApiBal th{font-size:24px; text-decoration:none; background:gray; color:white;}
#tableApiBal td{font-size:22px; text-decoration:none; background:#ffffff; color:black;}

 .foot{margin:0 0 0 100px; width:1350px; text-align:center; height:140px; float:left;}
 #siteseal{background:; width:300px; height:50px; float:left}
</style>


</head>
<body onLoad="apibal()">

<?php
	$url="http://api.rechapi.com/bal.php?format=xml&token=4x9tiI9Zz7Sxmi3G8qvhpczsijBLBt";
		$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);
		if($getserver["http_code"]==200)
		{
		
			$xml = simplexml_load_string($output);
			 $rechApiBal=$xml->bal;
		}
?>

<?php
          $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;
            }


?>

<?php
        $curl = curl_init();
        curl_setopt_array($curl, array(
        CURLOPT_URL => "http://sms2.kwikapi.com/getSMSCredit?username=sameermansuri111&apikey=dc086ecd-1a22-4928-9e4e-69703230fd4e",
        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", ));

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

           curl_close($curl);

           if ($err)
          {
              echo "cURL Error #:" . $err;
          }
          else
          { 
			    //echo $response1;
                 $rep1=str_replace(',"TRANS"]]',"","$response1");
                  $kwikSmsBal=str_replace('[[',"","$rep1");
				//$data3=json_decode($response1);
				  //echo  $kwikSmsBal = $data3->$response1->TRANS;
		  }
		  
        //DIZI_PAY API BALANCE//    
        $ApiKey="qYpom1zuu0%2bJMfK1iuYr%2fITnSZFQPeFEAE%2fdl%2fo69mY%3d";
        $ApiPwd="123456";
        $url="http://login.dizi-pay.com/retailer/api/do_check_balance.aspx?key=$ApiKey&password=$ApiPwd";
    
		$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);
		$xml = simplexml_load_string(preg_replace('/(<\?xml[^?]+?)utf-16/i', '$1utf-8', $output));
		
		$DiziPayApiBal=$xml->Balance;
?>
	<div class="head">
		<p id="p1">LLP</p>
		<p id="p2">Recharge</p>
		<p id="p3">The Complete Solution</p>
		<a id="link0" href="logout.php">Log Out</a>
		<p id="link1"><?php echo "Welcome $userid Admin";  ?></p>
	<div class="notifi">
	   <?php 
	        include'notification.php';
	   
	   ?>
			<div id="AFLI">
			    <?php
			        include'connection.php';
			        $quGetAutoFailedStatus="select Status from Auto_Failed where Id='1'";
			        $reGetAutoFailedStatus=mysqli_query($con,$quGetAutoFailedStatus);
			        $dataGetAutoFailedStatus=mysqli_fetch_array($reGetAutoFailedStatus);
			        $AutoFailedStatus=$dataGetAutoFailedStatus['Status'];
			        if($AutoFailedStatus=="Active")
			        {
		                echo "<a id='anchr' href='auto_failed_deactive.php' style='font-size:17px; color:green;'>Auto Failed Active</a>";
			        }
			        else
			        {
			            echo "<a id='anchr' href='auto_failed_active.php' style='font-size:17px; color:red;'>Auto Failed Deactive</a>";
			        }
		        
		        ?>
			</div>
	   </div>
	</div>
	
    <?php include 'menu.php'; ?>
	<div class="content">
	<?php
		include'connection.php';
		
		$queryAdmin="select * from admin";
		$resultAdmin=mysqli_query($con,$queryAdmin);
		$rowAdmin=mysqli_num_rows($resultAdmin);
		
		$quApiUsr="select * from retailer where ApiActive='1'";
		$reApiUsr=mysqli_query($con,$quApiUsr);
		$rowApiUsr=mysqli_num_rows($reApiUsr);
		
		$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;
		}
		
		$querylb="select * from distributer where Balance<5000";
		$resultlb=mysqli_query($con,$querylb);
		$rowlb=mysqli_num_rows($resultlb);
		
		$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;
		}
		
		$sum2=0;
		$query2="select * from recharge where Status='SUCCESS' and Rechargedate='$date'";
		$result2=mysqli_query($con,$query2);
		while($row2=mysqli_fetch_array($result2))
		{
			$rechbal=$row2['Amount'];
			$sum2=$sum2+$rechbal;
		}
		
		$query3="select * from commwallet where Userid='$userid'";
		$result3=mysqli_query($con,$query3);
		$sum3=0;
		while($row3=mysqli_fetch_array($result3))
		{
			$data3=$row3['Balance'];
			$sum3=$sum3+$data3;
		}
		
		$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;
		}
		
		$query5="select * from commwallet where Userid='$userid' and Active='1'";
		$result5=mysqli_query($con,$query5);
		$sum5=0;
		while($row5=mysqli_fetch_array($result5))
		{
			$data5=$row5['Balance'];
			$sum5=$sum5+$data5;
		}
		
		$query6="select * from retailer where Balance<1000";
		$result6=mysqli_query($con,$query6);
		$row6=mysqli_num_rows($result6);
		
		$query7="select * from commwallet where Userid='$userid' and Date='$date'";
		$result7=mysqli_query($con,$query7);
		$sum7=0;
		while($row7=mysqli_fetch_array($result7))
		{
			$data7=$row7['Balance'];
			$sum7=$sum7+$data7;
		}
		
		$date1=date_create($date);
		date_sub($date1,date_interval_create_from_date_string("7 days"));
		$resultdate=date_format($date1,"Y-m-d");
		$querydeac="select * from retailer where Lastrechdate<'$resultdate'";
		$resultdeac=mysqli_query($con,$querydeac);
		$rowdeac=mysqli_num_rows($resultdeac);
		
		
	?>
<div class="content">
	<a href="view_admin.php" target="_blank">
	<div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Total Admin</th></tr>
			<tr><td><?php echo $rowAdmin; ?></td></tr>
		</table>
	</div>
	</a>
	<a href="View_Api_User.php" target="_blank">
	<div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Total API User</th></tr>
			<tr><td><?php echo $rowApiUsr; ?></td></tr>
		</table>
	</div>
	</a>
	<a href="view_distributer.php" target="_blank">
	<div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Total Distributers</th></tr>
			<tr><td><?php echo $rowdis; ?></td></tr>
		</table>
	</div>
	</a>
	<a href="low_bal_distributer.php" target="_blank">
	<div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Low Balance Distributers</th></tr>
			<tr><td><?php echo $rowlb; ?></td></tr>
		</table>
	</div>
	</a>
	<a href="view_retailer.php" target="_blank">
	<div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Total Retailers</th></tr>
			<tr><td><?php echo $row1; ?></td></tr>
		</table>
	</div>
	</a>
	<a href="lazy_retailer.php" target="_blank"><div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Total Lazy Retailers</th></tr>
			<tr><td><?php echo $rowdeac; ?></td></tr>
		</table>
	</div></a>
	<a href="View_Lowbal_retailer.php" target="_blank">
	<div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Low Balance Retailers</th></tr>
			<tr><td><?php echo $row6; ?></td></tr>
		</table>
	</div>
	</a>
	<a href="withdraw_commision.php" target="_blank">
	<div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Admin Balance</th></tr>
			<tr><td><?php echo floor($currentbal); ?></td></tr>
		</table>
	</div>
	</a>
	<a href="view_md.php" target="_blank">
	<div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Total MD. Balance</th></tr>
			<tr><td><?php echo floor($sumMdBal); ?></td></tr>
		</table>
	</div>
	</a>
	<a href="view_distributer.php" target="_blank">
	<div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Total Distributers Balance</th></tr>
			<tr><td><?php echo floor($sumDisBal); ?></td></tr>
		</table>
	</div>
	</a>
	<a href="view_retailer.php" target="_blank">
	<div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Total Retailers Balance</th></tr>
			<tr><td><?php echo floor($sumRet); ?></td></tr>
		</table>
	</div>
	</a>
		<a href="withdraw_commision.php" target="_blank">
	<div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Total Pending Commission</th></tr>
			<tr><td><?php echo floor($sum4); ?></td></tr>
		</table>
	</div>
	</a>
		<a href="recharge_history.php" target="_blank"><div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>User Wallet Balance</th></tr>
			<tr><td><?php 
				$totalUserWalletBal=$sumMdBal+$sumDisBal+$sumRet+$sum4;
			echo floor($totalUserWalletBal); ?></td></tr>
		</table>
	</div></a>
	<a href="recharge_history.php" target="_blank"><div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Total Wallet Balance</th></tr>
			<tr><td><?php 
				$totalWalletBal=$currentbal+$sumMdBal+$sumDisBal+$sumRet+$sum4;
			echo floor($totalWalletBal); ?></td></tr>
		</table>
	</div></a>
	<a href="admin_recharge_history.php" target="_blank"><div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Today Recharge Amount</th></tr>
			<tr><td><?php echo $sum2; ?></td></tr>
		</table>
	</div></a>
    <?php
        $TotalApiBal=$ActualIdeaBal+$ActualJioBal+$ActualVodaBal+$ActualAirtelBal+$rechApiBal+$KwikApiBal+$UniqueAPIBal+$DiziPayApiBal;
	    $Managebal=$totalWalletBal-$TotalApiBal;
	    $BenefitBal=1000000-$Managebal;
    ?>
	<a href="AdminDiff.php" target="_blank"><div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>LLP Account Differences</th></tr>
			<tr><td><?php echo floor($BenefitBal); ?></td></tr>
		</table>
	</div></a>
	<a href="#"><div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Total MD Commission</th></tr>
			<tr><td><?php
			$sumMDIncome=0;
			$quGetMDTotalIncome="select * from commwallet where Userid='300000'";
			$reGetMDTotalIncome=mysqli_query($con,$quGetMDTotalIncome);
			while($dataGetMDTotalIncome=mysqli_fetch_array($reGetMDTotalIncome))
			{
			    $TotalMDIncome=$dataGetMDTotalIncome['Balance'];
			    $sumMDIncome=$sumMDIncome+$TotalMDIncome;
			}
			echo floor($sumMDIncome); ?></td></tr>
		</table>
	</div></a>
	<a href="#"><div class="content1">
		<table border="1" cellpadding="8">
			<tr><th>Today MD Commission</th></tr>
			<tr><td><?php
			$sumMDIncome1=0;
			$quGetMDTodayIncome1="select * from commwallet where Userid='300000' and Date='$date'";
			$reGetMDTodayIncome1=mysqli_query($con,$quGetMDTodayIncome1);
			while($dataGetMDTodayIncome1=mysqli_fetch_array($reGetMDTodayIncome1))
			{
			    $TodayMDIncome1=$dataGetMDTodayIncome1['Balance'];
			    $sumMDIncome1=$sumMDIncome1+$TodayMDIncome1;
			}
			echo floor($sumMDIncome1); ?></td></tr>
		</table>
	</div></a>
</div>
</div>
    <a href="AllApiBal.php" target="_blank"><div class="ApiBalDiv">
    <?php
        $AirtelTotalRech=0;
        $IdeaTotalRech=0;
        $JioTotalRech=0;
        $VodaTotalRech=0;
        $RechTotalRech=0;
        $UniqTotalRech=0;
        $KwikTotalRech=0;
        $DiziTotalRech=0;
        
        date_default_timezone_set("asia/kolkata");
		$dateApiBal=date("Y-m-d");
		$dateAB=date_create($dateApiBal);
		date_sub($dateAB,date_interval_create_from_date_string("1 days"));
		$resultdateAB=date_format($dateAB,"Y-m-d");
		
		// Total Recharge Of Tommarrow. 
		$queryAR="select * from recharge where Companyname='Airtel' and Status='SUCCESS' and Rechargedate='$resultdateAB'";
		$resultAR=mysqli_query($con,$queryAR);
		while($dataAR=mysqli_fetch_array($resultAR))
		{
		    $AirtelRech=$dataAR['Amount'];
		    $AirtelTotalRech=$AirtelTotalRech+$AirtelRech;
		}
		
		$queryIR="select * from recharge where Companyname='Idea' and Status='SUCCESS' and Rechargedate='$resultdateAB'";
		$resultIR=mysqli_query($con,$queryIR);
		while($dataIR=mysqli_fetch_array($resultIR))
		{
		    $IdeaRech=$dataIR['Amount'];
		    $IdeaTotalRech=$IdeaTotalRech+$IdeaRech;
		}
		
		$queryJR="select * from recharge where Companyname='Reliance Jio' and Status='SUCCESS' and Rechargedate='$resultdateAB'";
		$resultJR=mysqli_query($con,$queryJR);
		while($dataJR=mysqli_fetch_array($resultJR))
		{
		    $JioRech=$dataJR['Amount'];
		    $JioTotalRech=$JioTotalRech+$JioRech;
		}
		
		$queryVR="select * from recharge where Companyname='Vodafone' and Status='SUCCESS' and Rechargedate='$resultdateAB'";
		$resultVR=mysqli_query($con,$queryVR);
		while($dataVR=mysqli_fetch_array($resultVR))
		{
		    $VodaRech=$dataVR['Amount'];
		    $VodaTotalRech=$VodaTotalRech+$VodaRech;
		}
		
		$queryRR="select * from recharge where API='Rech_API' and Status='SUCCESS' and Rechargedate='$resultdateAB'";
		$resultRR=mysqli_query($con,$queryRR);
		while($dataRR=mysqli_fetch_array($resultRR))
		{
		    $RechRech=$dataRR['Amount'];
		    $RechTotalRech=$RechTotalRech+$RechRech;
		}
		
		$queryUR="select * from recharge where API='Unique_API' and Status='SUCCESS' and Rechargedate='$resultdateAB'";
		$resultUR=mysqli_query($con,$queryUR);
		while($dataUR=mysqli_fetch_array($resultUR))
		{
		    $UniqRech=$dataUR['Amount'];
		    $UniqTotalRech=$UniqTotalRech+$UniqRech;
		}
		
		$queryKR="select * from recharge where API='Kwik_API' and Status='SUCCESS' and Rechargedate='$resultdateAB'";
		$resultKR=mysqli_query($con,$queryKR);
		while($dataKR=mysqli_fetch_array($resultKR))
		{
		    $KwikRech=$dataKR['Amount'];
		    $KwikTotalRech=$KwikTotalRech+$KwikRech;
		}
		
		$queryDizi="select * from recharge where API='DiziPay_Api' and Status='SUCCESS' and Rechargedate='$resultdateAB'";
		$resultDizi=mysqli_query($con,$queryDizi);
		while($dataDizi=mysqli_fetch_array($resultDizi))
		{
		    $DiziRech=$dataDizi['Amount'];
		    $DiziTotalRech=$DiziTotalRech+$DiziRech;
		}
		
		// Total Recharge Of Today. 
		
		$AirtelTotalRechtoday=0;
        $IdeaTotalRechtoday=0;
        $JioTotalRechtoday=0;
        $VodaTotalRechtoday=0;
        $RechTotalRechtoday=0;
        $UniqTotalRechtoday=0;
        $KwikTotalRechtoday=0;
        $DiziTotalRechtoday=0;
		
		$queryARtoday="select * from recharge where Companyname='Airtel' and Status='SUCCESS' and Rechargedate='$dateApiBal'";
		$resultARtoday=mysqli_query($con,$queryARtoday);
		while($dataARtoday=mysqli_fetch_array($resultARtoday))
		{
		    $AirtelRechtoday=$dataARtoday['Amount'];
		    $AirtelTotalRechtoday=$AirtelTotalRechtoday+$AirtelRechtoday;
		}
		
		$queryIRtoday="select * from recharge where Companyname='Idea' and Status='SUCCESS' and Rechargedate='$dateApiBal'";
		$resultIRtoday=mysqli_query($con,$queryIRtoday);
		while($dataIRtoday=mysqli_fetch_array($resultIRtoday))
		{
		    $IdeaRechtoday=$dataIRtoday['Amount'];
		    $IdeaTotalRechtoday=$IdeaTotalRechtoday+$IdeaRechtoday;
		}
		
		$queryJRtoday="select * from recharge where Companyname='Reliance Jio' and Status='SUCCESS' and Rechargedate='$dateApiBal'";
		$resultJRtoday=mysqli_query($con,$queryJRtoday);
		while($dataJRtoday=mysqli_fetch_array($resultJRtoday))
		{
		    $JioRechtoday=$dataJRtoday['Amount'];
		    $JioTotalRechtoday=$JioTotalRechtoday+$JioRechtoday;
		}
		
		$queryVRtoday="select * from recharge where Companyname='Vodafone' and Status='SUCCESS' and Rechargedate='$dateApiBal'";
		$resultVRtoday=mysqli_query($con,$queryVRtoday);
		while($dataVRtoday=mysqli_fetch_array($resultVRtoday))
		{
		    $VodaRechtoday=$dataVRtoday['Amount'];
		    $VodaTotalRechtoday=$VodaTotalRechtoday+$VodaRechtoday;
		}
		
		$queryRRtoday="select * from recharge where API='Rech_API' and Status='SUCCESS' and Rechargedate='$dateApiBal'";
		$resultRRtoday=mysqli_query($con,$queryRRtoday);
		while($dataRRtoday=mysqli_fetch_array($resultRRtoday))
		{
		    $RechRechtoday=$dataRRtoday['Amount'];
		    $RechTotalRechtoday=$RechTotalRechtoday+$RechRechtoday;
		}
		
		$queryURtoday="select * from recharge where API='Unique_API' and Status='SUCCESS' and Rechargedate='$dateApiBal'";
		$resultURtoday=mysqli_query($con,$queryURtoday);
		while($dataURtoday=mysqli_fetch_array($resultURtoday))
		{
		    $UniqRechtoday=$dataURtoday['Amount'];
		    $UniqTotalRechtoday=$UniqTotalRechtoday+$UniqRechtoday;
		}
		
		$queryKRtoday="select * from recharge where API='Kwik_API' and Status='SUCCESS' and Rechargedate='$dateApiBal'";
		$resultKRtoday=mysqli_query($con,$queryKRtoday);
		while($dataKRtoday=mysqli_fetch_array($resultKRtoday))
		{
		    $KwikRechtoday=$dataKRtoday['Amount'];
		    $KwikTotalRechtoday=$KwikTotalRechtoday+$KwikRechtoday; 
		}
		
		$queryDizitoday="select * from recharge where API='DiziPay_Api' and Status='SUCCESS' and Rechargedate='$dateApiBal'";
		$resultDizitoday=mysqli_query($con,$queryDizitoday);
		while($dataDizitoday=mysqli_fetch_array($resultDizitoday))
		{
		    $DiziRechtoday=$dataDizitoday['Amount'];
		    $DiziTotalRechtoday=$DiziTotalRechtoday+$DiziRechtoday; 
		}
    ?>
    <script>
        
        function apibal()
        {
            var i;
            for(i=1;i<=10;i++)
        	{
        		Indicate("bal"+i,"roy"+i,"tdbal"+i);
        	}
        }
        
        function Indicate(a,b,c)
        {
            var bal = parseFloat(document.getElementById(a).value);
            var roy = parseFloat(document.getElementById(b).value);
            
            if(bal<roy*1.5)
            {
                document.getElementById(c).style.background="red";
                document.getElementById(c).style.color="white";
            }
        }
    </script>
    
    <table border="1" cellpadding="5" id="tableApiBal">
        <tr>
            <th>API</th>
            <th>BAL</th>
            <th>TOY</th>
            <th>TOT</th>
        </tr>
        <tr>
            <td>Airtel</td>
            <td id="tdbal1"><input type="text" id="bal1" value="<?php echo floor($TotalAirtelBal); ?>"/><?php echo floor($TotalAirtelBal); ?></td>
            <td><input type="text" id="roy1" value="<?php echo $AirtelTotalRech; ?>"/><?php echo $AirtelTotalRech; ?></td>
            <td><?php echo $AirtelTotalRechtoday; ?></td>
        </tr>
        <tr>
            <td>Idea</td>
            <td id="tdbal2"><input type="text" id="bal2" value="<?php echo floor($TotalIdeaBal); ?>"/><?php echo floor($TotalIdeaBal); ?></td>
            <td><input type="text" id="roy2" value="<?php echo $IdeaTotalRech; ?>"/><?php echo $IdeaTotalRech; ?></td>
            <td><?php echo $IdeaTotalRechtoday; ?></td>
        </tr>
        <tr>
            <td>Jio</td>
            <td id="tdbal3"><input type="text" id="bal3" value="<?php echo floor($TotalJioBal); ?>"/><?php echo floor($TotalJioBal); ?></td>
            <td><input type="text" id="roy3" value="<?php echo $JioTotalRech; ?>"/><?php echo $JioTotalRech; ?></td>
            <td><?php echo $JioTotalRechtoday; ?></td>
        </tr>
        <tr>
            <td>Voda</td>
            <td id="tdbal4"><input type="text" id="bal4" value="<?php echo floor($TotalVodaBal); ?>"/><?php echo floor($TotalVodaBal); ?></td>
            <td><input type="text" id="roy4" value="<?php echo $VodaTotalRech; ?>"/><?php echo $VodaTotalRech; ?></td>
            <td><?php echo $VodaTotalRechtoday; ?></td>
        </tr>
        <tr>
            <td>RechApi</td>
            <td id="tdbal5"><input type="text" id="bal5" value="<?php echo floor($rechApiBal); ?>"/><?php echo floor($rechApiBal); ?></td>
            <td><input type="text" id="roy5" value="<?php echo $RechTotalRech; ?>"/><?php echo $RechTotalRech; ?></td>
            <td><?php echo $RechTotalRechtoday; ?></td>
        </tr>
        <tr>
            <td>UniqApi</td>
            <td id="tdbal6"><input type="text" id="bal6" value="<?php echo floor($UniqueAPIBal); ?>"/><?php echo floor($UniqueAPIBal); ?></td>
            <td><input type="text" id="roy6" value="<?php echo $UniqTotalRech; ?>"/><?php echo $UniqTotalRech; ?></td>
            <td><?php echo $UniqTotalRechtoday; ?></td>
        </tr>
        <tr>
            <td >KwikApi</td>
            <td id="tdbal7"><input type="text" id="bal7" value="<?php echo floor($KwikApiBal); ?>"/><?php echo floor($KwikApiBal); ?></td>
            <td><input type="text" id="roy7" value="<?php echo $KwikTotalRech; ?>"/><?php echo $KwikTotalRech; ?></td>
            <td><?php echo $KwikTotalRechtoday; ?></td>
        </tr>
        <tr>
            <td >DiziApi</td>
            <td id="tdbal8"><input type="text" id="bal8" value="<?php echo floor($DiziPayApiBal); ?>"/><?php echo floor($DiziPayApiBal); ?></td>
            <td><input type="text" id="roy8" value="<?php echo $DiziTotalRech; ?>"/><?php echo $DiziTotalRech; ?></td>
            <td><?php echo $DiziTotalRechtoday; ?></td>
        </tr>
        <?php
            $TotalApiBal=$TotalAirtelBal+$TotalIdeaBal+$TotalJioBal+$TotalVodaBal+$rechApiBal+$UniqueAPIBal+$KwikApiBal+$DiziPayApiBal;
        ?>
        <tr>
            <td>Total BAL</td>
            <td><?php echo floor($TotalApiBal); ?></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td>SMS BAL</td>
            <td><?php echo floor($kwikSmsBal); ?></td>
            <td></td>
            <td></td>
        </tr>
    </table>
</div></a>
	<div class="foot">
    <span id="siteseal"><script async type="text/javascript" src="https://seal.godaddy.com/getSeal?sealID=8nspmyryhw6mnf2ODGzbNQNN52Sv4WRj3QJXtKB09eWdOFA8t8koauZ0dnA3"></script></span>
	</div>
	
    <?php echo "<META HTTP-EQUIV ='Refresh' Content ='600' >"; ?>
</body>
</html>