netgescon-day0/resources/views/filament/pages/contabilita/voci-spesa-prospetto.blade.php

173 lines
10 KiB
PHP
Executable File

<x-filament-panels::page>
<div class="space-y-3">
<div class="rounded-lg border overflow-hidden">
<div class="bg-danger-600 px-4 py-3">
<div class="text-white text-sm font-semibold">Voci di spesa</div>
</div>
<div class="bg-warning-50 px-4 py-4 space-y-2">
<div class="flex flex-wrap items-center justify-between gap-3">
@php
$tabs = [
'ordinaria' => 'ORDINARIE',
'acqua' => 'ACQUA',
'riscaldamento' => 'RISCALDAMENTO',
'straordinaria' => 'STRAORDINARIE',
];
@endphp
<div class="flex flex-wrap gap-2">
@foreach($tabs as $key => $label)
@php
$active = ($this->tipoGestioneTab ?? 'ordinaria') === $key;
$btnClass = $active
? 'fi-btn fi-btn-color-primary fi-btn-size-sm'
: 'fi-btn fi-btn-color-gray fi-btn-size-sm';
@endphp
<button
type="button"
wire:click="setTipoGestioneTab('{{ $key }}')"
class="{{ $btnClass }}"
>
{{ $label }}
</button>
@endforeach
</div>
<div class="flex flex-wrap items-center gap-3">
<div class="flex items-center gap-2">
<div class="text-xs font-medium text-gray-700">Anno</div>
<select
wire:model.live="gestioneContabileId"
class="fi-input fi-input-wrp fi-select-input text-xs"
>
<option value="">Tutte</option>
@foreach($this->getGestioniOptions() as $id => $label)
<option value="{{ $id }}">{{ $label }}</option>
@endforeach
</select>
</div>
<div class="flex items-center gap-2">
<div class="text-xs font-medium text-gray-700">Preset ripartizione</div>
<select
wire:model.live="presetRipartizione"
class="fi-input fi-input-wrp fi-select-input text-xs"
>
<option value="manuale">Manuale</option>
<option value="confedilizia">Confedilizia</option>
</select>
</div>
<label class="flex items-center gap-2 text-xs font-medium text-gray-700">
<input type="checkbox" wire:model.live="hideFirstTwoTabelle" class="fi-checkbox-input">
Nascondi prime 2 tabelle
</label>
</div>
</div>
<div class="rounded-lg border bg-white text-[12px] leading-tight [&_th]:py-1.5 [&_td]:py-1.5 [&_.fi-ta-cell]:py-1 [&_.fi-ta-actions]:gap-1 [&_.fi-ta-actions]:whitespace-nowrap">
{{ $this->table }}
</div>
@php($tabellaOptions = $this->getTabelleMillesimaliOptions())
@php($focus = $this->getDettaglioTabellaFocus())
@if(!empty($tabellaOptions))
<div class="rounded-lg border bg-white px-3 py-2">
<div class="flex flex-wrap items-center justify-between gap-2">
<div class="text-xs font-semibold text-gray-700">Dettaglio tabella</div>
<div class="flex items-center gap-2">
<div class="text-xs text-gray-600">Tabella</div>
<select wire:model.live="tabellaFocusId" class="fi-input fi-input-wrp fi-select-input text-xs">
@foreach($tabellaOptions as $id => $label)
<option value="{{ $id }}">{{ $label }}</option>
@endforeach
</select>
</div>
</div>
<div class="mt-2 rounded-md border bg-gray-50 px-3 py-2 text-xs flex flex-wrap items-center justify-between gap-2">
<div class="text-gray-700 font-semibold">{{ $focus['label'] ?? '—' }}</div>
<div class="flex flex-wrap gap-4">
<div><span class="text-gray-500">Voci:</span> <span class="font-semibold">{{ (int) ($focus['count'] ?? 0) }}</span></div>
<div><span class="text-gray-500">Totale Prev:</span> <span class="font-semibold">{{ number_format((float) ($focus['totale_prev'] ?? 0), 2, ',', '.') }}</span></div>
<div><span class="text-gray-500">Totale Cons:</span> <span class="font-semibold">{{ number_format((float) ($focus['totale_cons'] ?? 0), 2, ',', '.') }}</span></div>
</div>
</div>
@php($voci = is_array($focus['voci'] ?? null) ? $focus['voci'] : [])
<div class="mt-2 overflow-x-auto">
<table class="min-w-full text-[12px] leading-tight">
<thead class="text-[11px] text-gray-500">
<tr class="border-b">
<th class="py-2 pr-3 text-left">Cod.</th>
<th class="py-2 pr-3 text-left">Descrizione</th>
<th class="py-2 pr-3 text-right">Prev</th>
<th class="py-2 pr-3 text-right">Cons</th>
<th class="py-2 pr-3 text-right">%Prop</th>
<th class="py-2 pr-3 text-right">%Inq</th>
<th class="py-2 pr-0 text-right">Attiva</th>
</tr>
</thead>
<tbody class="divide-y">
@forelse($voci as $v)
@php($code = (string) ($v['codice'] ?? ''))
@php($desc = (string) ($v['descrizione'] ?? ''))
<tr>
<td class="py-1.5 pr-3 text-gray-700 font-semibold">{{ $code !== '' ? $code : '—' }}</td>
<td class="py-1.5 pr-3 text-gray-700">{{ $desc !== '' ? $desc : '—' }}</td>
<td class="py-1.5 pr-3 text-right">{{ number_format((float) ($v['prev'] ?? 0), 2, ',', '.') }}</td>
<td class="py-1.5 pr-3 text-right">{{ number_format((float) ($v['cons'] ?? 0), 2, ',', '.') }}</td>
<td class="py-1.5 pr-3 text-right">{{ number_format((float) ($v['prop'] ?? 0), 2, ',', '.') }}</td>
<td class="py-1.5 pr-3 text-right">{{ number_format((float) ($v['inq'] ?? 0), 2, ',', '.') }}</td>
<td class="py-1.5 pr-0 text-right">{{ !empty($v['attiva']) ? 'Sì' : 'No' }}</td>
</tr>
@empty
<tr>
<td colspan="7" class="py-3 text-gray-500">Nessuna voce associata alla tabella selezionata.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
@endif
<div class="flex items-center justify-end">
<div class="rounded-lg border bg-white px-3 py-2 text-xs flex gap-4">
<div>
<span class="text-gray-500">Totale Prev:</span>
<span class="font-semibold">{{ number_format((float) $this->getTotalePreventivo(), 2, ',', '.') }}</span>
</div>
<div>
<span class="text-gray-500">Totale Cons:</span>
<span class="font-semibold">{{ number_format((float) $this->getTotaleConsuntivo(), 2, ',', '.') }}</span>
</div>
@if(($this->tipoGestioneTab ?? 'ordinaria') !== 'acqua' && ((float) $this->getTotalePreventivoAcqua() > 0 || (float) $this->getTotaleConsuntivoAcqua() > 0))
<div>
<span class="text-gray-500">ACQUA Prev:</span>
<span class="font-semibold">{{ number_format((float) $this->getTotalePreventivoAcqua(), 2, ',', '.') }}</span>
</div>
<div>
<span class="text-gray-500">ACQUA Cons:</span>
<span class="font-semibold">{{ number_format((float) $this->getTotaleConsuntivoAcqua(), 2, ',', '.') }}</span>
</div>
<div>
<span class="text-gray-500">Totale Gen. Prev:</span>
<span class="font-semibold">{{ number_format((float) $this->getTotalePreventivoGenerale(), 2, ',', '.') }}</span>
</div>
<div>
<span class="text-gray-500">Totale Gen. Cons:</span>
<span class="font-semibold">{{ number_format((float) $this->getTotaleConsuntivoGenerale(), 2, ',', '.') }}</span>
</div>
@endif
</div>
</div>
</div>
</div>
</div>
</x-filament-panels::page>