<?php include "../../root.class.php";
$html = new html();
$db = new db_safeguard();
$html->add_styles_page();
// $html->check_user_type("ADMIN");

$lop_res = $db->query("batch_data", "SELECT * FROM batch_data WHERE status = 'LOP ROOMS'");
$lop = $lop_res->fetch_assoc();

?>

<br>
<h1>lop</h1>

<?php

while ($lop = $lop_res->fetch_assoc()) {
    $username_res = $db->query("users", "SELECT * FROM users WHERE record_id = '$jobcards[user_id]' AND username != 'DEV'");
    ?>

    <div class="form_down">
        <div
            style="display: flex; flex-direction: row; flex-wrap: wrap; justify-content: space-around; align-content: space-around;">
            <div class="searched_data">

                <div class="group_div">

                    <label class="labels">Batch Number:</label>
                    <label class="labels"><?php echo $all_batches['batch_number']; ?></label>
                </div>
                <div class="group_div">
                    <label class="label" for="date_time">DATE CREATED</label>
                    <textarea type="text" class="inputs"><?php echo $jobcards['date_created']; ?></textarea>
                </div>
                <?php if ($username = $username_res->fetch_assoc()) {
                    ?>
                    <div class="group_div">
                        <label class="label" for="user">USER</label>
                        <textarea type="text" class="inputs"><?php echo $username['username']; ?></textarea>
                    </div>
                    <?php
                } ?>
                <div class="group_div">
                    <label class="label" for="type">STATUS</label>
                    <?php
                    if ($jobcards['status'] == 0) {
                        ?>
                        <textarea type="text" class="inputs">PENDING</textarea>

                        <?php

                    } else {
                        ?>
                        <textarea type="text" class="inputs">COMPLETED</textarea>

                        <?php
                    }
                    ?>
                </div>
                <div class="group_div">
                    <a href="lop.php?batch_no=<?php echo $lop['batch_no']; ?>">
                        <button class="buttons">OPEN</button>
                    </a>

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


    <script>

        //auto refresh every 1 minute
        setTimeout(function () {
            location.reload();
        }, 60000);

    </script>

    <?php
}