
<?php
require '../../data.php';

function timeindo($jamnya) {
    $hari = date("l", strtotime($jamnya));

    switch($hari){
        case 'Monday':
            return 'Senin';
        break;

        case 'Tuesday':
            return 'Selasa';
        break;

        case 'Wednesday':
            return 'Rabu';
        break;

        case 'Thursday':
            return 'Kamis';
        break;

        case 'Friday':
            return 'Jumat';
        break;

        case 'Saturday':
            return 'Sabtu';
        break;

        case 'Sunday':
            return 'Minggu';
        break;
    }

}

    $sgames = "SELECT * FROM (SELECT res_pasaran, res_angka, MAX(res_jam) AS res_jam FROM result_lotto WHERE res_angka != 'xxxx' GROUP BY res_pasaran) AS x JOIN result_lotto USING (res_pasaran, res_jam) ORDER BY res_jam DESC";
    $qgames = mysqli_query($data, $sgames);

    if(mysqli_num_rows($qgames) > 0) {

        while($fgames = mysqli_fetch_assoc($qgames)) {  
            $pasaran = $fgames['res_pasaran'];
            $pangka = $fgames['res_angka'];
            $resjam = $fgames['res_jam'];

            echo '<!-- Mobile -->   
            <div id="cib" class="col-lg-12 d-md-none mb-3">
            <div style="background: linear-gradient(rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.6)), url(\'images/icon-market/'.$pasaran.'.png\')  center center no-repeat; background-size: cover;" class="card-game position-relative border-game rounded">
                <span data-bs-toggle="modal" data-bs-target="#infopas'.$pasaran.'" class="info-market"><i class="fas fa-info-circle"></i></span>
                    <h4 class="text-center text-uppercase fw-bold">'.$pasaran.'</h4>
                    <div class="res-pasaran">

                                <h3 class="my-2 rounded">'.$pangka.'</h3>
                                <p>Result : '.timeindo($resjam).', '.date("d-m-Y", strtotime($resjam)).'</p>
                            </div>
                    <div class="d-flex justify-content-between">
                            <button onclick="openLivedraw(\''.$pasaran.'\')" type="button" class="btn-small border-0"><i class="fas fa-info-circle"></i> Livedraw</button>
                            <a href="?page=prediksi-mobile&pre='.$pasaran.'" class="btn-small"><i class="fas fa-list"></i> Prediksi</a>
                            <a href="?page=data-keluaran-togel&pasar='.$pasaran.'" class="btn-small"><i class="fas fa-eye"></i> keluaran</a>
                    </div>
                    </div>
            </div>
                 <!-- /Mobile -->   
                 
            <div id="cib" class="col-lg-4 d-none d-md-block mb-2">
                    <div class="card-game position-relative rounded">
                        <span data-bs-toggle="modal" data-bs-target="#infopas'.$pasaran.'" class="info-market"><i class="fas fa-info-circle"></i></span>
                        <img src="images/icon-market/'.$pasaran.'.png" class="rounded img-fluid d-block mx-auto" />
                        
                            <div class="res-pasaran">
                            <h3 class="my-2 rounded">'.$pangka.'</h3>
                                <p class="text-uppercase">'.$pasaran.'</p>
                                <p class="">Result : '.timeindo($resjam).', '.date("d-m-Y", strtotime($resjam)).'</p>
                            </div>

                        <h6 onclick="openLivedraw(\''.$pasaran.'\')" style="font-size: 0.8rem; cursor: pointer;" class="bg-warning bg-gradient my-1 rounded d-block mx-auto text-center text-dark fw-bold p-2 text-uppercase"><i class="fas fa-info-circle"></i> Livedraw '.$pasaran.'</h6>
                        <a href="?page=prediksi-togel&pasaran='.$pasaran.'"><h6 style="font-size: 0.8rem;" class="bg-warning bg-gradient my-1 rounded d-block mx-auto text-center text-dark fw-bold p-2 text-uppercase"><i class="fas fa-info-circle"></i> Prediksi '.$pasaran.'</h6></a>
                        <a href="?page=data-keluaran-togel&pasar='.$pasaran.'"><h6 style="font-size: 0.8rem;" class="bg-warning bg-gradient my-1 rounded d-block mx-auto text-center text-dark fw-bold p-2 text-uppercase"><i class="fas fa-clock"></i> Result '.$pasaran.'</h6></a>
                    </div>
            </div>';
        }

    } else {
        echo '<div class="col-lg-12">
            <p>Pasaran Togel saat ini tidak tersedia!!</p>
        </div>';
    }
?>
