@extends('layouts.app') @section('title', 'Calendar') @section('breadcrumb')Calendar@endsection @section('content')

Calendar

Schedule appointments, deliveries, and installations

@foreach([ 'check_measure' => ['Check Measure','#60a5fa'], 'delivery' => ['Delivery','#fb923c'], 'installation' => ['Installation','#4ade80'], 'consultation' => ['Consultation','#f472b6'], 'follow_up' => ['Follow Up','#c084fc'], 'appointment' => ['Appointment','#fbbf24'], 'processing' => ['Processing','#2dd4bf'], 'contracts_admin' => ['Contracts Admin','#818cf8'], 'other' => ['Other','#94a3b8'], ] as $type => [$label, $color]) @endforeach
Filter installer:
@foreach(['Mon','Tue','Wed','Thu','Fri','Sat','Sun'] as $d)
{{ $d }}
@endforeach

No events on this day

Team Schedule
Team Member
?
Unassigned
@foreach(['check_measure'=>['Check Measure','#60a5fa'],'delivery'=>['Delivery','#fb923c'],'installation'=>['Installation','#4ade80'],'consultation'=>['Consultation','#f472b6'],'appointment'=>['Appointment','#fbbf24'],'follow_up'=>['Follow Up','#c084fc'],'processing'=>['Processing','#2dd4bf'],'contracts_admin'=>['Contracts Admin','#818cf8'],'other'=>['Other','#94a3b8']] as $type=>[$label,$color])
{{ $label }}
@endforeach

Upcoming

@forelse($upcomingEvents->take(8) as $event) @php $colors=['check_measure'=>'#60a5fa','delivery'=>'#fb923c','installation'=>'#4ade80','consultation'=>'#f472b6','follow_up'=>'#c084fc','processing'=>'#2dd4bf','contracts_admin'=>'#818cf8','other'=>'#94a3b8']; $c=$colors[$event->type]??'#94a3b8'; @endphp
{{ $event->title }}
{{ $event->start_at->format('D d M, g:ia') }}
@if($event->assignedTo)
{{ $event->assignedTo->name }}
@endif
@empty

No upcoming events

@endforelse
@auth

Quick Add Event

@csrf
@endauth
@push('scripts') @php $colorMap = [ 'check_measure' => '#60a5fa', 'delivery' => '#fb923c', 'installation' => '#4ade80', 'consultation' => '#f472b6', 'follow_up' => '#c084fc', 'appointment' => '#fbbf24', 'processing' => '#2dd4bf', 'contracts_admin' => '#818cf8', 'other' => '#94a3b8', ]; // ── Calendar events (from CalendarEvent model) ─────────────────────────── $calEvents = $events->map(fn($e) => [ 'id' => 'evt-'.$e->id, 'title' => $e->title, 'date' => $e->start_at->format('Y-m-d'), 'hour' => (int) $e->start_at->format('G'), 'time' => $e->start_at->format('g:ia'), 'type' => $e->type, 'color' => $colorMap[$e->type] ?? '#94a3b8', 'location' => $e->location ?? '', 'assigned' => $e->assignedTo?->name ?? '', 'assigned_id' => $e->assigned_to ?? null, ]); // ── Appointments from leads ─────────────────────────────────────────────── $apptEvents = $appointments->map(fn($a) => [ 'id' => 'appt-'.$a->id, 'title' => 'Appt: '.($a->lead?->contact?->full_name ?? 'Lead').($a->appointment_with ? ' ('.$a->appointment_with.')' : ''), 'date' => $a->appointment_date->format('Y-m-d'), 'hour' => $a->appointment_time ? (int)\Carbon\Carbon::createFromFormat('H:i:s', $a->appointment_time)->format('G') : 9, 'time' => $a->appointment_time ? \Carbon\Carbon::createFromFormat('H:i:s', $a->appointment_time)->format('g:ia') : '', 'type' => 'appointment', 'color' => '#fbbf24', 'location' => $a->appointment_location ?? '', 'assigned' => $a->lead?->contact?->full_name ?? '', 'assigned_id' => null, ]); // ── Follow-ups from leads ───────────────────────────────────────────────── $fuEvents = $followUps->map(fn($f) => [ 'id' => 'fu-'.$f->id, 'title' => 'Follow-up: '.($f->lead?->contact?->full_name ?? 'Lead').($f->follow_up_type ? ' ('.$f->follow_up_type.')' : ''), 'date' => $f->follow_up_date->format('Y-m-d'), 'hour' => $f->follow_up_time ? (int)\Carbon\Carbon::createFromFormat('H:i:s', $f->follow_up_time)->format('G') : 9, 'time' => $f->follow_up_time ? \Carbon\Carbon::createFromFormat('H:i:s', $f->follow_up_time)->format('g:ia') : '', 'type' => 'follow_up', 'color' => '#c084fc', 'location' => '', 'assigned' => $f->lead?->contact?->full_name ?? '', 'assigned_id' => null, ]); // ── Consultations from leads (booking_date) ─────────────────────────────── $consultEvents = $consultLeads->map(fn($l) => [ 'id' => 'consult-'.$l->id, 'title' => 'Consult: '.($l->contact?->full_name ?? 'Lead'), 'date' => $l->booking_date->format('Y-m-d'), 'hour' => 9, 'time' => '', 'type' => 'consultation', 'color' => '#f472b6', 'location' => '', 'assigned' => $l->contact?->full_name ?? '', 'assigned_id' => null, ]); // ── Check Measures (scheduled_date) ────────────────────────────────────── $checkMeasureEvents = $checkMeasures->map(fn($cm) => [ 'id' => 'cm-'.$cm->id, 'title' => 'Check Measure: '.($cm->job?->contact?->full_name ?? ($cm->job?->job_number ?? 'Job')), 'date' => $cm->scheduled_date->format('Y-m-d'), 'hour' => $cm->arrival_time ? (int)\Carbon\Carbon::createFromFormat('H:i:s', $cm->arrival_time)->format('G') : 9, 'time' => $cm->arrival_time ? \Carbon\Carbon::createFromFormat('H:i:s', $cm->arrival_time)->format('g:ia') : '', 'type' => 'check_measure', 'color' => '#60a5fa', 'location' => '', 'assigned' => $cm->measurer?->name ?? '', 'assigned_id' => $cm->measurer_id ?? null, ]); // ── Deliveries (scheduled_date) ─────────────────────────────────────────── $deliveryEvents = $deliveries->map(fn($d) => [ 'id' => 'del-'.$d->id, 'title' => 'Delivery: '.($d->job?->contact?->full_name ?? ($d->job?->job_number ?? 'Job')), 'date' => $d->scheduled_date->format('Y-m-d'), 'hour' => 9, 'time' => $d->delivery_window ?? '', 'type' => 'delivery', 'color' => '#fb923c', 'location' => '', 'assigned' => $d->driver?->name ?? '', 'assigned_id' => $d->driver_id ?? null, ]); // ── Installations (start_date) ──────────────────────────────────────────── $installationEvents = $installations->map(fn($i) => [ 'id' => 'inst-'.$i->id, 'title' => 'Installation: '.($i->job?->contact?->full_name ?? ($i->job?->job_number ?? 'Job')), 'date' => $i->start_date->format('Y-m-d'), 'hour' => 8, 'time' => '', 'type' => 'installation', 'color' => '#4ade80', 'location' => '', 'assigned' => $i->leadInstaller?->name ?? '', 'assigned_id' => $i->lead_installer_id ?? null, ]); $allCalEvents = $calEvents ->concat($apptEvents) ->concat($fuEvents) ->concat($consultEvents) ->concat($checkMeasureEvents) ->concat($deliveryEvents) ->concat($installationEvents) ->values(); $teamMembers = $users->map(fn($u) => [ 'id' => $u->id, 'name' => $u->name, 'initials'=> strtoupper(substr($u->name, 0, 2)), 'role' => $u->role?->name ?? '', ]); @endphp @endpush @endsection