<?php
@session_start();
include "control/activity.php";

 $dd = new activity();
 $loginStatus = $_SESSION['loginDetails'];


  if($loginStatus == null){
    echo "<script>window.open('login.php','_self')</script>";
  }



  $table = "admin_calculation";
  $condition = null;
  $getAdminDetails = $dd->single($table,$condition);
  

  @$iid = $_REQUEST['game'];
  $table = "wingo_game_runing";
  $condition = " where game_number='$iid'";
  $getK3Result = $dd->single($table,$condition);
  @$mResult = $getK3Result['manual_result'];
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title><?= $getAdminDetails['title']; ?></title>
</head>
<body>
<script>
    let gamnumber = 1;
</script>
    <div class="main" id="main">
		  <?php include "menu.php"; ?>
    <div class="right"> 
  <div class="tab-content">


   <?php include "headermenu.php"; ?>


        <!-- Overview -->
         <div id="overview" class="tab-pane active"  >
                <div class="content" >
                  
               <div class="content-wrapper">
                 <div class="container-fluid">

                      <!--======================================================  Content  ====================================================-->                                            
                          <ol class="breadcrumb">
                            <li class="breadcrumb-item">
                              <a href="dashboard.php">CUSTOM RESULT</a>
                            </li>
                          </ol>

                          <div class="row">
                               <div class="col-xl-11 col-sm-11 mb-11">
                                  <table class="table table-bordered data-table" style="margin-top:30px; width:">
                                    <tr>
                                        <td colspan="2px"></td>
                                        <td><input type="radio" name="gamingType" onclick="gettochangeGameState('randum')" <?php if($getAdminDetails['trxResult_type'] == "randum"){ echo "checked"; } ?>> Randum</td>
                                        <td><input type="radio" name="gamingType" onclick="gettochangeGameState('minimum')" <?php if($getAdminDetails['trxResult_type'] == "minimum"){ echo "checked"; } ?>> Minimum</td>
                                    </tr>
                                    <tr>
                                        <th><input id='game_number1' value="<?= $getAdminDetails['trx_1']; ?>" onkeyup="gettoupdatecustemnumber('game_number1','1')" class="form-control" oninput="this.value=this.value.replace(/\D/g, '')"  type="text" maxlength="1"  placeholder="Number"/> </th>
                                        <th><input id='game_number2' value="<?= $getAdminDetails['trx_2']; ?>" onkeyup="gettoupdatecustemnumber('game_number2','2')" class="form-control" oninput="this.value=this.value.replace(/\D/g, '')"  type="text" maxlength="1" max="1"  placeholder="Number"/> </th>
                                        <th><input id='game_number3' value="<?= $getAdminDetails['trx_3']; ?>" onkeyup="gettoupdatecustemnumber('game_number3','3')" class="form-control" oninput="this.value=this.value.replace(/\D/g, '')"  type="text" maxlength="1" max="1"  placeholder="Number"/> </th>
                                        <th><input id='game_number4' value="<?= $getAdminDetails['trx_4']; ?>" onkeyup="gettoupdatecustemnumber('game_number4','4')" class="form-control" oninput="this.value=this.value.replace(/\D/g, '')"  type="text" maxlength="1" max="1"  placeholder="Number"/> </th>
                                    </tr>
                                 </table>
                              </div>     
                              
<script>
    function gettoupdatecustemnumber(a,b){
        var tttt = document.getElementById(a).value;
        
        const xhttp = new XMLHttpRequest();
        xhttp.onload = function() {
            var demo_show = this.responseText;
            const myArr = JSON.parse(demo_show);
            gamnumber = b;
            
        }
        xhttp.open("GET", "updateTRXResultCustem.php?gamenumber="+b+"&num="+tttt);
        xhttp.send();
        
        
    }
    
    
    
    
    function gettochangeGameState(a){
        const xhttp = new XMLHttpRequest();
        xhttp.onload = function() {
            var demo_show = this.responseText;
            const myArr = JSON.parse(demo_show);
            
        }
        xhttp.open("GET", "changeTRXgameState.php?gameState="+a);
        xhttp.send();
    }
</script>                              
                              
                              
                              
                              
                              <div class="col-xl-11 col-sm-11 mb-11">
                                  
                                    <div id="content-container4"></div>

                                    <script>
                                        // Function to load the content
                                        function loadContent4() {
                                            $('#content-container4').load('refreshManualTRXResult.php?game='+gamnumber);
                                        }
                                
                                        // Initial load
                                        loadContent4();
                                
                                        // Refresh every 10 seconds
                                        setInterval(loadContent4, 3000); // 10000 milliseconds = 10 seconds
                                    </script>
                              </div>
                          </div>






      </div>
      <!-- /.container-fluid-->
       </div>  <!-- /content-wrapper-->


                </div>
                </div>
             </div><!--Right panel-->
</div><!--Main-->


</body>
</html>


<?php include "style.php" ?>

