new commit and update
This commit is contained in:
@@ -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 -->
|
||||
|
||||
Reference in New Issue
Block a user