new commit and update
This commit is contained in:
parent
5d64b2ed06
commit
2045c5e5a7
56
public/userportal/add-owner-to-home.php
Normal file
56
public/userportal/add-owner-to-home.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include('include/headscript.php');
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->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();
|
||||
BIN
public/userportal/assets/images/users/man.png
Normal file
BIN
public/userportal/assets/images/users/man.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
BIN
public/userportal/assets/images/users/user-a.png
Normal file
BIN
public/userportal/assets/images/users/user-a.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
BIN
public/userportal/assets/images/users/user.png
Normal file
BIN
public/userportal/assets/images/users/user.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
282
public/userportal/assign-owners.php
Normal file
282
public/userportal/assign-owners.php
Normal file
@ -0,0 +1,282 @@
|
||||
<?php include('include/headscript.php'); ?>
|
||||
<?php
|
||||
// Verifica se la variabile GET 'editpage' è impostata su 'nochange'
|
||||
$disableEditing = isset($_GET['editpage']) && $_GET['editpage'] === 'nochange';
|
||||
?>
|
||||
<?php
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->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();
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="it">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
|
||||
<title>Assegna Proprietari</title>
|
||||
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/icons.css" rel="stylesheet" type="text/css">
|
||||
<link href="assets/css/style.css" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
|
||||
<body class="fixed-left">
|
||||
<div id="wrapper">
|
||||
<?php include('include/navigationbar.php'); ?>
|
||||
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<?php include('include/topbar.php'); ?>
|
||||
<br>
|
||||
<div class="page-content-wrapper">
|
||||
<div class="container-fluid">
|
||||
<!-- Dettagli dell'immobile -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header bg-warning text-white">
|
||||
<h4 class="mb-0"><?php echo htmlspecialchars($homeDetails['name']); ?></h4>
|
||||
<span class="badge bg-info text-primary">
|
||||
<?php echo htmlspecialchars($homeDetails['address'] . ', ' . $homeDetails['zip'] . ', ' . $homeDetails['city'] . ', ' . $homeDetails['country']); ?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Proprietari associati -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header bg-success text-white">
|
||||
<h5 class="mb-0">Proprietari</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php if ($resultOwners->num_rows > 0) { ?>
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nome</th>
|
||||
<th>Codice Fiscale</th>
|
||||
<th>%</th>
|
||||
<th>Note</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php while ($owner = $resultOwners->fetch_assoc()) { ?>
|
||||
<tr>
|
||||
<td>
|
||||
<?php
|
||||
echo htmlspecialchars($owner['first_name'] . ' ' . $owner['last_name']);
|
||||
if ($owner['company_name']) {
|
||||
echo ' (' . htmlspecialchars($owner['company_name']) . ')';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo htmlspecialchars($owner['tax_code']); ?></td>
|
||||
<td><?php echo htmlspecialchars($owner['ownership_percentage']); ?></td>
|
||||
<td><?php echo htmlspecialchars($owner['notes']); ?></td>
|
||||
<td>
|
||||
<?php if (!$disableEditing) { ?>
|
||||
<button class="btn btn-danger btn-sm remove-owner-btn" data-id="<?php echo $owner['owner_id']; ?>">
|
||||
<i class="fas fa-trash-alt"></i> Rimuovi
|
||||
</button>
|
||||
<?php } ?>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } else { ?>
|
||||
<p class="text-muted">Nessun proprietario associato.</p>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Aggiungi proprietari -->
|
||||
<?php if (!$disableEditing) { ?>
|
||||
<div class="card mb-4">
|
||||
<div class="card-header bg-info text-white">
|
||||
<h5 class="mb-0">Aggiungi Proprietari</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form id="addOwnerForm" method="POST" action="add-owner-to-home.php">
|
||||
<input type="hidden" name="idhome" value="<?php echo $idhome; ?>">
|
||||
<div class="form-group">
|
||||
<label for="ownerSelect">Seleziona Proprietario</label>
|
||||
<select class="form-control" id="ownerSelect" name="owner_id" required>
|
||||
<option value="">-- Seleziona --</option>
|
||||
<?php while ($availableOwner = $resultAvailableOwners->fetch_assoc()) { ?>
|
||||
<option value="<?php echo $availableOwner['owner_id']; ?>">
|
||||
<?php
|
||||
echo htmlspecialchars($availableOwner['first_name'] . ' ' . $availableOwner['last_name']);
|
||||
if ($availableOwner['company_name']) {
|
||||
echo ' (' . htmlspecialchars($availableOwner['company_name']) . ')';
|
||||
}
|
||||
echo ' - ' . htmlspecialchars($availableOwner['tax_code']);
|
||||
?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="ownershipPercentage">Percentuale di Proprietà</label>
|
||||
<input type="number" step="0.01" class="form-control" id="ownershipPercentage" name="ownership_percentage" placeholder="Inserisci la percentuale (es. 50.00)">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="notes">Note</label>
|
||||
<textarea class="form-control" id="notes" name="notes" rows="3" placeholder="Aggiungi eventuali note"></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success mt-3">Aggiungi</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="mb-3">
|
||||
<button onclick="history.back()" class="btn btn-dark">
|
||||
<i class="fas fa-arrow-left"></i> Torna indietro
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="assets/js/jquery.min.js"></script>
|
||||
<script src="assets/js/bootstrap.min.js"></script>
|
||||
<script>
|
||||
$(document).on('click', '.remove-owner-btn', function() {
|
||||
const ownerId = $(this).data('id');
|
||||
const idhome = "<?php echo $idhome; ?>";
|
||||
|
||||
if (confirm('Sei sicuro di voler rimuovere questo proprietario?')) {
|
||||
$.post('remove-owner-from-home.php', {
|
||||
owner_id: ownerId,
|
||||
idhome: idhome
|
||||
}, function(response) {
|
||||
location.reload();
|
||||
}).fail(function() {
|
||||
alert('Errore durante la rimozione del proprietario.');
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).on('click', '.remove-owner-btn', function() {
|
||||
const ownerId = $(this).data('id');
|
||||
const idhome = "<?php echo $idhome; ?>";
|
||||
|
||||
Swal.fire({
|
||||
title: 'Sei sicuro?',
|
||||
text: 'Questa azione rimuoverà il proprietario selezionato.',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Sì, rimuovi',
|
||||
cancelButtonText: 'Annulla',
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.post('remove-owner-from-home.php', {
|
||||
owner_id: ownerId,
|
||||
idhome: idhome
|
||||
}, function(response) {
|
||||
try {
|
||||
const result = JSON.parse(response);
|
||||
if (result.success) {
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: 'Rimosso',
|
||||
text: result.message,
|
||||
timer: 1500,
|
||||
showConfirmButton: false,
|
||||
}).then(() => {
|
||||
location.reload(); // Ricarica la pagina
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Errore',
|
||||
text: result.message,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Errore di parsing JSON:', error);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Errore',
|
||||
text: 'Si è verificato un problema.',
|
||||
});
|
||||
}
|
||||
}).fail(function() {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Errore',
|
||||
text: 'Impossibile completare la richiesta.',
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -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
|
||||
?>
|
||||
<?php
|
||||
@ -37,7 +38,7 @@ $sharedSections = json_decode($sharingData['shared_sections'], true); // Decodif
|
||||
|
||||
// Recupera i dettagli della casa
|
||||
$queryHome = $conn->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();
|
||||
|
||||
@ -263,27 +263,35 @@ while ($row = $queryPages->fetch_assoc()) {
|
||||
<div class="page-content-wrapper">
|
||||
<div class="container-fluid">
|
||||
<!-- Dettagli della Casa -->
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<h4 class="page-title">Documenti per la Casa: <?php echo htmlspecialchars($homeData['name']); ?></h4>
|
||||
<p><strong>Indirizzo:</strong> <?php echo htmlspecialchars($homeData['address']) . ', ' . htmlspecialchars($homeData['city']) . ' ' . htmlspecialchars($homeData['zip']); ?></p>
|
||||
<div class="row align-items-center">
|
||||
<div class="col-sm-8">
|
||||
<h4 class="page-title m-0">Documenti per la Casa: <?php echo htmlspecialchars($homeData['name']); ?></h4>
|
||||
<p class="mb-0"><strong>Indirizzo:</strong> <?php echo htmlspecialchars($homeData['address']) . ', ' . htmlspecialchars($homeData['city']) . ' ' . htmlspecialchars($homeData['zip']); ?></p>
|
||||
</div>
|
||||
<div class="col-sm-4 text-right">
|
||||
<button onclick="history.back()" class="btn btn-dark">
|
||||
<i class="fas fa-arrow-left"></i> Torna indietro
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col-12 text-center">
|
||||
<div class="btn-group" role="group" aria-label="Pagine">
|
||||
<?php foreach ($pages as $page) { ?>
|
||||
<button
|
||||
class="btn btn-outline-primary filter-btn <?php echo $docpage === $page['slug'] ? 'active' : ''; ?>"
|
||||
onclick="window.location.href='?docpage=<?php echo htmlspecialchars($page['slug']); ?>&idhome=<?php echo htmlspecialchars($idhome); ?>';">
|
||||
<?php echo ucfirst(htmlspecialchars($page['namepages'])); ?>
|
||||
</button>
|
||||
<?php } ?>
|
||||
<?php foreach ($pages as $page) {
|
||||
if ($page['slug'] !== 'person') { ?>
|
||||
<button
|
||||
class="btn btn-outline-primary filter-btn <?php echo $docpage === $page['slug'] ? 'active' : ''; ?>"
|
||||
onclick="window.location.href='?docpage=<?php echo htmlspecialchars($page['slug']); ?>&idhome=<?php echo htmlspecialchars($idhome); ?>';">
|
||||
<?php echo ucfirst(htmlspecialchars($page['namepages'])); ?>
|
||||
</button>
|
||||
<?php }
|
||||
} ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Sezioni per documenti -->
|
||||
<div class="accordion" id="documentSections">
|
||||
<?php foreach ($documents as $sectionName => $sectionDocuments) { ?>
|
||||
|
||||
@ -235,6 +235,8 @@ while ($row = $resultLoadedDocuments->fetch_assoc()) {
|
||||
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<?php include('include/topbar.php'); ?>
|
||||
<br>
|
||||
<div class="page-content-wrapper">
|
||||
<div class="container-fluid">
|
||||
<!-- Page Title -->
|
||||
|
||||
BIN
public/userportal/homedocuments/1-1737108161-CIMAC_25-7.pdf
Normal file
BIN
public/userportal/homedocuments/1-1737108161-CIMAC_25-7.pdf
Normal file
Binary file not shown.
BIN
public/userportal/homedocuments/1-1737726680-CIMAC_25-7.pdf
Normal file
BIN
public/userportal/homedocuments/1-1737726680-CIMAC_25-7.pdf
Normal file
Binary file not shown.
@ -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();
|
||||
<div class="float-right">
|
||||
<!-- Pulsante per aggiungere una nuova casa -->
|
||||
<a href="manage-home.php" class="btn btn-success">
|
||||
<i class="fas fa-plus"></i> Aggiungi Casa
|
||||
<i class="fas fa-plus"></i> Aggiungi Casa/Terreno
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@ -80,18 +108,22 @@ $result = $stmt->get_result();
|
||||
<tr>
|
||||
<th>Nome</th>
|
||||
<th>Indirizzo</th>
|
||||
<th>CAP</th>
|
||||
|
||||
<th>Città</th>
|
||||
<th>Nazione</th>
|
||||
<th>Nomi Proprietari</th>
|
||||
<th>Proprietari</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<!-- Campi di input per i filtri -->
|
||||
<th><input type="text" placeholder="Cerca Nome" class="form-control form-control-sm"></th>
|
||||
<th><input type="text" placeholder="Cerca Indirizzo" class="form-control form-control-sm"></th>
|
||||
<th><input type="text" placeholder="Cerca CAP" class="form-control form-control-sm"></th>
|
||||
|
||||
<th><input type="text" placeholder="Cerca Città" class="form-control form-control-sm"></th>
|
||||
<th><input type="text" placeholder="Cerca Nazione" class="form-control form-control-sm"></th>
|
||||
<th><input type="text" placeholder="Cerca Proprietari" class="form-control form-control-sm"></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -100,42 +132,56 @@ $result = $stmt->get_result();
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($row['name']); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['address']); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['zip']); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['city']); ?></td>
|
||||
|
||||
<td><?php echo htmlspecialchars($row['zip']); ?> - <?php echo htmlspecialchars($row['city']); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['country']); ?></td>
|
||||
<td><?php echo nl2br(htmlspecialchars($row['owner_names'])); ?></td>
|
||||
<td>
|
||||
<!-- Pulsante per modificare i dettagli della casa -->
|
||||
<a href="manage-home.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-info btn-sm" title="Dettagli">
|
||||
<i class="fas fa-info-circle"></i>
|
||||
</a>
|
||||
|
||||
<!-- Pulsante per i documenti della casa -->
|
||||
<a href="documents-home.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-primary btn-sm" title="Documenti">
|
||||
<i class="fas fa-folder-open"></i>
|
||||
</a>
|
||||
|
||||
<!-- Pulsante per condividere la casa -->
|
||||
<a href="share-home.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-warning btn-sm" title="Condividi">
|
||||
<i class="fas fa-share-alt"></i>
|
||||
</a>
|
||||
|
||||
<!-- Pulsante per passaggio proprietà -->
|
||||
<button class="btn btn-secondary btn-sm transfer-property-btn" data-id="<?php echo $row['idhome']; ?>" title="Passaggio Proprietà">
|
||||
<i class="fas fa-exchange-alt"></i>
|
||||
</button>
|
||||
|
||||
<!-- Pulsante per assegnare le persone proprietarie -->
|
||||
<button class="btn btn-success btn-sm assign-owner-btn" data-id="<?php echo $row['idhome']; ?>" title="Assegna Proprietari">
|
||||
<i class="fas fa-user-plus"></i>
|
||||
</button>
|
||||
|
||||
<!-- Pulsante per eliminare la casa -->
|
||||
<button class="btn btn-danger btn-sm delete-home-btn" data-id="<?php echo $row['idhome']; ?>" title="Elimina">
|
||||
<i class="fas fa-trash-alt"></i>
|
||||
</button>
|
||||
<?php if ($row['owner_count'] == 0) { ?>
|
||||
<a href="assign-owners.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-danger btn-sm">
|
||||
<i class="fas fa-user-times"></i> Assegna Proprietario
|
||||
</a>
|
||||
<?php } else { ?>
|
||||
<a href="assign-owners.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-success btn-sm">
|
||||
<i class="fas fa-user-check"></i> <?php echo htmlspecialchars($row['owner_count']); ?> Proprietari
|
||||
</a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
|
||||
<td class="text-nowrap">
|
||||
<div class="d-flex justify-content-start align-items-center gap-2">
|
||||
<!-- Pulsante per modificare i dettagli della casa -->
|
||||
<a href="manage-home.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-info btn-sm me-2" title="Dettagli">
|
||||
<i class="fas fa-info-circle"></i>
|
||||
</a>
|
||||
|
||||
<!-- Pulsante per i documenti della casa -->
|
||||
<a href="documents-home.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-primary btn-sm me-2" title="Documenti">
|
||||
<i class="fas fa-folder-open"></i>
|
||||
</a>
|
||||
|
||||
<!-- Pulsante per condividere la casa -->
|
||||
<a href="share-home.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-warning btn-sm me-2" title="Condividi">
|
||||
<i class="fas fa-share-alt"></i>
|
||||
</a>
|
||||
|
||||
<!-- Pulsante per passaggio proprietà -->
|
||||
<button class="btn btn-secondary btn-sm me-2 transfer-property-btn" data-id="<?php echo $row['idhome']; ?>" title="Passaggio Proprietà">
|
||||
<i class="fas fa-exchange-alt"></i>
|
||||
</button>
|
||||
|
||||
<!-- Pulsante per eliminare la casa -->
|
||||
<button class="btn btn-danger btn-sm delete-home-btn" data-id="<?php echo $row['idhome']; ?>" title="Elimina">
|
||||
<i class="fas fa-trash-alt"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
@ -145,6 +191,11 @@ $result = $stmt->get_result();
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<button onclick="history.back()" class="btn btn-dark">
|
||||
<i class="fas fa-arrow-left"></i> Torna indietro
|
||||
</button>
|
||||
</div>
|
||||
</div><!-- container -->
|
||||
</div><!-- Page content Wrapper -->
|
||||
</div><!-- content -->
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="sidebar-user">
|
||||
<img src="assets/images/users/avatar-6.jpg" alt="user" class="rounded-circle img-thumbnail mb-1">
|
||||
<img src="assets/images/users/man.png" alt="user" class="rounded-circle img-thumbnail mb-1">
|
||||
<h6 class=""><?php echo $_SESSION["nameuser"]; ?> <?php echo $_SESSION["surnameuser"]; ?> </h6>
|
||||
<p class=" online-icon text-dark"><i class="mdi mdi-record text-success"></i>online</p>
|
||||
<ul class="list-unstyled list-inline mb-0 mt-2">
|
||||
@ -32,47 +32,58 @@
|
||||
|
||||
<div id="sidebar-menu">
|
||||
<ul>
|
||||
<!-- Sezione Main -->
|
||||
<li class="menu-title">Main</li>
|
||||
|
||||
<li>
|
||||
<a href="index.php" class="waves-effect">
|
||||
<i class="dripicons-device-desktop"></i>
|
||||
<i class="fas fa-tachometer-alt text-danger"></i>
|
||||
<span> Dashboard </span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
<!-- Sezione Immobili -->
|
||||
<li class="menu-title">Sezioni</li>
|
||||
|
||||
<li class="">
|
||||
<a href="homes-list.php" class="waves-effect"><i class="dripicons-blog"></i><span> I miei immobili </span></a>
|
||||
|
||||
<li>
|
||||
<a href="homes-list.php" class="waves-effect">
|
||||
<i class="fas fa-home text-primary"></i>
|
||||
<span> I miei immobili </span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="">
|
||||
<a href="person-list.php" class="waves-effect"><i class="dripicons-blog"></i><span> Persone/Società </span></a>
|
||||
|
||||
<li>
|
||||
<a href="person-list.php" class="waves-effect">
|
||||
<i class="fas fa-users text-success"></i>
|
||||
<span> Persone/Società </span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="">
|
||||
<a href="shared-homes.php" class="waves-effect"><i class="dripicons-blog"></i><span> Immobili Condivisi </span></a>
|
||||
|
||||
<li>
|
||||
<a href="shared-homes.php" class="waves-effect">
|
||||
<i class="fas fa-share-alt text-info"></i>
|
||||
<span> Immobili Condivisi </span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
<!-- Sezione Amministrazione -->
|
||||
<li class="menu-title">Amministrazione</li>
|
||||
|
||||
<li class="">
|
||||
<a href="admin.php" class="waves-effect"><i class="dripicons-blog"></i><span> Admin Page </span></a>
|
||||
|
||||
<li>
|
||||
<a href="admin.php" class="waves-effect">
|
||||
<i class="fas fa-cogs text-danger"></i>
|
||||
<span> Admin Page </span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="has_sub">
|
||||
<a href="tables-basic.html" class="waves-effect"><i class="dripicons-copy"></i><span> Template </span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
|
||||
<a href="pages-blank.html" target="_blank" class="waves-effect">
|
||||
<i class="fas fa-folder"></i>
|
||||
<span> Template </span>
|
||||
<span class="float-right">
|
||||
<i class="mdi mdi-chevron-right"></i>
|
||||
</span>
|
||||
</a>
|
||||
<ul class="list-unstyled">
|
||||
|
||||
<li><a href="pages-blank.html">Blank Page</a></li>
|
||||
|
||||
<li><a href="pages-blank.html"><i class="fas fa-file"></i> Blank Page</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</div> <!-- end sidebarinner -->
|
||||
|
||||
@ -45,7 +45,7 @@ $conn->close();
|
||||
<li class="list-inline-item dropdown notification-list">
|
||||
<a class="nav-link dropdown-toggle arrow-none waves-effect nav-user" data-toggle="dropdown" href="#" role="button"
|
||||
aria-haspopup="false" aria-expanded="false">
|
||||
<img src="assets/images/users/avatar-6.jpg" alt="user" class="rounded-circle">
|
||||
<img src="assets/images/users/man.png" alt="user" class="rounded-circle">
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right profile-dropdown ">
|
||||
<!-- item-->
|
||||
|
||||
@ -106,6 +106,54 @@ $totalDocuments = $resultDocuments->fetch_assoc()['total_documents'];
|
||||
/* Nasconde le tre righe quando la barra è aperta */
|
||||
}
|
||||
}
|
||||
|
||||
/* Stili per colori professionali */
|
||||
.btn-main {
|
||||
background-color: rgb(96, 93, 175);
|
||||
/* Blu professionale */
|
||||
color: #fff;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.btn-main:hover {
|
||||
background-color: #364fc7;
|
||||
/* Blu più scuro al passaggio */
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background-color: rgb(21, 190, 86);
|
||||
/* Grigio tenue */
|
||||
color: #212529;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background-color: #868e96;
|
||||
/* Grigio più scuro al passaggio */
|
||||
}
|
||||
|
||||
.btn-info-light {
|
||||
background-color: #ffd43b;
|
||||
/* Giallo professionale */
|
||||
color: #212529;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.btn-info-light:hover {
|
||||
background-color: #fcc419;
|
||||
/* Giallo più intenso al passaggio */
|
||||
}
|
||||
|
||||
/* Uniformità altezza */
|
||||
.equal-height {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.equal-height .flex-fill {
|
||||
flex: 1;
|
||||
}
|
||||
</style>
|
||||
|
||||
<body class="fixed-left">
|
||||
@ -215,25 +263,35 @@ $totalDocuments = $resultDocuments->fetch_assoc()['total_documents'];
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="row text-center">
|
||||
<div class="col-lg-4 col-md-6 mb-4">
|
||||
<a href="homes-list.php" class="btn btn-primary d-flex flex-column justify-content-center align-items-center py-5 shadow rounded-lg">
|
||||
<i class="mdi mdi-home-outline" style="font-size: 3rem;"></i>
|
||||
<span class="mt-2 fw-bold" style="font-size: 1.25rem;">I miei immobili</span>
|
||||
<!-- Pulsante principale - I miei immobili -->
|
||||
<div class="col-lg-8 col-md-12 mb-4 d-flex">
|
||||
<a href="homes-list.php"
|
||||
class="btn btn-main d-flex flex-column justify-content-center align-items-center py-5 shadow rounded-lg w-100">
|
||||
<i class="mdi mdi-home-outline" style="font-size: 4rem;"></i>
|
||||
<span class="mt-2 fw-bold" style="font-size: 1.75rem;">I miei immobili</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-6 mb-4">
|
||||
<a href="person-list.php" class="btn btn-success d-flex flex-column justify-content-center align-items-center py-5 shadow rounded-lg">
|
||||
<i class="mdi mdi-account-outline" style="font-size: 3rem;"></i>
|
||||
<span class="mt-2 fw-bold" style="font-size: 1.25rem;">Persone/Società</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-6 mb-4">
|
||||
<a href="shared-homes.php" class="btn btn-info d-flex flex-column justify-content-center align-items-center py-5 shadow rounded-lg">
|
||||
<i class="mdi mdi-share-outline" style="font-size: 3rem;"></i>
|
||||
<span class="mt-2 fw-bold" style="font-size: 1.25rem;">Immobili Condivisi</span>
|
||||
</a>
|
||||
<!-- Contenitore per i due pulsanti secondari -->
|
||||
<div class="col-lg-4 col-md-12 d-flex flex-column">
|
||||
<div class="row flex-grow-1">
|
||||
<!-- Pulsante Persone/Società -->
|
||||
<div class="col-12 mb-3 d-flex">
|
||||
<a href="person-list.php"
|
||||
class="btn btn-secondary d-flex flex-column justify-content-center align-items-center py-4 shadow rounded-lg w-100">
|
||||
<i class="mdi mdi-account-outline" style="font-size: 2.5rem;"></i>
|
||||
<span class="mt-2 fw-bold" style="font-size: 1.25rem;">Persone/Società</span>
|
||||
</a>
|
||||
</div>
|
||||
<!-- Pulsante Immobili Condivisi con me -->
|
||||
<div class="col-12 d-flex">
|
||||
<a href="shared-homes.php"
|
||||
class="btn btn-info-light d-flex flex-column justify-content-center align-items-center py-4 shadow rounded-lg w-100">
|
||||
<i class="mdi mdi-share-outline" style="font-size: 2.5rem;"></i>
|
||||
<span class="mt-2 fw-bold" style="font-size: 1.25rem;">Immobili Condivisi con me</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -242,6 +300,7 @@ $totalDocuments = $resultDocuments->fetch_assoc()['total_documents'];
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- end row -->
|
||||
|
||||
</div><!-- container -->
|
||||
|
||||
@ -79,18 +79,19 @@ $fulladdressdb = $homeData['fulladdress'];
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="page-title-box">
|
||||
<div class="btn-group float-right">
|
||||
<ol class="breadcrumb hide-phone p-0 m-0">
|
||||
<li class="breadcrumb-item"><a href="#">CasaDoc</a></li>
|
||||
<li class="breadcrumb-item active">Gestione Casa</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title"><?php echo $isNew ? "Aggiungi Casa" : "Modifica Casa"; ?></h4>
|
||||
<div class="page-title-box d-flex justify-content-between align-items-center">
|
||||
<!-- Titolo -->
|
||||
<h4 class="page-title m-0"><?php echo $isNew ? "Aggiungi Casa" : "Modifica Casa"; ?></h4>
|
||||
|
||||
<!-- Tasto Torna indietro -->
|
||||
<button onclick="history.back()" class="btn btn-dark">
|
||||
<i class="fas fa-arrow-left"></i> Torna indietro
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card card-body">
|
||||
|
||||
@ -38,7 +38,7 @@ $result = $stmt->get_result();
|
||||
<?php include('include/navigationbar.php'); ?>
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<?php //include('include/topbar.php');
|
||||
<?php include('include/topbar.php');
|
||||
?>
|
||||
|
||||
<div class="page-content-wrapper">
|
||||
@ -65,6 +65,11 @@ $result = $stmt->get_result();
|
||||
<i class="fas fa-plus"></i> Aggiungi Proprietario
|
||||
</a>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<button onclick="history.back()" class="btn btn-dark">
|
||||
<i class="fas fa-arrow-left"></i> Torna indietro
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
41
public/userportal/remove-owner-from-home.php
Normal file
41
public/userportal/remove-owner-from-home.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
include('include/headscript.php');
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
if ($conn->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;
|
||||
|
||||
// Verifica che tutti i dati necessari siano presenti
|
||||
if ($idhome <= 0 || $owner_id <= 0) {
|
||||
echo json_encode(['success' => false, 'message' => 'Dati mancanti.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Elimina il proprietario dalla tabella home_owners
|
||||
$queryDelete = $conn->prepare("DELETE FROM home_owners WHERE home_id = ? AND owner_id = ?");
|
||||
if ($queryDelete === false) {
|
||||
echo json_encode(['success' => false, 'message' => 'Errore nella preparazione della query.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$queryDelete->bind_param('ii', $idhome, $owner_id);
|
||||
|
||||
if ($queryDelete->execute()) {
|
||||
echo json_encode(['success' => true, 'message' => 'Proprietario rimosso con successo.']);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'message' => 'Errore nella rimozione del proprietario.']);
|
||||
}
|
||||
|
||||
$queryDelete->close();
|
||||
$conn->close();
|
||||
@ -18,7 +18,7 @@ $iduserlogin = intval($_SESSION['iduserlogin']);
|
||||
|
||||
// Recupera i dati inviati tramite POST
|
||||
$owner_id = isset($_POST['owner_id']) ? intval($_POST['owner_id']) : 0;
|
||||
$owner_type = isset($_POST['owner_type']) ? $conn->real_escape_string($_POST['owner_type']) : '';
|
||||
$owner_type = isset($_POST['owner_type']) ? $conn->real_escape_string($_POST['owner_type']) : 'individual'; // Default to 'individual'
|
||||
$first_name = !empty($_POST['first_name']) ? $conn->real_escape_string($_POST['first_name']) : null;
|
||||
$last_name = !empty($_POST['last_name']) ? $conn->real_escape_string($_POST['last_name']) : null;
|
||||
$company_name = !empty($_POST['company_name']) ? $conn->real_escape_string($_POST['company_name']) : null;
|
||||
@ -29,11 +29,8 @@ $address = !empty($_POST['address']) ? $conn->real_escape_string($_POST['address
|
||||
$postal_code = !empty($_POST['postal_code']) ? $conn->real_escape_string($_POST['postal_code']) : null;
|
||||
$city = !empty($_POST['city']) ? $conn->real_escape_string($_POST['city']) : null;
|
||||
$province = !empty($_POST['province']) ? $conn->real_escape_string($_POST['province']) : null;
|
||||
$country = isset($_POST['country']) ? intval($_POST['country']) : null; // Converti country in intero
|
||||
$country = isset($_POST['country']) ? intval($_POST['country']) : null;
|
||||
$role = !empty($_POST['role']) ? $conn->real_escape_string($_POST['role']) : null;
|
||||
$owner_type = isset($_POST['owner_type']) ? $conn->real_escape_string($_POST['owner_type']) : 'individual'; // Default to 'individual'
|
||||
|
||||
|
||||
|
||||
// Verifica se stiamo aggiungendo un nuovo proprietario o aggiornando uno esistente
|
||||
if ($owner_id > 0) {
|
||||
@ -52,77 +49,67 @@ if ($owner_id > 0) {
|
||||
|
||||
// Binding dei parametri
|
||||
$stmt->bind_param(
|
||||
'ssssssssssssiis', // Formato corretto
|
||||
$owner_type, // s (string)
|
||||
$first_name, // s (string)
|
||||
$last_name, // s (string)
|
||||
$company_name, // s (string, può essere null)
|
||||
$tax_code, // s (string)
|
||||
$email, // s (string)
|
||||
$phone, // s (string)
|
||||
$address, // s (string)
|
||||
$postal_code, // s (string)
|
||||
$city, // s (string)
|
||||
$province, // s (string)
|
||||
$country, // i (intero)
|
||||
$role, // s (string, può essere null)
|
||||
$owner_id, // i (intero)
|
||||
$iduserlogin // i (intero)
|
||||
'ssssssssssssiis',
|
||||
$owner_type,
|
||||
$first_name,
|
||||
$last_name,
|
||||
$company_name,
|
||||
$tax_code,
|
||||
$email,
|
||||
$phone,
|
||||
$address,
|
||||
$postal_code,
|
||||
$city,
|
||||
$province,
|
||||
$country,
|
||||
$role,
|
||||
$owner_id,
|
||||
$iduserlogin
|
||||
);
|
||||
|
||||
// Esegui la query
|
||||
if ($stmt->execute()) {
|
||||
// Reindirizza a manage-owner.php dopo il successo
|
||||
header("Location: person-list.php");
|
||||
exit();
|
||||
} else {
|
||||
die("Errore nell'aggiornamento: " . $stmt->error);
|
||||
}
|
||||
} else {
|
||||
// Inserisci un nuovo proprietario
|
||||
$query = "INSERT INTO property_owners
|
||||
(user_id, owner_type, first_name, last_name, company_name, tax_code, email, phone, address, postal_code, city, province, country, role)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
$query = "INSERT INTO property_owners (user_id, owner_type, first_name, last_name, company_name, tax_code, email, phone, address, postal_code, city, province, country, role)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
$stmt = $conn->prepare($query);
|
||||
if ($stmt === false) {
|
||||
die("Errore nella preparazione della query: " . $conn->error);
|
||||
}
|
||||
|
||||
$company_name = !empty($company_name) ? $company_name : null;
|
||||
$role = !empty($role) ? $role : null;
|
||||
|
||||
|
||||
|
||||
// Binding dei parametri
|
||||
$stmt->bind_param(
|
||||
'isssssssssssis', // Formato: 2 interi, 12 stringhe
|
||||
$iduserlogin, // i (user_id)
|
||||
$owner_type, // s (owner_type)
|
||||
$first_name, // s (first_name)
|
||||
$last_name, // s (last_name)
|
||||
$company_name, // s (company_name)
|
||||
$tax_code, // s (tax_code)
|
||||
$email, // s (email)
|
||||
$phone, // s (phone)
|
||||
$address, // s (address)
|
||||
$postal_code, // s (postal_code)
|
||||
$city, // s (city)
|
||||
$province, // s (province)
|
||||
$country, // i (country)
|
||||
$role // s (role)
|
||||
'isssssssssssis',
|
||||
$iduserlogin,
|
||||
$owner_type,
|
||||
$first_name,
|
||||
$last_name,
|
||||
$company_name,
|
||||
$tax_code,
|
||||
$email,
|
||||
$phone,
|
||||
$address,
|
||||
$postal_code,
|
||||
$city,
|
||||
$province,
|
||||
$country,
|
||||
$role
|
||||
);
|
||||
|
||||
// Esegui la query
|
||||
if ($stmt->execute()) {
|
||||
echo "Proprietario salvato con successo.";
|
||||
// Reindirizza a manage-owner.php dopo il successo
|
||||
header("Location: person-list.php");
|
||||
exit(); // Assicurati di terminare l'esecuzione dopo il reindirizzamento
|
||||
exit();
|
||||
} else {
|
||||
die("Errore nell'inserimento o aggiornamento: " . $stmt->error);
|
||||
die("Errore nell'inserimento: " . $stmt->error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Chiudi la connessione
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
|
||||
@ -80,14 +80,23 @@ $conn->close();
|
||||
|
||||
<div class="page-content-wrapper">
|
||||
<div class="container-fluid">
|
||||
<br>
|
||||
<div class="row align-items-center mb-3">
|
||||
<div class="col-sm-8">
|
||||
<h4 class="page-title m-0">Condivisioni per l'immobile</h4>
|
||||
<p class="mb-0"><strong>Dettagli immobile:</strong> <?php echo htmlspecialchars($homeDetails['address']); ?></p>
|
||||
</div>
|
||||
<div class="col-sm-4 text-right">
|
||||
|
||||
<h4 class="page-title">Condivisioni per l'immobile</h4>
|
||||
<p><strong>Dettagli immobile:</strong> <?php echo htmlspecialchars($homeDetails['address']); ?></p>
|
||||
<a href="add-sharing.php?idhome=<?php echo $idhome; ?>" class="btn btn-success">
|
||||
<i class="mdi mdi-plus"></i> Aggiungi Condivisione
|
||||
</a>
|
||||
<a href="javascript:history.back()" class="btn btn-dark mr-2">
|
||||
<i class="mdi mdi-arrow-left"></i> Torna Indietro
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Pulsante per aggiungere una nuova condivisione -->
|
||||
<a href="add-sharing.php?idhome=<?php echo $idhome; ?>" class="btn btn-success mb-3">
|
||||
<i class="mdi mdi-plus"></i> Aggiungi Condivisione
|
||||
</a>
|
||||
|
||||
<!-- Tabella delle condivisioni -->
|
||||
<table id="sharingTable" class="table table-striped table-bordered">
|
||||
|
||||
@ -9,23 +9,36 @@ $emailuser = $_SESSION['emailuser'];
|
||||
|
||||
// Query per ottenere gli immobili condivisi con l'utente loggato
|
||||
$sql = "
|
||||
SELECT
|
||||
hs.idhome,
|
||||
h.name,
|
||||
h.address,
|
||||
h.zip,
|
||||
h.city,
|
||||
h.country,
|
||||
hs.sharing_type,
|
||||
hs.expiration_date,
|
||||
au.first_name,
|
||||
au.last_name
|
||||
FROM home_sharing hs
|
||||
LEFT JOIN home h ON hs.idhome = h.idhome
|
||||
LEFT JOIN auth_users au ON hs.iduser = au.id
|
||||
WHERE
|
||||
(hs.idshareduser = ? OR hs.shared_email = ?)
|
||||
AND hs.status = 'accepted'
|
||||
SELECT
|
||||
hs.idhome,
|
||||
h.name,
|
||||
h.address,
|
||||
h.zip,
|
||||
h.city,
|
||||
h.country,
|
||||
hs.sharing_type,
|
||||
hs.expiration_date,
|
||||
au.first_name,
|
||||
au.last_name,
|
||||
COUNT(ho.owner_id) AS owner_count
|
||||
FROM home_sharing hs
|
||||
LEFT JOIN home h ON hs.idhome = h.idhome
|
||||
LEFT JOIN auth_users au ON hs.iduser = au.id
|
||||
LEFT JOIN home_owners ho ON hs.idhome = ho.home_id
|
||||
WHERE
|
||||
(hs.idshareduser = ? OR hs.shared_email = ?)
|
||||
AND hs.status = 'accepted'
|
||||
GROUP BY
|
||||
hs.idhome,
|
||||
h.name,
|
||||
h.address,
|
||||
h.zip,
|
||||
h.city,
|
||||
h.country,
|
||||
hs.sharing_type,
|
||||
hs.expiration_date,
|
||||
au.first_name,
|
||||
au.last_name;
|
||||
";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param('is', $iduserlogin, $emailuser);
|
||||
@ -91,7 +104,7 @@ $result = $stmt->get_result();
|
||||
<th>Città</th>
|
||||
<th>Nazione</th>
|
||||
<th>Condiviso da</th>
|
||||
<th>Tipo Condivisione</th>
|
||||
<th>Proprietari</th>
|
||||
<th>Data Scadenza</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
@ -105,16 +118,43 @@ $result = $stmt->get_result();
|
||||
<td><?php echo htmlspecialchars($row['city']); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['country']); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['first_name'] . ' ' . $row['last_name']); ?></td>
|
||||
<td><?php echo htmlspecialchars(ucfirst($row['sharing_type'])); ?></td>
|
||||
<td>
|
||||
<?php if ($row['owner_count'] == 0) { ?>
|
||||
<!-- Pulsante rosso per nessun proprietario -->
|
||||
<a href="assign-owners.php?idhome=<?php echo $row['idhome']; ?>&editpage=nochange" class="btn btn-danger btn-sm" title="Nessun Proprietario">
|
||||
<i class="fas fa-user-times"></i> <!-- Icona per nessun proprietario -->
|
||||
</a>
|
||||
<?php } else { ?>
|
||||
<!-- Pulsante verde con il numero dei proprietari -->
|
||||
<a href="assign-owners.php?idhome=<?php echo $row['idhome']; ?>&editpage=nochange" class="btn btn-success btn-sm" title="<?php echo $row['owner_count']; ?> Proprietari">
|
||||
<i class="fas fa-user-check"></i> <!-- Icona per proprietari presenti -->
|
||||
|
||||
</a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<?php echo $row['expiration_date'] ? htmlspecialchars($row['expiration_date']) : 'Nessuna'; ?>
|
||||
</td>
|
||||
<td>
|
||||
<!-- Pulsante per modificare i dettagli della casa -->
|
||||
<a href="manage-home.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-info btn-sm" title="Dettagli">
|
||||
<i class="fas fa-info-circle"></i>
|
||||
</a>
|
||||
<!-- Pulsante per visualizzare i dettagli -->
|
||||
<a href="documents-home-shared.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-primary btn-sm" title="Documenti">
|
||||
<i class="fas fa-folder-open"></i>
|
||||
</a>
|
||||
<!-- Pulsante per scaricare zip -->
|
||||
<a href="download-zip.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-warning btn-sm" title="Scarica ZIP">
|
||||
<i class="fas fa-file-archive"></i>
|
||||
</a>
|
||||
<!-- Pulsante per scaricare report -->
|
||||
<a href="download-report.php?idhome=<?php echo $row['idhome']; ?>" class="btn btn-danger btn-sm" title="Scarica Report">
|
||||
<i class="fas fa-file-alt"></i>
|
||||
</a>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
@ -122,6 +162,11 @@ $result = $stmt->get_result();
|
||||
</div><!-- end table-responsive -->
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<button onclick="history.back()" class="btn btn-dark">
|
||||
<i class="fas fa-arrow-left"></i> Torna indietro
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- container -->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user