diff --git a/public/userportal/add-owner-to-home.php b/public/userportal/add-owner-to-home.php new file mode 100644 index 0000000..bf1635b --- /dev/null +++ b/public/userportal/add-owner-to-home.php @@ -0,0 +1,56 @@ +connect_error) { + die("Errore di connessione: " . $conn->connect_error); +} + +// Recupera i dati inviati tramite POST +$idhome = isset($_POST['idhome']) ? intval($_POST['idhome']) : 0; +$owner_id = isset($_POST['owner_id']) ? intval($_POST['owner_id']) : 0; +$ownership_percentage = isset($_POST['ownership_percentage']) ? floatval($_POST['ownership_percentage']) : null; +$notes = isset($_POST['notes']) ? $conn->real_escape_string($_POST['notes']) : null; + +// Verifica che tutti i dati necessari siano presenti +if ($idhome <= 0 || $owner_id <= 0) { + die("Errore: Dati mancanti."); +} + +// Controlla se il proprietario è già associato a questa casa +$queryCheck = $conn->prepare("SELECT * FROM home_owners WHERE home_id = ? AND owner_id = ?"); +$queryCheck->bind_param('ii', $idhome, $owner_id); +$queryCheck->execute(); +$resultCheck = $queryCheck->get_result(); + +if ($resultCheck->num_rows > 0) { + die("Errore: Il proprietario è già associato a questa casa."); +} + +// Inserisce il nuovo proprietario nella tabella home_owners +$queryInsert = $conn->prepare(" + INSERT INTO home_owners (home_id, owner_id, ownership_percentage, notes, created_at, updated_at) + VALUES (?, ?, ?, ?, NOW(), NOW()) +"); +if ($queryInsert === false) { + die("Errore nella preparazione della query: " . $conn->error); +} + +$queryInsert->bind_param('iids', $idhome, $owner_id, $ownership_percentage, $notes); + +if ($queryInsert->execute()) { + // Reindirizza alla pagina di gestione dell'immobile + header("Location: assign-owners.php?idhome=$idhome&success=1"); + exit; +} else { + die("Errore nell'inserimento: " . $queryInsert->error); +} + +// Chiude la connessione +$conn->close(); diff --git a/public/userportal/assets/images/users/man.png b/public/userportal/assets/images/users/man.png new file mode 100644 index 0000000..d2881fc Binary files /dev/null and b/public/userportal/assets/images/users/man.png differ diff --git a/public/userportal/assets/images/users/user-a.png b/public/userportal/assets/images/users/user-a.png new file mode 100644 index 0000000..2da1fde Binary files /dev/null and b/public/userportal/assets/images/users/user-a.png differ diff --git a/public/userportal/assets/images/users/user.png b/public/userportal/assets/images/users/user.png new file mode 100644 index 0000000..4cc32ca Binary files /dev/null and b/public/userportal/assets/images/users/user.png differ diff --git a/public/userportal/assign-owners.php b/public/userportal/assign-owners.php new file mode 100644 index 0000000..1cdffae --- /dev/null +++ b/public/userportal/assign-owners.php @@ -0,0 +1,282 @@ + + +connect_error) { + die("Errore di connessione: " . $conn->connect_error); +} + +// Recupera l'id immobile (idhome) passato tramite GET +$idhome = isset($_GET['idhome']) ? intval($_GET['idhome']) : 0; + +// Recupera i dettagli dell'immobile +$queryHome = $conn->prepare("SELECT name, address, zip, city, country FROM home WHERE idhome = ?"); +$queryHome->bind_param('i', $idhome); +$queryHome->execute(); +$resultHome = $queryHome->get_result(); +$homeDetails = $resultHome->fetch_assoc(); + +if (!$homeDetails) { + die("Immobile non trovato o accesso non autorizzato."); +} + +// Recupera i proprietari associati all'immobile +$queryOwners = $conn->prepare(" + SELECT + po.owner_id, + po.first_name, + po.last_name, + po.company_name, + po.tax_code, + po.email, + ho.ownership_percentage, + ho.notes + FROM + home_owners AS ho + INNER JOIN + property_owners AS po ON ho.owner_id = po.owner_id + WHERE + ho.home_id = ? +"); +$queryOwners->bind_param('i', $idhome); +$queryOwners->execute(); +$resultOwners = $queryOwners->get_result(); + +// Recupera tutti i proprietari disponibili dell'utente per la selezione +$queryAvailableOwners = $conn->prepare(" + SELECT + owner_id, + first_name, + last_name, + company_name, + tax_code + FROM + property_owners + WHERE + user_id = ? + AND owner_id NOT IN ( + SELECT owner_id FROM home_owners WHERE home_id = ? + ) +"); +$queryAvailableOwners->bind_param('ii', $iduserlogin, $idhome); +$queryAvailableOwners->execute(); +$resultAvailableOwners = $queryAvailableOwners->get_result(); +?> + + + + + + + Assegna Proprietari + + + + + + +
+ + +
+
+ +
+
+
+ +
+
+

+ + + +
+
+ +
+
+
Proprietari
+
+
+ num_rows > 0) { ?> + + + + + + + + + + + + fetch_assoc()) { ?> + + + + + + + + + + +
NomeCodice Fiscale%NoteAzioni
+ + + + + +
+ +

Nessun proprietario associato.

+ +
+
+ + + +
+
+
Aggiungi Proprietari
+
+
+
+ +
+ + +
+
+ + +
+
+ + +
+ +
+
+
+ + +
+ +
+
+
+
+ +
+
+ + + + + + + + + \ No newline at end of file diff --git a/public/userportal/documents-home-shared.php b/public/userportal/documents-home-shared.php index 7a3ac24..38829de 100644 --- a/public/userportal/documents-home-shared.php +++ b/public/userportal/documents-home-shared.php @@ -7,13 +7,13 @@ error_reporting(E_ALL); $conn = new mysqli($servername, $username, $password, $database); // Recupera l'id utente loggato $iduserlogin = $_SESSION['iduserlogin']; - +//echo $iduserlogin; // Recupera l'id della casa dall'URL $idhome = isset($_GET['idhome']) ? intval($_GET['idhome']) : 0; // Recupera lo sharing_type e le sezioni condivise per questa casa $querySharing = $conn->prepare(" - SELECT sharing_type, shared_sections + SELECT sharing_type, shared_sections , iduser FROM home_sharing WHERE idhome = ? AND idshareduser = ? AND status = 'accepted' "); @@ -29,6 +29,7 @@ if (!$sharingData) { // Ottieni i dati di condivisione $sharingType = $sharingData['sharing_type']; +$sharingIdUser = $sharingData['iduser']; $sharedSections = json_decode($sharingData['shared_sections'], true); // Decodifica il JSON ?> prepare("SELECT * FROM home WHERE idhome = ? AND iduser = ?"); -$queryHome->bind_param('ii', $idhome, $iduserlogin); +$queryHome->bind_param('ii', $idhome, $sharingIdUser); $queryHome->execute(); $resultHome = $queryHome->get_result(); $homeData = $resultHome->fetch_assoc(); diff --git a/public/userportal/documents-home.php b/public/userportal/documents-home.php index d5edd56..d698ab6 100644 --- a/public/userportal/documents-home.php +++ b/public/userportal/documents-home.php @@ -263,27 +263,35 @@ while ($row = $queryPages->fetch_assoc()) {
-
-
-

Documenti per la Casa:

-

Indirizzo:

+
+
+

Documenti per la Casa:

+

Indirizzo:

+
+
+
+
- - - + + +
-
+
$sectionDocuments) { ?> diff --git a/public/userportal/documents-person.php b/public/userportal/documents-person.php index 9f5eb17..3148093 100644 --- a/public/userportal/documents-person.php +++ b/public/userportal/documents-person.php @@ -235,6 +235,8 @@ while ($row = $resultLoadedDocuments->fetch_assoc()) {
+ +
diff --git a/public/userportal/homedocuments/1-1737108161-CIMAC_25-7.pdf b/public/userportal/homedocuments/1-1737108161-CIMAC_25-7.pdf new file mode 100644 index 0000000..bb692d9 Binary files /dev/null and b/public/userportal/homedocuments/1-1737108161-CIMAC_25-7.pdf differ diff --git a/public/userportal/homedocuments/1-1737726680-CIMAC_25-7.pdf b/public/userportal/homedocuments/1-1737726680-CIMAC_25-7.pdf new file mode 100644 index 0000000..bb692d9 Binary files /dev/null and b/public/userportal/homedocuments/1-1737726680-CIMAC_25-7.pdf differ diff --git a/public/userportal/homes-list.php b/public/userportal/homes-list.php index f1d9b74..1acd145 100644 --- a/public/userportal/homes-list.php +++ b/public/userportal/homes-list.php @@ -7,7 +7,35 @@ $conn = new mysqli($servername, $username, $password, $database); $iduserlogin = $_SESSION['iduserlogin']; // Query per ottenere le case dell'utente -$sql = "SELECT idhome, name, address, zip, city, country FROM home WHERE iduser = ?"; +$sql = " + SELECT + h.idhome, + h.name, + h.address, + h.zip, + h.city, + h.country, + COUNT(ho.owner_id) AS owner_count, + GROUP_CONCAT( + CASE + WHEN po.owner_type = 'individual' + THEN CONCAT(po.first_name, ' ', po.last_name) + ELSE po.company_name + END + SEPARATOR '\n' + ) AS owner_names + FROM + home h + LEFT JOIN + home_owners ho ON h.idhome = ho.home_id + LEFT JOIN + property_owners po ON ho.owner_id = po.owner_id + WHERE + h.iduser = ? + GROUP BY + h.idhome +"; + $stmt = $conn->prepare($sql); $stmt->bind_param('i', $iduserlogin); $stmt->execute(); @@ -64,7 +92,7 @@ $result = $stmt->get_result();
@@ -80,18 +108,22 @@ $result = $stmt->get_result(); Nome Indirizzo - CAP + Città Nazione + Nomi Proprietari + Proprietari Action - + + + @@ -100,42 +132,56 @@ $result = $stmt->get_result(); - - + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + Assegna Proprietario + + + + Proprietari + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + @@ -145,6 +191,11 @@ $result = $stmt->get_result();
+
+ +
diff --git a/public/userportal/include/navigationbar.php b/public/userportal/include/navigationbar.php index df115d3..27abe6e 100644 --- a/public/userportal/include/navigationbar.php +++ b/public/userportal/include/navigationbar.php @@ -12,7 +12,7 @@
diff --git a/public/userportal/include/topbar.php b/public/userportal/include/topbar.php index 49adc56..45e6e21 100644 --- a/public/userportal/include/topbar.php +++ b/public/userportal/include/topbar.php @@ -45,7 +45,7 @@ $conn->close();