

<?php $__env->startSection('title', 'Jenis Sekolah'); ?>

<?php $__env->startSection('content_header'); ?>
    <h1><i class="fas fa-school mr-2"></i>Jenis Sekolah</h1>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <?php if(session('success')): ?>
        <div class="alert alert-success alert-dismissible">
            <button type="button" class="close" data-dismiss="alert">&times;</button>
            <?php echo e(session('success')); ?>

        </div>
    <?php endif; ?>

    <div class="row">
        <!-- Form Tambah -->
        <div class="col-md-4">
            <div class="card card-outline card-primary">
                <div class="card-header">
                    <h3 class="card-title"><i class="fas fa-plus-circle mr-1"></i> Tambah Jenis Sekolah</h3>
                </div>
                <div class="card-body">
                    <?php if($errors->any()): ?>
                        <div class="alert alert-danger alert-dismissible">
                            <button type="button" class="close" data-dismiss="alert">&times;</button>
                            <ul class="mb-0">
                                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <li><?php echo e($error); ?></li>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </ul>
                        </div>
                    <?php endif; ?>

                    <form action="<?php echo e(route('admin.jenis-sekolah.store')); ?>" method="POST">
                        <?php echo csrf_field(); ?>
                        <div class="form-group">
                            <label>Kod Jenis <span class="text-danger">*</span></label>
                            <input type="text" name="kod_jenis"
                                class="form-control <?php $__errorArgs = ['kod_jenis'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>" value="<?php echo e(old('kod_jenis')); ?>"
                                placeholder="Contoh: SK, SMK, SJK" style="text-transform: uppercase">
                            <?php $__errorArgs = ['kod_jenis'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback"><?php echo e($message); ?></div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <div class="form-group">
                            <label>Nama Jenis Sekolah <span class="text-danger">*</span></label>
                            <input type="text" name="nama_jenis"
                                class="form-control <?php $__errorArgs = ['nama_jenis'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                value="<?php echo e(old('nama_jenis')); ?>" placeholder="Contoh: Sekolah Kebangsaan">
                            <?php $__errorArgs = ['nama_jenis'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback"><?php echo e($message); ?></div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <div class="form-group">
                            <label>Penerangan</label>
                            <textarea name="penerangan" rows="3" class="form-control <?php $__errorArgs = ['penerangan'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                                placeholder="Masukkan penerangan (jika ada)"><?php echo e(old('penerangan')); ?></textarea>
                            <?php $__errorArgs = ['penerangan'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                <div class="invalid-feedback"><?php echo e($message); ?></div>
                            <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                        </div>

                        <button type="submit" class="btn btn-primary btn-block">
                            <i class="fas fa-save mr-1"></i> Simpan
                        </button>
                    </form>
                </div>
            </div>
        </div>

        <!-- Senarai -->
        <div class="col-md-8">
            <div class="card card-outline card-primary">
                <div class="card-header">
                    <h3 class="card-title"><i class="fas fa-list mr-1"></i> Senarai Jenis Sekolah</h3>
                </div>
                <div class="card-body table-responsive p-0">
                    <table class="table table-hover table-striped">
                        <thead class="thead-dark">
                            <tr>
                                <th width="50">#</th>
                                <th width="100">Kod</th>
                                <th>Nama Jenis Sekolah</th>
                                <th>Penerangan</th>
                                <th width="110">Tindakan</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $senarai; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td><?php echo e($index + 1); ?></td>
                                    <td><span class="badge badge-primary"><?php echo e($item->kod_jenis); ?></span></td>
                                    <td><?php echo e($item->nama_jenis); ?></td>
                                    <td><?php echo e($item->penerangan ?? '-'); ?></td>
                                    <td>
                                        <div class="d-flex gap-1">
                                            <!-- Butang Edit -->
                                            <button type="button" class="btn btn-warning btn-sm mr-1" data-toggle="modal"
                                                data-target="#modalEdit" data-id="<?php echo e($item->id); ?>"
                                                data-kod="<?php echo e($item->kod_jenis); ?>" data-nama="<?php echo e($item->nama_jenis); ?>"
                                                data-penerangan="<?php echo e($item->penerangan); ?>">
                                                <i class="fas fa-edit"></i>
                                            </button>
                                            <!-- Butang Padam -->
                                            <form action="<?php echo e(route('admin.jenis-sekolah.destroy', $item->id)); ?>"
                                                method="POST" onsubmit="return confirm('Padam jenis sekolah ini?')">
                                                <?php echo csrf_field(); ?>
                                                <?php echo method_field('DELETE'); ?>
                                                <button type="submit" class="btn btn-danger btn-sm">
                                                    <i class="fas fa-trash"></i>
                                                </button>
                                            </form>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="5" class="text-center text-muted">Tiada data jenis sekolah.</td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>

    <!-- Modal Edit -->
    <div class="modal fade" id="modalEdit" tabindex="-1" role="dialog">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header bg-warning">
                    <h5 class="modal-title"><i class="fas fa-edit mr-1"></i> Kemaskini Jenis Sekolah</h5>
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>
                <form id="formEdit" method="POST">
                    <?php echo csrf_field(); ?>
                    <?php echo method_field('PUT'); ?>
                    <div class="modal-body">
                        <div class="form-group">
                            <label>Kod Jenis <span class="text-danger">*</span></label>
                            <input type="text" name="kod_jenis" id="edit_kod_jenis" class="form-control"
                                style="text-transform: uppercase" required>
                        </div>
                        <div class="form-group">
                            <label>Nama Jenis Sekolah <span class="text-danger">*</span></label>
                            <input type="text" name="nama_jenis" id="edit_nama_jenis" class="form-control" required>
                        </div>
                        <div class="form-group">
                            <label>Penerangan</label>
                            <textarea name="penerangan" id="edit_penerangan" rows="3" class="form-control"></textarea>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">
                            <i class="fas fa-times mr-1"></i> Batal
                        </button>
                        <button type="submit" class="btn btn-warning">
                            <i class="fas fa-save mr-1"></i> Kemaskini
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('js'); ?>
    <script>
        $('#modalEdit').on('show.bs.modal', function(e) {
            var btn = $(e.relatedTarget);
            var id = btn.data('id');
            var kod = btn.data('kod');
            var nama = btn.data('nama');
            var penerangan = btn.data('penerangan');

            $('#edit_kod_jenis').val(kod);
            $('#edit_nama_jenis').val(nama);
            $('#edit_penerangan').val(penerangan);

            var url = '<?php echo e(url('admin/jenis-sekolah')); ?>/' + id;
            $('#formEdit').attr('action', url);
        });
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('adminlte::page', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\myspbt\resources\views/admin/jenis_sekolah/index.blade.php ENDPATH**/ ?>