<?php $this->load->view('template/header'); ?>

<div class="container">
    <div class="card my-5 text-dark bg-light mb-3">
        <div class="card-header">Data Penjualan</div>
        <div class="card-body">
            <div class="table-responsive">
                <table class="table" id="datatable" data-ordering="false">
                    <thead>
                        <tr>
                            <th>No</th>
                            <th>Nama Pembeli</th>
                            <th>Alamat Pembeli</th>
                            <th>Nama Produk</th>
                            <th>Jumlah Porsi</th>
                            <th>Tanggal Pengantaran</th>
                            <th>Total Harga</th>
                            <th>Pesan</th>
                            <th>Status Pesanan</th>
                            <th>Tanggal Pembelian</th>
                            <th>Tanggal Pembayaran</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $nama_bulan = array(
                            '01' => 'Januari',
                            '02' => 'Februari',
                            '03' => 'Maret',
                            '04' => 'April',
                            '05' => 'Mei',
                            '06' => 'Juni',
                            '07' => 'Juli',
                            '08' => 'Agustus',
                            '09' => 'September',
                            '10' => 'Oktober',
                            '11' => 'November',
                            '12' => 'Desember'
                        );
                        $no = 1?>
                    <?php foreach ($penjualan as $row) : ?>
                            <tr>
                                <td><?= $no++?></td>
                                <td><?= $row['nama_pembeli'] ?></td>
                                <td><?= $row['alamat'] ?></td>
                                <td><?= $row['nama_produk'] ?></td>
                                <td><?= $row['jumlah'] ?></td>
                                <td><?= date("d-", strtotime($row['date_pemesanan'])) . $nama_bulan[date("m", strtotime($row['date_pemesanan']))] . date("-Y H:i", strtotime($row['date_pemesanan'])) ?></td>
                                <td><?= $row['total'] ?></td>
                                <td><?= $row['keterangan'] ?></td>
                                <td><?= $row['status_pesanan'] ?></td>
                                <td><?= date("d-", strtotime($row['tanggal'])) . $nama_bulan[date("m", strtotime($row['tanggal']))] . date("-Y", strtotime($row['tanggal'])) ?></td>
                                <td><?= date("d-", strtotime($row['tanggal_pembayaran'])) . $nama_bulan[date("m", strtotime($row['tanggal']))] . date("-Y", strtotime($row['tanggal'])) ?></td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

<?php $this->load->view('template/js'); ?>
<?php $this->load->view('template/footer'); ?>