
<?php
    use Illuminate\Support\Facades\Storage;
?>

<?php $__env->startSection('title', 'إدارة العروض'); ?>

<?php $__env->startSection('content'); ?>
<div class="container-fluid px-0">
    <!-- Header -->
    <div class="row mb-4">
        <div class="col-12">
            <div class="d-flex justify-content-between align-items-center">
                <h1 class="h3 mb-0" style="color: var(--text-light);">
                    <i class="fas fa-tags" style="color: var(--primary-yellow);"></i>
                    إدارة العروض
                </h1>
                <div class="btn-group">
                    <a href="<?php echo e(route('admin.offers-ads.offers.create')); ?>" class="btn btn-primary">
                        <i class="fas fa-plus"></i> إضافة عرض جديد
                    </a>
                    <a href="<?php echo e(route('admin.offers-ads.index', ['type' => 'ads'])); ?>" class="btn btn-outline-primary">
                        <i class="fas fa-bullhorn"></i> الإعلانات
                    </a>
                    <a href="<?php echo e(route('admin.dashboard')); ?>" class="btn btn-outline-primary">
                        <i class="fas fa-arrow-right"></i> العودة
                    </a>
                </div>
            </div>
        </div>
    </div>

    <!-- علامات التبويب -->
    <div class="row mb-4">
        <div class="col-12">
            <ul class="nav nav-tabs">
                <li class="nav-item">
                    <a class="nav-link active" href="<?php echo e(route('admin.offers-ads.index', ['type' => 'offers'])); ?>">
                        <i class="fas fa-tags"></i> العروض
                    </a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="<?php echo e(route('admin.offers-ads.index', ['type' => 'ads'])); ?>">
                        <i class="fas fa-bullhorn"></i> الإعلانات
                    </a>
                </li>
            </ul>
        </div>
    </div>

    <!-- قائمة العروض -->
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-body">
                    <?php if($offers->count() > 0): ?>
                        <div class="table-responsive">
                            <table class="table table-hover" style="background: var(--card-bg) !important; color: var(--text-light) !important;">
                                <thead>
                                    <tr style="background: transparent !important;">
                                        <th style="color: var(--primary-yellow) !important; font-weight: 600; background: transparent !important;">#</th>
                                        <th style="color: var(--primary-yellow) !important; font-weight: 600; background: transparent !important;">الصورة</th>
                                        <th style="color: var(--primary-yellow) !important; font-weight: 600; background: transparent !important;">العنوان</th>
                                        <th style="color: var(--primary-yellow) !important; font-weight: 600; background: transparent !important;">نوع العرض</th>
                                        <th style="color: var(--primary-yellow) !important; font-weight: 600; background: transparent !important;">الخصم</th>
                                        <th style="color: var(--primary-yellow) !important; font-weight: 600; background: transparent !important;">تاريخ البداية</th>
                                        <th style="color: var(--primary-yellow) !important; font-weight: 600; background: transparent !important;">تاريخ النهاية</th>
                                        <th style="color: var(--primary-yellow) !important; font-weight: 600; background: transparent !important;">الحالة</th>
                                        <th style="color: var(--primary-yellow) !important; font-weight: 600; background: transparent !important;">الإجراءات</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $__currentLoopData = $offers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $offer): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <tr style="background: var(--card-bg) !important;">
                                            <td style="color: var(--text-light) !important; background: var(--card-bg) !important;"><?php echo e($offer->id); ?></td>
                                            <td style="background: var(--card-bg) !important;">
                                                <?php if($offer->image): ?>
                                                    <img src="<?php echo e(Storage::url($offer->image)); ?>" alt="<?php echo e($offer->title); ?>" style="width: 60px; height: 60px; object-fit: cover; border-radius: 8px;" onerror="this.onerror=null; this.parentElement.innerHTML='<div style=\'width: 60px; height: 60px; background: var(--primary-yellow); border-radius: 8px; display: flex; align-items: center; justify-content: center;\'><i class=\'fas fa-tag\' style=\'color: var(--dark-bg);\'></i></div>';">
                                                <?php else: ?>
                                                    <div style="width: 60px; height: 60px; background: var(--primary-yellow); border-radius: 8px; display: flex; align-items: center; justify-content: center;">
                                                        <i class="fas fa-tag" style="color: var(--dark-bg);"></i>
                                                    </div>
                                                <?php endif; ?>
                                            </td>
                                            <td style="color: var(--text-light) !important; background: var(--card-bg) !important;">
                                                <strong><?php echo e($offer->title_ar ?? $offer->title); ?></strong>
                                            </td>
                                            <td style="color: var(--text-light) !important; background: var(--card-bg) !important;">
                                                <?php if($offer->offer_type == 'food'): ?>
                                                    <span class="badge badge-info" style="background-color: var(--primary-yellow); color: var(--dark-bg);">طعام</span>
                                                <?php elseif($offer->offer_type == 'gas'): ?>
                                                    <span class="badge badge-info" style="background-color: var(--primary-yellow); color: var(--dark-bg);">غاز</span>
                                                <?php elseif($offer->offer_type == 'taxi'): ?>
                                                    <span class="badge badge-info" style="background-color: var(--primary-yellow); color: var(--dark-bg);">تاكسي</span>
                                                <?php else: ?>
                                                    <span class="badge badge-info" style="background-color: var(--primary-yellow); color: var(--dark-bg);">عام</span>
                                                <?php endif; ?>
                                            </td>
                                            <td style="color: var(--text-light) !important; background: var(--card-bg) !important;">
                                                <?php if($offer->discount_percentage): ?>
                                                    <span style="color: var(--success-green); font-weight: bold;"><?php echo e($offer->discount_percentage); ?>%</span>
                                                <?php elseif($offer->discount_amount): ?>
                                                    <span style="color: var(--success-green); font-weight: bold;"><?php echo e(number_format($offer->discount_amount, 0)); ?> دينار</span>
                                                <?php else: ?>
                                                    <span style="color: rgba(245, 245, 245, 0.5);">لا يوجد</span>
                                                <?php endif; ?>
                                            </td>
                                            <td style="color: var(--text-light) !important; background: var(--card-bg) !important;">
                                                <small><?php echo e($offer->start_date->format('Y-m-d')); ?></small>
                                            </td>
                                            <td style="color: var(--text-light) !important; background: var(--card-bg) !important;">
                                                <small><?php echo e($offer->end_date->format('Y-m-d')); ?></small>
                                            </td>
                                            <td style="background: var(--card-bg) !important;">
                                                <?php
                                                    $isActive = $offer->is_active;
                                                    $startDateOnly = $offer->start_date->format('Y-m-d');
                                                    $endDateOnly = $offer->end_date->format('Y-m-d');
                                                    $nowDateOnly = now()->format('Y-m-d');
                                                    $startDateOk = $startDateOnly <= $nowDateOnly;
                                                    $endDateOk = $endDateOnly >= $nowDateOnly;
                                                    $isCurrentlyActive = $isActive && $startDateOk && $endDateOk;
                                                ?>
                                                <?php if($isCurrentlyActive): ?>
                                                    <span class="badge badge-success" style="background-color: var(--success-green); color: white;">نشط</span>
                                                <?php elseif(!$isActive): ?>
                                                    <span class="badge badge-warning" style="background-color: #FFC107; color: var(--dark-bg);">معطل</span>
                                                <?php elseif($startDateOnly > $nowDateOnly): ?>
                                                    <span class="badge badge-info" style="background-color: rgba(33, 150, 243, 0.8); color: white;">قادم</span>
                                                <?php else: ?>
                                                    <span class="badge badge-secondary" style="background-color: rgba(245, 245, 245, 0.3); color: var(--text-light);">منتهي</span>
                                                <?php endif; ?>
                                            </td>
                                            <td style="background: var(--card-bg) !important;">
                                                <div class="btn-group" role="group">
                                                    <a href="<?php echo e(route('admin.offers-ads.offers.edit', $offer->id)); ?>" class="btn btn-sm btn-primary">
                                                        <i class="fas fa-edit"></i>
                                                    </a>
                                                    <form action="<?php echo e(route('admin.offers-ads.offers.destroy', $offer->id)); ?>" method="POST" style="display: inline;" onsubmit="return confirm('هل أنت متأكد من حذف هذا العرض؟');">
                                                        <?php echo csrf_field(); ?>
                                                        <?php echo method_field('DELETE'); ?>
                                                        <button type="submit" class="btn btn-sm btn-danger">
                                                            <i class="fas fa-trash"></i>
                                                        </button>
                                                    </form>
                                                </div>
                                            </td>
                                        </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                        </div>

                        <!-- Pagination -->
                        <div class="mt-3">
                            <?php echo e($offers->links()); ?>

                        </div>
                    <?php else: ?>
                        <div class="text-center py-5" style="color: rgba(245, 245, 245, 0.7);">
                            <i class="fas fa-tags fa-3x mb-3" style="color: var(--primary-yellow);"></i>
                            <p style="color: var(--text-light);">لا توجد عروض حالياً</p>
                            <a href="<?php echo e(route('admin.offers-ads.offers.create')); ?>" class="btn btn-primary mt-3">
                                <i class="fas fa-plus"></i> إضافة عرض جديد
                            </a>
                        </div>
                    <?php endif; ?>
                </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/offers_ads/offers.blade.php ENDPATH**/ ?>