

<?php $__env->startSection('title', 'الوحدات التنظيمية'); ?>

<?php $__env->startSection('content'); ?>
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-header">
                        <?php echo e(__('الوحدات التنظيمية')); ?>

                        <a href="<?php echo e(route('organizational-units.create')); ?>" class="btn btn-primary btn-sm float-end"><?php echo e(__('إضافة وحدة تنظيمية')); ?></a>
                    </div>

                    <div class="card-body">
                        <?php if(session('status')): ?>
                            <div class="alert alert-success" role="alert">
                                <?php echo e(session('status')); ?>

                            </div>
                        <?php endif; ?>

                        <table class="table table-striped table-bordered">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>الاسم</th>
                                    <th>نوع الوحدة</th>
                                    <th>الوحدة الأب</th>
                                    <th>عدد الوحدات الفرعية</th>
                                    <th>الأسئلة المجابة</th>
                                    <th>تاريخ الإنشاء</th>
                                    <th>الإجراءات</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $organizationalUnits; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $unit): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td><?php echo e($unit->id); ?></td>
                                        <td><?php echo e($unit->name); ?></td>
                                        <td><?php echo e($unit->unitType->type_name ?? 'N/A'); ?></td>
                                        <td><?php echo e($unit->parent->name ?? 'لا يوجد'); ?></td>
                                        <td><?php echo e($unit->children->count()); ?></td>
                                        <td><span class="badge bg-primary"><?php echo e($unit->office_answers_count); ?></span></td>
                                        <td><?php echo e($unit->created_at->format('Y-m-d')); ?></td>
                                        <td>
                                            <a href="<?php echo e(route('organizational-units.show', $unit->id)); ?>" class="btn btn-sm btn-info text-white">عرض</a>
                                            <a href="<?php echo e(route('organizational-units.edit', $unit->id)); ?>" class="btn btn-sm btn-warning">تعديل</a>
                                            <form action="<?php echo e(route('organizational-units.destroy', $unit->id)); ?>" method="POST" style="display:inline;">
                                                <?php echo csrf_field(); ?>
                                                <?php echo method_field('DELETE'); ?>
                                                <button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('هل أنت متأكد من الحذف؟')">حذف</button>
                                            </form>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="8" class="text-center">لا توجد وحدات تنظيمية</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp82\htdocs\GeneralProject-form\resources\views/organizational-units/index.blade.php ENDPATH**/ ?>