<?php
$pinjam_inv = $this->db->query("SELECT * FROM pinjam_inv INNER JOIN user, inventaris WHERE pinjam_inv.id_user=user.id_user AND pinjam_inv.id_inv=inventaris.id_inv AND pinjam_inv.status!=2 ORDER BY tgl_pinjam ASC")->result();
?>

<div class="content-wrapper">
    <section class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1><?= $title; ?></h1>
                </div>
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a href="#"><?= $root; ?></a></li>
                        <li class="breadcrumb-item active"><?= $title; ?></li>
                    </ol>
                </div>
            </div>
        </div><!-- /.container-fluid -->
    </section>
    <div class="container-fluid mt-3">
        <div class="card">
            <div class="card-header text-center">
                <h2>Kelola Peminjaman Inventaris</h2>
            </div>
            <div class="card-body">
                <?php echo $this->session->flashdata('notif'); ?>
                <div class="table-responsive">
                    <table id="tabel" class="table table-bordered table-hover">
                        <thead>
                            <tr>
                                <th>No</th>
                                <th>Nama Peminjam </th>
                                <th>Nama Inventaris</th>
                                <th>Tanggal</th>
                                <th>Yang Melayani</th>
                                <th>Aksi</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $no = 1; ?>
                            <?php  foreach ($pinjam_inv as $p) : ?>
                                <tr>
                                    <td><?php echo $no++; ?></td>
                                    <td><?php echo $p->nama_lengkap; ?></td>
                                    <td><?php echo $p->nama_inv; ?></td>
                                    <td><?php $date = date_create($p->tgl_pinjam);
		                                echo date_format($date, 'd/m/Y'); ?></td>
                                    <td><?php echo $p->yg_melayani;?></td>
                                    <td>
                                    <a href="<?php echo base_url('inventaris/accinv/' . $p->id_pinjam) ?>" onclick="return confirm('Terima Peminjaman?')" class="badge badge-primary">Terima</a>
                                    <a href="<?php echo base_url('inventaris/disaccinv/' . $p->id_pinjam) ?>" onclick="return confirm('Terima Peminjaman?')" class="badge badge-danger">Tolak</a>
                                    <a href="<?php echo base_url('inventaris/termpengembalian/' . $p->id_pinjam) ?>" onclick="return confirm('Apakah Sudah Dikembalikan?')" class="badge badge-success">Terima Pengembalian</a>

                                    </td>
                                </tr>
                                <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>