
<?php $__env->startSection('title'); ?>اطلاعیه‌ها<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
<div class="container-xxl flex-grow-1 container-p-y">

    <div class="d-flex align-items-center justify-content-between mb-4">
        <div>
            <h4 class="mb-1">اطلاعیه‌ها</h4>
            <p class="text-muted mb-0">اطلاعیه‌هایی که به کاربران در پنل نمایش داده می‌شوند</p>
        </div>
        <a href="<?php echo e(route('admin.announcements.create')); ?>" class="btn btn-primary">
            <i class="ti ti-plus me-1"></i> اطلاعیه جدید
        </a>
    </div>

    <?php if(session('success')): ?>
        <div class="alert alert-success alert-dismissible mb-4">
            <?php echo e(session('success')); ?><button type="button" class="btn-close" data-bs-dismiss="alert"></button>
        </div>
    <?php endif; ?>

    <div class="card">
        <div class="table-responsive">
            <table class="table border-top align-middle mb-0">
                <thead class="table-light">
                    <tr>
                        <th>#</th>
                        <th>عنوان اطلاعیه</th>
                        <th>نویسنده</th>
                        <th>تاریخ</th>
                        <th style="width:130px">عملیات</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><span class="text-muted small"><?php echo e($loop->iteration); ?></span></td>
                            <td>
                                <span class="fw-medium d-block"><?php echo e($announcement->title); ?></span>
                                <small class="text-muted" dir="ltr"><?php echo e($announcement->slug); ?></small>
                            </td>
                            <td><?php echo e($announcement->author?->first_name); ?> <?php echo e($announcement->author?->last_name); ?></td>
                            <td><span class="text-muted small"><?php echo e($announcement->shamsiDate()); ?></span></td>
                            <td>
                                <div class="d-flex gap-1">
                                    <a href="<?php echo e(route('panel.announcements.show', $announcement->slug)); ?>" target="_blank"
                                       class="btn btn-sm btn-outline-secondary">
                                        <i class="ti ti-eye ti-xs"></i>
                                    </a>
                                    <a href="<?php echo e(route('admin.announcements.edit', $announcement->slug)); ?>"
                                       class="btn btn-sm btn-outline-primary">
                                        <i class="ti ti-edit ti-xs"></i>
                                    </a>
                                    <form method="POST" action="<?php echo e(route('admin.announcements.destroy', $announcement->slug)); ?>"
                                          class="delete-form">
                                        <?php echo csrf_field(); ?> <?php echo method_field('DELETE'); ?>
                                        <button type="button" class="btn btn-sm btn-outline-danger btn-delete"
                                                data-name="<?php echo e($announcement->title); ?>">
                                            <i class="ti ti-trash ti-xs"></i>
                                        </button>
                                    </form>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="5" class="text-center py-5 text-muted">
                                <i class="ti ti-bell-off fs-3 d-block mb-2"></i>
                                هیچ اطلاعیه‌ای ثبت نشده است.
                            </td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
        <?php if($announcements->isNotEmpty()): ?>
            <div class="card-footer text-muted small d-flex align-items-center justify-content-between">
                <span><?php echo e($announcements->total()); ?> اطلاعیه</span>
                <?php echo e($announcements->links()); ?>

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

</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('customjs'); ?>
<script>
document.querySelectorAll('.btn-delete').forEach(function (btn) {
    btn.addEventListener('click', function () {
        var name = this.dataset.name;
        var form = this.closest('.delete-form');
        Swal.fire({
            title: 'حذف اطلاعیه',
            html: 'حذف <strong>' + name + '</strong> قابل بازگشت نیست. ادامه؟',
            icon: 'warning', showCancelButton: true,
            confirmButtonText: 'بله، حذف شود', cancelButtonText: 'انصراف',
            confirmButtonColor: '#d33', reverseButtons: true,
        }).then(function (r) { if (r.isConfirmed) form.submit(); });
    });
});
</script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('admin.layouts.layout', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/louishop/public_html/engine/resources/views/admin/announcements/index.blade.php ENDPATH**/ ?>