@extends('layouts.base') @section('content') @section('breadcrumb') @endsection @if(session('success')) @endif @if(session('error')) @endif @if ($errors->any()) @endif

@if(isset($lot)) Modifier le lot {{ $lot->number }} @else Ajouter un lot @endif

Renseignez les informations du lot

@if(isset($lot)) {{ $lot->slug }} @if($lot->type) {{ $lot->type->label() }} @endif Fiche lot @endif
Annuler
@csrf @if(isset($lot)) @method('PUT') @endif @php $genderFieldIdPrefix = 'gender_lot_' . ($lot?->id ?? 'create'); $selectedGender = old('gender', $lot?->gender?->value ?? 'appartement'); @endphp
@foreach(\App\Enums\ProductType::genderTypes() as $genderType) value ? 'checked' : '' }}> @endforeach
Facultatif
@php $defaultLotStateValue = \App\Enums\ProductState::LIBRE->value; $selectableLotStateValues = array_map( fn (\App\Enums\ProductState $s) => $s->value, \App\Enums\ProductState::selectableCases(), ); $resolvedLotStateValue = $defaultLotStateValue; if (isset($lot)) { $latestLotState = $lot->states->sortByDesc('created_at')->first(); if ($latestLotState && $latestLotState->type) { $persistedStateValue = $latestLotState->type instanceof \BackedEnum ? $latestLotState->type->value : (string) $latestLotState->type; if (in_array($persistedStateValue, $selectableLotStateValues, true)) { $resolvedLotStateValue = $persistedStateValue; } } } @endphp
@if(isset($lot) && auth()->user() && auth()->user()->isRole('ROLE_SUPPORT'))
Laisser vide pour recalculer à partir du numéro de lot. Valeur rendue unique dans le programme si besoin.
@endif
Surfaces
@php $lotMainSurfaceTypeCases = [ \App\Enums\SurfaceType::HABITABLE, \App\Enums\SurfaceType::CARREZ, \App\Enums\SurfaceType::TOTALE, \App\Enums\SurfaceType::SURFACE_180, ]; $lotMainSurfaceLabels = [ \App\Enums\SurfaceType::HABITABLE->value => 'Habitable (m²)', \App\Enums\SurfaceType::CARREZ->value => 'Carrez (m²)', \App\Enums\SurfaceType::TOTALE->value => 'Totale (m²)', \App\Enums\SurfaceType::SURFACE_180->value => 'Sous 1m80 (m²)', ]; $lotSurfacesExceptMain = isset($lot) && $lot->surfaces ? $lot->surfaces->filter(fn ($s) => ! in_array($s->type, $lotMainSurfaceTypeCases, true))->values() : collect(); @endphp
@foreach($lotMainSurfaceTypeCases as $mainSurfaceIdx => $mainSurfaceType) @php $mainSurfaceRow = isset($lot) ? $lot->surfaces->first(fn ($s) => $s->type === $mainSurfaceType) : null; @endphp
@if($mainSurfaceRow) @endif
@endforeach
Orientations
@php $existingOrientations = isset($lot) ? $lot->orientations->pluck('type')->map(fn($o) => $o->value)->toArray() : []; $orientationFieldIdPrefix = 'orientation_lot_' . ($lot?->id ?? 'create'); @endphp
@foreach(\App\Enums\Orientation::selectableCases() as $orientation) value, old('orientations', $existingOrientations)) ? 'checked' : '' }}> @endforeach
Fiscalités
@php $allFiscaliteCases = \App\Enums\Fiscalite::selectableCases(); $lotFiscaliteValues = isset($lot) ? $lot->fiscalites->pluck('type')->map(fn ($t) => $t->value)->toArray() : []; $oldFiscalites = old('fiscalites'); $selectedFiscalites = is_array($oldFiscalites) ? $oldFiscalites : (isset($lot) ? $lotFiscaliteValues : $programFiscaliteValues); @endphp
@foreach($allFiscaliteCases as $case) @php $isAllowedForLotProgram = in_array($case->value, $programFiscaliteValues, true); $isChecked = in_array($case->value, $selectedFiscalites, true); $inputId = 'lot-fiscalite-' . $case->value; @endphp
@endforeach
{{--
Descriptions
@foreach(\App\Enums\DescriptionLotType::selectableCases() as $descType)
@php $existingDesc = isset($lot) ? $lot->descriptions->firstWhere('type', $descType->value) : null; @endphp @if($existingDesc) @endif
@endforeach --}} {{--
is_active ?? true) ? 'checked' : '' }}>
--}}
Éligible TVA 5,5%
@php $tva55EligibleOld = old('tva_55_eligible'); $existingTva55ForEligibility = isset($lot) ? $lot->prices->firstWhere('type', \App\Enums\PriceType::PRIX_IMMO_TTC_5_5->value) : null; $tva55EligibleDefault = isset($lot) ? (bool) $existingTva55ForEligibility?->value : false; $tva55Eligible = $tva55EligibleOld !== null ? (bool) $tva55EligibleOld : $tva55EligibleDefault; $selectedFiscalitesForVisibility = old('fiscalites', isset($lot) ? $lot->fiscalites?->pluck('type')->map(fn ($t) => $t->value)->all() : []); $selectedFiscalitesForVisibility = is_array($selectedFiscalitesForVisibility) ? $selectedFiscalitesForVisibility : []; $lotFormFieldVisibility = \App\Services\LotFormFieldVisibility::forSelectedFiscaliteValuesAndTva55Eligible( $selectedFiscalitesForVisibility, (bool) $tva55Eligible ); @endphp
Prix du lot
@php $immoPriceTypes = collect(\App\Enums\PriceType::selectableCases()) ->filter(fn($priceType) => $priceType->choosable('immo_choosable')); @endphp
@foreach($immoPriceTypes as $index => $priceType) @php $existingImmoPrice = isset($lot) ? $lot->prices->firstWhere('type', $priceType->value) : null; $immoPriceDisabled = ( ($priceType === \App\Enums\PriceType::PRIX_IMMO_TTC && ! $lotFormFieldVisibility->showPrixImmoTtc) || ($priceType === \App\Enums\PriceType::PRIX_IMMO_HT && ! $lotFormFieldVisibility->showPrixImmoHt) || ($priceType === \App\Enums\PriceType::PRIX_MOBILIER_TTC && ! $lotFormFieldVisibility->showPrixMobilierTtc) || (($priceType === \App\Enums\PriceType::PRIX_TVA_IMMO || $priceType === \App\Enums\PriceType::PRIX_MOBILIER_HT || $priceType === \App\Enums\PriceType::PRIX_TVA_MOBILIER) && ! $lotFormFieldVisibility->showPrixTvaImmo) || $priceType === \App\Enums\PriceType::PRIX_IMMO_TTC_10 || $priceType === \App\Enums\PriceType::PRIX_IMMO_TTC_5_5 ); @endphp
@if($existingImmoPrice) @endif
@endforeach
Prix foncier
@php $foncierPriceTypes = collect(\App\Enums\PriceType::selectableCases()) ->filter(fn($priceType) => $priceType->choosable('foncier_choosable')); @endphp
@foreach($foncierPriceTypes as $index => $priceType) @php $existingFoncierPrice = isset($lot) ? $lot->prices->firstWhere('type', $priceType->value) : null; $foncierLabel = $priceType === \App\Enums\PriceType::PRIX_FONCIER_TTC ? 'Foncier TTC' : $priceType->label(); @endphp
@if($existingFoncierPrice) @endif
@endforeach
Prix des travaux
@php $travauxPriceTypes = collect(\App\Enums\PriceType::selectableCases()) ->filter(fn($priceType) => in_array($priceType->value, ['prix_travaux_eligible', 'prix_travaux_non_eligible'])); @endphp
@foreach($travauxPriceTypes as $index => $priceType) @php $existingTravauxPrice = isset($lot) ? $lot->prices->firstWhere('type', $priceType->value) : null; $readOnlyKey = 'travaux_prices.'.$index.'.read_only'; $readOnlyValue = old( $readOnlyKey, $existingTravauxPrice ? ($existingTravauxPrice->read_only ? 1 : 0) : 1 ); $travauxLabel = $priceType === \App\Enums\PriceType::PRIX_TRAVAUX_ELIGIBLE ? 'Prix travaux éligibles' : 'Prix travaux non-éligibles'; @endphp
@if($existingTravauxPrice) @endif
@endforeach
Loyer
@php $mensuelTtcPriceType = \App\Enums\PriceTypeLoyer::MENSUEL_TTC; $mensuelHtPriceType = \App\Enums\PriceTypeLoyer::MENSUEL_HT; $mensuelPlafonneDispositifFiscalPriceType = \App\Enums\PriceTypeLoyer::MENSUEL_PLAFONNE_DISPOSITIF_FISCAL; $mensuelSocialJeanBrunPriceType = \App\Enums\PriceTypeLoyer::MENSUEL_SOCIAL_JEAN_BRUN; $mensuelTresSocialJeanBrunPriceType = \App\Enums\PriceTypeLoyer::MENSUEL_TRES_SOCIAL_JEAN_BRUN; $rentalPriceIndexTtc = 0; $rentalPriceIndexHt = 1; $rentalPriceIndexPlafonneDispositifFiscal = 2; $rentalPriceIndexSocialJeanBrun = 3; $rentalPriceIndexTresSocialJeanBrun = 4; $existingMensuelTtcRentalPrice = isset($lot) ? $lot->prices->firstWhere('type', $mensuelTtcPriceType->value) : null; $existingMensuelHtRentalPrice = isset($lot) ? $lot->prices->firstWhere('type', $mensuelHtPriceType->value) : null; $existingMensuelPlafonneDispositifFiscalRentalPrice = isset($lot) ? $lot->prices->firstWhere('type', $mensuelPlafonneDispositifFiscalPriceType->value) : null; $existingMensuelSocialJeanBrunRentalPrice = isset($lot) ? $lot->prices->firstWhere('type', $mensuelSocialJeanBrunPriceType->value) : null; $existingMensuelTresSocialJeanBrunRentalPrice = isset($lot) ? $lot->prices->firstWhere('type', $mensuelTresSocialJeanBrunPriceType->value) : null; $mensuelTtcReadOnlyKey = 'rental_prices.'.$rentalPriceIndexTtc.'.read_only'; $mensuelTtcReadOnlyValue = old($mensuelTtcReadOnlyKey, $existingMensuelTtcRentalPrice && $existingMensuelTtcRentalPrice->read_only ? 1 : 0); $mensuelHtReadOnlyKey = 'rental_prices.'.$rentalPriceIndexHt.'.read_only'; $mensuelHtReadOnlyValue = old($mensuelHtReadOnlyKey, $existingMensuelHtRentalPrice && $existingMensuelHtRentalPrice->read_only ? 1 : 0); $mensuelPlafonneDispositifFiscalReadOnlyKey = 'rental_prices.'.$rentalPriceIndexPlafonneDispositifFiscal.'.read_only'; $mensuelPlafonneDispositifFiscalReadOnlyValue = old($mensuelPlafonneDispositifFiscalReadOnlyKey, $existingMensuelPlafonneDispositifFiscalRentalPrice && $existingMensuelPlafonneDispositifFiscalRentalPrice->read_only ? 1 : 0); $mensuelSocialJeanBrunReadOnlyKey = 'rental_prices.'.$rentalPriceIndexSocialJeanBrun.'.read_only'; $mensuelSocialJeanBrunReadOnlyValue = old($mensuelSocialJeanBrunReadOnlyKey, $existingMensuelSocialJeanBrunRentalPrice && $existingMensuelSocialJeanBrunRentalPrice->read_only ? 1 : 0); $mensuelTresSocialJeanBrunReadOnlyKey = 'rental_prices.'.$rentalPriceIndexTresSocialJeanBrun.'.read_only'; $mensuelTresSocialJeanBrunReadOnlyValue = old($mensuelTresSocialJeanBrunReadOnlyKey, $existingMensuelTresSocialJeanBrunRentalPrice && $existingMensuelTresSocialJeanBrunRentalPrice->read_only ? 1 : 0); @endphp
showLoyerMensuelTtc) disabled @endif> @if($existingMensuelTtcRentalPrice) showLoyerMensuelTtc) disabled @endif> @endif showLoyerMensuelTtc) disabled @endif > showLoyerMensuelTtc) disabled @endif >
showLoyerMensuelHt) disabled @endif> @if($existingMensuelHtRentalPrice) showLoyerMensuelHt) disabled @endif> @endif showLoyerMensuelHt) disabled @endif > showLoyerMensuelHt) disabled @endif >
showLoyerMensuelPlafonneDispositifFiscal) disabled @endif> @if($existingMensuelPlafonneDispositifFiscalRentalPrice) showLoyerMensuelPlafonneDispositifFiscal) disabled @endif> @endif showLoyerMensuelPlafonneDispositifFiscal) disabled @endif > showLoyerMensuelPlafonneDispositifFiscal) disabled @endif >
showLoyerJeanBrunNeufAncienSocialLoyers) disabled @endif> @if($existingMensuelSocialJeanBrunRentalPrice) showLoyerJeanBrunNeufAncienSocialLoyers) disabled @endif> @endif showLoyerJeanBrunNeufAncienSocialLoyers) disabled @endif > showLoyerJeanBrunNeufAncienSocialLoyers) disabled @endif >
showLoyerJeanBrunNeufAncienSocialLoyers) disabled @endif> @if($existingMensuelTresSocialJeanBrunRentalPrice) showLoyerJeanBrunNeufAncienSocialLoyers) disabled @endif> @endif showLoyerJeanBrunNeufAncienSocialLoyers) disabled @endif > showLoyerJeanBrunNeufAncienSocialLoyers) disabled @endif >
Charges
@php $chargePriceTypes = \App\Enums\PriceTypeCharge::selectableCases(); @endphp
@foreach($chargePriceTypes as $index => $priceType) @php $existingChargePrice = isset($lot) ? $lot->prices->firstWhere('type', $priceType->value) : null; $readOnlyKey = 'charge_prices.'.$index.'.read_only'; $readOnlyValue = old($readOnlyKey, $existingChargePrice && $existingChargePrice->read_only ? 1 : 0); @endphp
@if($existingChargePrice) @endif
@endforeach
Autres frais
@php $fraisPriceTypes = collect(\App\Enums\PriceTypeFrais::selectableCases()) ->filter(fn($priceType) => $priceType->choosable('frais_choosable')); @endphp
@foreach($fraisPriceTypes as $index => $priceType) @php $existingFraisPrice = isset($lot) ? $lot->prices->firstWhere('type', $priceType->value) : null; $readOnlyKey = 'frais_prices.'.$index.'.read_only'; $readOnlyValue = old($readOnlyKey, $existingFraisPrice && $existingFraisPrice->read_only ? 1 : 0); $hideFraisGerance = $priceType === \App\Enums\PriceTypeFrais::FRAIS_GERANCE && !$lotFormFieldVisibility->showFraisGerance; @endphp
@if($existingFraisPrice) @endif
@endforeach
{{--
Surfaces du lot
@if($lotSurfacesExceptMain->isNotEmpty()) @foreach($lotSurfacesExceptMain as $offset => $surface) @php $surfaceIndex = $offset + 4; @endphp
@endforeach @endif
Annexes du lot
@if(isset($lot) && $lot->annexes->count() > 0) @foreach($lot->annexes as $annexeIndex => $existingAnnexe)
{{ $existingAnnexe->type->label() }}
Numéro d'identification de l'annexe
@php $annexeSurface = $existingAnnexe->surfaces->first(); @endphp @if($annexeSurface) @endif
@if($existingAnnexe->type->priceable())
@php $salePrices = $existingAnnexe->prices->filter(function($price) { return in_array($price->type, ['prix_ht', 'prix_ttc', 'prix_tva_5_5', 'prix_tva_10']); })->values(); $salePriceIdx = 0; @endphp @foreach($salePrices as $price)
@php $readOnlyKey = 'annexes_items.'.$annexeIndex.'.prices.'.$salePriceIdx.'.read_only'; $readOnlyValue = old($readOnlyKey, $price->read_only ? 1 : 0); @endphp
@php $salePriceIdx++; @endphp @endforeach
@endif @if($existingAnnexe->type->rentable())
@php $rentalPrices = $existingAnnexe->prices->filter(function($price) { return in_array($price->type, ['mensuel_garage', 'mensuel_parking', 'mensuel_ttc', 'mensuel_ht', 'mensuel_denormandie_ttc', 'mensuel_denormandie_ht']); })->values(); $rentalIndex = 0; @endphp @foreach($rentalPrices as $price)
@php $rentalIndex++; @endphp @endforeach
@endif
@endforeach @endif
@foreach(\App\Enums\ProductType::annexeTypes() as $annexeType) @endforeach
Documents PDF
@if(isset($lot) && $lot->documents->count() > 0)
@endif
Vous pouvez sélectionner plusieurs fichiers à la fois
--}} @if(isset($formEditor) && $formEditor && $formEditor->fields->count() > 0)
Champs personnalisés

Ces champs sont spécifiques à cette application. Ils ne concernent pas l’affichage sur le site de diffusion (gestion interne uniquement).

@foreach($formEditor->fields as $field)
@php $fieldName = $field->name ?? 'field_' . $field->id; $fieldLabel = $field->label ?? $field->type->label(); $fieldValue = old('custom_fields.' . $fieldName); if ($fieldValue === null && $field->data && isset($field->data->json['value'])) { $fieldValue = $field->data->json['value']; } @endphp @if($field->description) {{ $field->description }} @endif @if($field->type === \App\Enums\FieldType::TEXT) @elseif($field->type === \App\Enums\FieldType::CHECKBOX)
@elseif($field->type === \App\Enums\FieldType::NUMBER) @elseif($field->type === \App\Enums\FieldType::DATE) @endif
@endforeach
@endif
@include('modals.lot-assistant') {{-- Confirmation lors du retrait d'une fiscalité sur le lot (impact champs masqués / supprimés) --}} @endsection