netgescon-day0/resources/views/admin/gescon-import/partials/menu.blade.php

106 lines
5.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- Menu in-page Gescon Import: sezioni principali sopra, sottomenu sotto (senza card wrapper) -->
<div class="flex flex-wrap items-center gap-2 mb-2 netgescon-mainmenu">
<!-- Main sections -->
<?php
$sections = [
'anagrafica' => ['label' => 'ANAGRAFICA', 'icon' => 'mdi mdi-book-account'],
'ordinaria' => ['label' => 'ORDINARIA', 'icon' => 'mdi mdi-clipboard-text'],
'riscaldamento' => ['label' => 'RISCALDAMENTO', 'icon' => 'mdi mdi-fire'],
'straordinarie' => ['label' => 'STRAORDINARIE', 'icon' => 'mdi mdi-hammer-wrench'],
'varie' => ['label' => 'VARIE', 'icon' => 'mdi mdi-dots-horizontal'],
'fiscali' => ['label' => 'FISCALI', 'icon' => 'mdi mdi-file-document'],
'utilita' => ['label' => 'UTILITA', 'icon' => 'mdi mdi-tools'],
];
$activeSection = request()->get('sec', 'anagrafica');
$activeItem = request()->get('item', 'stabili');
?>
<?php foreach($sections as $key => $s): ?>
<a href="<?= route('admin.gescon-import.index', array_merge(request()->query(), ['sec' => $key])) ?>"
class="netgescon-btn netgescon-btn-sm <?= $activeSection === $key ? 'netgescon-btn-primary' : 'netgescon-btn-outline-primary' ?>"
data-gescon-section="<?= $key ?>">
<i class="<?= $s['icon'] ?> me-1"></i><?= $s['label'] ?>
</a>
<?php endforeach; ?>
</div>
<!-- Submenu for ANAGRAFICA -->
<?php if(($activeSection ?? 'anagrafica') === 'anagrafica'): ?>
<div class="netgescon-submenu">
@php
$items = [
'stabili' => ['label' => 'Stabili', 'icon' => 'mdi mdi-home-group'],
'condomini' => ['label' => 'Condomini', 'icon' => 'mdi mdi-account-group'],
'comuni' => ['label' => 'Comuni', 'icon' => 'mdi mdi-city'],
'tabelle' => ['label' => 'Tabelle Millesimali', 'icon' => 'mdi mdi-table'],
'voci' => ['label' => 'Voci', 'icon' => 'mdi mdi-receipt'],
'amministratore' => ['label' => 'Amministratore', 'icon' => 'mdi mdi-account-tie'],
'fornitori' => ['label' => 'Fornitori', 'icon' => 'mdi mdi-store'],
// 'config' => ['label' => 'Configurazione Import', 'icon' => 'mdi mdi-cog'],
];
$onConfig = request()->routeIs('admin.gescon-import.config');
@endphp
@foreach($items as $key => $i)
@php
$isActive = ($key === 'config') ? $onConfig : ($activeItem === $key && !$onConfig);
$baseHref = ($key === 'config')
? route('admin.gescon-import.config')
: route('admin.gescon-import.index', array_merge(request()->query(), ['sec' => 'anagrafica', 'item' => $key]));
$hash = '';
if ($key === 'stabili') $hash = '#stabili';
if ($key === 'condomini') $hash = '#soggetti';
if ($key === 'fornitori') $hash = '#fornitori';
if ($key === 'comuni') $hash = '#comuni';
$href = $baseHref . $hash;
@endphp
@if($key !== 'config' || auth()->user()->can('gescon-import.config'))
<x-netgescon.submenu-pill :href="$href" :active="$isActive" :icon="$i['icon']"
data-gescon-item="{{ $key }}" data-gescon-hash="{{ $hash }}">
{{ $i['label'] }}
@if($key==='stabili')
<span class="ms-1 text-xs text-slate-500">({{ (int)($stats['stabili']['totali'] ?? ($stats['stabili_totali'] ?? 0)) }})</span>
@endif
</x-netgescon.submenu-pill>
@endif
@endforeach
</div>
<?php endif; ?>
<script>
// Enhance in-content menu: for Stabili/Condomini/Fornitori do full navigation to render server-side state; otherwise switch tab smoothly
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('[data-gescon-item]').forEach(function(a){
a.addEventListener('click', function(e){
var item = a.getAttribute('data-gescon-item');
var hash = a.getAttribute('data-gescon-hash') || '';
// Always allow navigation for config and for items that need server-rendered state
if (item === 'config' || item === 'stabili' || item === 'condomini' || item === 'fornitori') {
return; // default browser navigation
}
// For other items with a tab hash, switch tab without reload
if (hash) {
e.preventDefault();
var tabId = hash.replace('#','');
if (typeof window.showGesconTab === 'function') {
window.showGesconTab(tabId);
} else {
var tab = document.querySelector('#' + tabId + '-tab');
if (tab && window.bootstrap) {
new bootstrap.Tab(tab).show();
} else if (tab) {
tab.click();
}
}
// Update URL (query + hash) without reload
try {
var url = new URL(a.href, window.location.origin);
history.replaceState({}, '', url.pathname + url.search + hash);
} catch(_) {}
}
});
});
});
</script>