<div class="row">
    <div class="col-md-12">
        <div class="box box-primary box-solid">
            <div class="box-header with-border">
                <h3 class="box-title">Data Document</h3>

                <div class="box-tools pull-right">
                    <?php if (session()->level == 1) : ?>
                        <a href="<?= base_url('identitas/add') ?>" class="btn btn-primary btn-sm btn-flat">
                            <i class="fa fa-plus"></i> Add</a>
                    <?php endif; ?>
                    <?php if (session()->level == 2) : ?>
                        <a href="<?= base_url('identitas/add') ?>" class="btn btn-primary btn-sm btn-flat">
                            <i class="fa fa-plus"></i> Add</a>
                    <?php endif; ?>
                </div>
                <!-- /.box-tools -->
            </div>
            <!-- /.box-header -->
            <div class="box-body">

                <?php
                if (session()->getFlashdata('pesan')) {
                    echo '<div class="alert alert-success alert-dismissible">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                    <h4><i class="icon fa fa-check"></i> Success! - ';
                    echo session()->getFlashdata('pesan');
                    echo '</h4></div>';
                }
                ?>
                <table id="example1" class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>No</th>
                            <th>Nama </th>
                            <th>Kategori</th>
                            <th>Upload</th>
                            <th>Update</th>
                            <th>Admin</th>
                            <th>Departemen</th>
                            <th>File</th>
                            <?php if (session()->level == 1) : ?><th width="100px">Action</th><?php endif; ?>
                            <?php if (session()->level == 2) : ?><th width="100px">Action</th><?php endif; ?>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $no = 1;
                        foreach ($identitas as $key => $value) { ?>
                            <tr>
                                <td><?= $no++; ?></td>
                                <td><?= $value['nama_identitas']; ?></td>
                                <td><?= $value['nama_kategori_identitas']; ?></td>
                                <td><?= $value['tgl_upload']; ?></td>
                                <td><?= $value['tgl_update']; ?></td>
                                <td><?= $value['nama_user']; ?></td>
                                <td><?= $value['nama_dep']; ?></td>
                                <td class="text-center">
                                    <a href="<?= base_url('identitas/viewpdf/' . $value['id_identitas']) ?>">
                                        <i class="fa fa-file-pdf-o fa-2x label-danger"></i></a><br>
                                    <?= number_format($value['ukuran_file'], 0) ?> Byte
                                </td>
                                <td class="text-center">
                                    <?php if (session()->level == 1) : ?>
                                        <a href="<?= base_url('identitas/edit/' . $value['id_identitas']) ?>" class="btn btn-xs btn-warning">Edit</a>
                                        <button class="btn btn-xs btn-danger" data-toggle="modal" data-target="#delete<?= $value['id_identitas']; ?>">Delete</button>
                                    <?php endif; ?>
                                    <?php if (session()->level == 2) : ?>
                                        <a href="<?= base_url('identitas/edit/' . $value['id_identitas']) ?>" class="btn btn-xs btn-warning">Edit</a>
                                        <button class="btn btn-xs btn-danger" data-toggle="modal" data-target="#delete<?= $value['id_identitas']; ?>">Delete</button>
                                    <?php endif; ?>
                                </td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>

            </div>
            <!-- /.box-body -->
        </div>
        <!-- /.box -->
    </div>
</div>


<!-- /.modal delete kategori -->
<?php foreach ($identitas as $key => $value) { ?>
    <div class="modal fade" id="delete<?= $value['id_identitas']; ?>">
        <div class="modal-dialog modal-sm modal-danger">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">Hapus User</h4>
                </div>
                <div class="modal-body">

                    Apakah Anda Yakin Ingin Hapus <b><?= $value['nama_identitas']; ?></b>..?
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default pull-left" data-dismiss="modal">Tidak</button>
                    <a href="<?= base_url('identitas/delete/' . $value['id_identitas']) ?>" type="submit" class="btn btn-primary">Ya</a>
                </div>

            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
<?php } ?>
<!-- end modal delete kategori -->