

<?php $__env->startSection('title', 'إدارة مكاتب الغاز'); ?>
<?php $__env->startSection('page-title', 'إدارة مكاتب الغاز'); ?>
<?php $__env->startSection('page-icon', 'fas fa-building'); ?>

<?php $__env->startSection('content'); ?>
<div class="row g-3">
    <div class="col-12">
        <div class="card">
            <div class="card-header d-flex justify-content-between align-items-center">
                <div><i class="fas fa-building"></i> إدارة مكاتب الغاز</div>
                <div class="d-flex gap-2">
                    <a href="<?php echo e(route('admin.gas-offices.create')); ?>" class="btn btn-primary btn-sm">
                        <i class="fas fa-plus"></i> إضافة مكتب
                    </a>
                    <a href="<?php echo e(route('admin.gas-offices.stats')); ?>" class="btn btn-info btn-sm">
                        <i class="fas fa-chart-bar"></i> الإحصائيات
                    </a>
                </div>
            </div>
                <div class="card-body">
                    <!-- فلترة -->
                    <div class="row mb-3">
                        <div class="col-md-12">
                            <form method="GET" action="<?php echo e(route('admin.gas-offices.index')); ?>" class="form-inline">
                                <div class="form-group mr-3">
                                    <label for="search" class="mr-2">البحث:</label>
                                    <input type="text" name="search" id="search" class="form-control" 
                                           value="<?php echo e(request('search')); ?>" placeholder="اسم المكتب">
                                </div>
                                <div class="form-group mr-3">
                                    <label for="status" class="mr-2">الحالة:</label>
                                    <select name="status" id="status" class="form-control">
                                        <option value="">جميع الحالات</option>
                                        <option value="active" <?php echo e(request('status') == 'active' ? 'selected' : ''); ?>>نشط</option>
                                        <option value="inactive" <?php echo e(request('status') == 'inactive' ? 'selected' : ''); ?>>غير نشط</option>
                                    </select>
                                </div>
                                <div class="form-group mr-3">
                                    <label for="governorate" class="mr-2">المحافظة:</label>
                                    <input type="text" name="governorate" id="governorate" class="form-control" 
                                           value="<?php echo e(request('governorate')); ?>" placeholder="المحافظة">
                                </div>
                                <button type="submit" class="btn btn-primary">
                                    <i class="fas fa-search"></i> بحث
                                </button>
                                <a href="<?php echo e(route('admin.gas-offices.index')); ?>" class="btn btn-secondary">
                                    <i class="fas fa-times"></i> مسح
                                </a>
                            </form>
                        </div>
                    </div>

                    <div class="table-responsive">
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>اسم المكتب</th>
                                    <th>المالك</th>
                                    <th>الهاتف</th>
                                    <th>العنوان</th>
                                    <th>المناطق</th>
                                    <th>التقييم</th>
                                    <th>الحالة</th>
                                    <th>مفتوح</th>
                                    <th>الإجراءات</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $gasOffices; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $office): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td><?php echo e($office->id); ?></td>
                                    <td>
                                        <div class="d-flex align-items-center">
                                            <?php if($office->logo): ?>
                                                <img src="<?php echo e(asset('storage/' . $office->logo)); ?>" 
                                                     alt="Logo" class="img-circle mr-2" style="width: 40px; height: 40px; object-fit: cover;">
                                            <?php endif; ?>
                                            <strong><?php echo e($office->name); ?></strong>
                                        </div>
                                    </td>
                                    <td><?php echo e($office->owner->name ?? 'غير محدد'); ?></td>
                                    <td><?php echo e($office->phone); ?></td>
                                    <td><?php echo e(Str::limit($office->address, 30)); ?></td>
                                    <td>
                                        <?php if($office->service_areas): ?>
                                            <?php $__currentLoopData = array_slice($office->service_areas, 0, 2); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $area): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <span class="badge badge-info"><?php echo e($area); ?></span>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            <?php if(count($office->service_areas) > 2): ?>
                                                <span class="badge badge-secondary">+<?php echo e(count($office->service_areas) - 2); ?></span>
                                            <?php endif; ?>
                                        <?php endif; ?>
                                    </td>
                                    <td>
                                        <div class="d-flex align-items-center">
                                            <span class="text-warning">
                                                <?php for($i = 1; $i <= 5; $i++): ?>
                                                    <?php if($i <= floor($office->rating)): ?>
                                                        <i class="fas fa-star"></i>
                                                    <?php elseif($i - $office->rating < 1): ?>
                                                        <i class="fas fa-star-half-alt"></i>
                                                    <?php else: ?>
                                                        <i class="far fa-star"></i>
                                                    <?php endif; ?>
                                                <?php endfor; ?>
                                            </span>
                                            <span class="ml-1">(<?php echo e($office->rating_count); ?>)</span>
                                        </div>
                                    </td>
                                    <td>
                                        <span class="badge badge-<?php echo e($office->is_active ? 'success' : 'danger'); ?>">
                                            <?php echo e($office->is_active ? 'نشط' : 'غير نشط'); ?>

                                        </span>
                                    </td>
                                    <td>
                                        <span class="badge badge-<?php echo e($office->is_open ? 'success' : 'warning'); ?>">
                                            <?php echo e($office->is_open ? 'مفتوح' : 'مغلق'); ?>

                                        </span>
                                    </td>
                                    <td>
                                        <div class="btn-group" role="group">
                                            <a href="<?php echo e(route('admin.gas-offices.show', $office)); ?>" 
                                               class="btn btn-info btn-sm" title="عرض">
                                                <i class="fas fa-eye"></i>
                                            </a>
                                            <a href="<?php echo e(route('admin.gas-offices.edit', $office)); ?>" 
                                               class="btn btn-warning btn-sm" title="تعديل">
                                                <i class="fas fa-edit"></i>
                                            </a>
                                            <form method="POST" action="<?php echo e(route('admin.gas-offices.toggle-status', $office)); ?>" 
                                                  class="d-inline">
                                                <?php echo csrf_field(); ?>
                                                <?php echo method_field('PATCH'); ?>
                                                <button type="submit" class="btn btn-<?php echo e($office->is_active ? 'secondary' : 'success'); ?> btn-sm" 
                                                        title="<?php echo e($office->is_active ? 'إلغاء تفعيل' : 'تفعيل'); ?>">
                                                    <i class="fas fa-<?php echo e($office->is_active ? 'ban' : 'check'); ?>"></i>
                                                </button>
                                            </form>
                                            <form method="POST" action="<?php echo e(route('admin.gas-offices.toggle-open', $office)); ?>" 
                                                  class="d-inline">
                                                <?php echo csrf_field(); ?>
                                                <?php echo method_field('PATCH'); ?>
                                                <button type="submit" class="btn btn-<?php echo e($office->is_open ? 'warning' : 'success'); ?> btn-sm" 
                                                        title="<?php echo e($office->is_open ? 'إغلاق' : 'فتح'); ?>">
                                                    <i class="fas fa-<?php echo e($office->is_open ? 'lock' : 'unlock'); ?>"></i>
                                                </button>
                                            </form>
                                            <form method="POST" action="<?php echo e(route('admin.gas-offices.destroy', $office)); ?>" 
                                                  class="d-inline" onsubmit="return confirm('هل أنت متأكد من حذف هذا المكتب؟')">
                                                <?php echo csrf_field(); ?>
                                                <?php echo method_field('DELETE'); ?>
                                                <button type="submit" class="btn btn-danger btn-sm" title="حذف">
                                                    <i class="fas fa-trash"></i>
                                                </button>
                                            </form>
                                        </div>
                                    </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="10" class="text-center">لا توجد مكاتب غاز</td>
                                </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>

                    <!-- Pagination -->
                    <div class="d-flex justify-content-center">
                        <?php echo e($gasOffices->appends(request()->query())->links('pagination::bootstrap-4')); ?>

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

<?php echo $__env->make('admin.layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\wamp64\www\taxi_app\resources\views/admin/gas-offices/index.blade.php ENDPATH**/ ?>