diff --git a/public/userportal/get-documents.php b/public/userportal/get-documents.php index 8d922d7..7e0b52b 100644 --- a/public/userportal/get-documents.php +++ b/public/userportal/get-documents.php @@ -13,6 +13,9 @@ $idhome = isset($_GET['idhome']) ? intval($_GET['idhome']) : 0; // Recupera lo slug dalla richiesta $docpage = isset($_GET['slug']) ? $_GET['slug'] : 'legal'; +// Recupera il parametro showOnlyRequired +$showOnlyRequired = isset($_GET['showOnlyRequired']) && $_GET['showOnlyRequired'] === 'true'; + // Recupera i dettagli della casa (per verifica accesso) $queryHome = $conn->prepare("SELECT * FROM home WHERE idhome = ? AND iduser = ?"); $queryHome->bind_param('ii', $idhome, $iduserlogin); @@ -40,20 +43,26 @@ if (!$pageData) { $page_id = $pageData['idpages']; // Recupera i documenti associati al `page_id`, con le sezioni -$queryDocuments = $conn->prepare(" +$sql = " SELECT d.*, s.section_name AS section_name FROM documents d LEFT JOIN sections s ON d.idsections = s.idsections WHERE d.page_id = ? - ORDER BY s.section_name, d.document_name -"); +"; +if ($showOnlyRequired) { + $sql .= " AND d.is_required = 1"; +} +$sql .= " ORDER BY s.section_name, d.document_name"; + +$queryDocuments = $conn->prepare($sql); $queryDocuments->bind_param('i', $page_id); $queryDocuments->execute(); $resultDocuments = $queryDocuments->get_result(); $documents = []; while ($row = $resultDocuments->fetch_assoc()) { - $documents[$row['section_name']][] = $row; + $sectionName = $row['section_name'] ?: 'Senza sezione'; + $documents[$sectionName][] = $row; } // Recupera i documenti già caricati per questa casa diff --git a/public/userportal/tabs/documenti.php b/public/userportal/tabs/documenti.php index e03d607..3af7e25 100644 --- a/public/userportal/tabs/documenti.php +++ b/public/userportal/tabs/documenti.php @@ -37,22 +37,35 @@ $docpage = isset($_GET['docpage']) ? $_GET['docpage'] : 'legal'; -
-
- - -
-
-
- - + +
+
+ +
+
+ + +
+
+ +
+ + +
+ +
+ + +
@@ -230,6 +243,107 @@ $docpage = isset($_GET['docpage']) ? $_GET['docpage'] : 'legal'; width: 100% !important; } } + + /* Stile per la sezione filtri */ + .filter-section { + background-color: #f8f9fa; + border: 1px solid #e0e0e0; + border-radius: 10px; + padding: 15px; + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05); + } + + /* Stile per il checkbox */ + .form-check.form-switch { + display: flex; + align-items: center; + margin-bottom: 0; + } + + .form-check-input { + width: 2em; + height: 1em; + margin-right: 8px; + cursor: pointer; + } + + .form-check-input:checked { + background-color: #007bff; + border-color: #007bff; + } + + .form-check-label { + font-size: 0.95rem; + font-weight: 500; + color: #333; + cursor: pointer; + display: flex; + align-items: center; + } + + .form-check-label i { + color: #007bff; + font-size: 1rem; + margin-right: 5px; + } + + .form-check-label:hover { + color: #0056b3; + } + + /* Stile per le etichette dei filtri */ + .form-label { + font-size: 0.9rem; + color: #555; + } + + /* Stile per il dropdown e il campo di ricerca */ + .form-control { + border-radius: 6px; + font-size: 0.95rem; + padding: 8px 12px; + transition: border-color 0.3s ease; + } + + .form-control:focus { + border-color: #007bff; + box-shadow: 0 0 5px rgba(0, 123, 255, 0.2); + } + + /* Stile per i risultati della ricerca */ + #searchResults { + border-radius: 6px; + border: 1px solid #ddd; + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); + } + + #searchResults .list-group-item { + font-size: 0.9rem; + padding: 8px 12px; + } + + #searchResults .list-group-item:hover { + background-color: #f1f3f5; + } + + /* Responsive: impila i filtri su schermi piccoli */ + @media (max-width: 767.98px) { + .filter-section { + padding: 10px; + } + + .form-check.form-switch { + justify-content: center; + } + + .form-label { + text-align: center; + } + + .form-control { + width: 100% !important; + } + }