customerQueries = $customerQueries; } public function mount(int $customer): void { $this->authorize('customers.use'); abort_if($this->customerQueries->findSummary($customer) === null, 404); $this->customerId = $customer; } #[Computed] public function customer(): CustomerSummary { return $this->customerQueries->findSummary($this->customerId) ?? abort(404); } /** * The personal identity code as this user may see it: in full for admins * and management, masked for others. Computed, so the full code is never * kept in the component state sent to the browser. */ #[Computed] public function personalIdentityCode(): ?string { if (Gate::allows('customers.view-personal-identity-code')) { return $this->customerQueries->personalIdentityCodeOf($this->customerId); } return $this->customer->personalIdentityCodeMasked; } /** * @return list */ #[Computed] public function contacts(): array { return $this->customerQueries->contactsOf($this->customerId); } /** * @return list */ #[Computed] public function billingUnits(): array { return $this->customerQueries->billingUnitsOf($this->customerId); } /** * Opens the remove dialog for a contact or a billing unit of this customer. */ public function confirmRemoval(string $type, int $id): void { $this->authorize('customers.use'); $name = match ($type) { 'contact' => $this->customerQueries->findContact($this->customerId, $id)?->name, 'billing_unit' => $this->customerQueries->findBillingUnit($this->customerId, $id)?->name, default => null, }; if ($name === null) { $this->statusMessage = __('customers.removal.already_removed'); return; } $this->removalType = $type; $this->removalId = $id; $this->removalName = $name; $this->statusMessage = ''; $this->js("document.getElementById('".self::REMOVE_DIALOG."').showModal()"); } public function remove(RemoveContact $removeContact, RemoveBillingUnit $removeBillingUnit): void { $this->authorize('customers.use'); if ($this->removalType === null || $this->removalId === null) { return; } try { match ($this->removalType) { 'contact' => $removeContact->execute($this->customerId, $this->removalId), 'billing_unit' => $removeBillingUnit->execute($this->customerId, $this->removalId), }; $this->statusMessage = __('customers.removal.removed_'.$this->removalType, ['name' => $this->removalName]); } catch (ContactNotFound|BillingUnitNotFound) { $this->statusMessage = __('customers.removal.already_removed'); } // The removed row's button is gone, so focus moves to its section heading. $heading = $this->removalType === 'contact' ? 'contacts-heading' : 'billing-units-heading'; $this->js("document.getElementById('".self::REMOVE_DIALOG."').close(); document.getElementById('{$heading}').focus()"); $this->reset('removalType', 'removalId', 'removalName'); } public function render(): mixed { return $this->view()->title($this->customer->name); } }; ?>

{{ $this->customer->name }}

@if (session('status')) @endif
{{ __('customers.fields.type') }}
{{ __('customers.types.'.$this->customer->type->value) }}
@if ($this->customer->businessId !== null)
{{ __('customers.fields.business_id') }}
{{ $this->customer->businessId }}
@endif @if ($this->customer->type === CustomerType::Consumer)
{{ __('customers.fields.personal_identity_code') }}
@if ($this->personalIdentityCode !== null) {{ $this->personalIdentityCode }} @else @endif
@endif

{{ $statusMessage }}

{{ __('customers.contacts.title') }}

@if ($this->contacts === [])

{{ __('customers.contacts.empty') }}

@else
    @foreach ($this->contacts as $contact)
  • {{ $contact->name }}

    @if ($contact->title !== null)

    {{ $contact->title }}

    @endif @if ($contact->phone !== null)

    {{ __('customers.contacts.fields.phone') }}: {{ $contact->phone }}

    @endif @if ($contact->email !== null)

    {{ __('customers.contacts.fields.email') }}: {{ $contact->email }}

    @endif @if ($contact->note !== null)

    {{ $contact->note }}

    @endif
  • @endforeach
@endif

{{ __('customers.billing_units.title') }}

@if ($this->billingUnits === [])

{{ __('customers.billing_units.empty') }}

@else
    @foreach ($this->billingUnits as $billingUnit)
  • {{ $billingUnit->name }}

    @if ($billingUnit->billingAddress !== null)
    {{ __('customers.billing_units.fields.billing_address') }}
    {{ $billingUnit->billingAddress }}
    @endif @if ($billingUnit->eInvoiceAddress !== null)
    {{ __('customers.billing_units.fields.e_invoice_address') }}
    {{ $billingUnit->eInvoiceAddress }}
    {{ __('customers.billing_units.fields.e_invoice_operator') }}
    {{ $billingUnit->eInvoiceOperator }}
    @endif @if ($billingUnit->reference !== null)
    {{ __('customers.billing_units.fields.reference') }}
    {{ $billingUnit->reference }}
    @endif
  • @endforeach
@endif

@if ($removalType !== null) {{ __('customers.removal.question_'.$removalType, ['name' => $removalName]) }} @endif