<?php
session_start();
ob_start();
include('includes/config.php');
if($_SESSION['name'] == '')
 {
     header("location:index.php");
 }
    
 else{       
        ?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
    	<meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Forcecrypto Admin</title>
        <link rel="stylesheet" href="css/bootstrap.min.css" media="screen" >
        <link rel="stylesheet" href="css/font-awesome.min.css" media="screen" >
        <link rel="stylesheet" href="css/animate-css/animate.min.css" media="screen" >
        <link rel="stylesheet" href="css/lobipanel/lobipanel.min.css" media="screen" >
        <link rel="stylesheet" href="css/prism/prism.css" media="screen" > <!-- USED FOR DEMO HELP - YOU CAN REMOVE IT -->
        <link rel="stylesheet" type="text/css" href="js/DataTables/datatables.min.css"/>
        <link rel="stylesheet" href="css/main.css" media="screen" >
        <script src="js/modernizr/modernizr.min.js"></script>
          <style>
        .errorWrap {
    padding: 10px;
    margin: 0 0 20px 0;
    background: #fff;
    border-left: 4px solid #dd3d36;
    -webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
    box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
}
.succWrap{
    padding: 10px;
    margin: 0 0 20px 0;
    background: #fff;
    border-left: 4px solid #5cb85c;
    -webkit-box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
    box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
}

.btn-secondary {
    color: #000;
    background-color: #fff;
    border-color: #6700ff;
    box-shadow: none;
    padding: 3px 35px;
}
.box-header {
    color: #444;
    display: block;
    padding: 10px;
    position: relative;
}
.box-header2 {
    border-bottom: #ccc 1px solid;
    padding-top: 4px;
    padding-bottom: 4px;
}
.txrlt h4{font-size:14px; text-align:center !important;}
#overlay {
  position:absolute;
  display: none;
  width: 70%;
  height: 70px;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  /*background-color: rgba(0,0,0,0.5);*/
  z-index: 9;
  cursor: pointer;
}
.text-maroon {
    color: #6700ff !important;
}
.btn-secondary {
    color: #000;
    background-color: #fff;
    border-color: #6700ff;
    box-shadow: none;
	padding: 3px 35px;
}
.btn-secondary:hover {
    color: #000;
    background-color: #fff;
    border-color: #ccc;
    box-shadow: none;
}
.label {
    display: inline-block;
    max-width: 100%;
    margin-bottom: 5px;
    font-weight: 700;
}
.label {
    display: block;
    padding-bottom: 0.21875em;
    margin-bottom: -0.125em;
}
.h5 {
    display: block;
    font-size: 0.83em;
    margin-block-start: 1.67em;
    margin-block-end: 1.67em;
    margin-inline-start: 0px;
    margin-inline-end: 0px;
    font-weight: bold;
}
.text-center {
    text-align: center;
}
.red_txt {
    color: #f00;
}
.btn-group>.btn:first-child:not(:last-child):not(.dropdown-toggle) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}
        </style>
    </head>
    <body class="top-navbar-fixed">
        <div class="main-wrapper">

            <!-- ========== TOP NAVBAR ========== -->
   <?php include('includes/topbar.php');?> 
            <!-- ========== WRAPPER FOR BOTH SIDEBARS & MAIN CONTENT ========== -->
            <div class="content-wrapper">
                <div class="content-container">
<?php include('includes/leftbar.php');?>  

                    <div class="main-page">
                        <div class="container-fluid">
                            <div class="row page-title-div">
                                <div class="col-md-6">
                                    <h2 class="title">Manage Color Result</h2>
                                
                                </div>
                                
                                <!-- /.col-md-6 text-right -->
                            </div>
                            <!-- /.row -->
                            <div class="row breadcrumb-div">
                                <div class="col-md-6">
                                    
                                </div>
                             
                            </div>
                            <!-- /.row -->
                        </div>
                        <!-- /.container-fluid -->

                        <section class="section">
                            <div class="container-fluid">

                             

                                <div class="row">
                                    <div class="col-md-12">

                                        <div class="panel">
                                            <div class="panel-heading">
                                                <div class="panel-title">
                                                 <div class="box-header box-header2 txrlt">
<div id="overlay"></div>
              <div class="col-md-2">
                <div class="gameidtimer"> 
      <h4>Count Down:</br><spam id="demo" class="red_txt"></spam></h4>       
      </div>
              </div>
              <div class="col-md-2 text-center">
    <h4>Active Period Id:</br> <spam id="activeperiodid" class="text-success"><?php echo sprintf("%03d",gameid($com));?></spam></h4>
    <input type="hidden" name="periodid" id="periodid" value="<?php echo sprintf("%03d",gameid($com));?>">
              </div>
              <?php 
 $chkswitchQuery=mysqli_query($com,"select * from `tbl_manualresultswitch` where `id`='1'");
 $role=mysqli_fetch_array($chkswitchQuery);
 ?>
              <div class="col-md-5 text-center">
              <h5 class="text-maroon" style="color: #6700ff !important;">
             <label>Parity <br><input type="radio" class="tabbtn" name="tab" value="parity" <?php if($role['tab']=='parity'){echo"checked";} ?>></label>&nbsp;&nbsp;&nbsp;&nbsp;
             <label>Sapre <br><input type="radio" class="tabbtn" name="tab" value="sapre" <?php if($role['tab']=='sapre'){echo"checked";} ?>></label>&nbsp;&nbsp;&nbsp;&nbsp;
             <label>Bcone <br><input type="radio" class="tabbtn" name="tab" value="bcone" <?php if($role['tab']=='bcone'){echo"checked";} ?>></label>&nbsp;&nbsp;&nbsp;&nbsp;
             <label>Emerd <br><input type="radio" class="tabbtn" name="tab" value="emerd" <?php if($role['tab']=='emerd'){echo"checked";} ?>></label>
             <input type="hidden" name="tabtype" id="tabtype" value="<?php echo $role['tab'];?>">
             </h5>
              </div>
              <div class="col-md-3">
                <div class="main-input vb1">
 
                    <label>Do you want manual result ?</label>
                    <div class="mt-0">
                <div >
                <input type="radio" class="switchbutton" type="radio" name="switch" id="switchyes" value="yes" <?php if($role['switch']=='yes'){echo"checked";} ?>>
                Yes
                <input type="radio" class="switchbutton" name="switch" id="switchno" value="no" <?php if($role['switch']=='no'){echo"checked";} ?>>
                No
          
                      </div>
                    </div>
                  </div>
              </div>
            </div>   
                                                </div>
                                            </div>

                                            <div class="panel-body p-20">
<form id="formID" name="formID" method="post" action="#" enctype="multipart/form-data">
                                                <table  class="display table table-striped table-bordered" cellspacing="0" width="100%">
                                                    <thead>
                                                         <tr>
                      <th>Result</th>
                      <th>Number</th>
                      <th>No. of User</th>
                      <th>Amount</th>
                      <th>Action</th>
                    </tr>
                                                    </thead>
                                                    
                                                    <tbody id="betdetail">
                    <?php
  $Query=mysqli_query($com,"select * from `tbl_manualresult` order by id asc");
  
  while($row=mysqli_fetch_array($Query)){?>
                    <tr>
                      <td><?php echo @$row["color"]; ?></td>
                      <td><?php echo $row['number'];?></td>
                      <td class="text-orange">wait..</td>
                     <td class="text-orange">wait..</td>

                      <td>
                        <?php 
	  if($row['status']==1){
	  ?>
                        &nbsp; <a href="javascript:void(0);" class="update-person" style="color:#090; font-size:16px;" data-toggle="tooltip" title="Publish"><i class="fa fa-check-square-o"></i></a>
                        <?php } else if($row['status']==0){?>
                        &nbsp; <a href="javascript:void(0);" class="update-person" style="color:#f00; font-size:16px;" data-toggle="tooltip" title="Wait..."><i class="fa fa-square-o"></i></a>
                        <?php }?></td>
                    </tr>
                    <?php }?>
                  </tbody>
                                                </table>

                                         
                                                <!-- /.col-md-12 -->
                                            </div>
                                        </div>
                                    </div>
                                    <!-- /.col-md-6 -->

                                                               
                                                </div>
                                                <!-- /.col-md-12 -->
                                            </div>
                                        </div>
                                        <!-- /.panel -->
                                    </div>
                                    <!-- /.col-md-6 -->

                                </div>
                                <!-- /.row -->

                            </div>
                            <!-- /.container-fluid -->
                        </section>
                        <!-- /.section -->

                    </div>
                    <!-- /.main-page -->

                    

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

        </div>
        <script src="js/jquery/jquery-2.2.4.min.js"></script>
        <script src="js/bootstrap/bootstrap.min.js"></script>
        <script src="js/pace/pace.min.js"></script>
        <script src="js/lobipanel/lobipanel.min.js"></script>
        <script src="js/iscroll/iscroll.js"></script>
        <script src="js/prism/prism.js"></script>
        <script src="js/DataTables/datatables.min.js"></script>
        <script src="js/main.js"></script>
        <script>
            $(function($) {
                $('#example').DataTable();

                $('#example2').DataTable( {
                    "scrollY":        "300px",
                    "scrollCollapse": true,
                    "paging":         false
                } );

                $('#example3').DataTable();
            });
        </script>
        <script>
  $(function () {
    $('#example1').DataTable({
      "paging": true,
      "lengthChange": false,
      "searching": false,
      "ordering": false,
      "info": true,
      "autoWidth": true,
	  "pageLength": 15
    });
  });
$(document).ready(function () {
var x = setInterval(function() { 
start_count_down();  
}, 1e3);

$(".switchbutton").change(function(){ 
var value=$(this).val();
//alert(value);
$.ajax({
   type: "Post",
    data:"value=" + value + "& type=" + "switch" ,
    url: "activePeriodid.php",
    success: function (html){},
});
});

$(".tabbtn").change(function(){ //alert($(this).val());
var value=$(this).val();
document.getElementById("tabtype").value = value;
$.ajax({
   type: "Post",
    data:"value=" + value + "& type=" + "tab" ,
    url: "activePeriodid.php",
    success: function (html){},
});

});
});  
function resettab()
{
$(".tabbtn").prop('checked', false);
$("#tabtype").val('');
var value='';
	$.ajax({
    type: "Post",
    data:"value=" + value + "& type=" + "tabreset" ,
    url: "activePeriodid.php",
    success: function (html){},
});
	}

//====================counter start===================================
function start_count_down() { 
$(".showload").hide();
$(".none").show();
var countDownDate = Date.parse(new Date) / 1e3;
  var now = new Date().getTime();
  var distance = 180 - countDownDate % 180;
  //alert(distance);
  var i = distance / 60,
   n = distance % 60,
   o = n / 10,
   s = n % 10;
  var minutes = Math.floor(i);
  var seconds = ('0'+Math.floor(n)).slice(-2);
  document.getElementById("demo").innerHTML = "<span class='timer'>0"+Math.floor(minutes)+"</span>" + "<span>:</span>" +"<span class='timer'>"+seconds+"</span>";

if(distance==180){
document.getElementById("activeperiodid").innerHTML = 'Wait...';
}
if(distance==166){
getbettingdata('refreshtdata');
}
if(distance==165){
getactivegameid();
$("#switchno").click();
document.getElementById("overlay").style.display = "none";
resettab();
}

if(distance<=30)
{ 
getbettingdata('getdata');
document.getElementById("overlay").style.display = "block";
}
}
//=====================counter end=====================================
function getactivegameid()
{
	$.ajax({
    type: "Post",
    url: "activePeriodid.php",
    success: function (html) {
     //alert(html);
	 document.getElementById("activeperiodid").innerHTML = html;
	 document.getElementById("periodid").value = html;
      return false;
      },
      error: function (e) {}
      });
	}

function getbettingdata(actiontype)
{
var periodid=$("#periodid").val();
var tabtype=$("#tabtype").val();
if ((tabtype)== "")
 {return false;}

	$.ajax({
    type: "Post",
	data:"periodid=" + periodid + "& tabtype=" + tabtype+ "& actiontype=" + actiontype ,
    url: "getbettinguseramount.php",
    success: function (html) {
     //alert(html);
	 document.getElementById("betdetail").innerHTML = html;
      return false;
      },
      error: function (e) {}
      });
	}

</script>

 
<script type="text/javascript">
 function Respond(Id) { 
 var strconfirm = confirm("Are you sure you want to Unpublish?");

           if (strconfirm == true) {
               $.ajax({
                   type: "Post",
                  data:"id=" + Id + "& type=" + "chk" ,
                   url: "activePeriodid.php",
                   success: function (html) {
                       //alert(html);
                       //window.location = '';
                       return false;
                   },
                   error: function (e) {
                   }
               });
           }

       }
</script> 
<script type="text/javascript">
 function UnRespond(Id) {
           var strconfirm = confirm("Are you sure you want to Publish?");
           if (strconfirm == true) {
			   $("#switchyes").click();
               $.ajax({
                   type: "Post",
                   data:"id=" + Id + "& type=" + "unchk" ,
                   url: "activePeriodid.php",
                   success: function (html) {
                       if(html==1)
					   {alert("You have allready selected !");}
                       return false;
                   },
                   error: function (e) {
                   }
               });
           }

       }
</script>
    </body>
</html>
<?php } ?>

