<?php
session_start();
require '../config.php';
require '../lib/session_user.php';
require '../lib/header.php';
?>
<div class="content-wrapper">
    <div class="row ">
        <div class="col-12 grid-margin">
            <div class="card">
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table">
                            <thead>
                                <tr>
                                <th>Order</th>
                                <th>ID Layanan</th>
                                <th>Layanan</th>
                                <th>Mulai</th>
                                <th>Selesai</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php 
                                      $cek_pesanan = $conn->query("SELECT * FROM monitoring_sosmed ORDER BY id DESC LIMIT 200"); // edit
                                        while ($data_pesanan = $cek_pesanan->fetch_assoc()) {
                                        
                                        $Layanan_sosmed = $conn->query("SELECT * FROM layanan_sosmed WHERE service_id = '".$data_pesanan['services_id']."'"); 
                                        $D_layanan = $Layanan_sosmed->fetch_assoc(); 
                                        if($D_layanan['service_id'] == true){
                                        $id_layanan = $D_layanan['service_id'];
                                        $TX = "muted";
                                         } else {
                                        $id_layanan = "ID Telah Updated";  
                                        $TX = "danger";
                                         }
                                    ?>
                                    <tr class="text-<?php echo $TX; ?>">
                                    <td><a href="<?php echo $config['web']['url']; ?>pemesanan/single?id_services=<?php echo $D_layanan['id']; ?>" class="btn btn-sm btn-success"><i class="mdi mdi-cart"></i></a></td>
                                    <td><?php echo $id_layanan; ?></td>
                                    <td><?php echo $D_layanan['layanan']; ?></td>
                                    <td><?php echo tanggal_indo($data_pesanan['date']); ?> <?php echo $data_pesanan['time']; ?></td>
                                    <td><?php echo  $data_pesanan['average']; ?></td>
                                    </td>
                                </tr>
                                <?php } ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--MODAL-->
<div class="modal fade" id="myDetail">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">Detail Order</h4>
                <button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body" id="data_order">
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<?php
require '../lib/footer.php';
?>