<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <!-- general form elements -->
            <div class="card card-warning">
                <div class="card-header">
                    <h3 class="card-title"> <?php echo $halaman; ?></h3>
                </div>


                <div class="card-body">
                    <a class="btn btn-primary" href="<?php echo base_url() ?>petugas/petugas/add_view/">Tambah</a>
                    <div style="margin-bottom: 10px;"></div>
                    <div class="table-responsive">
                        <table id='table' class='table table-bordered table-striped'>
                            <thead>
                                <tr>
                                    <th>No.</th>
                                    <th>Aksi</th>
                                    <th>Kode</th>
                                    <th>Nama</th>
                                    <th>Email</th>
                                    <th>Status</th>
                                </tr>
                            </thead>

                            <tbody>

                                <?php
                                $no = 1;
                                foreach ($petugas->result_array() as $row) { ?>
                                    <tr>
                                        <td align="center"><?php echo $no++ ?></td>

                                        <td width="270px">
                                            <a id="btn" class="btn btn-warning" href="<?php echo base_url() ?>petugas/petugas/update_view/<?php echo $row['mst_petugas_id'] ?>">Update</a>

                                            <a id="btn2" class="btn btn-danger" href="<?php echo base_url() ?>petugas/petugas/hapus/<?php echo $row['mst_petugas_id'] ?>">Hapus</a>
                                        </td>

                                        <td>
                                            <?php echo $row['mst_petugas_kode'] ?>
                                        </td>

                                        <td>
                                            <?php echo $row['mst_petugas_nama_lengkap'] ?>
                                        </td>

                                        <td>
                                            <?php echo $row['mst_petugas_email'] ?>
                                        </td>

                                        <td>
                                            <?php
                                            if ($row['mst_petugas_status'] == "Aktif") { ?>
                                                <div class='btn btn-success'> <?php echo $row['mst_petugas_status'] ?></div>
                                            <?php } else { ?>
                                                <div class='btn btn-danger'> <?php echo $row['mst_petugas_status'] ?></div>
                                            <?php } ?>
                                        </td>
                                    </tr>
                                <?php } ?>

                            </tbody>
                        </table>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="<?php echo base_url(); ?>assets/plugins/jquery/jquery.min.js"></script>



<script>
    $(document).ready(function() {
        $("#btn").click(function() {

        });

        $("#btn2").click(function() {

        });
    });

    $(function() {
        $("#table").DataTable({
            "responsive": true,
            "lengthChange": false,
            "autoWidth": true,
            "ordering": true,
            "info": true,
            "paging": true,
            "buttons": ["copy", "print"]
        }).buttons().container().appendTo('#table_wrapper .col-md-6:eq(0)');


    });

    <?php
    $sukses = $this->session->flashdata('berhasil');
    if ($sukses) { ?>
        $(function() {
            var Toast = Swal.mixin({
                toast: true,
                position: 'top-end',
                showConfirmButton: false,
                timer: 3000
            });
            $('.toastrDefaultSuccess').ready(function() {
                toastr.success('<?php echo $sukses; ?>.')
            })
        });

    <?php }

    $gagal = $this->session->flashdata('gagal');
    if ($gagal) { ?>
        $(function() {
            var Toast = Swal.mixin({
                toast: true,
                position: 'top-end',
                showConfirmButton: false,
                timer: 3000
            });
            $('.toastrDefaultSuccess').ready(function() {
                toastr.success('<?php echo $gagal; ?>.')
            })
        });
    <?php } ?>
</script>