update document page
This commit is contained in:
@@ -1,14 +1,22 @@
|
||||
<?php
|
||||
include('include/headscript.php');
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die("Errore di connessione: " . $conn->connect_error);
|
||||
}
|
||||
require_once 'class/db-functions.php';
|
||||
|
||||
// Inizializza la connessione al database
|
||||
$dbHandler = DBHandlerSelect::getInstance();
|
||||
$pdo = $dbHandler->getConnection();
|
||||
|
||||
// Recupera l'ID dell'immobile
|
||||
$idhome = isset($_GET['idhome']) ? intval($_GET['idhome']) : 0;
|
||||
|
||||
$queryOwners = $conn->prepare("
|
||||
if ($idhome <= 0) {
|
||||
echo '<p class="text-muted">Errore: ID immobile non valido.</p>';
|
||||
exit();
|
||||
}
|
||||
|
||||
// Recupera i proprietari associati all'immobile
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT
|
||||
po.owner_id,
|
||||
po.first_name,
|
||||
@@ -25,13 +33,12 @@ $queryOwners = $conn->prepare("
|
||||
WHERE
|
||||
ho.home_id = ?
|
||||
");
|
||||
$queryOwners->bind_param('i', $idhome);
|
||||
$queryOwners->execute();
|
||||
$resultOwners = $queryOwners->get_result();
|
||||
$stmt->execute([$idhome]);
|
||||
$owners = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
$totalPercentage = 0;
|
||||
|
||||
echo '<table class="table table-bordered">
|
||||
if (!empty($owners)) {
|
||||
?>
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Nome</th>
|
||||
@@ -41,32 +48,35 @@ echo '<table class="table table-bordered">
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
|
||||
while ($owner = $resultOwners->fetch_assoc()) {
|
||||
$totalPercentage += $owner['ownership_percentage'];
|
||||
echo "<tr>
|
||||
<td>" . htmlspecialchars($owner['first_name'] . ' ' . $owner['last_name']) . "</td>
|
||||
<td>" . htmlspecialchars($owner['tax_code']) . "</td>
|
||||
<td class='ownership-percentage'>" . htmlspecialchars($owner['ownership_percentage']) . "</td>
|
||||
<td>" . htmlspecialchars($owner['notes']) . "</td>
|
||||
<td>
|
||||
<button class='btn btn-danger btn-sm remove-owner-btn' data-id='" . $owner['owner_id'] . "'>
|
||||
<i class='fas fa-trash-alt'></i> Rimuovi
|
||||
</button>
|
||||
</td>
|
||||
</tr>";
|
||||
<tbody id="ownersTableBody">
|
||||
<?php
|
||||
$totalPercentage = 0;
|
||||
foreach ($owners as $owner) {
|
||||
$totalPercentage += $owner['ownership_percentage'];
|
||||
echo "<tr>
|
||||
<td>" . htmlspecialchars($owner['first_name'] . ' ' . $owner['last_name']) . "</td>
|
||||
<td>" . htmlspecialchars($owner['tax_code']) . "</td>
|
||||
<td class='ownership-percentage'>" . htmlspecialchars($owner['ownership_percentage']) . "</td>
|
||||
<td>" . htmlspecialchars($owner['notes']) . "</td>
|
||||
<td>
|
||||
<button class='btn btn-danger btn-sm remove-owner-btn' data-id='" . $owner['owner_id'] . "'>
|
||||
<i class='fas fa-trash-alt'></i> Rimuovi
|
||||
</button>
|
||||
</td>
|
||||
</tr>";
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Totale % Proprietà:</strong></td>
|
||||
<td id="totalOwnership" class="font-weight-bold text-center"><?php echo $totalPercentage; ?>%</td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php
|
||||
} else {
|
||||
echo '<p class="text-muted">Nessun proprietario associato.</p>';
|
||||
}
|
||||
|
||||
echo '</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="2"><strong>Totale % Proprietà:</strong></td>
|
||||
<td id="totalOwnership" class="font-weight-bold text-center">' . $totalPercentage . '%</td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>';
|
||||
|
||||
$queryOwners->close();
|
||||
$conn->close();
|
||||
?>
|
||||
Reference in New Issue
Block a user