connect_error) { die("Errore di connessione: " . $conn->connect_error); } // Recupera l'idhome dalla query string $idhome = isset($_GET['idhome']) ? intval($_GET['idhome']) : 0; // Recupera i dettagli dell'immobile $queryHome = $conn->prepare("SELECT * FROM home WHERE idhome = ?"); $queryHome->bind_param('i', $idhome); $queryHome->execute(); $resultHome = $queryHome->get_result(); $homeDetails = $resultHome->fetch_assoc(); // Recupera tutte le condivisioni per l'immobile specifico $querySharing = $conn->prepare(" SELECT hs.*, sr.role_name FROM home_sharing hs LEFT JOIN sharing_roles sr ON hs.role_id = sr.idrole WHERE hs.idhome = ? ORDER BY hs.created_at DESC "); $querySharing->bind_param('i', $idhome); $querySharing->execute(); $resultSharing = $querySharing->get_result(); $sharings = []; while ($row = $resultSharing->fetch_assoc()) { // Decode JSON sections $sharedSections = json_decode($row['shared_sections'], true) ?: []; if (!empty($sharedSections)) { // Match section IDs with names from the `sections` table $placeholders = implode(',', array_fill(0, count($sharedSections), '?')); $sectionQuery = $conn->prepare("SELECT section_name FROM sections WHERE idsections IN ($placeholders)"); $sectionQuery->bind_param(str_repeat('i', count($sharedSections)), ...$sharedSections); $sectionQuery->execute(); $sectionResult = $sectionQuery->get_result(); $sectionNames = $sectionResult->fetch_all(MYSQLI_ASSOC); $row['section_names'] = array_column($sectionNames, 'section_name'); } else { $row['section_names'] = ['Tutte le sezioni']; } $sharings[] = $row; } $queryHome->close(); $querySharing->close(); $conn->close(); ?> Gestione Condivisioni

Condivisioni per l'immobile

Dettagli immobile:

ID Email Ruolo Tipologia Sezioni Scadenza Azioni