<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
        <div class="container-fluid">
            <?= $this->session->flashdata('msg') ?>
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1 class="m-0">Bobot Preferensi</h1>
                </div><!-- /.col -->
                <div class="col-sm-6">
                    <ol class="breadcrumb float-sm-right">
                        <li class="breadcrumb-item"><a href="<?=base_url('dashboard')?>">Beranda</a></li>
                        <li class="breadcrumb-item active">Bobot Preferensi</li>
                    </ol>
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <div class="content">
        <div class="container-fluid">
            <div class="card">
                <!-- /.card-header -->
                <div class="card-body">
                    <a data-toggle="modal" data-target="#tambah" href=""><button
                            class="btn btn-sm bg-blue text-white">Tambah Data Bobot Preferensi</button></a>
                    <br><br>
                    <div class="table-responsive">
                        <table class="table table-flush" id="datatable-basic">
                            <thead>
                                <tr>
                                    <th>#No</th>
                                    <th>Keterangan</th>
                                    <th>Nilai</th>
                                    <th>Aksi</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $i = 1; foreach ($list_bobotpreferensi as $row): ?>
                                <tr>
                                    <td><?= $i++ ?> </td>
                                    <td><?= $row->keterangan ?></td>
                                    <td><?= $row->nilai ?></td>
                                    <td>
                                        <a data-toggle="modal" data-target="#edit-<?=$row->id_bobot?>" href=""><button
                                                class="btn btn-sm bg-warning text-white">Edit</button></a>
                                        <a data-toggle="modal" data-target="#delete-<?=$row->id_bobot?>" href=""><button
                                                class="btn btn-sm bg-red text-white">Hapus</button></a>
                                    </td>
                                </tr>
                                <?php endforeach; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <!-- /.container-fluid -->
        </div>
        <!-- /.content -->
    </div>
    <!-- /.content -->
</div>
<!-- /.content-wrapper -->

<!-- form untuk tambah data  -->
<div class="modal fade" id="tambah">
    <div class="modal-dialog tambah">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">Form Tambah Data Bobot Preferensi</h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form action="<?= base_url('bobotpreferensi/prosesbobotpreferensi')?>" method="POST">
                    <table class="table table-bordered table-striped table-hover" style="max-height: 300px">
                        <tbody>
                            <tr>
                                <th style="width: 30%">
                                    Keterangan
                                </th>
                                <td>
                                    <input type="text" class="form-control" placeholder="Masukkan Keterangan"
                                        name="keterangan" required autofocus>
                                </td>
                            </tr>
                            <tr>
                                <th style="width: 30%">
                                    Nilai
                                </th>
                                <td>
                                    <input type="text" class="form-control" placeholder="Masukkan Nilai" name="nilai"
                                        required autofocus>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <input type="submit" class="btn bg-blue text-white btn-block" name="tambah" value="Simpan">
                </form>
            </div>
            <div class="modal-footer justify-content-between">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>

<!-- form untuk edit data  -->
<?php foreach ($list_bobotpreferensi as $row): ?>
<div class="modal fade" id="edit-<?=$row->id_bobot?>">
    <div class="modal-dialog edit-<?=$row->id_bobot?>">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">Form Edit Data Bobot Preferensi</h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <form action="<?= base_url('bobotpreferensi/prosesbobotpreferensi')?>" method="post">
                    <input type="hidden" name="id_bobot" value="<?=$row->id_bobot?>">
                    <table class="table table-bordered table-striped table-hover" style="max-height: 300px">
                        <tbody>
                            <tr>
                                <th style="width: 30%">
                                    Keterangan
                                </th>
                                <td>
                                    <input type="text" class="form-control" name="keterangan"
                                        placeholder="Masukkan Keterangan" required autofocus
                                        value="<?=$row->keterangan?>">
                                </td>
                            </tr>
                            <tr>
                                <th style="width: 30%">
                                    Nilai
                                </th>
                                <td>
                                    <input type="text" class="form-control" name="nilai" placeholder="Masukkan Nilai"
                                        required autofocus value="<?=$row->nilai?>">
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <input type="submit" class="btn bg-blue btn-block text-white" name="edit" value="Simpan"> <br><br>
                </form>
            </div>
            <div class="modal-footer justify-content-between">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<?php endforeach; ?>


<!-- form untuk hapus data  -->
<?php $i = 1; foreach ($list_bobotpreferensi as $row): ?>
<div class="modal fade" id="delete-<?=$row->id_bobot?>">
    <div class="modal-dialog delete-<?=$row->id_bobot?>">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">Hapus Bobot Preferensi : <?=$row->keterangan?></h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">

                        <form action="<?= base_url('bobotpreferensi/prosesbobotpreferensi')?>" method="Post">
                            <input type="hidden" value="<?=$row->id_bobot?>" name="id_bobot">
                            <input type="submit" class="btn bg-green btn-block " name="hapus" value="Ya">

                    </div>
                    <div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
                        <button type="button" class="btn bg-red btn-block text-white"
                            data-dismiss="modal">Tidak</button>
                    </div>
                    <?php echo form_close() ?>
                </div>
            </div>

        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<?php endforeach; ?>