This commit is contained in:
Claudio 2025-02-25 14:08:48 +01:00
parent 80ece398c4
commit a08f3f5e8c
6 changed files with 31 additions and 24 deletions

View File

@ -484,7 +484,7 @@ $result = $stmt->get_result();
<div class="card-body text-center"> <div class="card-body text-center">
<h5 class="card-title"><?php echo htmlspecialchars($row['name']); ?></h5> <h5 class="card-title"><?php echo htmlspecialchars($row['name']); ?></h5>
<p class="card-text"><?php echo htmlspecialchars($row['address']); ?></p> <p class="card-text"><?php echo htmlspecialchars($row['address']); ?> - <?php echo htmlspecialchars($row['city']); ?></p>
</div> </div>
</div> </div>
</div> </div>
@ -591,7 +591,11 @@ $result = $stmt->get_result();
<script> <script>
// Gestisci l'eliminazione con SweetAlert // Gestisci l'eliminazione con SweetAlert
$('.delete-home-btn').on('click', function() { $('.delete-home-btn').on('click', function() {
var idhome = $(this).data('id'); // Ottieni l'id della casa console.log("Bottone eliminazione cliccato!"); // Debugging
var idhome = $(this).data('id');
console.log("ID Casa:", idhome); // Debugging
Swal.fire({ Swal.fire({
title: 'Sei sicuro?', title: 'Sei sicuro?',
text: "Questa azione eliminerà la casa e non può essere annullata.", text: "Questa azione eliminerà la casa e non può essere annullata.",
@ -603,16 +607,7 @@ $result = $stmt->get_result();
cancelButtonText: 'Annulla' cancelButtonText: 'Annulla'
}).then((result) => { }).then((result) => {
if (result.isConfirmed) { if (result.isConfirmed) {
// Chiude il dropdown prima di eseguire l'azione console.log("Utente ha confermato l'eliminazione."); // Debugging
let dropdownMenu = $(this).closest('.dropdown-menu');
let dropdownButton = dropdownMenu.prev('.dropdown-toggle');
let dropdownInstance = bootstrap.Dropdown.getInstance(dropdownButton[0]);
if (dropdownInstance) {
dropdownInstance.hide();
}
// Reindirizza al file di eliminazione
window.location.href = "delete-home.php?idhome=" + idhome; window.location.href = "delete-home.php?idhome=" + idhome;
} }
}); });

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

View File

@ -213,7 +213,7 @@ $cadastral_notesdb = $homeData['cadastral_notes'];
</div> </div>
</div> </div>
<button type="submit" class="btn btn-primary mt-3 w-100 save-btn d-none"><i class="fas fa-save"></i> Salva</button> <!-- <button type="submit" class="btn btn-primary mt-3 w-100 save-btn d-none"><i class="fas fa-save"></i> Salva</button> -->
</form> </form>
</div> </div>
</div> </div>
@ -238,7 +238,7 @@ $cadastral_notesdb = $homeData['cadastral_notes'];
// Se è un nuovo record, entra automaticamente in modalità modifica // Se è un nuovo record, entra automaticamente in modalità modifica
if (isNewRecord) { if (isNewRecord) {
// Modifica il testo del pulsante // Modifica il testo del pulsante
editToggleBtn.innerHTML = '<i class="fas fa-eye"></i> Visualizza'; editToggleBtn.innerHTML = '<i class="fas fa-save"></i> Salva';
editToggleBtn.classList.remove('btn-light'); editToggleBtn.classList.remove('btn-light');
editToggleBtn.classList.add('btn-info'); editToggleBtn.classList.add('btn-info');
@ -262,9 +262,9 @@ $cadastral_notesdb = $homeData['cadastral_notes'];
if (editMode) { if (editMode) {
// Attiva modalità modifica // Attiva modalità modifica
editToggleBtn.innerHTML = '<i class="fas fa-eye"></i> Visualizza'; editToggleBtn.innerHTML = '<i class="fas fa-save"></i> Salva';
editToggleBtn.classList.remove('btn-light'); editToggleBtn.classList.remove('btn-light');
editToggleBtn.classList.add('btn-info'); editToggleBtn.classList.add('btn-success');
// Abilita tutti i campi // Abilita tutti i campi
formFields.forEach(field => { formFields.forEach(field => {
@ -334,15 +334,27 @@ $cadastral_notesdb = $homeData['cadastral_notes'];
}); });
// Anteprima immagine selezionata // Anteprima immagine selezionata
document.getElementById("photo").addEventListener("change", function(event) { document.getElementById('photo').addEventListener('change', function(event) {
let file = event.target.files[0]; let file = event.target.files[0];
if (file) { if (!file) return;
let reader = new FileReader();
reader.onload = function(e) { let formData = new FormData();
document.getElementById("photo-preview").src = e.target.result; formData.append("photo", file);
}; formData.append("idhome", <?php echo $idhome; ?>);
reader.readAsDataURL(file);
} let xhr = new XMLHttpRequest();
xhr.open("POST", "save-home.php", true);
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
let response = JSON.parse(xhr.responseText);
if (response.success) {
document.getElementById('photo-preview').src = "mainphoto/" + response.filename;
} else {
alert("Errore nel caricamento: " + response.message);
}
}
};
xhr.send(formData);
}); });
</script> </script>