<?php
require 'assets/data.php';
require 'assets/config.php';
?>

<!DOCTYPE html>
<html lang="id">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/blog-togel.css?v=<?php echo rand(0, 99); ?>">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.13.0/css/all.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />
    <link rel="icon" type="image/png" href="images/ico.png" sizes="192x192">
    <link rel="apple-touch-icon" sizes="180x180" href="images/ico.png">

    <?php

            $sseo = "SELECT content_seo, halaman_seo FROM seo_web WHERE halaman_seo = 'turnamen'";
            $qseo = mysqli_query($data, $sseo);

            if(mysqli_num_rows($qseo) > 0) {
                $fseo = mysqli_fetch_assoc($qseo);
                $seo = $fseo['content_seo'];
                $halaman = $fseo['halaman_seo'];
                    echo $seo;

            }
    ?>

    <?php echo ftab("web_master", "web_setting", "web_master") ?>
    
    <script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
    <style>
    body{
    background-color: rgb(240, 240, 240) !important;
    font-family: "ubuntu1";
    }
    </style>
</head>
<body>

<div class="bg-head-turnamen">
    <div class="container-fluid">
            <div class="row align-items-center">
                    <div class="col-3" onclick="window.open('','_parent','');window.close();">
                        <a class="close-turnamen" href="#"><i class="fas fa-times-circle"></i></a>
                    </div>

                    <div class="col-9">
                        <h3 class="title-turnamen">TURNAMEN LIVE GAMES</h3>
                    </div>

            </div>
    </div>
</div>

<div class="container-fluid bg-light my-3">
    <h2 class="title-leaderboard">LEADERBOARDS</h2>

    <div class="row mb-4 g-1">
        <div class="col-lg-4 mb-2 col-6">
            <div class="leaderboard-card bg-gradient">
                <h4 class="my-2">Mulai : <span class="leaderboard-date">
                 <?php echo date("d M Y", strtotime(ftab("mulai_tglto", "mulai_to", "mulai_tglto")))?>
                </span></h4>
            </div>
        </div>

        <div class="col-lg-4 mb-2 col-6">
            <div class="leaderboard-card bg-gradient">
                <h4 class="my-2">Akhir : <span class="leaderboard-date"><?php echo date("d M Y", strtotime(ftab("akhir_tglto", "mulai_to", "akhir_tglto")))?></span> </h4>
            </div>
        </div>

        <div class="col-lg-4 mb-2">
            <div class="leaderboard-card bg-gradient">
                <h4 class="my-2">Terakhir Update TO : <span class="leaderboard-date">
                    <?php
                        $sudate = "SELECT tanggal_to FROM peserta_to ORDER BY tanggal_to DESC LIMIT 1";
                        $qudate = mysqli_query($data, $sudate);

                        if(mysqli_num_rows($qudate) > 0) {
                            $fda = mysqli_fetch_assoc($qudate);
                            echo date("d M Y", strtotime($fda['tanggal_to']));
                        } else {
                            echo '-';
                        }
                    ?>
                </span></h4>
            </div>
            

            <div class="d-flex my-2 justify-content-end">
                <a data-bs-toggle="modal" data-bs-target="#syarat" class="link-syarat" href="#"><u>Syarat & Ketentuan</u></a>
            </div>

        </div>

    </div>

    <div class="daftar-pemenang bg-primary text-light p-1 rounded-top">
        <h5>DAFTAR PEMENANG</h5>
    </div>

   <div class="table-responsive">
    <table class="table table-hover text-center table-striped w-100">
        <thead class="bg-primary text-light">
            <tr>
                <th><img src="images/crown.png" class="d-block mx-auto" width="38" alt="mahkota pemenang turnamen"></th>
                <th>ID PLAYER</th>
                <th>PERMAINAN</th>
                <th>TOTAL TO</th>
                <th>TOTAL HADIAH</th>
            </tr>
        </thead>

        <tbody class="fw-bold">

        <?php 
                            $sturna = "SELECT * FROM peserta_to";
                            $qturna = mysqli_query($data, $sturna);

                            if(mysqli_num_rows($qturna) > 0) {
                                $x = 1;
                                while($fturna = mysqli_fetch_assoc($qturna))  {
                                        $namauser1 = $fturna['nama_user'];
                                        $namauser = substr($namauser1, 0, -3). 'xxx';
                                        $touser = $fturna['to_user'];
                                        $hadiah = $fturna['hadiah_user'];
                                        $gameuser = $fturna['game_user'];
                                        $tgl = $fturna['tanggal_to'];

                                        echo '<tr>
                                        <th scope="row">'.$x++.'</th>
                                        <td>'.$namauser.'</td>
                                        <td class="text-uppercase">'.$gameuser.'</td>
                                        <td>Rp.'.number_format($touser, 0, ',', '.').'</td>
                                        <td>Rp.'.number_format($hadiah, 0, ',', '.').'</td>
                                        
                                    </tr>';

                                }
                            }
                        
                        ?>
        </tbody>
    </table>
    </div>

</div>


<!-- Syarat Ketentuan -->
<div class="modal fade" id="syarat" tabindex="-1" aria-labelledby="syaratlabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title text-uppercase" id="syaratlabel">Syarat & Ketentuan</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>

      <div class="modal-body">
        <?php echo ftab("turnamen_text", "change_text", "turnamen_text"); ?>
      </div>

    </div>
  </div>
</div>


<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/blog-tgel.js"></script>
<?php echo ftab("content_script", "web_setting", "content_script")?>
</body>
</html>