<?php 

@session_start();


if($_SESSION['regID'] !=''){

}else{
	die;
}

	
	if($_REQUEST['logout'] == 1){
		$sqlL = 'UPDATE '.$DB->pre.'user_logs SET logStatus="0" WHERE userID="'.$_REQUEST['retID'].'"';
		$DB->dbQuery($sqlL);
	}

	if(isset($_REQUEST['bntSubmit1'])){
		saveResultLive();
		
		header('Location:'.SITEURL.'/live-betting/');
		//echo "in";
	}
	function saveResultLive(){
		global $DB;

		echo $sqlD = 'DELETE FROM '.$DB->pre.'result_tran WHERE  lotdate="'.date('Y-m-d').'" AND lotTime="'.$_REQUEST['drawTime'].'" AND gameID="'.$_REQUEST['gameID'].'"';
		$DB->dbQuery($sqlD);

		$sqlM = 'SELECT multiple FROM '.$DB->pre.'multiple WHERE gameID="1" AND lotTime="'.$period.'"';
		$M = $DB->dbRow($sqlM);

	//	$sqlI1 = 'INSERT INTO '.$DB->pre.'result_tran SET gameID="1",cellID="'.$cell2[$minCell2].'",lotTime="'.$period.'",lotdate="'.date('Y-m-d').'",dateAdded="'.date('Y-m-d h:i:s').'",xval="'.intval($M['multiple']).'"';
						//	$DB->dbQuery($sqlI1); 
				
		$sqlI = 'INSERT INTO '.$DB->pre.'result_tran SET cellID="'.$_REQUEST['cellID'].'",lotdate="'.date('Y-m-d').'",lotTime="'.$_REQUEST['drawTime'].'",gameID="'.$_REQUEST['gameID'].'",dateAdded="'.date('Y-m-d H:i:s').'"';
		$DB->dbQuery($sqlI);
		$str = 'OK';
		
	}
?>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=11" >
<meta http-equiv="refresh" content="10">
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="<?php echo SITEURL?>/css/ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="<?php echo SITEURL?>/css/ie7.css">
<![endif]-->
<link rel="stylesheet" type="text/css" href="<?php echo SITEURL?>/css/ie7.css">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.1/font/bootstrap-icons.css">

<script>
function myFunction() {
  var x = document.getElementById("myTopnav");
  if (x.className === "topnav") {
    x.className += " responsive";
  } else {
    x.className = "topnav";
  }
  document.getElementById("myTopnav").style.background= "white";
  document.getElementById("myTopnav").style.marginLeft= "60px";
  document.getElementById("aa").style.marginTop= "-651px";
  document.getElementById("myTopnav").style.height= "100%";
  document.getElementById("bars").style.display= "none";
}
</script>

<style>

body {
  margin: 0;
  background:#f2f2f2 !important;
}

.topnav {
  overflow: hidden;
  background-color: #f2f2f2;
  width:100%;
}

.topnav a {
  float: left;
  display: block;
  color: #5a37c3;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

.topnav a:hover {
  background-color: #2470a0;
  color: #fff;
}

.topnav a.active {
  background-color:  #2470a0;
  color: white;
}

.topnav .icon {
  display: none;
}

@media screen and (max-width: 600px) {
  .topnav a {display: none;}
  .topnav a.icon {
    float: right;
    display: block;
    margin-left:100px;
  }
}

@media screen and (max-width: 600px) {
  .topnav.responsive {position: relative;}
  .topnav.responsive .icon {
    position: absolute;
    margin-right:50px !important;
  }
  .topnav.responsive a {
    float: none;
    display: block;
    text-align: left;
  }

}

@media only screen and (min-width:320px) and (max-width:650px) {
            #aa{
                padding:1px !important;
                margin-top:-47px;
            }
            #aa h2{
                font-size:16px !important;
                margin-bottom:60px !important;
                margin-left:10px;
			}
			#bb{
              margin-right:15px !important;
              margin-top:-30px !important;
            }
        }
</style>

</head>

<body>
	<div class="container">

	<div class="topnav" id="myTopnav">
	&nbsp; &nbsp; 
  <a href="<?php echo SITEURL?>/agent"><i class="fa fa-home" style="font-size:20px"></i>  &nbsp; Home</a>
  <a href="<?php echo SITEURL?>/agent-list1"><i class="fa fa-user" style="font-size:20px"></i>  &nbsp; Agent</a>
  <a href="<?php echo SITEURL?>/balance"> <i class="fa fa-suitcase" style="font-size:20px"></i> &nbsp; Balance</a>
  <a href="<?php echo SITEURL?>/live-list" class="active"> <i class="fa fa-television" style="font-size:20px"></i> &nbsp; Live(0)</a>
  
  <a href="<?php echo SITEURL?>/result"> <i class="fa fa-list-alt" style="font-size:20px"></i> &nbsp;Result</a>
  <a href="<?php echo SITEURL?>/?xAction=xLogout"> <i class="fa fa-sign-out" style="font-size:20px"></i> &nbsp; Logout</a>
  <a href="javascript:void(0);" class="icon" id="bars" onclick="myFunction()">
    <i class="fa fa-bars" style="font-size:20px;color:white !important;"></i>
  </a>
</div>

<div id="aa" style="background:#233142;padding:30px;">
        <h2 style="color:white"> <span style="color:#00adb5;"> FUNGAMEASIA </span>BACK OFFICE </h2>  
		<p id="bb" style="float:right;color:white;margin-top:-10px;"><i class="bi bi-person" style="font-size:18px;"></i> &nbsp; <?php echo $_SESSION['name']?></p>  
</div>


	<!--	<div class="menus">
      <ul style="">
          <?php echo innerAdminMenu()?>
      </ul>
    </div>  -->


	<p><b> Draw Time : <?php echo drawTime();
	$drawTime = drawTime();?></b> </p>	
        
        <table>
		<tr >
				<td colspan="2">ABC</td>	
		</tr>
			<tr>
					<th>Cell No.</th>
					<th>Amount</th>
			</tr>
			
		<?php
                    	
						//$drawTime = '5:09';

						$sql = 'SELECT sum(cv) as C,cellID FROM '.$DB->pre.'lottary WHERE lotdate="'.date('Y-m-d').'" AND lotTime="'.$drawTime.'" AND status="1" AND cv>0 AND gameID="1" GROUP BY cellID';
						$D = $DB->dbRows($sql) ;
						
						$sqlR = 'SELECT cellID FROM '.$DB->pre.'result_tran WHERE lotdate="'.date('Y-m-d').'" AND lotTime="'.$drawTime.'" AND gameID="1"';
						$R = $DB->dbRow($sqlR);

						$color = '';
						
						foreach($D as $D){  
							if($R['cellID'] == $D['cellID']){
									?>
									<tr>
								<td>
								<form id="" name="" action="" method="POST">
									<input id="cellID" name="cellID" type="hidden" value="<?php echo $D['cellID']?>">
									<input id="gameID" name="gameID" type="hidden" value="1">
									<input id="drawTime" name="drawTime" type="hidden" value="<?php echo drawTime();?>">
								<button id="bntSubmit1" value="1" name="bntSubmit1" type="submit" style="width:50px;background:yellow;"><?php echo $D['cellID']?></button>
									
								</form>
								</td>
								<td ><?php echo $D['C'].' X '.' 90'.' => '.($D['C']*9)?></td>
						</tr>
									<?php
							}else{
						?>
						<tr>
								<td>
								<form id="" name="" action="" method="POST">
									<input id="cellID" name="cellID" type="hidden" value="<?php echo $D['cellID']?>">
									<input id="gameID" name="gameID" type="hidden" value="1">
									<input id="drawTime" name="drawTime" type="hidden" value="<?php echo drawTime();?>">
								<button id="bntSubmit1" value="1" name="bntSubmit1" type="submit" style="width:50px;<?php echo $color;?>"><?php echo $D['cellID']?></button>
									
								</form>
								</td>
								<td><?php echo $D['C'].' X '.' 90'.' => '.($D['C']*9)?></td>
						</tr>
						<?php } }?>
						</table>

<hr style="color:red;"></hr>
<p><b>Draw Time : <?php echo drawTime12();?></b></p>
						<table>
		<tr>
				<td colspan="2">Roulete</td>	
		</tr>
			<tr>
					<th>Cell No.</th>
					<th>Amount</th>
			</tr>
			
		<?php
                    	
						//$drawTime = '5:09';

						$sql = 'SELECT sum(cv) as C,cellID FROM '.$DB->pre.'lottary WHERE lotdate="'.date('Y-m-d').'" AND lotTime="'.drawTime12().'" AND status="1" AND cv>0 AND gameID="2" GROUP BY cellID';
						$D = $DB->dbRows($sql) ;
						
						$sqlR = 'SELECT cellID FROM '.$DB->pre.'result_tran WHERE lotdate="'.date('Y-m-d').'" AND lotTime="'.drawTime12().'" AND gameID="2"';
						$R = $DB->dbRow($sqlR);

						$color = '';
						
						foreach($D as $D){  
							if($R['cellID'] == $D['cellID']){
									?>
									<tr>
								<td>
								<form id="" name="" action="" method="POST">
									<input id="cellID" name="cellID" type="hidden" value="<?php echo $D['cellID']?>">
									<input id="gameID" name="gameID" type="hidden" value="2">
									<input id="drawTime" name="drawTime" type="hidden" value="<?php echo drawTime12();?>">
								<button id="bntSubmit1" value="1" name="bntSubmit1" type="submit" style="width:50px;background:yellow;"><?php echo $D['cellID']?></button>
									
								</form>
								</td>
								<td ><?php echo $D['C'].' X '.' 100'.' => '.($D['C']*9)?></td>
						</tr>
									<?php
							}else{
						?>
						<tr>
								<td>
								<form id="" name="" action="" method="POST">
									<input id="cellID" name="cellID" type="hidden" value="<?php echo $D['cellID']?>">
									<input id="gameID" name="gameID" type="hidden" value="2">
									<input id="drawTime" name="drawTime" type="hidden" value="<?php echo drawTime12();?>">
								<button id="bntSubmit1" value="1" name="bntSubmit1" type="submit" style="width:50px;<?php echo $color;?>"><?php echo $D['cellID']?></button>
									
								</form>
								</td>
								<td><?php echo $D['C'].' X '.' 100'.' => '.($D['C']*9)?></td>
						</tr>
						<?php } }?>
						</table>
			

	</div>

</body>
</html>
<?php

function drawTime(){
	global $DB;
	date_default_timezone_set('Asia/Kolkata');


return date('H:i',strtotime('+1 minutes'));
}

function drawTime12(){
	global $DB;
	date_default_timezone_set('Asia/Kolkata');
return  date('H:i',strtotime('+1 minutes'));
}

?>
