<?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);
}
   .ubox {
    width: 23%;
}

.uinfo {
    background: #E0E0E0;
}
.uinfo, .user-box {
    margin: 0px 12px;
    padding: 10px;
    margin-bottom: 20px;
}
        </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">User Details</h2>
                                
                                </div>
                               <?php
       $userid = $_GET['user'];
       $Query=mysqli_query($com,"select * from `loginuser` where id='$userid'");
       
       $row=mysqli_fetch_array($Query);
       
       ?>
                            </div>
                            <!-- /.row -->
                            <div class="row breadcrumb-div">
                                <div class="col-md-12">
                                   
            <div class="col-lg-6 col-sm-6 col-xs-6 user-info">
                <ul class="list">
                    <li>User Id : <b><?php echo $row['id'];   ?></b></li>
                     <li>Phone No. : <b><?php echo $row['mobile'];   ?></b>  </li>
                    <li>Created At : <b><?php echo $row['createdate'];   ?></b></li>
                    
                    
                </ul>
            </div>
            
            <div class="col-lg-4 col-sm-4 col-xs-4 user-info">
                <ul class="list">
                   <li>Referal Id : <b>
                    <?php
       $code = $row['code'];
       $Query1=mysqli_query($com,"select * from `loginuser` where owncode='$code'");
       
       $row1=mysqli_fetch_array($Query1);
       echo $row1['id'];
       ?></b></li>
                    
                    <li>Refered By : <b><?php echo $row1['mobile'];   ?></b></li>
                </ul>
            </div> 
                                </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>
                                            </div>
<div class="row user-box" style="margin:0px;padding:0px;width:100%;">
            <div class="col-md-3 col-sm-12  col-lg-3 uinfo ubox" >
                <strong>TOTAL BALANCE</strong>
                <h2><?php echo number_format(wallet($com,'amount',$row["id"]),2);?></h2>
            </div>
            <div class="col-md-3 col-sm-12  col-lg-3 uinfo ubox" >
                <strong>TOTAL REFERRAL</strong>
                <h2><?php
       $owncode = $row['owncode'];
       $Query12=mysqli_query($com,"select * from `loginuser` where code='$owncode'");
       
       $row12=mysqli_num_rows($Query12);
       echo $row12;
       ?></h2>
            </div>
            <div class="col-md-3 col-sm-12 col-lg-3 uinfo ubox" >
                <strong>TOTAL BET AMOUNT</strong>
                <h2>
                <?php
       $userid = $row['id'];
       
       $sql1=mysqli_query($com,"select sum(amount)as color from `tbl_betting` where userid='$userid'");
       $row1=mysqli_fetch_array($sql1);
       $amount1 = $row1['color'];
       $sql2=mysqli_query($com,"select sum(amount)as first from `first_bet` where userid='$userid'");
       $row2=mysqli_fetch_array($sql2);
       $amount2 = $row2['first'];
       $sql3=mysqli_query($com,"select sum(amount)as andar from `andar_bet` where userid='$userid'");
       $row3=mysqli_fetch_array($sql3);
       $amount3 = $row3['andar'];
       
       
       echo $amount1+$amount2+$amount3;
       ?></h2>
            </div>
            <div class="col-md-3 col-sm-12 col-lg-3 uinfo ubox" >
                <strong>TOTAL WITHDRAWN</strong>
                <h2><?php 
			  $totalrecharge=mysqli_query($com,"select sum(`amount`)as total from  `withdrawal` where `userid`='".$row["id"]."' and `status`=1");
			  $totalResult=mysqli_fetch_array($totalrecharge);
			  echo number_format($totalResult['total'],2);?></h2>
            </div>
        </div>
                                            <div class="panel-body p-20">
                                                 <h2>DEPOSIT RECORD</h2>
                                                 <br>
                                                <table id="example" class="display table table-striped table-bordered" cellspacing="0" width="100%">
                                                    <thead>
                                                   <tr>
                <th>#</th>         
                <th>Updated At</th>
                <th>Transaction ID</th>
                <th>Payment Method</th>
                <th>Phone </th>
                <th>Amount</th>
                 <th>Status</th>
                 
                </tr>
                                                    </thead>
                                                    
                                                    <tbody>
                              <?php
                    $userid = $row['id'];
                     $Query1234=mysqli_query($com,"select * from walletsummery where actiontype='recharge' and userid='$userid' order by id desc");
                    $cnt=1;
                    while($row1=mysqli_fetch_array($Query1234))
                    {
                    ?>
                    <tr class="odd">
                         <td><?php echo htmlentities($cnt);?></td>
                        <td><?php echo @$row1["createdate"]; ?></td>
                        <td><?php echo @$row1["utr_no"]; ?></td>
                        <td></td>
                        <td><?php echo @$row1["phone"]; ?></td>
                        <td><?php echo number_format($row1["amount"], 2) ?></td>
                        <td>	<?php if($row1['status']==0){?>
                                                            <span class="btn btn-warning disabled">PENDING</span>
                                                        <?php }else if($row1['status']==1){ ?>
                                                            <span class="btn btn-success disabled">SUCCESS</span>
                                                        <?php }else{ ?>
                                                            <span class="btn btn-danger disabled">FAIL</span>
                                                        <?php }?></td>
                    </tr>
                    <?php $cnt=$cnt+1; } ?>
                       
                                                    
                                                    </tbody>
                                                </table>

                                         
                                                <!-- /.col-md-12 -->
                                            </div>
                                            
                                            <br><br>
                                            <div class="panel-body p-20">
                                                 <h2>WITHDRAW RECORD</h2>
                                                 <br>
                                                <table id="example1" class="display table table-striped table-bordered" cellspacing="0" width="100%">
                                                    <thead>
                                                   <tr>
                <th>#</th>         
                <th >Updated At</th>
                            <th >Amount</th>
                            <th>Payout</th>
                            <th >Status</th>
                 
                </tr>
                                                    </thead>
                                                    
                                                    <tbody>
                              <?php
                   $totalwith=mysqli_query($com,"select * from  `withdrawal` where `userid`='".$row["id"]."' order by id desc");
                   $cnt=1;
			  while($totalResult=mysqli_fetch_array($totalwith)){
                    
                    
                    ?>
                    <tr class="odd">
                         <td><?php echo htmlentities($cnt);?></td>
                        <td><?php echo $totalResult['createdate'];   ?></td>
                       <td><?php echo $totalResult['amount'];   ?></td>
                       <td></td>
                       <td><?php if($totalResult['status']==1){?>
                                                            <span class="btn btn-warning disabled">PENDING</span>
                                                        <?php }else if($totalResult['status']==0){ ?>
                                                            <span class="btn btn-success disabled">SUCCESS</span>
                                                        <?php }else{ ?>
                                                            <span class="btn btn-danger disabled">FAIL</span>
                                                        <?php }?></td>
                    </tr>
                    <?php $cnt=$cnt+1; } ?>
                       
                                                    
                                                    </tbody>
                                                </table>

                                         
                                                <!-- /.col-md-12 -->
                                            </div>
                                            <br><br>
                                            <div class="panel-body p-20">
                                                 <h2>REFERAL RECORD</h2>
                                                 <br>
                                                <table id="example12" class="display table table-striped table-bordered" cellspacing="0" width="100%">
                                                    <thead>
                                                   <tr>
                <th>#</th>         
                <th >Updated At</th>
                            <th >Refered To</th>
                            <th >Email</th>
                 
                </tr>
                                                    </thead>
                                                    
                                                    <tbody>
                              <?php
                  
                   $cnt=1;
			 $owncode = $row['owncode'];
       $Query123=mysqli_query($con,"select * from `loginusert` where code='$owncode' order by id desc");
       
      while($row123=mysqli_fetch_array($Query123)){
                    
                    ?>
                    <tr class="odd">
                         <td><?php echo htmlentities($cnt);?></td>
                        <td><?php echo $row123['createdate']; ?></td>
                        <td><?php echo $row123['mobile']; ?></td>
                        <td><?php echo $row123['email']; ?></td>
                    </tr>
                    <?php $cnt=$cnt+1; } ?>
                       
                                                    
                                                    </tbody>
                                                </table>

                                         
                                                <!-- /.col-md-12 -->
                                            </div>
                                            <br><br>
                                            <div class="panel-body p-20">
                                                 <h2>GAME BET RECORD</h2>
                                                 <br>
                                                <table id="example13" class="display table table-striped table-bordered" cellspacing="0" width="100%">
                                                    <thead>
                                                   <tr>
                <th>#</th>         
               <th >Created At</th>
                            <th >Period Id</th>
                            <th >Result</th>
                            <th >Value</th>
                            <th >Amount</th>
                            <th >Tab</th>
                 
                </tr>
                                                    </thead>
                                                    
                                                    <tbody>
                              <?php
                  
                   $cnt=1;
			 $userid = $row['id'];
       
       $sql1=mysqli_query($com,"select * from `tbl_betting` where userid='$userid'");
        
      while($row1=mysqli_fetch_array($sql1)){
                    
                    ?>
                    <tr class="odd">
                         <td><?php echo htmlentities($cnt);?></td>
                        <td><?php echo $row1['createdate'];   ?></td>
                        <td><?php echo $row1['periodid'];   ?></td>
                        <td><?php echo $row1['type'];   ?></td>
                        <td><?php echo $row1['value'];   ?></td>
                        <td><?php echo $row1['amount'];   ?></td>
                        <td><?php echo $row1['tab'];   ?></td>
                    </tr>
                    <?php $cnt=$cnt+1; } ?>
                       
                                                    
                                                    </tbody>
                                                </table>

                                         
                                                <!-- /.col-md-12 -->
                                            </div>
                                            
                                            <br><br>
                                            <div class="panel-body p-20">
                                                 <h2>BANK DETAILS</h2>
                                                 <br>
                                                <table id="example14" class="display table table-striped table-bordered" cellspacing="0" width="100%">
                                                    <thead>
                                                   <tr>
                  
               <th >Bank Name</th>
                            <th >Account Holder</th>
                            <th >Account Number</th>
                            <th >IFSC</th>
                            <th >Type</th>
                            <th >Status</th>
                 
                </tr>
                                                    </thead>
                                                    
                                                    <tbody>
                              <?php
                  
                  $userid = $row['id'];
$selectBankQuery=mysqli_query($com,"select * from `bankdetail` where `userid`='".$userid."'");
while($bankResult=mysqli_fetch_array($selectBankQuery)){
                    
                    ?>
                    <tr class="odd">
                         <td><?php echo $bankResult['bankname'];?></td>
                     <td><?php echo $bankResult['name'];?></td>
                     <td><?php echo $bankResult['account'];?></td>
                     <td><?php echo $bankResult['ifsc'];?></td>
                     <td><?php echo $bankResult['type'];?></td>
                     <td><?php echo $bankResult['status'];?></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>
        <!-- /.main-wrapper -->

        <!-- ========== COMMON JS FILES ========== -->
        <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>

        <!-- ========== PAGE JS FILES ========== -->
        <script src="js/prism/prism.js"></script>
        <script src="js/DataTables/datatables.min.js"></script>

        <!-- ========== THEME JS ========== -->
        <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();

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

                $('#example3').DataTable();
            });
        </script>
        <script>
            $(function($) {
                $('#example12').DataTable();

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

                $('#example3').DataTable();
            });
        </script>
        <script>
            $(function($) {
                $('#example13').DataTable();

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

                $('#example3').DataTable();
            });
        </script>
        <script>
            $(function($) {
                $('#example14').DataTable();

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

                $('#example3').DataTable();
            });
        </script>
    </body>
</html>
<?php } ?>

