changed assegna proprietario
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
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);
|
||||
}
|
||||
|
||||
$idhome = isset($_GET['idhome']) ? intval($_GET['idhome']) : 0;
|
||||
|
||||
// Recupera tutti i proprietari disponibili per l'assegnazione
|
||||
$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();
|
||||
|
||||
// Genera il nuovo dropdown
|
||||
echo '<select class="form-control" id="ownerSelect" name="owner_id" required>';
|
||||
echo '<option value="">-- Seleziona --</option>';
|
||||
while ($availableOwner = $resultAvailableOwners->fetch_assoc()) {
|
||||
echo '<option value="' . $availableOwner['owner_id'] . '">';
|
||||
echo htmlspecialchars($availableOwner['first_name'] . ' ' . $availableOwner['last_name']);
|
||||
if ($availableOwner['company_name']) {
|
||||
echo ' (' . htmlspecialchars($availableOwner['company_name']) . ')';
|
||||
}
|
||||
echo ' - ' . htmlspecialchars($availableOwner['tax_code']);
|
||||
echo '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
|
||||
$conn->close();
|
||||
Reference in New Issue
Block a user