visualizzazione e gestione firme e lista firme con ACL

This commit is contained in:
2025-09-05 15:35:03 +02:00
parent 835e123444
commit 9b7f845414
5 changed files with 606 additions and 39 deletions

View File

@ -1,44 +1,85 @@
<?php
\defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
/** @var \Pcrt\Component\Circolari\Site\View\Circolare\HtmlView $this */
$item = $this->item;
dump($item);
$app = Factory::getApplication();
$input = $app->getInput();
$buttons = $this->getModel()->getBottoniFirma((int)$item->tipologia_firma_id);
dump($this->getModel()->currentUser);
// Prendo dati dalla view con fallback ai getter
$items = $this->items ?? ($this->get('Items') ?? []);
$pagination = $this->pagination ?? ($this->get('Pagination') ?? null);
// Normalizzo items
if (!is_array($items)) { $items = (array) $items; }
$items = array_values(array_filter($items, static fn($it) => is_object($it) && !empty($it->id)));
$Itemid = (int) $input->getInt('Itemid', 0);
?>
<div class="circolari-list">
<div class="container my-5 mega-container">
<div class="row mb-4 align-items-end">
<div class="col-md-9 col-12">
<h1 class="h2 mb-1"><?= $this->escape($item->title); ?></h1>
</div>
<div class="col-md-3 col-12 text-md-end mt-2 mt-md-0">
<a href="#" class="small text-decoration-none text-uppercase fw-bold">Condividi</a>
<?php if (!count($items)) : ?>
<div class="alert alert-info">
<span class="icon-info-circle" aria-hidden="true"></span>
<span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
<?php echo Text::_('COM_CIRCOLARI_NO_ITEMS') ?: 'Nessuna circolare'; ?>
</div>
<?php if ( $item->firma_obbligatoria && !empty($buttons)) : ?>
<div class="mt-4">
<div class="d-flex flex-wrap gap-2">
<?php foreach ($buttons as $btn) : ?>
<button type="button" class="btn btn-primary btn-sm">
<?php echo htmlspecialchars($btn->label, ENT_QUOTES, 'UTF-8'); ?>
</button>
<?php else : ?>
<table class="table table-striped table-bordered table-hover">
<caption class="visually-hidden"><?php echo Text::_('COM_CIRCOLARI_ELENCO') ?: 'Elenco circolari'; ?></caption>
<thead class="visually-hidden">
<tr>
<th scope="col">Titolo</th>
<th scope="col" class="text-end">Visite</th>
</tr>
</thead>
<tbody>
<?php foreach ($items as $i => $item) : ?>
<?php
$url = Route::_(
'index.php?option=com_circolari&view=circolare'
. '&id=' . (int) $item->id
. '&catid=' . (int) ($item->catid ?? 0)
. ($Itemid ? '&Itemid=' . $Itemid : '')
);
$title = $item->title ?? ('#' . (int) $item->id);
$hits = isset($item->hits) ? (int) $item->hits : null;
?>
<tr class="cat-list-row<?php echo $i % 2; ?>">
<th class="list-title" scope="row">
<a href="<?php echo $url; ?>">
<?php echo htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?>
</a>
</th>
<td class="text-end">
<?php if ($hits !== null) : ?>
<span class="btn btn-secondary btn-sm disabled" aria-disabled="true">
<?php echo Text::_('JGLOBAL_HITS') ?: 'Visite'; ?>: <?php echo $hits; ?>
</span>
<?php else : ?>
<span class="text-muted">—</span>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<div class="article-body mt-3">
<?php echo $item->description ?: $item->testo ?: $item->descrizione ?: '<em>(Nessun testo)</em>'; ?>
</div>
</div>
</tbody>
</table>
<?php endif; ?>
</div>
<?php if ($pagination && (int) $pagination->pagesTotal > 1) : ?>
<div class="com-content-category__navigation w-100">
<div class="d-flex align-items-center mt-2">
<div class="flex-grow-1 d-flex justify-content-center">
<?php echo $pagination->getPagesLinks(); ?>
</div>
<p class="com-content-category__counter counter mb-0 ps-3">
<?php echo $pagination->getPagesCounter(); ?>
</p>
</div>
</div>
<?php endif; ?>
</div>