<?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 Cricket 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
 
 $over_sql = mysqli_query($com,"select * from cricket_over order by id desc limit 1");
 $over_rows = mysqli_fetch_array($over_sql);
 $over = $over_rows['over'];
 $ball = $over_rows['ball'];
 
 ?>  
 <div class="box-header box-header2 txrlt">
<div id="overlay"></div>
              <div class="col-md-2">
                <div class="gameidtimer"> 
      <h5>Next Result - Over: <spam><?php echo $over; ?></spam> Ball : <spam><?php echo $ball; ?></spam></h5>    
      </div>
              </div>
              <div class="col-md-2 text-center">
                  <?php 
 $chkswitchQuery=mysqli_query($com,"select * from `tbl_cricketswitch` where `id`='1'");
 $role=mysqli_fetch_array($chkswitchQuery);
 ?>
    <div class="col-md-4">
                <div class="main-input vb1">
 
                    <label>Click Enabled/Disabled</label>
                    <div class="mt-0">
                <div class="btn-group btn-group-toggle padd-l-15" data-toggle="buttons">
           <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>
              <?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
  $Query0=mysqli_query($com,"select * from `cricket_bet` where `over`='$over' and `ball`='$ball' and `name`='0'");
  $num0 = mysqli_num_rows($Query0);
  $a0=0;
  while($re0 = mysqli_fetch_array($Query0))
  {
    $a0= $a0+ $re0['amount']; 
  }
  
  
 $Query1=mysqli_query($com,"select * from `cricket_bet` where `over`='$over' and `ball`='$ball' and `name`='1'");
  $num1 = mysqli_num_rows($Query1);
  $a1=0;
  while($re1 = mysqli_fetch_array($Query1))
  {
    $a1= $a1+ $re1['amount'];  
  
  }
   $Query2=mysqli_query($com,"select * from `cricket_bet` where `over`='$over' and `ball`='$ball' and `name`='2'");
  $num2 = mysqli_num_rows($Query2);
  $a2=0;
  while($re2 = mysqli_fetch_array($Query2))
  {
    $a2= $a2+ $re2['amount']; 
  }
  
  
 $Query3=mysqli_query($com,"select * from `cricket_bet` where `over`='$over' and `ball`='$ball' and `name`='3'");
  $num3 = mysqli_num_rows($Query3);
  $a3=0;
  while($re3 = mysqli_fetch_array($Query3))
  {
    $a3= $a3+ $re3['amount'];  
  
  }
  
  $Query4=mysqli_query($com,"select * from `cricket_bet` where `over`='$over' and `ball`='$ball' and `name`='4'");
  $num4 = mysqli_num_rows($Query4);
  $a4=0;
  while($re4 = mysqli_fetch_array($Query4))
  {
    $a4= $a4+ $re4['amount']; 
  }
  
  
 $Query6=mysqli_query($com,"select * from `cricket_bet` where `over`='$over' and `ball`='$ball' and `name`='6'");
  $num6 = mysqli_num_rows($Query6);
  $a6=0;
  while($re6 = mysqli_fetch_array($Query6))
  {
    $a6= $a6+ $re6['amount'];  
  
  }
   $Querycw=mysqli_query($com,"select * from `cricket_bet` where `over`='$over' and `ball`='$ball' and `name`='CW'");
  $numcw = mysqli_num_rows($Querycw);
  $acw=0;
  while($recw = mysqli_fetch_array($Querycw))
  {
    $acw= $acw+ $recw['amount']; 
  }
  
  
 $Querybw=mysqli_query($com,"select * from `cricket_bet` where `over`='$over' and `ball`='$ball' and `name`='BW'");
  $numbw = mysqli_num_rows($Querybw);
  $abw=0;
  while($rebw = mysqli_fetch_array($Querybw))
  {
    $abw= $abw+ $rebw['amount'];  
  
  }
  
  $Querysw=mysqli_query($com,"select * from `cricket_bet` where `over`='$over' and `ball`='$ball' and `name`='SW'");
  $numsw = mysqli_num_rows($Querysw);
  $asw=0;
  while($resw = mysqli_fetch_array($Querysw))
  {
    $asw= $asw+ $resw['amount']; 
  }
  
  
 $Querylpw=mysqli_query($com,"select * from `cricket_bet` where `over`='$over' and `ball`='$ball' and `name`='LPW'");
  $numlpw = mysqli_num_rows($Querylpw);
  $alpw=0;
  while($relpw = mysqli_fetch_array($Querylpw))
  {
    $alpw= $alpw+ $relpw['amount'];  
  
  }
   $Queryrw=mysqli_query($com,"select * from `cricket_bet` where `over`='$over' and `ball`='$ball' and `name`='RW'");
  $numrw = mysqli_num_rows($Queryrw);
  $arw=0;
  while($rerw = mysqli_fetch_array($Queryrw))
  {
    $arw= $arw+ $rerw['amount']; 
  }
  
  
 $Querynb=mysqli_query($com,"select * from `cricket_bet` where `over`='$over' and `ball`='$ball' and `name`='NB'");
  $numnb = mysqli_num_rows($Querynb);
  $anb=0;
  while($renb = mysqli_fetch_array($Querynb))
  {
    $anb= $anb+ $renb['amount'];  
  
  }
  
  $Querywb=mysqli_query($com,"select * from `cricket_bet` where `over`='$over' and `ball`='$ball' and `name`='WB'");
  $numwb = mysqli_num_rows($Querywb);
  $awb=0;
  while($rewb = mysqli_fetch_array($Querywb))
  {
    $awb= $awb+ $rewb['amount']; 
  }
  
 
  ?>
  
  
                    <tr>
                      <td>
                          <?php echo 0; ?>
                      </td>
                      <td>
                          <?php echo $num0; ?>
                          
                      </td>
                      <td ><?php echo $a0 ;?></td>
                      
                      <td ><input type="checkbox" id="c0" name="c0" value="0" onclick="myfunction(this.value)"></td>
                     
                    </tr>
                   <tr>
                      <td>
                          <?php echo 1; ?>
                      </td>
                      <td>
                          <?php echo $num1;?>
                          
                      </td>
                      <td ><?php echo $a1;?></td>
                      
                     <td ><input type="checkbox" id="c1" name="c1" value="1" onclick="myfunction(this.value)"></td>
                    </tr> 
                    <tr>
                      <td>
                          <?php echo 2; ?>
                      </td>
                      <td>
                          <?php echo $num2; ?>
                          
                      </td>
                      <td ><?php echo $a2 ;?></td>
                      
                      <td ><input type="checkbox" id="c2" name="c2" value="2" onclick="myfunction(this.value)"></td>
                     
                    </tr>
                   <tr>
                      <td>
                          <?php echo 3; ?>
                      </td>
                      <td>
                          <?php echo $num3;?>
                          
                      </td>
                      <td ><?php echo $a3;?></td>
                      
                     <td ><input type="checkbox" id="c3" name="c2" value="3" onclick="myfunction(this.value)"></td>
                    </tr> 
                    <tr>
                      <td>
                          <?php echo 4; ?>
                      </td>
                      <td>
                          <?php echo $num4; ?>
                          
                      </td>
                      <td ><?php echo $a4 ;?></td>
                      
                      <td ><input type="checkbox" id="c4" name="c4" value="4" onclick="myfunction(this.value)"></td>
                     
                    </tr>
                   <tr>
                      <td>
                          <?php echo 6; ?>
                      </td>
                      <td>
                          <?php echo $num6;?>
                          
                      </td>
                      <td ><?php echo $a6;?></td>
                      
                     <td ><input type="checkbox" id="c6" name="c6" value="6" onclick="myfunction(this.value)"></td>
                    </tr> 
                    <tr>
                      <td>
                          <?php echo CW; ?>
                      </td>
                      <td>
                          <?php echo $numcw; ?>
                          
                      </td>
                      <td ><?php echo $acw ;?></td>
                      
                      <td ><input type="checkbox" id="CW" name="CW" value="CW" onclick="myfunction(this.value)"></td>
                     
                    </tr>
                   <tr>
                      <td>
                          <?php echo BW; ?>
                      </td>
                      <td>
                          <?php echo $numbw;?>
                          
                      </td>
                      <td ><?php echo $abw;?></td>
                      
                     <td ><input type="checkbox" id="BW" name="BW" value="BW" onclick="myfunction(this.value)"></td>
                    </tr> 
                             <tr>
                      <td>
                          <?php echo SW ; ?>
                      </td>
                      <td>
                          <?php echo $numsw; ?>
                          
                      </td>
                      <td ><?php echo $asw ;?></td>
                      
                      <td ><input type="checkbox" id="SW" name="SW" value="SW" onclick="myfunction(this.value)"></td>
                     
                    </tr>
                   <tr>
                      <td>
                          <?php echo LPW; ?>
                      </td>
                      <td>
                          <?php echo $numlpw;?>
                          
                      </td>
                      <td ><?php echo $alpw;?></td>
                      
                     <td ><input type="checkbox" id="LPW" name="LPW" value="LPW" onclick="myfunction(this.value)"></td>
                    </tr> 
                    <tr>
                      <td>
                          <?php echo RW; ?>
                      </td>
                      <td>
                          <?php echo $numrw; ?>
                          
                      </td>
                      <td ><?php echo $arw ;?></td>
                      
                      <td ><input type="checkbox" id="RW" name="RW" value="RW" onclick="myfunction(this.value)"></td>
                     
                    </tr>
                   <tr>
                      <td>
                          <?php echo NB ; ?>
                      </td>
                      <td>
                          <?php echo $numnb;?>
                          
                      </td>
                      <td ><?php echo $anb;?></td>
                      
                     <td ><input type="checkbox" id="NB" name="NB" value="NB" onclick="myfunction(this.value)"></td>
                    </tr> 
                    <tr>
                      <td>
                          <?php echo WB ; ?>
                      </td>
                      <td>
                          <?php echo $numwb; ?>
                          
                      </td>
                      <td ><?php echo $awb ;?></td>
                      
                      <td ><input type="checkbox" id="WB" name="WB" value="WB" onclick="myfunction(this.value)"></td>
                     
                    </tr>
                   
                  </tbody>
                </table>
                <input type="hidden" name="over" id="over" value="<?php echo $over;?>">
                 <input type="hidden" name="ball" id="ball" value="<?php echo $ball;?>">
                </form>
                <script>
                    function myfunction(val)
                    {
                       var value = val;
                      var over = document.getElementById("over").value;
                      var ball = document.getElementById("ball").value;
                   $.ajax({
                  url: "ajax_cricketresult.php",
                  type: "POST",
                  data: { value: value,over: over,ball: ball},
                  success : function(data){
                      
                         alert(data);   
                     
                        
               }
            });
                    }
                </script>
                                            </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() { 

}, 1e3);

$(".switchbutton").change(function(){ //alert($(this).val());
var value=$(this).val();
$.ajax({
   type: "Post",
    data:"value=" + value + "& type=" + "switch" ,
    url: "cricketswitch.php",
    success: function (html){
        //alert(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===================================

//=====================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 } ?>

