<?= $this->extend('layout/template') ?>


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


<div class="card">


<div class="card-header">

<h3 class="card-title">

Edit Peminjaman Buku

</h3>

</div>




<div class="card-body">


<form action="<?= base_url('peminjaman/update/'.$pinjam['id']) ?>"
      method="post">


<?= csrf_field(); ?>



<div class="row">


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


<div class="form-group">


<label>
Nama Anggota
</label>


<select name="anggota_id"
        class="form-control"
        required>



<?php foreach($anggota as $a): ?>


<option value="<?= $a['id'] ?>"
    
<?php if($a['id']==$pinjam['anggota_id']) echo 'selected'; ?>>


<?= $a['nama'] ?>


</option>



<?php endforeach; ?>



</select>



</div>


</div>






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


<div class="form-group">


<label>
Buku
</label>



<select name="buku_id"
        class="form-control"
        required>




<?php foreach($buku as $b): ?>


<option value="<?= $b['id'] ?>"


<?php if($b['id']==$pinjam['buku_id']) echo 'selected'; ?>


>


<?= $b['judul'] ?>


(Stok <?= $b['stok'] ?>)


</option>



<?php endforeach; ?>



</select>


</div>


</div>


</div>







<div class="row">


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


<div class="form-group">


<label>
Tanggal Pinjam
</label>



<input type="date"
       name="tanggal_pinjam"
       class="form-control"
       value="<?= $pinjam['tanggal_pinjam'] ?>"
       required>


</div>


</div>





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


<div class="form-group">


<label>
Tanggal Kembali
</label>



<input type="date"
       name="tanggal_kembali"
       class="form-control"
       value="<?= $pinjam['tanggal_kembali'] ?>"
       required>


</div>


</div>


</div>







<div class="form-group">


<label>
Status
</label>



<select name="status"
        class="form-control">



<option value="Dipinjam"

<?= ($pinjam['status']=="Dipinjam")?'selected':'' ?>>

Dipinjam

</option>



<option value="Dikembalikan"

<?= ($pinjam['status']=="Dikembalikan")?'selected':'' ?>>

Dikembalikan

</option>



</select>


</div>





<button type="submit"
        class="btn btn-primary">


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

Update


</button>




<a href="<?= base_url('peminjaman') ?>"
   class="btn btn-secondary">


Kembali


</a>



</form>


</div>


</div>



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