

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

<?php $__env->startSection('content'); ?>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
    <div class="flex flex-col sm:flex-row justify-between items-start sm:items-center mb-6 gap-4">
        <h1 class="text-3xl font-bold text-gray-800">My Appointments</h1>
        <div class="flex gap-2">
            <a href="<?php echo e(route('pharmacist.appointments.create')); ?>" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded">
                <i class="fas fa-plus mr-2"></i>Create New Appointment
            </a>
            <a href="<?php echo e(route('pharmacist.dashboard')); ?>" class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded">
                <i class="fas fa-arrow-left mr-2"></i>Back to Dashboard
            </a>
        </div>
    </div>

    <?php if(session('success')): ?>
        <div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-4">
            <?php echo e(session('success')); ?>

        </div>
    <?php endif; ?>

    <?php if(session('error')): ?>
        <div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
            <?php echo e(session('error')); ?>

        </div>
    <?php endif; ?>

    <!-- Filters and Search -->
    <div class="bg-white rounded-lg shadow p-4 mb-4">
        <form method="GET" action="<?php echo e(route('pharmacist.appointments')); ?>" class="space-y-3">
            <div class="grid grid-cols-1 md:grid-cols-4 gap-3">
                <div>
                    <input type="text" name="search" value="<?php echo e(request('search')); ?>" placeholder="Search patients, doctors, branches..." class="w-full px-3 py-2 border rounded text-sm">
                </div>
                <div>
                    <select name="doctor_id" class="w-full px-3 py-2 border rounded text-sm">
                        <option value="">All Doctors</option>
                        <?php $__currentLoopData = $doctors ?? []; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $doctor): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($doctor->id); ?>" <?php echo e(request('doctor_id') == $doctor->id ? 'selected' : ''); ?>><?php echo e($doctor->full_name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
                <div>
                    <select name="patient_id" class="w-full px-3 py-2 border rounded text-sm">
                        <option value="">All Patients</option>
                        <?php $__currentLoopData = $patients ?? []; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $patient): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($patient->id); ?>" <?php echo e(request('patient_id') == $patient->id ? 'selected' : ''); ?>><?php echo e($patient->full_name); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
                <div>
                    <select name="status" class="w-full px-3 py-2 border rounded text-sm">
                        <option value="">All Status</option>
                        <option value="pending" <?php echo e(request('status') == 'pending' ? 'selected' : ''); ?>>Pending</option>
                        <option value="confirmed" <?php echo e(request('status') == 'confirmed' ? 'selected' : ''); ?>>Confirmed</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="grid grid-cols-1 md:grid-cols-3 gap-3">
                <div>
                    <label class="block text-xs text-gray-600 mb-1">Date From</label>
                    <input type="date" name="date_from" value="<?php echo e(request('date_from')); ?>" class="w-full px-3 py-2 border rounded text-sm">
                </div>
                <div>
                    <label class="block text-xs text-gray-600 mb-1">Date To</label>
                    <input type="date" name="date_to" value="<?php echo e(request('date_to')); ?>" class="w-full px-3 py-2 border rounded text-sm">
                </div>
                <div class="flex items-end gap-2">
                    <button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded text-sm">Filter</button>
                    <a href="<?php echo e(route('pharmacist.appointments')); ?>" class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded text-sm">Clear</a>
                </div>
            </div>
        </form>
    </div>

    <div class="bg-white rounded-lg shadow overflow-hidden">
        <div class="overflow-x-auto -mx-4 sm:mx-0" style="scrollbar-width: thin;">
            <div class="inline-block min-w-full align-middle">
                <table class="min-w-full divide-y divide-gray-200" style="min-width: 900px;">
                <thead class="bg-gray-50">
                    <tr>
                        <th class="px-3 sm:px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Patient</th>
                        <th class="px-3 sm:px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase hidden md:table-cell">Doctor</th>
                        <th class="px-3 sm:px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase hidden lg:table-cell">Branch</th>
                        <th class="px-3 sm:px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">APPOINTMENT DATE</th>
                        <th class="px-3 sm:px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase hidden sm:table-cell">Type</th>
                        <th class="px-3 sm:px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase hidden lg:table-cell">Payment Mode</th>
                        <th class="px-3 sm:px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Status</th>
                        <th class="px-3 sm:px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Actions</th>
                    </tr>
                </thead>
                <tbody class="bg-white divide-y divide-gray-200">
                    <?php $__empty_1 = true; $__currentLoopData = $appointments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $appointment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td class="px-3 sm:px-6 py-4 whitespace-nowrap">
                            <span class="text-sm sm:text-base"><?php echo e($appointment->patient->full_name); ?></span>
                        </td>
                        <td class="px-3 sm:px-6 py-4 whitespace-nowrap hidden md:table-cell">
                            <span class="text-sm"><?php echo e($appointment->doctor ? $appointment->doctor->full_name : 'N/A'); ?></span>
                        </td>
                        <td class="px-3 sm:px-6 py-4 whitespace-nowrap hidden lg:table-cell">
                            <span class="text-sm"><?php echo e($appointment->branch->name); ?></span>
                        </td>
                        <td class="px-3 sm:px-6 py-4 whitespace-nowrap">
                            <span class="text-xs sm:text-sm"><?php echo e($appointment->appointment_date->format('M d, Y H:i')); ?></span>
                        </td>
                        <td class="px-3 sm:px-6 py-4 whitespace-nowrap hidden sm:table-cell">
                            <span class="text-xs sm:text-sm"><?php echo e($appointment->consultation_type); ?></span>
                        </td>
                        <td class="px-3 sm:px-6 py-4 whitespace-nowrap hidden lg:table-cell">
                            <span class="text-xs sm:text-sm"><?php echo e($appointment->patient->payment_mode); ?></span>
                        </td>
                        <td class="px-3 sm:px-6 py-4 whitespace-nowrap">
                            <span class="px-2 py-1 text-xs rounded-full 
                                <?php if($appointment->status === 'completed'): ?> bg-green-100 text-green-800
                                <?php elseif($appointment->status === 'pending'): ?> bg-orange-100 text-orange-800
                                <?php elseif($appointment->status === 'in_progress'): ?> bg-blue-100 text-blue-800
                                <?php elseif($appointment->status === 'cancelled'): ?> bg-red-100 text-red-800
                                <?php else: ?> bg-gray-100 text-gray-800
                                <?php endif; ?>">
                                <?php echo e(ucfirst($appointment->status)); ?>

                            </span>
                        </td>
                        <td class="px-3 sm:px-6 py-4 whitespace-nowrap text-xs sm:text-sm font-medium">
                            <div class="flex flex-col gap-1">
                                <?php if($appointment->status !== 'completed'): ?>
                                    <a href="<?php echo e(route('pharmacist.appointments.edit', $appointment->id)); ?>" class="text-blue-600 hover:text-blue-900">Edit</a>
                                <?php endif; ?>
                                <?php if($appointment->status === 'pending'): ?>
                                    <form method="POST" action="<?php echo e(route('pharmacist.appointments.cancel', $appointment->id)); ?>" onsubmit="return confirm('Are you sure you want to cancel this appointment?');" class="inline">
                                        <?php echo csrf_field(); ?>
                                        <button type="submit" class="text-red-600 hover:text-red-900">Cancel</button>
                                    </form>
                                <?php endif; ?>
                                <?php if($appointment->google_meet_link): ?>
                                    <a href="<?php echo e($appointment->google_meet_link); ?>" target="_blank" class="text-green-600 hover:text-green-900 whitespace-nowrap">
                                        <i class="fas fa-video"></i> <span class="hidden sm:inline">Google Meet</span><span class="sm:hidden">Meet</span>
                                    </a>
                                <?php elseif($appointment->video_call_room_id): ?>
                                    <a href="<?php echo e(route('pharmacist.video-call', $appointment->id)); ?>" class="text-blue-600 hover:text-blue-900 whitespace-nowrap">
                                        <i class="fas fa-video"></i> <span class="hidden sm:inline">Video Call</span><span class="sm:hidden">Video</span>
                                    </a>
                                <?php endif; ?>
                                <?php if($appointment->doctor && $appointment->doctor->phone): ?>
                                    <a href="https://wa.me/<?php echo e(preg_replace('/[^0-9]/', '', $appointment->doctor->phone)); ?>" target="_blank" class="text-green-600 hover:text-green-900 whitespace-nowrap">
                                        <i class="fab fa-whatsapp"></i> <span class="hidden sm:inline">Call Doctor</span><span class="sm:hidden">Doctor</span>
                                    </a>
                                <?php endif; ?>
                            </div>
                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="8" class="px-6 py-4 text-center text-gray-500">
                            No appointments found.
                        </td>
                    </tr>
                    <?php endif; ?>
                </tbody>
            </table>
            </div>
        </div>
    </div>

    <?php if($appointments->count() > 0): ?>
    <div class="mt-4 text-sm text-gray-600">
        Showing <?php echo e($appointments->count()); ?> appointment(s)
    </div>
    <?php endif; ?>
</div>
<?php $__env->stopSection(); ?>


<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\BrainTech\Documents\BEAUTEZ SYSTEM\BEAUTEZ SYSTEM\resources\views/pharmacist/appointments.blade.php ENDPATH**/ ?>