<?= $this->extend('layouts/window.php') ?>

<?= $this->section('content') ?>
<style>
    .linkstyle{
        color: #00224D;
        font-weight: bold;
        /* text-decoration: underline; */
    }
    .delete-link{
        color: red;
        font-weight: bold;
    }
    p{
        margin:0;
    }
    strong{
        font-weight: bold;
    }
</style>

<?php
if ( isset($guidebook) ) {

    foreach($guidebook as $row) {
        $guideid = $row['guideid'];
        $guidetitle = $row['guidetitle'];
        $guidedetail = $row['guidedetail'];
        $userid_creator = $row['userid_creator'];
        $fullname = $row['fullname'];
        $createdate = $row['createdate'];
        $createdate = date_create($row['createdate']);
    }

}
?>

<div class="container-fluid mb-3 bg-light">

    <div class="row page-titles">
        
        <div class="col-12">
            <?php if ( isset($guidebook) ) { ?>
                <div class='ps-md-5 pe-md-5 ms-md-5 me-md-5'>
                    <h1 class="card-title fw-bold text-center mb-2" style="color:#142e54;"><?= $guidetitle ?></h1>
                    
                    <div class="row">
                        <div class="col-sm-6">
                            <h6 class="card-subtitle mt-3 mb-3 text-muted">
                            creator <span class='fw-bold text-dark'><?= $fullname ?></span>
                            on <u class='fw-light text-dark'><?= date_format($createdate,"D, d M Y");?></u>
                            </h6>
                        </div>
                        <div class="col-sm-6 text-end">
                            <?php if($_SESSION['level'] < 2) { ?>
                                <a href="/guidebook/edit/<?=$guideid;?>" class='btn btn-outline-dark btn-sm mt-1 mb-1 '>
                                    <i class='fa-solid fa-bug'></i> &nbsp;Edit Post
                                </a>
                                <!-- <a href="/guidebook/delete/<?=$guideid;?>" class='btn btn-outline-danger btn-sm mt-1 mb-1 delete-link'>
                                    <i class="fa-regular fa-trash-can"></i> &nbsp;Delete Post
                                </a> -->
                            <?php } ?>
                        </div>
                    </div>

                    <hr class="mt-2 ">
                    
                    <p class="card-text"><?= $guidedetail ?></p>
                </div>
            <?php } ?>
        </div>

    </div>

</div>

<?= $this->endSection() ?>

<?= $this->section('script') ?>
<script>
    
    let element = document.getElementById("body");
    let element_link = document.getElementsByTagName("a");
    for (let i = 0; i < element_link.length; i++) {
        // Tambahkan sebuah kelas untuk menerapkan gaya
        element_link[i].classList.add('linkstyle');
    }
    // element_link.classList.add("bg-white");
    element.classList.add("bg-white");
    console.log('asasa');

</script>
<?= $this->endSection() ?>