diff --git a/public/userportal/documents-home.php b/public/userportal/documents-home.php index fa59e9a..a1a8495 100644 --- a/public/userportal/documents-home.php +++ b/public/userportal/documents-home.php @@ -21,51 +21,8 @@ $queryHome->execute(); $resultHome = $queryHome->get_result(); $homeData = $resultHome->fetch_assoc(); -if (!isset($_GET['docpage'])) { - $docpage = "legal"; // Slug predefinito -} else { - $docpage = $_GET['docpage']; // Slug passato via GET -} - -// Recupera il `page_id` corrispondente allo slug -$queryPageId = $conn->prepare("SELECT idpages FROM pages WHERE slug = ?"); -$queryPageId->bind_param('s', $docpage); -$queryPageId->execute(); -$resultPageId = $queryPageId->get_result(); -$pageData = $resultPageId->fetch_assoc(); - -if ($pageData) { - $page_id = $pageData['idpages']; // Page ID trovato -} else { - die("Errore: Pagina non valida."); // Slug non trovato -} - -// Recupera i documenti associati al `page_id`, con le sezioni -$queryDocuments = $conn->prepare(" - 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 -"); -$queryDocuments->bind_param('i', $page_id); -$queryDocuments->execute(); -$resultDocuments = $queryDocuments->get_result(); - -$documents = []; -while ($row = $resultDocuments->fetch_assoc()) { - $documents[$row['section_name']][] = $row; -} - -// Recupera i documenti già caricati per questa casa -$queryLoadedDocuments = $conn->prepare("SELECT * FROM doc_storage WHERE idhome = ?"); -$queryLoadedDocuments->bind_param('i', $idhome); -$queryLoadedDocuments->execute(); -$resultLoadedDocuments = $queryLoadedDocuments->get_result(); - -$loadedDocuments = []; -while ($row = $resultLoadedDocuments->fetch_assoc()) { - $loadedDocuments[$row['document_id']][] = $row; +if (!$homeData) { + die("Errore: Casa non trovata o accesso non autorizzato."); } // Recupera le pagine disponibili nella tabella 'documents' @@ -74,8 +31,10 @@ $pages = []; while ($row = $queryPages->fetch_assoc()) { $pages[] = $row; } -?> +// Imposta lo slug predefinito o usa quello passato via GET +$docpage = isset($_GET['docpage']) ? $_GET['docpage'] : 'legal'; +?> @@ -98,9 +57,6 @@ while ($row = $queryPages->fetch_assoc()) { - - - @@ -252,6 +208,51 @@ while ($row = $queryPages->fetch_assoc()) { display: none; /* Nasconde inizialmente l'area */ } + + /* Stile per il gruppo input su desktop */ + .input-group { + max-width: 400px; + /* Limita la larghezza totale su desktop */ + margin: 0 auto; + /* Centra orizzontalmente su mobile */ + } + + #documentSearch { + border-radius: 0.25rem 0 0 0.25rem; + /* Arrotonda solo l'angolo sinistro */ + } + + /* Stile per i risultati della ricerca */ + #searchResults { + background-color: #fff; + border: 1px solid #ddd; + border-radius: 0.25rem; + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); + } + + #searchResults .list-group-item { + cursor: pointer; + } + + #searchResults .list-group-item:hover { + background-color: #f8f9fa; + } + + /* Su tablet e mobile, allinea tutto al centro e separa in due righe */ + @media (max-width: 767.98px) { + .input-group { + max-width: 100%; + /* Usa tutta la larghezza su mobile */ + margin-top: 10px; + /* Spazio sopra il campo di ricerca */ + } + + #pageSelectDropdown, + #documentSearch { + width: 100% !important; + /* Usa tutta la larghezza su mobile */ + } + } @@ -278,106 +279,27 @@ while ($row = $queryPages->fetch_assoc()) {