143 lines
5.9 KiB
PHP
143 lines
5.9 KiB
PHP
<div class="netgescon-card">
|
|
<div class="netgescon-card-header flex justify-between items-center">
|
|
<h3 class="card-title mb-0"><i class="mdi mdi-link-variant me-2"></i> Mapping Unità e Anagrafiche</h3>
|
|
<div class="flex gap-2">
|
|
<a href="#unita" class="netgescon-btn netgescon-btn-sm netgescon-btn-outline-secondary" onclick="window.showGesconTab && window.showGesconTab('unita'); return false;">
|
|
<i class="mdi mdi-home-variant"></i> Vai a Unità
|
|
</a>
|
|
<button type="button" class="netgescon-btn netgescon-btn-sm netgescon-btn-outline-secondary" onclick="location.reload()">
|
|
<i class="mdi mdi-refresh"></i> Aggiorna
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="netgescon-card-body">
|
|
<!-- Filtri -->
|
|
<form id="unita-mapping-filters" class="grid grid-cols-1 md:grid-cols-5 gap-3 mb-3">
|
|
<div>
|
|
<label class="netgescon-label">Stabile</label>
|
|
<select class="netgescon-input">
|
|
<option value="">Tutti</option>
|
|
@foreach(($stabili ?? []) as $s)
|
|
<option value="{{ $s->id }}">{{ $s->denominazione ?? $s->codice_stabile }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="netgescon-label">Tipo</label>
|
|
<select class="netgescon-input">
|
|
<option value="">Tutti</option>
|
|
<option value="abitazione">Abitazione</option>
|
|
<option value="cantina">Cantina</option>
|
|
<option value="box">Box</option>
|
|
<option value="negozio">Negozio</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="netgescon-label">Scala</label>
|
|
<input type="text" class="netgescon-input" placeholder="A" />
|
|
</div>
|
|
<div>
|
|
<label class="netgescon-label">Interno</label>
|
|
<input type="text" class="netgescon-input" placeholder="es. 12 o CAN5" />
|
|
</div>
|
|
<div class="flex items-end">
|
|
<button type="button" class="netgescon-btn netgescon-btn-primary w-full">
|
|
<i class="mdi mdi-filter"></i> Filtra
|
|
</button>
|
|
</div>
|
|
</form>
|
|
|
|
<!-- Dual-pane mapping (legacy vs dominio) -->
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
<!-- Sorgente Legacy -->
|
|
<div class="netgescon-card p-0">
|
|
<div class="p-3 border-b"><strong>Sorgente (GESCON)</strong></div>
|
|
<div class="p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-sm table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Stabile</th>
|
|
<th>Scala</th>
|
|
<th>Interno</th>
|
|
<th>Proprietario</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@forelse(($legacyUnita ?? []) as $r)
|
|
<tr data-key="{{ $r->cod_stabile }}|{{ $r->scala }}|{{ $r->interno }}">
|
|
<td>{{ $r->cod_stabile }}</td>
|
|
<td>{{ $r->scala }}</td>
|
|
<td>{{ $r->interno }}</td>
|
|
<td>{{ trim(($r->cognome ?? '').' '.($r->nome ?? '')) }}</td>
|
|
</tr>
|
|
@empty
|
|
<tr><td colspan="4" class="text-center text-gray-500">Nessun dato sorgente disponibile</td></tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Destinazione Dominio -->
|
|
<div class="netgescon-card p-0">
|
|
<div class="p-3 border-b flex items-center justify-between">
|
|
<strong>Destinazione (NetGescon)</strong>
|
|
<div class="text-xs text-slate-500">Salvataggio per-stabile</div>
|
|
</div>
|
|
<div class="p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-sm table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Codice Unità</th>
|
|
<th>Scala</th>
|
|
<th>Interno</th>
|
|
<th>Proprietario (se noto)</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@forelse(($unita ?? []) as $u)
|
|
<tr>
|
|
<td><span class="netgescon-badge netgescon-badge-secondary">{{ $u->codice_unita ?? '—' }}</span></td>
|
|
<td>{{ $u->scala ?? '—' }}</td>
|
|
<td>{{ $u->interno ?? '—' }}</td>
|
|
@php $ownersCollection = ($u->proprietari instanceof \Illuminate\Support\Collection) ? $u->proprietari : collect($u->proprietari); $firstOwner = $ownersCollection->first(); @endphp
|
|
<td>{{ $firstOwner->cognome ?? '—' }}</td>
|
|
</tr>
|
|
@empty
|
|
<tr><td colspan="4" class="text-center text-gray-500">Nessuna unità presente</td></tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Azioni -->
|
|
<form class="mt-3 flex items-center gap-2" method="post" action="{{ route('admin.gescon-import.mapping.save') }}" onsubmit="return prepareUnitaMapping(event)">
|
|
@csrf
|
|
<input type="hidden" name="_mapping_only" value="1">
|
|
<input type="hidden" name="_legacy_code" value="{{ request('legacy_code') }}">
|
|
<input type="hidden" name="unita_mapping" id="unita_mapping" value="{}">
|
|
<button type="submit" class="netgescon-btn netgescon-btn-primary">
|
|
<i class="mdi mdi-content-save"></i> Salva mapping Unità/Anagrafiche
|
|
</button>
|
|
<button type="button" class="netgescon-btn netgescon-btn-outline-primary" onclick="alert('Preset in arrivo: useremo suggerimenti per scala/interno, proprietari/inquilini')">
|
|
<i class="mdi mdi-auto-fix"></i> Applica preset suggeriti
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function prepareUnitaMapping(e){
|
|
try{
|
|
// Segnaposto: salviamo un flag abilitazione; in step successivo saranno aggiunti i campi specifici
|
|
document.getElementById('unita_mapping').value = JSON.stringify({ enabled: true });
|
|
return true;
|
|
}catch(err){ e.preventDefault(); alert('Errore'); return false; }
|
|
}
|
|
</script>
|