Proprietari
+| Nome | +Codice Fiscale | +% | +Note | +Azioni | +
|---|---|---|---|---|
| + + | ++ | + | + | + + + + | + +
Nessun proprietario associato.
+ +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(); +?> + + + +
+ + +| Nome | +Codice Fiscale | +% | +Note | +Azioni | +
|---|---|---|---|---|
| + + | ++ | + | + | + + + + | + +
Nessun proprietario associato.
+ +Indirizzo:
+Indirizzo:
+
-
Dettagli immobile:
+Dettagli immobile:
+ + Aggiungi Condivisione + + + Torna Indietro + +| Città | Nazione | Condiviso da | -Tipo Condivisione | +Proprietari | Data Scadenza | Azioni | @@ -105,16 +118,43 @@ $result = $stmt->get_result();- | + | + + + + + + + + + + + + + | ++ + + + + + + + + + + + | + @@ -122,6 +162,11 @@ $result = $stmt->get_result(); +
|---|