FEATURE: Confirmation Modal only grab clients initials for client side nav

This commit is contained in:
johnnyq 2023-09-05 18:26:15 -04:00
parent 316afa5603
commit 4b368ee5af
8 changed files with 43 additions and 27 deletions

View File

@ -202,7 +202,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<i class="fas fa-fw fa-user-secret mr-2"></i>Anonymize & Archive
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger" href="post.php?archive_contact=<?php echo $contact_id; ?>">
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_contact=<?php echo $contact_id; ?>">
<i class="fas fa-fw fa-archive mr-2"></i>Archive
</a>
<div class="dropdown-divider"></div>

View File

@ -1,20 +0,0 @@
<div class="modal" id="deleteClientModal<?php echo $client_id; ?>" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div class="mb-4" style="text-align: center;">
<i class="far fa-10x fa-times-circle text-danger mb-3 mt-3"></i>
<h2>Are you sure?</h2>
<h6 class="mb-4 text-secondary">Do you really want to <b>delete <?php echo $client_name; ?></b> and all associated data including financial data, logs, shared links etc.? This process cannot be undone.</h6>
<div class="form-group">
<input type="hidden" id="clientName<?php echo $client_id ?>" value="<?php echo $client_name; ?>">
<input class="form-control" type="text" id="clientNameProvided<?php echo $client_id ?>" onkeyup="validateClientNameDelete(<?php echo $client_id ?>)" placeholder="Please enter: '<?php echo $client_name; ?>'">
</div>
<button type="button" class="btn btn-outline-secondary btn-lg px-5 mr-4" data-dismiss="modal">Cancel</button>
<a class="btn btn-danger btn-lg px-5 disabled" id="clientDeleteButton<?php echo $client_id ?>" href="post.php?delete_client=<?php echo $client_id; ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>">Yes, Delete!</a>
</div>
</div>
</div>
</div>
</div>
<script src="js/client_delete_confirm.js"></script>

View File

@ -2,7 +2,7 @@
<aside class="main-sidebar sidebar-dark-<?php echo nullable_htmlentities($config_theme); ?> d-print-none">
<a class="brand-link pb-1 mt-1" href="clients.php">
<p class="h5"><i class="nav-icon fas fa-arrow-left ml-3 mr-2"></i> Back | <strong><?php echo $client_name; ?></strong></p>
<p class="h5"><i class="nav-icon fas fa-arrow-left ml-3 mr-2"></i> Back | <strong><?php echo initials($client_name); ?></strong></p>
</a>
<!-- Sidebar -->

View File

@ -286,11 +286,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<i class="fas fa-fw fa-edit mr-2"></i>Edit
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger" href="post.php?archive_client=<?php echo $client_id; ?>">
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_client=<?php echo $client_id; ?>">
<i class="fas fa-fw fa-archive mr-2"></i>Archive
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger text-bold" href="#" data-toggle="modal" data-target="#deleteClientModal<?php echo $client_id; ?>">
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_client=<?php echo $client_id; ?>">
<i class="fas fa-fw fa-trash mr-2"></i>Delete
</a>
</div>
@ -302,7 +302,6 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<?php
require("client_edit_modal.php");
require("client_delete_modal.php");
} ?>

View File

@ -1,3 +1,5 @@
<?php require_once("inc_confirm_modal.php"); ?>
</div><!-- /.container-fluid -->
</div>
<!-- /.content -->

View File

@ -154,6 +154,5 @@
require_once("client_edit_modal.php");
require_once("client_download_pdf_modal.php");
require_once("client_delete_modal.php");
require_once("category_quick_add_modal.php");

19
inc_confirm_modal.php Normal file
View File

@ -0,0 +1,19 @@
<div class="modal fade" id="confirmationModal" tabindex="-1" role="dialog" aria-labelledby="confirmationModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="confirmationModalLabel">Confirm</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Are you sure you?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="confirmSubmitBtn">Yes</button>
</div>
</div>
</div>
</div>

View File

@ -104,4 +104,21 @@ clipboard.on('error', function(e) {
// Enable Popovers
$(function () {
$('[data-toggle="popover"]').popover()
});
});
$(document).ready(function() {
$("a.confirm-link").click(function(e) {
e.preventDefault();
// Save the link reference to use after confirmation
var linkReference = this;
// Show the confirmation modal
$("#confirmationModal").modal('show');
// When the submission is confirmed via the modal
$("#confirmSubmitBtn").off('click').on('click', function() {
window.location.href = $(linkReference).attr('href');
});
});
});