<?php if (auth()->user()->role == 'customer'): ?>
    <?= $this->extend('layouts/topbar') ?>
<?php else: ?>
    <?= $this->extend('layouts/sidebar') ?>
<?php endif; ?>

<?= $this->section('content') ?>
<section class="content">
    <div class="container-fluid">
        <!-- Small boxes (Stat box) -->
        <div class="card mb-3">
            <div class="card-body">
                <table id="example1" class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>No</th>
                            <th>No Order</th>
                            <th>Customer</th>
                            <th>Tanggal Order</th>
                            <th>Tanggal Pengembalian</th>
                            <th>Nominal Pelunasan</th>
                            <th>Status Pelunasan</th>
                            <?php if (auth()->user()->role != 'pemilik_toko'): ?>
                                <th>Aksi</th>
                            <?php endif; ?>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $i = 1 ?>
                        <?php foreach ($data as $data) : ?>
                            <tr>
                                <td style="width: 30px;"><?= $i++ ?></td>
                                <td><?= $data->no_order_custom  ?></td>
                                <td><?= $data->nama  ?></td>
                                <td><?= $data->tanggal_order  ?></td>
                                <td><?= $data->tanggal_pengambilan ?></td>
                                <td>Rp. <?= number_format($data->nominal_pelunasan, 0, ",", ".") ?></td>
                                <td>
                                    <?php if ($data->status_pelunasan == 2): ?>
                                        <span class="badge badge-success">Sudah Dibayar</span>
                                    <?php elseif ($data->status_pelunasan == 1): ?>
                                        <span class="badge badge-warning">DP</span>
                                    <?php else: ?>
                                        <span class="badge badge-danger">Belum dibayar</span>
                                    <?php endif; ?>
                                </td>
                                <?php if (auth()->user()->role != 'pemilik_toko'): ?>
                                    <td style="width: 200px;">
                                        <a class="btn btn-warning btn-sm mt-1" onclick="show_lg('<?= base_url('permintaan_perubahan/create/' . $data->kode_permintaan_custom) ?>')"><i class="fas fa-pencil-alt"></i>&nbsp;&nbsp;Revisi</a>
                                    </td>
                                <?php endif; ?>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div><!-- /.container-fluid -->
</section>
<?= $this->endSection() ?>