Add Bulk Actions to Locations
This commit is contained in:
+1
-1
@@ -131,7 +131,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
<input class="form-check-input bulk-select" type="checkbox" name="domain_ids[]" value="<?php echo $domain_id ?>">
|
<input class="form-check-input bulk-select" type="checkbox" name="domain_ids[]" value="<?php echo $domain_id ?>">
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class="">
|
||||||
<a class="text-dark" href="#" data-toggle="modal" onclick="populateDomainEditModal(<?php echo $client_id, ",", $domain_id ?>)" data-target="#editDomainModal">
|
<a class="text-dark" href="#" data-toggle="modal" onclick="populateDomainEditModal(<?php echo $client_id, ",", $domain_id ?>)" data-target="#editDomainModal">
|
||||||
<div class="media">
|
<div class="media">
|
||||||
<i class="fa fa-fw fa-2x fa-globe mr-3"></i>
|
<i class="fa fa-fw fa-2x fa-globe mr-3"></i>
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<div class="modal" id="bulkAssignTagsModal" tabindex="-1">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content bg-dark">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title"><i class="fa fa-fw fa-tags mr-2"></i>Bulk Assign Tags</h5>
|
||||||
|
<button type="button" class="close text-white" data-dismiss="modal">
|
||||||
|
<span>×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-body bg-white">
|
||||||
|
<input type="hidden" name="bulk_remove_tags" value="0">
|
||||||
|
|
||||||
|
<div class="form-group form-check">
|
||||||
|
<input type="checkbox" class="form-check-input" name="bulk_remove_tags" value="1">
|
||||||
|
<label class="form-check-label text-danger">Remove Existing Tags</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Tags</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text"><i class="fa fa-fw fa-tags"></i></span>
|
||||||
|
</div>
|
||||||
|
<select class="form-control select2" name="bulk_tags[]" data-placeholder="Add some tags" multiple>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$sql_tags_select = mysqli_query($mysqli, "SELECT * FROM tags WHERE tag_type = 2 ORDER BY tag_name ASC");
|
||||||
|
while ($row = mysqli_fetch_array($sql_tags_select)) {
|
||||||
|
$tag_id_select = intval($row['tag_id']);
|
||||||
|
$tag_name_select = nullable_htmlentities($row['tag_name']);
|
||||||
|
?>
|
||||||
|
<option value="<?php echo $tag_id_select; ?>"><?php echo $tag_name_select; ?></option>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer bg-white">
|
||||||
|
<button type="submit" name="bulk_assign_location_tags" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Assign</button>
|
||||||
|
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
+53
-1
@@ -95,22 +95,57 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<div class="float-right">
|
<div class="btn-group float-right">
|
||||||
<?php if($archived == 1){ ?>
|
<?php if($archived == 1){ ?>
|
||||||
<a href="?client_id=<?php echo $client_id; ?>&archived=0" class="btn btn-primary"><i class="fa fa-fw fa-archive mr-2"></i>Archived</a>
|
<a href="?client_id=<?php echo $client_id; ?>&archived=0" class="btn btn-primary"><i class="fa fa-fw fa-archive mr-2"></i>Archived</a>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<a href="?client_id=<?php echo $client_id; ?>&archived=1" class="btn btn-default"><i class="fa fa-fw fa-archive mr-2"></i>Archived</a>
|
<a href="?client_id=<?php echo $client_id; ?>&archived=1" class="btn btn-default"><i class="fa fa-fw fa-archive mr-2"></i>Archived</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
<div class="dropdown ml-2" id="bulkActionButton" hidden>
|
||||||
|
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">
|
||||||
|
<i class="fas fa-fw fa-layer-group mr-2"></i>Bulk Action (<span id="selectedCount">0</span>)
|
||||||
|
</button>
|
||||||
|
<div class="dropdown-menu">
|
||||||
|
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#bulkAssignTagsModal">
|
||||||
|
<i class="fas fa-fw fa-tags mr-2"></i>Assign Tags
|
||||||
|
</a>
|
||||||
|
<?php if ($archived) { ?>
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
|
<button class="dropdown-item text-info"
|
||||||
|
type="submit" form="bulkActions" name="bulk_unarchive_locations">
|
||||||
|
<i class="fas fa-fw fa-redo mr-2"></i>Unarchive
|
||||||
|
</button>
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
|
<button class="dropdown-item text-danger text-bold"
|
||||||
|
type="submit" form="bulkActions" name="bulk_delete_locations">
|
||||||
|
<i class="fas fa-fw fa-trash mr-2"></i>Delete
|
||||||
|
</button>
|
||||||
|
<?php } else { ?>
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
|
<button class="dropdown-item text-danger confirm-link"
|
||||||
|
type="submit" form="bulkActions" name="bulk_archive_locations">
|
||||||
|
<i class="fas fa-fw fa-archive mr-2"></i>Archive
|
||||||
|
</button>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<hr>
|
<hr>
|
||||||
|
<form id="bulkActions" action="post.php" method="post">
|
||||||
|
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
|
||||||
<div class="table-responsive-sm">
|
<div class="table-responsive-sm">
|
||||||
<table class="table table-striped table-borderless table-hover">
|
<table class="table table-striped table-borderless table-hover">
|
||||||
<thead class="<?php if ($num_rows[0] == 0) { echo "d-none"; } ?>">
|
<thead class="<?php if ($num_rows[0] == 0) { echo "d-none"; } ?>">
|
||||||
<tr>
|
<tr>
|
||||||
|
<td class="bg-light pr-0">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" id="selectAllCheckbox" type="checkbox" onclick="checkAll(this)">
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=location_name&order=<?php echo $disp; ?>">Name</a></th>
|
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=location_name&order=<?php echo $disp; ?>">Name</a></th>
|
||||||
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=location_address&order=<?php echo $disp; ?>">Address</a></th>
|
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=location_address&order=<?php echo $disp; ?>">Address</a></th>
|
||||||
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=location_phone&order=<?php echo $disp; ?>">Phone</a></th>
|
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=location_phone&order=<?php echo $disp; ?>">Phone</a></th>
|
||||||
@@ -145,6 +180,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
$location_photo = nullable_htmlentities($row['location_photo']);
|
$location_photo = nullable_htmlentities($row['location_photo']);
|
||||||
$location_notes = nullable_htmlentities($row['location_notes']);
|
$location_notes = nullable_htmlentities($row['location_notes']);
|
||||||
$location_created_at = nullable_htmlentities($row['location_created_at']);
|
$location_created_at = nullable_htmlentities($row['location_created_at']);
|
||||||
|
$location_archived_at = nullable_htmlentities($row['location_archived_at']);
|
||||||
$location_contact_id = intval($row['location_contact_id']);
|
$location_contact_id = intval($row['location_contact_id']);
|
||||||
$location_primary = intval($row['location_primary']);
|
$location_primary = intval($row['location_primary']);
|
||||||
if ( $location_primary == 1 ) {
|
if ( $location_primary == 1 ) {
|
||||||
@@ -178,6 +214,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td class="pr-0 bg-light">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input bulk-select" type="checkbox" name="location_ids[]" value="<?php echo $location_id ?>">
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a class="text-dark" href="#" data-toggle="modal" data-target="#editLocationModal<?php echo $location_id; ?>">
|
<a class="text-dark" href="#" data-toggle="modal" data-target="#editLocationModal<?php echo $location_id; ?>">
|
||||||
<div class="media">
|
<div class="media">
|
||||||
@@ -209,10 +250,17 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
||||||
</a>
|
</a>
|
||||||
<?php if ($session_user_role == 3 && $location_primary == 0) { ?>
|
<?php if ($session_user_role == 3 && $location_primary == 0) { ?>
|
||||||
|
<?php if ($location_archived_at) { ?>
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
|
<a class="dropdown-item text-info confirm-link" href="post.php?unarchive_location=<?php echo $location_id; ?>">
|
||||||
|
<i class="fas fa-fw fa-redo mr-2"></i>Unarchive
|
||||||
|
</a>
|
||||||
|
<?php } else { ?>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_location=<?php echo $location_id; ?>">
|
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_location=<?php echo $location_id; ?>">
|
||||||
<i class="fas fa-fw fa-archive mr-2"></i>Archive
|
<i class="fas fa-fw fa-archive mr-2"></i>Archive
|
||||||
</a>
|
</a>
|
||||||
|
<?php } ?>
|
||||||
<?php if ($config_destructive_deletes_enable) { ?>
|
<?php if ($config_destructive_deletes_enable) { ?>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_location=<?php echo $location_id; ?>">
|
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_location=<?php echo $location_id; ?>">
|
||||||
@@ -232,11 +280,15 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<?php require_once "client_location_bulk_assign_tags_modal.php"; ?>
|
||||||
|
</form>
|
||||||
<?php require_once "pagination.php";
|
<?php require_once "pagination.php";
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script src="js/bulk_actions.js"></script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once "client_location_add_modal.php";
|
require_once "client_location_add_modal.php";
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td class="pr-0">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input bulk-select" type="checkbox" name="scheduled_ticket_ids[]" value="<?php echo $scheduled_ticket_id ?>">
|
<input class="form-check-input bulk-select" type="checkbox" name="scheduled_ticket_ids[]" value="<?php echo $scheduled_ticket_id ?>">
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+167
-3
@@ -158,9 +158,9 @@ if(isset($_GET['archive_location'])){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_GET['undo_archive_location'])){
|
if(isset($_GET['unarchive_location'])){
|
||||||
|
|
||||||
$location_id = intval($_GET['undo_archive_location']);
|
$location_id = intval($_GET['unarchive_location']);
|
||||||
|
|
||||||
// Get Location Name and Client ID for logging and alert message
|
// Get Location Name and Client ID for logging and alert message
|
||||||
$sql = mysqli_query($mysqli,"SELECT location_name, location_client_id FROM locations WHERE location_id = $location_id");
|
$sql = mysqli_query($mysqli,"SELECT location_name, location_client_id FROM locations WHERE location_id = $location_id");
|
||||||
@@ -171,7 +171,7 @@ if(isset($_GET['undo_archive_location'])){
|
|||||||
mysqli_query($mysqli,"UPDATE locations SET location_archived_at = NULL WHERE location_id = $location_id");
|
mysqli_query($mysqli,"UPDATE locations SET location_archived_at = NULL WHERE location_id = $location_id");
|
||||||
|
|
||||||
//Logging
|
//Logging
|
||||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Location', log_action = 'Undo Archive', log_description = '$session_name restored location $location_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $location_id");
|
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Location', log_action = 'Unarchive', log_description = '$session_name restored location $location_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $location_id");
|
||||||
|
|
||||||
$_SESSION['alert_message'] = "Location <strong>$location_name</strong> restored";
|
$_SESSION['alert_message'] = "Location <strong>$location_name</strong> restored";
|
||||||
|
|
||||||
@@ -206,6 +206,170 @@ if(isset($_GET['delete_location'])){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['bulk_assign_location_tags'])) {
|
||||||
|
|
||||||
|
validateTechRole();
|
||||||
|
|
||||||
|
// Get Selected Count
|
||||||
|
$count = count($_POST['location_ids']);
|
||||||
|
|
||||||
|
// Assign Tags to Selected
|
||||||
|
if (!empty($_POST['location_ids'])) {
|
||||||
|
foreach($_POST['location_ids'] as $location_id) {
|
||||||
|
$location_id = intval($location_id);
|
||||||
|
|
||||||
|
// Get Contact Details for Logging
|
||||||
|
$sql = mysqli_query($mysqli,"SELECT location_name, location_client_id FROM locations WHERE location_id = $location_id");
|
||||||
|
$row = mysqli_fetch_array($sql);
|
||||||
|
$location_name = sanitizeInput($row['location_name']);
|
||||||
|
$client_id = intval($row['location_client_id']);
|
||||||
|
|
||||||
|
if($_POST['bulk_remove_tags']) {
|
||||||
|
// Delete tags if chosed to do so
|
||||||
|
mysqli_query($mysqli, "DELETE FROM location_tags WHERE location_id = $location_id");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add new tags
|
||||||
|
foreach($_POST['bulk_tags'] as $tag) {
|
||||||
|
$tag = intval($tag);
|
||||||
|
|
||||||
|
$sql = mysqli_query($mysqli,"SELECT * FROM location_tags WHERE location_id = $location_id AND tag_id = $tag");
|
||||||
|
if (mysqli_num_rows($sql) == 0) {
|
||||||
|
mysqli_query($mysqli, "INSERT INTO location_tags SET location_id = $location_id, tag_id = $tag");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Logging
|
||||||
|
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Location', log_action = 'Modify', log_description = '$session_name added tags to $location_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $location_id");
|
||||||
|
|
||||||
|
} // End Assign Location Loop
|
||||||
|
|
||||||
|
$_SESSION['alert_message'] = "Assigned tags for <b>$count</b> locations";
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['bulk_archive_locations'])) {
|
||||||
|
validateAdminRole();
|
||||||
|
validateCSRFToken($_POST['csrf_token']);
|
||||||
|
|
||||||
|
$count = 0; // Default 0
|
||||||
|
$location_ids = $_POST['location_ids']; // Get array of IDs to be deleted
|
||||||
|
|
||||||
|
if (!empty($location_ids)) {
|
||||||
|
|
||||||
|
// Cycle through array and archive each contact
|
||||||
|
foreach ($location_ids as $location_id) {
|
||||||
|
|
||||||
|
$location_id = intval($location_id);
|
||||||
|
|
||||||
|
// Get Name and Client ID for logging and alert message
|
||||||
|
$sql = mysqli_query($mysqli,"SELECT location_name, location_client_id, location_primary FROM locations WHERE location_id = $location_id");
|
||||||
|
$row = mysqli_fetch_array($sql);
|
||||||
|
$location_name = sanitizeInput($row['location_name']);
|
||||||
|
$location_primary = intval($row['location_primary']);
|
||||||
|
$client_id = intval($row['location_client_id']);
|
||||||
|
|
||||||
|
|
||||||
|
if($location_primary == 0) {
|
||||||
|
mysqli_query($mysqli,"UPDATE locations SET location_archived_at = NOW() WHERE location_id = $location_id");
|
||||||
|
|
||||||
|
// Individual Contact logging
|
||||||
|
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Location', log_action = 'Archive', log_description = '$session_name archived location $location_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $location_id");
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bulk Logging
|
||||||
|
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Location', log_action = 'Archive', log_description = '$session_name archived $count locations', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id");
|
||||||
|
|
||||||
|
$_SESSION['alert_type'] = "error";
|
||||||
|
$_SESSION['alert_message'] = "Archived $count location(s)";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['bulk_unarchive_locations'])) {
|
||||||
|
validateAdminRole();
|
||||||
|
validateCSRFToken($_POST['csrf_token']);
|
||||||
|
|
||||||
|
$count = 0; // Default 0
|
||||||
|
$location_ids = $_POST['location_ids']; // Get array of IDs
|
||||||
|
|
||||||
|
if (!empty($location_ids)) {
|
||||||
|
|
||||||
|
// Cycle through array and unarchive
|
||||||
|
foreach ($location_ids as $location_id) {
|
||||||
|
|
||||||
|
$location_id = intval($location_id);
|
||||||
|
|
||||||
|
// Get Name and Client ID for logging and alert message
|
||||||
|
$sql = mysqli_query($mysqli,"SELECT location_name, location_client_id FROM locations WHERE location_id = $location_id");
|
||||||
|
$row = mysqli_fetch_array($sql);
|
||||||
|
$location_name = sanitizeInput($row['location_name']);
|
||||||
|
$client_id = intval($row['location_client_id']);
|
||||||
|
|
||||||
|
mysqli_query($mysqli,"UPDATE locations SET location_archived_at = NULL WHERE location_id = $location_id");
|
||||||
|
|
||||||
|
// Individual logging
|
||||||
|
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Asset', log_action = 'Unarchive', log_description = '$session_name Unarchived location $location_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $location_id");
|
||||||
|
|
||||||
|
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bulk Logging
|
||||||
|
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Asset', log_action = 'Unarchive', log_description = '$session_name Unarchived $count locations', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id");
|
||||||
|
|
||||||
|
$_SESSION['alert_message'] = "Unarchived $count location(s)";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['bulk_delete_locations'])) {
|
||||||
|
validateAdminRole();
|
||||||
|
validateCSRFToken($_POST['csrf_token']);
|
||||||
|
|
||||||
|
$count = 0; // Default 0
|
||||||
|
$location_ids = $_POST['location_ids']; // Get array of IDs to be deleted
|
||||||
|
|
||||||
|
if (!empty($location_ids)) {
|
||||||
|
|
||||||
|
// Cycle through array and delete each record
|
||||||
|
foreach ($location_ids as $location_id) {
|
||||||
|
|
||||||
|
$location_id = intval($location_id);
|
||||||
|
|
||||||
|
// Get Name and Client ID for logging and alert message
|
||||||
|
$sql = mysqli_query($mysqli,"SELECT location_name, location_client_id FROM locations WHERE location_id = $location_id");
|
||||||
|
$row = mysqli_fetch_array($sql);
|
||||||
|
$location_name = sanitizeInput($row['location_name']);
|
||||||
|
$client_id = intval($row['location_client_id']);
|
||||||
|
|
||||||
|
|
||||||
|
mysqli_query($mysqli, "DELETE FROM locations WHERE location_id = $location_id AND location_client_id = $client_id");
|
||||||
|
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Location', log_action = 'Delete', log_description = '$session_name deleted location $location_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $location_id");
|
||||||
|
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logging
|
||||||
|
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Location', log_action = 'Delete', log_description = '$session_name bulk deleted $count locations', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id");
|
||||||
|
|
||||||
|
$_SESSION['alert_message'] = "Deleted $count location(s)";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||||
|
}
|
||||||
|
|
||||||
if(isset($_POST['export_client_locations_csv'])){
|
if(isset($_POST['export_client_locations_csv'])){
|
||||||
$client_id = intval($_POST['client_id']);
|
$client_id = intval($_POST['client_id']);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user