<?= $this->extend('layouts/owner') ?>

<?= $this->section('content') ?>

<div class="container-fluid">

    <div class="row mb-3">

        <div class="col-md-6">

            <h3>

                <i class="fas fa-industry"></i>

                Detail Produksi

            </h3>

        </div>

        <div class="col-md-6 text-end">

            <a href="<?= base_url('owner/production') ?>" class="btn btn-secondary">

                <i class="fas fa-arrow-left"></i>

                Kembali

            </a>

        </div>

    </div>

    <div class="row">

        <div class="col-md-8">

            <div class="card shadow">

                <div class="card-header bg-primary text-white">

                    Informasi Queue

                </div>

                <div class="card-body">

                    <table class="table table-bordered">

                        <tr>

                            <th width="220">Nomor Order</th>

                            <td><?= esc($queue['order_number'] ?? '-') ?></td>

                        </tr>

                        <tr>

                            <th>Produk</th>

                            <td><?= esc($queue['nama_product'] ?? '-') ?></td>

                        </tr>

                        <tr>

                            <th>Qty Order</th>

                            <td><?= $queue['qty_order'] ?></td>

                        </tr>

                        <tr>

                            <th>Qty Diproduksi</th>

                            <td><?= $queue['qty_hari_ini'] ?></td>

                        </tr>

                        <tr>

                            <th>Sisa Produksi</th>

                            <td><?= $queue['qty_sisa'] ?></td>

                        </tr>

                        <tr>

                            <th>Periode</th>

                            <td><?= !empty($queue['tanggal_produksi']) ? esc(date('m/Y', strtotime($queue['tanggal_produksi']))) : '-' ?></td>

                        </tr>

                        <tr>

                            <th>Tanggal Produksi</th>

                            <td><?= $queue['tanggal_produksi'] ?></td>

                        </tr>

                        <tr>

                            <th>Status</th>

                            <td>

                                <?php if($queue['status']=='antrian'): ?>

                                    <span class="badge bg-warning">

                                        Waiting

                                    </span>

                                <?php elseif($queue['status']=='produksi'): ?>

                                    <span class="badge bg-primary">

                                        Process

                                    </span>

                                <?php else: ?>

                                    <span class="badge bg-success">

                                        Completed

                                    </span>

                                <?php endif ?>

                            </td>

                        </tr>

                    </table>

                </div>

            </div>

        </div>

        <div class="col-md-4">

            <div class="card shadow">

                <div class="card-header bg-success text-white">

                    Aksi Produksi

                </div>

                <div class="card-body d-grid gap-2">

                    <a href="<?= base_url('owner/production/waiting/'.$queue['id_queue']) ?>"

                       class="btn btn-warning">

                        Waiting

                    </a>

                    <a href="<?= base_url('owner/production/process/'.$queue['id_queue']) ?>"

                       class="btn btn-primary">

                        Process

                    </a>

                    <a href="<?= base_url('owner/production/finish/'.$queue['id_queue']) ?>"

                       class="btn btn-success">

                        Finish

                    </a>

                    <a href="<?= base_url('owner/production/cancel/'.$queue['id_queue']) ?>"

                       class="btn btn-danger">

                        Cancel

                    </a>

                </div>

            </div>

        </div>

    </div>

    <div class="card shadow mt-4">

        <div class="card-header bg-dark text-white">

            Riwayat Produksi

        </div>

        <div class="card-body">

            <table class="table table-bordered">

                <thead>

                <tr>

                    <th>No</th>

                    <th>Status Sebelum</th>

                    <th>Status Sesudah</th>

                    <th>Waktu</th>

                </tr>

                </thead>

                <tbody>

                <?php $no=1 ?>

                <?php foreach($history as $row): ?>

                    <tr>

                        <td><?= $no++ ?></td>

                        <td><?= $row['status_sebelum'] ?></td>

                        <td><?= $row['status_sesudah'] ?></td>

                        <td><?= $row['updated_at'] ?></td>

                    </tr>

                <?php endforeach ?>

                </tbody>

            </table>

        </div>

    </div>

</div>

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