update for Audit form Contact for Accredia M18b

This commit is contained in:
2024-09-18 16:01:31 +02:00
parent eb475f257e
commit 91ae77aff1
5 changed files with 332 additions and 200 deletions
+90 -15
View File
@@ -283,7 +283,7 @@ $idprotectioncategoryJson = json_encode($idproteccategorylistRecord);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script> -->
<script src="https://kit.fontawesome.com/f13e61f9bf.js" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
@@ -518,31 +518,51 @@ $idprotectioncategoryJson = json_encode($idproteccategorylistRecord);
<p><?php echo $auditcompanylocation; ?></p>
<?php
$audticontactdata = new WA_MySQLi_RS("audticontactdata", $cmctrfdb, 1);
$audticontactdata->setQuery("SELECT * FROM contacts WHERE contacts.idtrf='$idtrf' AND contacts.kindofcontacts='audit'");
$audticontactdata->execute();
$auditcontactlist = new WA_MySQLi_RS("auditcontactlist", $cmctrfdb, 0);
$auditcontactlist->setQuery("SELECT * FROM contacts WHERE contacts.idtrf='$idtrf' AND contacts.kindofcontacts='audit'");
$auditcontactlist->execute();
?>
<table class="table mb-0">
<thead>
<tr>
<th scope="col"><?php echo $anagraficacompany; ?></th>
<th scope="col"><?php echo $anagraficaaddress; ?></th>
<th scope="col"><?php echo $anagraficacity; ?></th>
<th><?php echo $anagraficacompany; ?></th>
<th><?php echo $anagraficaaddress; ?></th>
<th><?php echo $anagraficacity; ?></th>
<th><?php echo "Action"; ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo ($audticontactdata->getColumnVal("companyname")); ?></td>
<td><?php echo ($audticontactdata->getColumnVal("address")); ?></td>
<td><?php echo ($audticontactdata->getColumnVal("city")); ?></td>
</tr>
<?php while (!$auditcontactlist->atEnd()) { ?>
<tr>
<td><?php echo $auditcontactlist->getColumnVal("companyname"); ?></td>
<td><?php echo $auditcontactlist->getColumnVal("address"); ?></td>
<td><?php echo $auditcontactlist->getColumnVal("city"); ?></td>
<td>
<!-- Pulsante di modifica -->
<a class="badge_btn" onclick="window.open('contactpopaudit.php?kindcontacts=audit&idtrf=<?php echo $idtrf; ?>&idcontacts=<?php echo ($auditcontactlist->getColumnVal("idcontacts")); ?>', '_blank', 'location=yes,height=950,width=1400,scrollbars=yes,status=yes');">
<button type="button" class="btn btn-primary waves-effect waves-light">MODIFICA</button>
</a>
<!-- Pulsante di eliminazione (cestino) -->
<button type="button" class="btn btn-danger waves-effect waves-light delete-contact" data-id="<?php echo $auditcontactlist->getColumnVal('idcontacts'); ?>">
<i class="fas fa-trash-alt"></i>
</button>
</td>
</tr>
<?php
$auditcontactlist->moveNext();
}
?>
</tbody>
</table> <br>
<a class="badge_btn" onclick="window.open('contactpopaudit.php?kindcontacts=audit&idtrf=<?php echo $idtrf; ?>&idcontacts=<?php echo ($audticontactdata->getColumnVal("idcontacts")); ?>', '_blank', 'location=yes,height=950,width=1400,scrollbars=yes,status=yes');"><button type="button" class="btn btn-primary waves-effect waves-light">MODIFICA</button></a>
<a class="badge_btn" onclick="window.open('contactpopaudit.php?kindcontacts=audit&idtrf=<?php echo $idtrf; ?>&idcontacts=<?php echo ($auditcontactlist->getColumnVal("idcontacts")); ?>', '_blank', 'location=yes,height=950,width=1400,scrollbars=yes,status=yes');"><button type="button" class="btn btn-primary waves-effect waves-light">MODIFICA</button></a>
<!-- Pulsante per aggiungere un nuovo contatto -->
<a class="badge_btn" onclick="window.open('contactpopaudit.php?kindcontacts=audit&idtrf=<?php echo $idtrf; ?>&add_new_contact=1', '_blank', 'location=yes,height=950,width=1400,scrollbars=yes,status=yes');">
<button type="button" class="btn btn-success waves-effect waves-light">AGGIUNGI</button>
</a>
@@ -776,7 +796,62 @@ $idprotectioncategoryJson = json_encode($idproteccategorylistRecord);
<!-- end page-wrapper -->
<script>
$(document).ready(function() {
// Quando si clicca sul pulsante di eliminazione
$('.delete-contact').on('click', function() {
var contactId = $(this).data('id');
var row = $(this).closest('tr'); // Memorizza la riga da rimuovere
// Utilizza SweetAlert per conferma
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
// Invia la richiesta AJAX per eliminare il contatto
$.ajax({
url: 'delete_contact.php', // Il file PHP che esegue l'eliminazione
type: 'POST',
data: {
idcontacts: contactId
},
success: function(response) {
if (response === 'success') {
// Rimuovi la riga dalla tabella
row.remove();
// Mostra messaggio di successo con SweetAlert
Swal.fire(
'Deleted!',
'The contact has been deleted.',
'success'
);
} else {
Swal.fire(
'Error!',
'Failed to delete the contact.',
'error'
);
}
},
error: function() {
Swal.fire(
'Error!',
'An error occurred while deleting the contact.',
'error'
);
}
});
}
});
});
});
</script>
<!-- jQuery -->
<!-- <script src="assets/js/jquery.min.js"></script> -->