@extends('layouts.base') @section('content') @section('breadcrumb') @endsection @php $canLotsWrite = auth()->user()->canAccessPartnerLotsWrite(); $address = $program->addresses->first(); $lotDocumentTypeFilterOptions = collect(\App\Enums\DocumentTypeLot::selectableCases()) ->map(fn ($type) => ['value' => $type->value, 'label' => $type->label()]) ->all(); $lotOptionStateFilterOptions = collect(\App\Enums\OptionState::selectableCases()) ->map(fn ($state) => ['value' => $state->value, 'label' => $state->label()]) ->all(); $activeLotTab = strtolower((string) request('tab', 'informations')); if (! in_array($activeLotTab, ['options', 'documents', 'notes'], true)) { $activeLotTab = 'informations'; } $lotInternalNotes = $lot->notes()->with('user')->orderByDesc('created_at')->get(); try { $lotType = $lot->type; $lotTypeValid = $lotType && $lotType !== \App\Enums\ProductType::NON_DEFINI; } catch (\Throwable $e) { $lotType = null; $lotTypeValid = false; } @endphp
@if(session('success')) @endif @if(session('error')) @endif @if ($errors->any()) @endif

Lot {{ $lot->number }} {{ $lot->gender ? $lot->gender->label() : '' }} {{ $lotTypeValid ? $lotType->label() : '' }}

@if($lotTypeValid && $lotType->isPMR()) PMR @endif @if($lot->fiscalites->isNotEmpty()) @foreach($lot->fiscalites as $fiscalite) {{ $fiscalite->type->label() }} @endforeach @endif @if($address && $address->city) {{ $address->city }} @endif
{{ $lot->current_state->label() }} @if($canLotsWrite) @else @if($lot->is_active)Actif @elseInactif @endif @endif
Modifié le {{ $lot->updated_at->format('d/m/Y à H:i') }} ID #{{ $lot->id }}
@include('partner.lots.show-prix-vente-total-card') @include('partner.lots.show-annexes-card') {{-- @include('partner.lots.show-recettes-charges-card') --}} @if(isset($formEditor) && $formEditor && $formEditor->fields->count() > 0)
Champs personnalisés
Données spécifiques à cette application
@foreach($formEditor->fields as $field) @php $fieldValue = $field->data && isset($field->data->json['value']) ? $field->data->json['value'] : null; @endphp @if($fieldValue !== null && $fieldValue !== '')
@if($field->type === \App\Enums\FieldType::TEXT || $field->type === \App\Enums\FieldType::NUMBER)

{{ $fieldValue }}

@elseif($field->type === \App\Enums\FieldType::CHECKBOX)

@if($fieldValue == '1') Activé @else Désactivé @endif

@elseif($field->type === \App\Enums\FieldType::DATE)

{{ \Carbon\Carbon::parse($fieldValue)->format('d/m/Y') }}

@else

{{ $fieldValue }}

@endif @if($field->description) {{ $field->description }} @endif
@endif @endforeach
@if($formEditor->fields->filter(fn($f) => $f->data && isset($f->data->json['value']) && $f->data->json['value'] !== '')->count() === 0)
Aucune donnée personnalisée renseignée
@endif
@endif
Programme

{{ $program->name }}

@if($program->getMedia('images')->count() > 0) {{ $program->name }} @endif
Caractéristiques du lot
Type
{{ $lot->type?->label() }}
Niveau
{{ $lot->floor?->label() }}
Orientation
{{ ($lot->orientations ?? collect())->map(fn($o) => $o->type?->label())->filter()->implode(', ') ?: '—' }}
Tantieme
{{ $lot->tantieme }}
@if($lotTypeValid && $lotType->isPMR())
PMR
PMR
@endif
Surface
@if($lot->surfaces && $lot->surfaces->count() > 0) @foreach($lot->surfaces as $surface)
{{ $surface->type->label() }}
{{ number_format($surface->value, 2, ',', ' ') }} m²
@endforeach @endif
@php $exteriorAnnexeRows = []; foreach (\App\Enums\ProductType::exteriorPrivatifTypes() as $typeCase) { $annexesOfType = $lot->annexes->filter(fn ($a) => $a->type === $typeCase); if ($annexesOfType->isEmpty()) { continue; } $surfaceSum = $annexesOfType->sum(fn ($a) => (float) ($a->surfaces->where('type', \App\Enums\SurfaceType::ANNEXE)->first()?->value ?? 0)); $numbersStr = $annexesOfType->map(fn ($a, $i) => $a->number ?? '#' . ($i + 1))->implode(', '); $iconClass = in_array($typeCase, [\App\Enums\ProductType::JARDIN, \App\Enums\ProductType::TERRASSE], true) ? 'icon-tree-deciduous' : 'icon-clipboard-list'; $exteriorAnnexeRows[] = [ 'icon' => $iconClass, 'label' => $typeCase->label(), 'numbers' => $numbersStr, 'surface' => $surfaceSum, ]; } $hasExteriorAnnexes = count($exteriorAnnexeRows) > 0; @endphp
Espaces extérieurs privatifs
@if($hasExteriorAnnexes) @endif
@if($hasExteriorAnnexes) @foreach($exteriorAnnexeRows as $row)
{{ $row['label'] }}
@if($row['numbers']) {{ $row['numbers'] }} @endif {{ number_format($row['surface'], 2, ',', ' ') }} m²
@endforeach @else

Aucun espace extérieur ajouté

Ajoutez les espaces extérieurs inclus avec ce lot

@endif
@if($lot->descriptions && $lot->descriptions->count() > 0)
Descriptions du lot
@foreach($lot->descriptions as $description) @php $descType = $description->type instanceof \App\Enums\DescriptionLotType ? $description->type : \App\Enums\DescriptionLotType::tryFrom($description->attributes['type'] ?? null); @endphp @if($descType)
{{ $descType->label() }}

{{ $description->text }}

@endif @endforeach
@endif
@php $lotOptionsQuery = \App\Models\Option::where('product_id', $lot->id) ->where('application_id', $application->id) ->with(['client']); $sortBy = request('options_sort_by', 'created_at'); $sortDir = request('options_sort_dir', 'desc'); $lotOptions = $lotOptionsQuery->get()->sortBy(function($option) use ($sortBy) { return match($sortBy) { 'client' => ($option->client->lastname ?? '') . ' ' . ($option->client->firstname ?? ''), 'rank' => $option->getRang() ?? 999, 'created_at' => $option->created_at?->timestamp ?? 0, 'date_end' => $option->date_end?->timestamp ?? 0, 'state' => $option->state?->label() ?? '', default => $option->created_at?->timestamp ?? 0, }; }, SORT_REGULAR); $lotOptions = $sortDir === 'asc' ? $lotOptions->values() : $lotOptions->reverse()->values(); @endphp @if($lotOptions->isEmpty())

Aucune option sur ce lot

@else @include('partner.lots.partials.options-table', [ 'options' => $lotOptions, 'application' => $application, 'program' => $program, 'lot' => $lot, 'sortBy' => $sortBy, 'sortDir' => $sortDir, 'optionStateFilterOptions' => $lotOptionStateFilterOptions, ]) @endif
@if($lot->documents->count() > 0)
Tout télécharger
@include('partner.lots.partials.documents-table', [ 'documents' => $lot->documents->sortBy('order')->values(), 'application' => $application, 'program' => $program, 'lot' => $lot, ])
@else

Aucun document

@endif
@if($canLotsWrite)
@csrf
@endif
@if($lotInternalNotes->isNotEmpty()) @foreach($lotInternalNotes as $note) @php $firstInitial = strtoupper(substr($note->user->firstname ?? '', 0, 1)); $lastInitial = strtoupper(substr($note->user->lastname ?? '', 0, 1)); $initials = trim($firstInitial.$lastInitial); $canManageNote = $canLotsWrite && (int) ($note->user_id ?? 0) === (int) auth()->id(); @endphp

{{ $note->content }}

@if($canManageNote)
@csrf @method('PUT')
@endif
{{ $note->created_at->format('d/m/Y') }} @if($initials !== '') {{ $initials }} @endif {{ $note->user?->firstname }} {{ $note->user?->lastname }} @if($canManageNote) @endif
@if($canManageNote) @endif @endforeach @endif
@include('modals.detach-annexe') @include('modals.cannot-detach-annexe') @include('modals.detach-annexe') @include('modals.cannot-detach-annexe') @endsection