<?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;
    }

}

function monthindo($jamnya) {
    $hari = date("F", strtotime($jamnya));

    switch($hari){
        case 'January':
            return 'Januari';
        break;

        case 'February':
            return 'Februari';
        break;

        case 'March':
            return 'Maret';
        break;

        case 'April':
            return 'April';
        break;

        case 'May':
            return 'Mei';
        break;

        case 'June':
            return 'Juni';
        break;

        case 'July':
            return 'Juli';
        break;

        case 'August':
            return 'Agustus';
        break;

        case 'September':
            return 'September';
        break;

        case 'November':
            return 'November';
        break;

        case 'December':
            return 'Desember';
        break;
    }

}

    if(isset($_GET['blog'])) {
        $blog = mysqli_real_escape_string($data, $_GET['blog']);

        $sbl = "SELECT * FROM panduan_post WHERE title_slug_panduan = '$blog'";
        $qbl = mysqli_query($data, $sbl);
        echo '<div class="row g-2">';

        if(mysqli_num_rows($qbl) > 0) {
           

                $fbl = mysqli_fetch_assoc($qbl);
                $title = $fbl['title_panduan'];
                $slug = $fbl['title_slug_panduan'];
                $thumbnail = $fbl['thumbnail_panduan'];
                $content = $fbl['content_panduan'];
                $tanggal = $fbl['tanggal_panduan'];

                echo '<div class="col-xl-9">
                            <h1 class="title-pp"><small><i class="fas fa-info-circle"></i></small> '.$title.'</h1>
                            <p style="font-size: 0.8rem" class="mb-1 fw-bold text-secondary"><small><i class="fas fa-calendar-alt"></i></small> '.timeindo($tanggal).', '.date("d", strtotime($tanggal)).' '.monthindo($tanggal).' '.date("Y H:i", strtotime($tanggal)).' WIB</p>
                        <div class="card">
                        <img src="'.$thumbnail.'" class="card-img-top" alt="'.$slug.'">
                            <div class="card-body">
                                '.html_entity_decode($content).'
                            </div>
                        </div>
                </div>';
            
        } else {
            echo '<div class="col-xl-9">
            <h2 class="title-pp text-center text-danger"><small><i class="fas fa-times-circle"></i></small> 404 Artikel Tidak ditemukan!!</h2>
                    <div class="d-flex justify-content-center">
                        <a class="btn fw-bold btn-warning" href="/?page=bukti-jp-member">Kembali ke Beranda</a>
                    </div>
            </div>';
        }

        $gar = "SELECT * FROM panduan_post WHERE title_slug_panduan != '$blog' AND panduan_status = '1' ORDER BY tanggal_panduan DESC LIMIT 2";
        $qar = mysqli_query($data, $gar);

        if(mysqli_num_rows($qar) > 0) {
            echo '<div class="col-xl-3">
            <h3>Bukti JP Lainnya:</h3>';
            while($far = mysqli_fetch_assoc($qar)) {
                    $title = $far['title_panduan'];
                    $slug = $far['title_slug_panduan'];
                    $desc = $far['short_dec_panduan'];
                    $thumbnail = $far['thumbnail_panduan'];
                    $tanggal = $far['tanggal_panduan'];

                    echo '<div class="card mb-2 card-posts">
                    <a href="?page=bukti-jp-member&blog='.$slug.'"> <img src="'.$thumbnail.'" class="card-img-top" alt="'.$slug.'"></a>
                     <div class="card-body card-posts">
                         <h5 class="card-title">'.$title.'</h5>
                         <p class="card-text">'.$desc.'</p>
                         <p class="card-text"><small class="text-muted">Diupload Pada : '.timeindo($tanggal).', '.date("d", strtotime($tanggal)).' '.monthindo($tanggal).' '.date("Y", strtotime($tanggal)).'</small></p>
                             <div class="d-flex justify-content-end">
                                 <a href="?page=bukti-jp-member&blog='.$slug.'" class="btn btn-sm btn-warning"><i class="fas fa-info-circle"></i> Baca Selengkapnya</a>
                             </div>
                     </div>
                 </div>';
            }
            
            echo '</div>';
        }

        echo '</div>';
    } else {

?>

<h6 class="text-center text-uppercase">BUKTI JACKPOT LUNAS <?php echo ftab("link_masukbo", "web_setting", "link_masukbo"); ?></h6>
<hr class="w-75 d-block mx-auto" />
    <div class="row">
            <div class="col-9"></div>

            <div class="col-xl-3 mb-2">
                        <div class="input-group">
                            <input name="panduan" id="buktijpsearch" type="text" placeholder="Cari Bukti JP Disini.." class="form-control">
                            <button type="button" class="btn btn-warning"><i class="fas fa-search"></i></button>
                        </div>
            </div>

            <div class="col-xl-12">

                    <div id="search-bukti"></div>

                    <!-- Post Panduan -->
                    <div id="post-bukti">
                            <div class="row g-2">
                                    <?php
                                        $gpanduan = "SELECT * FROM panduan_post WHERE panduan_status = '1' ORDER BY tanggal_panduan DESC";
                                        $qpanduan = mysqli_query($data, $gpanduan);

                                        if(mysqli_num_rows($qpanduan) > 0) {
                                            while($fpanduan = mysqli_fetch_assoc($qpanduan)) {
                                                $title = $fpanduan['title_panduan'];
                                                $slug = $fpanduan['title_slug_panduan'];
                                                $desc = $fpanduan['short_dec_panduan'];
                                                $thumbnail = $fpanduan['thumbnail_panduan'];
                                                $tanggal = $fpanduan['tanggal_panduan'];


                                                echo ' <div class="col-xl-4 mb-2">
                                                <div class="card card-posts">
                                                   <a href="?page=bukti-jp-member&blog='.$slug.'"> <img src="'.$thumbnail.'" class="card-img-top" alt="'.$slug.'"></a>
                                                    <div class="card-body card-posts">
                                                        <h5 class="card-title">'.$title.'</h5>
                                                        <p class="card-text">'.$desc.'</p>
                                                        <p class="card-text"><small class="text-muted">Diupload Pada : '.timeindo($tanggal).', '.date("d", strtotime($tanggal)).' '.monthindo($tanggal).' '.date("Y", strtotime($tanggal)).'</small></p>
                                                            <div class="d-flex justify-content-end">
                                                                <a href="?page=bukti-jp-member&blog='.$slug.'" class="btn btn-warning"><i class="fas fa-info-circle"></i> Baca Selengkapnya</a>
                                                            </div>
                                                    </div>
                                                </div>
                                            </div>';

                                            }
                                        }
                                    ?>
                                   
                            </div>
                    </div>
                    <!-- /Post Panduan -->
            </div>
    </div>

    <?php
    }
    ?>



