

<?php $__env->startSection('title', 'Requests'); ?>

<?php $__env->startSection('content'); ?>
<div class="content-wrapper">
    <div class="content-header">
        <div class="container-fluid">
            <div class="row mb-2">
                <div class="col-sm-6">
                    <h1 class="m-0">Requests</h1>
                </div>
                <div class="col-sm-6">
                    <div class="float-sm-right">
                        <?php if(auth()->user()->isOwner()): ?>
                            <a href="<?php echo e(route('requests.create')); ?>" class="btn btn-primary">
                                <i class="fas fa-plus"></i> New Request
                            </a>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <section class="content">
        <div class="container-fluid">
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">All Requests</h3>
                </div>
                <div class="card-body">
                    <form action="<?php echo e(route('requests.index')); ?>" method="GET" class="mb-4">
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group">
                                    <div class="input-group">
                                        <input type="text" name="search" class="form-control" placeholder="Search by note, name, email or phone..." value="<?php echo e(request('search')); ?>">
                                        <div class="input-group-append">
                                            <button type="submit" class="btn btn-primary">
                                                <i class="fas fa-search"></i>
                                            </button>
                                            <?php if(request('search')): ?>
                                                <a href="<?php echo e(route('requests.index', array_merge(request()->except('search'), ['search' => '']))); ?>" class="btn btn-danger">
                                                    <i class="fas fa-times"></i>
                                                </a>
                                            <?php endif; ?>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <select name="status" class="form-control" onchange="this.form.submit()">
                                        <option value="">All Statuses</option>
                                        <option value="pending" <?php echo e(request('status') == 'pending' ? 'selected' : ''); ?>>Pending</option>
                                        <option value="in_progress" <?php echo e(request('status') == 'in_progress' ? 'selected' : ''); ?>>In Progress</option>
                                        <option value="completed" <?php echo e(request('status') == 'completed' ? 'selected' : ''); ?>>Completed</option>
                                        <option value="cancelled" <?php echo e(request('status') == 'cancelled' ? 'selected' : ''); ?>>Cancelled</option>
                                    </select>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <select name="type" class="form-control" onchange="this.form.submit()">
                                        <option value="">All Types</option>
                                        <?php $__currentLoopData = $requestTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $type): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($type->id); ?>" <?php echo e(request('type') == $type->id ? 'selected' : ''); ?>>
                                                <?php echo e($type->name); ?>

                                            </option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </form>

                    <div class="table-responsive">
                        <table class="table table-bordered table-striped">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Type</th>
                                    <th>Owner</th>
                                    <th>Phone</th>
                                    <th>Note</th>
                                    <th>Status</th>
                                    <th>Created</th>
                                    <th>Actions</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $requests; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $request): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td><?php echo e($request->id); ?></td>
                                        <td><?php echo e($request->requestType->name); ?></td>
                                        <td><?php echo e($request->user->name); ?></td>
                                        <td><?php echo e($request->user->phone); ?></td>
                                        <td><?php echo e(Str::limit($request->note, 50)); ?></td>
                                        <td>
                                            <?php
                                                $statusColors = [
                                                    'pending' => ['bg' => 'bg-warning', 'text' => 'text-dark'],
                                                    'in_progress' => ['bg' => 'bg-info', 'text' => 'text-white'],
                                                    'completed' => ['bg' => 'bg-success', 'text' => 'text-white'],
                                                    'cancelled' => ['bg' => 'bg-danger', 'text' => 'text-white']
                                                ];
                                                $status = $request->status;
                                                $colors = $statusColors[$status];
                                            ?>
                                            <span class="badge <?php echo e($colors['bg']); ?> <?php echo e($colors['text']); ?> p-2">
                                                <?php echo e(ucfirst($status)); ?>

                                            </span>
                                        </td>
                                        <td><?php echo e($request->created_at->format('M d, Y H:i')); ?></td>
                                        <td>
                                            <a href="<?php echo e(route('requests.show', $request)); ?>" class="btn btn-sm btn-info">
                                                <i class="fas fa-eye"></i>
                                            </a>
                                            <?php if(auth()->user()->isAdmin() || auth()->user()->isOperation()): ?>
                                                <a href="<?php echo e(route('requests.edit', $request)); ?>" class="btn btn-sm btn-primary">
                                                    <i class="fas fa-edit"></i>
                                                </a>
                                            <?php endif; ?>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td colspan="7" class="text-center">No requests found</td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="card-footer">
                    <?php echo e($requests->appends(request()->query())->links()); ?>

                </div>
            </div>
        </div>
    </section>
</div>

<style>
.badge {
    font-size: 0.9em;
    font-weight: 500;
    padding: 0.5em 1em;
}
.badge.bg-warning {
    background-color: #ffc107 !important;
}
.badge.bg-info {
    background-color: #17a2b8 !important;
}
.badge.bg-success {
    background-color: #28a745 !important;
}
.badge.bg-danger {
    background-color: #dc3545 !important;
}
</style>
<?php $__env->stopSection(); ?> 
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\laragon\www\solen-north-coast\resources\views/requests/index.blade.php ENDPATH**/ ?>