

<?php $__env->startSection('content'); ?>
<div class="container-fluid">
    <div class="row mb-3">
        <div class="col-md-6">
            <h4><i class="bi bi-megaphone-fill me-2"></i>Manajemen Informasi Terkini</h4>
        </div>
        <div class="col-md-6 text-end">
            <a href="<?php echo e(route('admin-dinas.announcements.create')); ?>" class="btn btn-primary">
                <i class="bi bi-plus-circle me-1"></i> Tambah Pengumuman
            </a>
        </div>
    </div>

    <?php if(session('success')): ?>
        <div class="alert alert-success alert-dismissible fade show" role="alert">
            <i class="bi bi-check-circle me-2"></i><?php echo e(session('success')); ?>

            <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        </div>
    <?php endif; ?>

    <div class="card border-0 shadow-sm">
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead class="bg-light">
                        <tr>
                            <th width="5%">#</th>
                            <th width="25%">Judul</th>
                            <th width="30%">Konten</th>
                            <th width="10%">Tipe</th>
                            <th width="10%">Popup</th>
                            <th width="10%">Status</th>
                            <th width="5%">Urutan</th>
                            <th width="5%">Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $announcements; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $announcement): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td><?php echo e($loop->iteration + ($announcements->currentPage() - 1) * $announcements->perPage()); ?></td>
                                <td><strong><?php echo e($announcement->title); ?></strong></td>
                                <td><?php echo e(Str::limit($announcement->content, 100)); ?></td>
                                <td>
                                    <span class="badge bg-<?php echo e($announcement->type == 'info' ? 'info' : ($announcement->type == 'warning' ? 'warning' : ($announcement->type == 'success' ? 'success' : 'danger'))); ?>">
                                        <?php echo e(ucfirst($announcement->type)); ?>

                                    </span>
                                </td>
                                <td>
                                    <?php if($announcement->is_popup): ?>
                                        <span class="badge bg-success"><i class="bi bi-check-circle"></i> Ya</span>
                                    <?php else: ?>
                                        <span class="badge bg-secondary"><i class="bi bi-x-circle"></i> Tidak</span>
                                    <?php endif; ?>
                                </td>
                                <td>
                                    <div class="form-check form-switch">
                                        <input class="form-check-input toggle-status" type="checkbox" 
                                               data-id="<?php echo e($announcement->id); ?>" 
                                               <?php echo e($announcement->is_active ? 'checked' : ''); ?>>
                                    </div>
                                </td>
                                <td><?php echo e($announcement->order); ?></td>
                                <td>
                                    <div class="btn-group btn-group-sm" role="group">
                                        <a href="<?php echo e(route('admin-dinas.announcements.edit', $announcement)); ?>" 
                                           class="btn btn-outline-primary" title="Edit">
                                            <i class="bi bi-pencil"></i>
                                        </a>
                                        <form action="<?php echo e(route('admin-dinas.announcements.destroy', $announcement)); ?>" 
                                              method="POST" class="d-inline"
                                              onsubmit="return confirm('Yakin ingin menghapus pengumuman ini?')">
                                            <?php echo csrf_field(); ?>
                                            <?php echo method_field('DELETE'); ?>
                                            <button type="submit" class="btn btn-outline-danger" title="Hapus">
                                                <i class="bi bi-trash"></i>
                                            </button>
                                        </form>
                                    </div>
                                </td>
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td colspan="8" class="text-center py-4">
                                    <i class="bi bi-inbox fs-1 text-muted"></i>
                                    <p class="text-muted mt-2">Belum ada pengumuman</p>
                                </td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table>
            </div>

            <?php if($announcements->hasPages()): ?>
                <div class="mt-3">
                    <?php echo e($announcements->links()); ?>

                </div>
            <?php endif; ?>
        </div>
    </div>
</div>

<?php $__env->startPush('scripts'); ?>
<script>
$(document).ready(function() {
    $('.toggle-status').on('change', function() {
        const announcementId = $(this).data('id');
        const isChecked = $(this).is(':checked');
        
        $.ajax({
            url: `/admin-dinas/announcements/${announcementId}/toggle-status`,
            type: 'POST',
            data: {
                _token: '<?php echo e(csrf_token()); ?>'
            },
            success: function(response) {
                if (response.success) {
                    toastr.success(response.message);
                }
            },
            error: function() {
                toastr.error('Gagal mengubah status pengumuman');
            }
        });
    });
});
</script>
<?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\xampp\htdocs\appsuper\resources\views/admin-dinas/announcements/index.blade.php ENDPATH**/ ?>