{{-- resources/views/itins/create.blade.php --}} @extends('layouts.base') @section('title', __('Create an itinerary')) @section('content') @php $isPro = request()->routeIs('pro.*'); // URLs AJAX $urlAdmins = route(($isPro ? 'pro.' : 'admin.').'itins.adminsForSociety', ['locale'=>app()->getLocale()]); $urlUsers = route(($isPro ? 'pro.' : 'admin.').'itins.usersForSociety', ['locale'=>app()->getLocale()]); $urlPoints = route(($isPro ? 'pro.' : 'admin.').'itins.pointsForContext', ['locale'=>app()->getLocale()]); // URL submit / back $postUrl = route(($isPro ? 'pro.' : 'admin.').'itins.store', ['locale'=>app()->getLocale()]); $backUrl = route(($isPro ? 'pro.' : 'admin.').'itins.index', ['locale'=>app()->getLocale()]); // --- Pré-seed pour admin pro --- // Pour un admin pro : // - il n’a accès qu’à SA société (normalement une seule dans $societies) // - l’admin pro responsable = lui-même // - les users = membres de SA société // On va donc préparer ces valeurs pour le JS. $seedSocietyId = null; $seedAdminId = null; $authUser = auth()->user(); if ($isPro && $authUser) { // société unique du pro: on prend la première du tableau $societies // (dans ton controller create(), pour un pro tu dois déjà limiter $societies à SES sociétés) $firstSoc = $societies->first(); if ($firstSoc) { $seedSocietyId = $firstSoc->id; } // l'admin pro responsable = l'utilisateur courant $seedAdminId = $authUser->id; } @endphp

{{ __('Back') }} {{ __('Create an itinerary') }}

@if($errors->any())
@endif
@csrf
{{-- Name --}}
{{ __('A unique itinerary name.') }}
{{-- Company --}}
{{-- --}} @if($isPro) {{-- admin pro: société imposée --}} @php $soc = $societies->first(); @endphp {{--
{{ $soc?->name ?? '—' }}
{{ __('This itinerary will belong to your company.') }} --}} @else {{-- super admin: choix libre --}} {{ __('Pick the company this itinerary belongs to.') }} @endif
{{-- Pro admin owner --}}
{{-- --}} @if($isPro) {{-- admin pro: c'est lui-même --}} {{--
{{ trim(($authUser->firstname ?? '').' '.($authUser->lastname ?? '')) ?: ('#'.$authUser->id) }}
{{ __('You are responsible for this itinerary.') }} --}} @else {{-- super admin: à charger dynamiquement selon la société --}} {{ __('This user will be the itinerary manager.') }} @endif
{{-- Assigned users --}}
@if($isPro) {{ __('Loading…') }} @else {{ __('Select a company to list its users.') }} @endif
{{ __('All selected users will see this itinerary.') }}
{{-- Waypoints --}}
{{ __('Add points (sites / lieux) to visit. You can reorder them.') }}
{{-- Available --}}

{{ __('Available') }}

@if($isPro) {{ __('Loading…') }} @else {{ __('Select a company and a Pro admin.') }} @endif
{{-- Selected --}}

{{ __('Selected (drag to reorder)') }}

{{ __('No waypoint selected yet.') }}
{{-- hidden inputs reflect final order --}}
@endsection