<?php
$page_title = 'Daftar Departemen';
require_once('includes/load.php');
page_require_level(4);

$departments = find_all('departments');
?>

<?php include_once('layouts/header.php'); ?>
<div class="row">
    <div class="col-md-12">
        <?php echo display_msg($msg); ?>
    </div>
    <div class="col-md-8">
        <div class="panel panel-default">
            <div class="panel-heading clearfix">
                <strong>
                    <span class="glyphicon glyphicon-th"></span>
                    <span>Daftar Departemen</span>
                </strong>
                <a href="add_department.php" class="btn btn-info pull-right">Tambah Departemen</a>
            </div>
            <div class="panel-body">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th class="text-center" style="width: 50px;">#</th>
                            <th>Nama Departemen</th>
                            <th class="text-center" style="width: 100px;">Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($departments as $dept): ?>
                        <tr>
                            <td class="text-center"><?php echo (int)$dept['id']; ?></td>
                            <td><?php echo remove_junk($dept['name']); ?></td>
                            <td class="text-center">
                                <div class="btn-group">
                                    <a href="edit_department.php?id=<?php echo (int)$dept['id'];?>" class="btn btn-xs btn-warning" data-toggle="tooltip" title="Edit">
                                        <span class="glyphicon glyphicon-pencil"></span>
                                    </a>
                                    <a href="delete_department.php?id=<?php echo (int)$dept['id'];?>" class="btn btn-xs btn-danger" data-toggle="tooltip" title="Hapus" onclick="return confirm('Apakah Anda yakin ingin menghapus departemen ini?');">
                                        <span class="glyphicon glyphicon-remove"></span>
                                    </a>
                                </div>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<?php include_once('layouts/footer.php'); ?>