<?php
	session_start();
	if($_SESSION['adm'])
	{
		$userid= $_SESSION['adm'];
	}
	else
	{
		header('location:../login.php');
	}
?>
<?php
	include'connection.php';
		
		$query8="select * from wallet where Userid='$userid' order by Id desc";
		$result8=mysqli_query($con,$query8);
		$data8=mysqli_fetch_array($result8);
		$currentbal= $data8['Balance'];
		
		$quMyAPI="select * from myapi where LapuName='Idea1'";
		$reMyAPI=mysqli_query($con,$quMyAPI);
		$dataMyAPI=mysqli_fetch_array($reMyAPI);
		$LapuIdea1Bal=$dataMyAPI['LapuBal'];
		
		$quMyAPI2="select * from myapi where LapuName='Idea2'";
		$reMyAPI2=mysqli_query($con,$quMyAPI2);
		$dataMyAPI2=mysqli_fetch_array($reMyAPI2);
		$LapuIdea2Bal=$dataMyAPI2['LapuBal'];
		
		$quMyAPI3="select * from myapi where LapuName='Idea3'";
		$reMyAPI3=mysqli_query($con,$quMyAPI3);
		$dataMyAPI3=mysqli_fetch_array($reMyAPI3);
		$LapuIdea3Bal=$dataMyAPI3['LapuBal'];
		
		$quMyApiJio="select * from myapi where LapuName='JIO1'";
		$reMyApiJio=mysqli_query($con,$quMyApiJio);
		$dataMyApiJio=mysqli_fetch_array($reMyApiJio);
		$LapuJioBal=$dataMyApiJio['LapuBal'];
		
		$quMyApiJio2="select * from myapi where LapuName='JIO2'";
		$reMyApiJio2=mysqli_query($con,$quMyApiJio2);
		$dataMyApiJio2=mysqli_fetch_array($reMyApiJio2);
		$LapuJioBal2=$dataMyApiJio2['LapuBal'];
		
		$quUniqueApi="select * from myapi where LapuName='Unique_API'";
		$reUniqueApi=mysqli_query($con,$quUniqueApi);
		$dataUniqueApi=mysqli_fetch_array($reUniqueApi);
		$LapuUniqueAPIBal=$dataUniqueApi['LapuBal'];
		
		$quMyApiVoda1="select * from myapi where LapuName='Voda1'";
		$reMyApiVoda1=mysqli_query($con,$quMyApiVoda1);
		$dataMyApiVoda1=mysqli_fetch_array($reMyApiVoda1);
		$LapuVoda1Bal=$dataMyApiVoda1['LapuBal'];
		
		$quMyApiVoda2="select * from myapi where LapuName='Voda2'";
		$reMyApiVoda2=mysqli_query($con,$quMyApiVoda2);
		$dataMyApiVoda2=mysqli_fetch_array($reMyApiVoda2);
		$LapuVoda2Bal=$dataMyApiVoda2['LapuBal'];
		
		$quMyApiVdth="select * from myapi where LapuName='VDTH'";
		$reMyApiVdth=mysqli_query($con,$quMyApiVdth);
		$dataMyApiVdth=mysqli_fetch_array($reMyApiVdth);
		$LapuVdthBal=$dataMyApiVdth['LapuBal'];
		
		$quMyApiAirtel="select * from myapi where LapuName='Airtel'";
		$reMyApiAirtel=mysqli_query($con,$quMyApiAirtel);
		$dataMyApiAirtel=mysqli_fetch_array($reMyApiAirtel);
		$LapuAirtelBal=$dataMyApiAirtel['LapuBal'];
		
		$quMyApiAirtel2="select * from myapi where LapuName='Airtel2'";
		$reMyApiAirtel2=mysqli_query($con,$quMyApiAirtel2);
		$dataMyApiAirtel2=mysqli_fetch_array($reMyApiAirtel2);
		$LapuAirtelBal2=$dataMyApiAirtel2['LapuBal'];
		
		$TotalIdeaLapuBal=$LapuIdea1Bal+$LapuIdea2Bal;
        $TotalVodaLapuBal=$LapuVoda1Bal+$LapuVoda2Bal;
        $TotalJioLapuBal=$LapuJioBal+$LapuJioBal2;
        $TotalAirteLapuBal=$LapuAirtelBal+$LapuAirtelBal2;
?>
<html>
<head>
    <script>
    (function(d, w, c) 
    {
        w.ChatraID = 'Sr6ymd5eynBxqu7Jr';
        var s = d.createElement('script');
        
        w[c] = w[c] || function() {
            (w[c].q = w[c].q || []).push(arguments);
        };
        s.async = true;
        s.src = 'https://call.chatra.io/chatra.js';
        if (d.head) d.head.appendChild(s);
    })(document, window, 'Chatra');
</script>

<style>
body{background:url(bg.jpg); background-size:cover; margin:0; padding:0; width:1580px;}
.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;}

.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:15px; 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;}
#AFLI:hover{background:#f5f5f5;}
.notifi{background:#995702; width:150px; height:580px;float:left; margin:10 0 0 10px; border-radius:5px; text-align:center;}
.notifi h3{text-align:center; color:white;}
#notifidiv{background:red; width:40px; height:40px; text-align:center; border-radius:50%;
margin:10 0 0 80px; z-index:4; color:white; line-height:40px; font-size:28px; position:absolute;}
img{width:80px; height:80px; z-index:1; margin-top:5px;}
 .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{display:none;}
#roy1,#roy2,#roy3,#roy4,#roy5,#roy6,#roy7{display:none;}
.ApiBalDiv{width:260px; height:500px; background:; float:left; margin:15 10 10 0px;}
#tableApiBal{text-align:center; width:260px; 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:10 0 0 100px; width:1350px; text-align:center; height:140px;}
 #siteseal{background:red; width:300px; height:50px;}
</style>
</head>
<body onload="apibal()">
   
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://www.rechargedaddy.in/RDRechargeAPI/RechargeAPI.aspx",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"MobileNo\"\r\n\r\n9897095971\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"APIKey\"\r\n\r\nFROY38amkREsr7mHOutxIou64PDe3t02Qr9\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"REQTYPE\"\r\n\r\nBAL\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"RESPTYPE\"\r\n\r\nJSON\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
  CURLOPT_HTTPHEADER => array(
    "Postman-Token: 1aefc6a6-7b92-4330-b713-4924dfea7f7d",
    "cache-control: no-cache",
    "content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"
  ),
));

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

curl_close($curl);

if ($err)
{
  echo "cURL Error #:" . $err;
} 
else
{
   $response;
  
  $data2=json_decode($response);
  $QuickApiMsg=$data2->STATUSMSG;
  if($QuickApiMsg=="Success")
  {
        $QuickAPIBal= $data2->BALANCE;
  }
  else
  {
      $QuickAPIBal= $data2->STATUSMSG;
  }
 
}
?>
<?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;
		  }
?>
	<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>
    <?php include 'menu.php'; ?>
	<div class="notifi">
	   <h3>Notifications</h3><hr>
	   <?php
	   include'connection.php';
	  
	   $quGetPay="select * from paymentreq where Active='0'";
	   $reGetPay=mysqli_query($con,$quGetPay);
	   $pay=mysqli_num_rows($reGetPay);
	  
	   if($pay==0) {
	   }
	   else
	   {
	        echo "<a href='view_payment1.php' target='_blank'><div id='notifidiv'>
	            ". $pay."
	            </div></a>";
	   }
	  ?>
	   <a href="view_payment1.php" target="_blank"><div class="imgdiv">
	    <img src="payment.png"></img>
	   </div></a>
	   
	  <?php
	  date_default_timezone_set("asia/kolkata");
		$date=date("Y-m-d");
		
	   $quGetComp="select * from complain where Active='0'";
	   $reGetComp=mysqli_query($con,$quGetComp);
	   $comp=mysqli_num_rows($reGetComp);
	  
	   if($comp==0) {
	   }
	   else
	   {
	        echo "<a href='list_complain.php' target='_blank'><div id='notifidiv'>
	            ". $comp."
	            </div></a>";
	   }
	   ?>
	   <a href="list_complain.php" target="_blank"><div class="imgdiv">
	    <img src="complain.png"></img>
	   </div></a>
	
	   <?php
    	$quGetMsg="select * from contactus where Active='0'";
	   $reGetMsg=mysqli_query($con,$quGetMsg);
	   $msg=mysqli_num_rows($reGetMsg);
	   if($msg==0) {
	   }
	   else
	   {
	        echo "<a href='contact_us.php' target='_blank'><div id='notifidiv'>
	            ". $msg."
	            </div></a>";
	   }
	   ?>
	   <a href="contact_us.php" target="_blank"><div class="imgdiv">
	    <img src="msg.png"></img>
	   </div></a>
	   
	   <?php
    	$quGetWaitRech="select * from recharge where Rechargedate='$date' and Status='PENDING'";
	   $reGetWaitRech=mysqli_query($con,$quGetWaitRech);
	   $waitRech=mysqli_num_rows($reGetWaitRech);
	          if($waitRech=="0") {
	               
	          }
    	     else
	          {
	              echo "<a href='pending_recharge.php' target='_blank'><div id='notifidiv'>
	            ". $waitRech."
	            </div></a>";
	          }
	   
	   ?>
	   <a href="pending_recharge.php" target="_blank"><div class="imgdiv">
	    <img src="waiting.png"></img>
	   </div></a>
	   
	   <?php
    	$quGetDupRef="select Paynrechid, count(Paynrechid) from wallet where Transactiontype='Recharge_Refund' and ActiveRefund='0' group By Paynrechid having Count(Paynrechid)>1;";
	   $reGetDupRef=mysqli_query($con,$quGetDupRef);
	   $DupRef=mysqli_num_rows($reGetDupRef);
	          if($DupRef=="0") {
	               
	          }
    	     else
	          {
	              echo "<a href='Duplicate_Refund.php' target='_blank'><div id='notifidiv'>
	            ". $DupRef."
	            </div></a>";
	          }
	   
	   ?>
	   <a href="Duplicate_Refund.php" target="_blank"><div class="imgdiv">
	    <img src="Duplicate_Payment.png"></img>
	   </div></a>
	   
	   
	    <?php
    	 $quGetSucRech="select * from recharge where Status='SUCCESS' and Rechargedate='$date'";
         $reGetSucRech=mysqli_query($con,$quGetSucRech);
         $sl=0;
            while($dataGetSucRech=mysqli_fetch_array($reGetSucRech))
            {
                $successRechId=$dataGetSucRech['Id'];
        
               $quGetSucRechRef="select * from wallet where Paynrechid='$successRechId' and Transactiontype='Recharge_Refund' and ActiveRefund='0'";
               $reGetSucRechRef=mysqli_query($con,$quGetSucRechRef);
                $countSucRechRef=mysqli_num_rows($reGetSucRechRef);
        
               while($dataGetSucRechRef=mysqli_fetch_array($reGetSucRechRef))
               {
                  $sl=$sl+1;
                  echo "<tr>";
                       "<td>".$sl."</td>";
                      "<td>".$dataGetSucRechRef['Paynrechid']."</td>";
                      "<td><a href='ReverseWrongRefund.php?id=".$dataGetSucRechRef['Paynrechid']."'>Reverse Wrong Refund</a></td>";
                 echo "</tr>";
                }
             }
	          if($sl>="1")
	          {
	              echo "<a href='Wrong_Refund.php' target='_blank'><div id='notifidiv'>
	            ". $sl."
	            </div></a>";
	          }
	   
	   ?>
	   <a href="Wrong_Refund.php" target="_blank"><div class="imgdiv">
	    <img src="zigzag.png"></img>
	   </div></a>
	  </div>
	 
	<div class="content">
			<?php
		include'connection.php';
		date_default_timezone_set("asia/kolkata");
		$date=date("Y-m-d");
		
		$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;
		}
		
		date_default_timezone_set("asia/kolkata");
		$date1=date("Y-m-d");
		$date=date_create($date1);
		date_sub($date,date_interval_create_from_date_string("7 days"));
		$resultdate=date_format($date,"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_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
	
	$ActualLapuIdea1Bal=$LapuIdea1Bal*96.34/100;
	$ActualLapuIDEA2Bal=$LapuIdea2Bal*96.34/100;
	$ActualLapuIDEA3Bal=$LapuIdea3Bal*96.34/100;
	$ActualLapuJioBal=$LapuJioBal*93.46/100;
	$ActualLapuJioBal2=$LapuJioBal2*93.46/100;
	$ActualLapuVoda1Bal=$LapuVoda1Bal*96.34/100;
	$ActualLapuVoda2Bal=$LapuVoda2Bal*96.34/100;
	$ActualLapuVDTHBal=$LapuVdthBal*96.16/100;
	$ActualLapuAirtelBal=$LapuAirtelBal*97.39/100;
	$ActualLapuAirtelBal2=$LapuAirtelBal2*96.25/100;
	
	
	
	$TotalApiBal=$ActualLapuJioBal+$ActualLapuJioBal2+$ActualLapuIdea1Bal+$ActualLapuIDEA2Bal+$rechApiBal+$KwikApiBal+$LapuUniqueAPIBal+$ActualLapuVoda1Bal+$ActualLapuVoda2Bal+$ActualLapuAirtelBal+$ActualLapuAirtelBal2+$ActualLapuIDEA3Bal;
	$Managebal=$totalWalletBal-$TotalApiBal;
	$BenefitBal=1000000-$Managebal;
	
	?>
	<a href="#"><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
				date_default_timezone_set("asia/kolkata");
                $date=date("Y-m-d");
			$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;
        
        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");
		
		
		$TotalRech=0;
		    function GetTotalRech($OperatorName, $RechargeDate)
		    {
		        $AirtelTotalRech=0;
	        echo	$queryAR="select * from recharge where Companyname='$OperatorName' and Status='SUCCESS' and Rechargedate='$RechargeDate'";
    	    	$resultAR=mysqli_query($con,$queryAR);
	    	    while($dataAR=mysqli_fetch_array($resultAR))
        		{
    		        $AirtelRech=$dataAR['Amount'];
	    	        $AirtelTotalRech=$AirtelTotalRech+$AirtelRech;
		        }
        		return $AirtelTotalRech;
		    }
		  //  $op="Airtel";
		 echo GetTotalRech("Airtel",$resultdateAB);
		
		
		$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;
		}
    ?>
    <script>
        
        function apibal()
        {
            var i;
            for(i=1;i<=10;i++)
        	{
        		Indicate("bal"+i,"roy"+i,"tdbal"+i);
        	}
        }
        
        function Indicate(a,b,c)
        {
            var bal1 = parseFloat(document.getElementById(a).value);
            var roy1 = parseFloat(document.getElementById(b).value);
            
            if(bal1<roy1*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>ROY</th>
        </tr>
        <tr>
            <td>Airtel</td>
            <td id="tdbal1"><input type="text" id="bal1" value="<?php echo floor($TotalAirteLapuBal); ?>"/><?php echo floor($TotalAirteLapuBal); ?></td>
            <td><input type="text" id="roy1" value="<?php echo $AirtelTotalRech; ?>"/><?php echo $AirtelTotalRech; ?></td>
        </tr>
        <tr>
            <td>Idea</td>
            <td id="tdbal2"><input type="text" id="bal2" value="<?php echo floor($TotalIdeaLapuBal); ?>"/><?php echo floor($TotalIdeaLapuBal); ?></td>
            <td><input type="text" id="roy2" value="<?php echo $IdeaTotalRech; ?>"/><?php echo $IdeaTotalRech; ?></td>
        </tr>
        <tr>
            <td>Jio</td>
            <td id="tdbal3"><input type="text" id="bal3" value="<?php echo floor($TotalJioLapuBal); ?>"/><?php echo floor($TotalJioLapuBal); ?></td>
            <td><input type="text" id="roy3" value="<?php echo $JioTotalRech; ?>"/><?php echo $JioTotalRech; ?></td>
        </tr>
        <tr>
            <td>Voda</td>
            <td id="tdbal4"><input type="text" id="bal4" value="<?php echo floor($TotalVodaLapuBal); ?>"/><?php echo floor($TotalVodaLapuBal); ?></td>
            <td><input type="text" id="roy4" value="<?php echo $VodaTotalRech; ?>"/><?php echo $VodaTotalRech; ?></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>
        </tr>
        <tr>
            <td>UniqApi</td>
            <td id="tdbal6"><input type="text" id="bal6" value="<?php echo floor($LapuUniqueAPIBal); ?>"/><?php echo floor($LapuUniqueAPIBal); ?></td>
            <td><input type="text" id="roy6" value="<?php echo $UniqTotalRech; ?>"/><?php echo $UniqTotalRech; ?></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>
        </tr>
        <tr>
            <td>SMS BAL</td>
            <td><?php echo floor($kwikSmsBal); ?></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>