<?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 Andar Bahar 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">
    <?php
 
 $periodid_sql = mysqli_query($com,"select * from periodid order by id desc");
 $periodid_rows = mysqli_fetch_array($periodid_sql);
 $periodid = $periodid_rows['period'];
 
 
 
 ?>                                             <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 $periodid;?></spam></h4>
    <input type="hidden" name="periodid" id="periodid" value="<?php echo $periodid;?>">
              </div>
              <?php 
 $chkswitchQuery=mysqli_query($com,"select * from `tbl_manualresultswitch` where `id`='1'");
 $role=mysqli_fetch_array($chkswitchQuery);
 ?>
              
              
            </div>   
                                                </div>
                                            </div>

                                            <div class="panel-body p-20">
<form  method="post" action="#" enctype="multipart/form-data">
                                                <table  class="display table table-striped table-bordered" cellspacing="0" width="100%">
                                                    <thead>
                                                         <tr>
                     <th>Type</th>
                      <th>No Of User</th>
                      <th>Amount</th>
                      <th>Result</th>
                    </tr>
                                                    </thead>
                                                    
                                                    <tbody id="betdetail">
                    <?php
  $Query=mysqli_query($com,"select * from andar_bet where period_id='$periodid' and name='1'");
  $numandar = mysqli_num_rows($Query);
  $a=0;
  while($reandar = mysqli_fetch_array($Query))
  {
    $a= $a+ $reandar['amount']; 
  }
  
  
 $Querybahar=mysqli_query($com,"select * from andar_bet where period_id='$periodid' and name='2'");
  $numbahar = mysqli_num_rows($Querybahar);
  $b=0;
  while($rebahar = mysqli_fetch_array($Query))
  {
    $b= $b+ $rebahar['amount'];  
  
  }
  ?>
  
  
                    <tr>
                      <td>
                          <?php echo Andar; ?>
                      </td>
                      <td>
                          <?php echo $numandar; ?>
                          
                      </td>
                      <td ><?php echo $a ;?></td>
                      
                      <td ><input type="checkbox" id="cd" name="andar" value="1" onclick="myfunction(this.value)"></td>
                     
                    </tr>
                   <tr>
                      <td>
                          <?php echo Bahar; ?>
                      </td>
                      <td>
                          <?php echo $numbahar;?>
                          
                      </td>
                      <td ><?php echo $b;?></td>
                      
                     <td ><input type="checkbox" id="dd" name="bahar" value="2" onclick="myfunction(this.value)"></td>
                    </tr>
                  </tbody>
                                                </table>

                        <input type="hidden" name="periodid" id="periodid" value="<?php echo $periodid;?>">                 
                                                <!-- /.col-md-12 -->
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- /.col-md-6 -->

                              <script>
                    function myfunction(val)
                    {
                       var value = val;
                      var periodid = document.getElementById("periodid").value
                   $.ajax({
                  url: "ajax_result.php",
                  type: "POST",
                  data: { value: value,periodid: periodid},
                  success : function(data){
                      
                         alert(data);   
                     
                        
               }
            });
                    }
                </script>                                 
                                                </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 = 60 - countDownDate % 60;
  //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 ==60)
{ 
window.location.href = window.location.href;
}
}
//=====================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 } ?>

