

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

<?php $__env->startSection('content'); ?>
<div class="card">
    <div class="card-header d-flex justify-content-between align-items-center">
        <h5 class="mb-0">Customers</h5>
        <a href="<?php echo e(route('customers.create')); ?>" class="btn btn-primary">
            <i class="bi bi-plus-circle me-2"></i>Add Customer
        </a>
    </div>
    <div class="card-body">
        <?php if(session('success')): ?>
            <div class="alert alert-success">
                <?php echo e(session('success')); ?>

            </div>
        <?php endif; ?>

        <div class="row mb-4">
            <div class="col-md-6">
                <form method="GET" action="<?php echo e(route('customers.index')); ?>" class="d-flex gap-2">
                    <div class="input-group">
                        <input type="text" 
                               name="search" 
                               class="form-control" 
                               placeholder="Search by email or phone..."
                               value="<?php echo e(request('search')); ?>">
                        <button class="btn btn-outline-secondary" type="submit">
                            <i class="bi bi-search"></i>
                        </button>
                        <?php if(request('search')): ?>
                            <a href="<?php echo e(route('customers.index', ['is_owner' => request('is_owner')])); ?>" 
                               class="btn btn-outline-secondary">
                                <i class="bi bi-x"></i>
                            </a>
                        <?php endif; ?>
                    </div>
                </form>
            </div>
            <div class="col-md-6">
                <form method="GET" action="<?php echo e(route('customers.index')); ?>" class="d-flex justify-content-end">
                    <div class="input-group" style="width: auto;">
                        <label for="is_owner" class="input-group-text">Filter by Owner:</label>
                        <select name="is_owner" id="is_owner" class="form-select" onchange="this.form.submit()">
                            <option value="">All</option>
                            <option value="1" <?php echo e(request('is_owner') == '1' ? 'selected' : ''); ?>>Owner</option>
                            <option value="0" <?php echo e(request('is_owner') == '0' ? 'selected' : ''); ?>>Not Owner</option>
                        </select>
                        <?php if(request('is_owner') !== null): ?>
                            <a href="<?php echo e(route('customers.index', ['search' => request('search')])); ?>" 
                               class="btn btn-outline-secondary">
                                <i class="bi bi-x"></i>
                            </a>
                        <?php endif; ?>
                    </div>
                </form>
            </div>
        </div>

        <div class="table-responsive">
            <table class="table table-hover">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Email</th>
                        <th>Phone</th>
                        <th>Type</th>
                        <th>Status</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $customers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td><?php echo e($user->name); ?></td>
                            <td><?php echo e($user->email); ?></td>
                            <td><?php echo e($user->phone); ?></td>
                            <td>
                                <?php if($user->is_owner): ?>
                                    <span class="badge bg-primary">Owner</span>
                                <?php else: ?>
                                    <span class="badge bg-secondary">Customer</span>
                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if($user->deactivated_at): ?>
                                    <span class="badge bg-danger">Deactivated</span>
                                <?php else: ?>
                                    <span class="badge bg-success">Active</span>
                                <?php endif; ?>
                            </td>
                            <td>
                                <div class="btn-group" role="group">
                                    <a href="<?php echo e(route('customers.edit', $user)); ?>" 
                                       class="btn btn-sm btn-info text-white me-2"
                                       data-bs-toggle="tooltip"
                                       data-bs-placement="top"
                                       title="Edit Customer">
                                        <i class="bi bi-pencil"></i>
                                    </a>
                                    <form action="<?php echo e(route('customers.reset-password', $user)); ?>" 
                                          method="POST" 
                                          class="d-inline me-2">
                                        <?php echo csrf_field(); ?>
                                        <button type="submit" 
                                                class="btn btn-sm btn-warning"
                                                data-bs-toggle="tooltip"
                                                data-bs-placement="top"
                                                title="Reset Password"
                                                onclick="return confirm('Are you sure you want to reset the password?')">
                                            <i class="bi bi-key"></i>
                                        </button>
                                    </form>
                                    <form action="<?php echo e(route('customers.toggle-status', $user)); ?>" 
                                          method="POST" 
                                          class="d-inline">
                                        <?php echo csrf_field(); ?>
                                        <button type="submit" 
                                                class="btn btn-sm <?php echo e($user->deactivated_at ? 'btn-success' : 'btn-danger'); ?>"
                                                data-bs-toggle="tooltip"
                                                data-bs-placement="top"
                                                title="<?php echo e($user->deactivated_at ? 'Activate Customer' : 'Deactivate Customer'); ?>"
                                                onclick="return confirm('Are you sure you want to <?php echo e($user->deactivated_at ? 'activate' : 'deactivate'); ?> this customer?')">
                                            <i class="bi <?php echo e($user->deactivated_at ? 'bi-person-check' : 'bi-person-x'); ?>"></i>
                                        </button>
                                    </form>
                                </div>
                            </td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr>
                            <td colspan="6" class="text-center py-4">
                                <?php if(request('search')): ?>
                                    No customers found matching your search criteria.
                                <?php else: ?>
                                    No customers found.
                                <?php endif; ?>
                            </td>
                        </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>

<?php $__env->startPush('scripts'); ?>
<script>
    // Initialize all tooltips
    var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
    var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
        return new bootstrap.Tooltip(tooltipTriggerEl)
    })
</script>
<?php $__env->stopPush(); ?>
<?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/customers/index.blade.php ENDPATH**/ ?>