@extends('layouts.app') @section('title', 'Settings — Projects') @section('content') {{-- Page header --}}

Projects, Locations & Departments

Manage projects with their sub-locations and departments.

{{-- Stat boxes --}}
{{ $stats['total_companies'] }}
Companies
{{ $stats['total_projects'] }}
Projects
{{ $stats['total_locations'] }}
Locations
{{ $stats['total_departments'] }}
Departments
{{ $stats['active_projects'] }}
Active Projects
{{-- Add Company --}}

{{-- Build data maps for safe JS passing --}} @php $allLocsData = []; $allDeptsData = []; foreach ($companies as $company) { foreach ($company->projects as $proj) { foreach ($proj->locations as $loc) { $allLocsData[$loc->id] = [ 'id' => $loc->id, 'name' => $loc->name, 'address' => $loc->address, 'latitude' => $loc->latitude, 'longitude' => $loc->longitude, 'is_active' => $loc->is_active, ]; } foreach ($proj->departments as $dept) { $allDeptsData[$dept->id] = [ 'id' => $dept->id, 'name' => $dept->name, 'is_active' => $dept->is_active, ]; } } } $allLocsJson = json_encode($allLocsData); $allDeptsJson = json_encode($allDeptsData); @endphp {{-- Companies list --}}
@forelse($companies as $company) {{-- Company card --}}
{{-- Company header --}}
{{ $company->name }} Inactive {{ $company->projects->count() }} {{ Str::plural('project', $company->projects->count()) }}
{{-- Company edit strip --}}

{{-- Add project strip --}}

{{-- Projects container --}}
@forelse($company->projects as $project) @php $isLast = $loop->last; @endphp
{{-- Project header --}}
{{ $project->name }} Inactive
{{-- Project edit strip --}}

{{-- Project body: Locations + Departments --}}
{{-- Locations --}}
Locations
@forelse($project->locations as $location)
{{ $location->name }} Inactive
{{ $location->address }}
@if($location->latitude && $location->longitude){{ number_format((float)$location->latitude,6) }}°, {{ number_format((float)$location->longitude,6) }}°@endif
@empty
No locations yet.
@endforelse
{{-- Departments --}}
Departments
@forelse($project->departments as $dept)
{{ $dept->name }} Inactive
@empty
No departments yet.
@endforelse
{{-- end proj-body-inner --}}
{{-- end proj-body --}}
{{-- end proj-card --}} @empty
No projects yet — click "+ Add Project" above.
@endforelse
{{-- end proj-list --}}
{{-- end company-card --}} @empty
No companies yet. Add your first company above.
@endforelse
{{-- end companies-list --}} {{-- ═══════════════ Location Map Modal ═══════════════ --}}
{{-- Header --}}

{{-- Two-panel body --}}
{{-- Left: form fields --}}

Map tips:
• Click anywhere on the map to place the pin
• Drag the pin to fine-tune position
• Type an address and press or click 🔍 to find it

{{-- Right: Leaflet map --}}
Click map to place pin • Drag pin to adjust
{{-- Footer --}}
{{-- ═══════════════════════════════════════════════════ --}} @endsection