Undo: the message after archiving, a move or a bulk change has Undo, which puts it back as it was unless it changed since, and archiving no longer asks first except for clients; covers archiving every kind on Archived with contact roles, document links and a client's recurring invoices, file, document, folder and rack moves, and the bulk changes that set a field on tickets, assets, contacts, clients, projects, invoices, products and IP addresses

This commit is contained in:
johnnyq
2026-11-19 23:15:07 -05:00
parent c105d8f5e5
commit 6a5bc6cf55
52 changed files with 589 additions and 48 deletions

View File

@@ -403,7 +403,7 @@ if (mysqli_num_rows($sql) == 0) {
</a>
<?php } ?>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_asset=<?= $asset_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<a class="dropdown-item text-danger" href="post.php?archive_asset=<?= $asset_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -456,7 +456,7 @@ $search_noun = $type_filter ? $asset_type_tabs[$type_filter]['label'] : 'assets'
<?php } ?>
<?php } else { ?>
<div class="dropdown-divider"></div>
<button class="dropdown-item text-danger confirm-link"
<button class="dropdown-item text-danger"
type="submit" form="bulkActions" name="bulk_archive_assets">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</button>
@@ -777,7 +777,7 @@ $search_noun = $type_filter ? $asset_type_tabs[$type_filter]['label'] : 'assets'
</a>
<?php } ?>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_asset=<?= $asset_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<a class="dropdown-item text-danger" href="post.php?archive_asset=<?= $asset_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -238,7 +238,7 @@ $export_extra = [
</button>
<?php } ?>
<?php } else { ?>
<button class="dropdown-item text-danger confirm-link" type="submit" form="bulkActions" name="bulk_archive_certificates">
<button class="dropdown-item text-danger" type="submit" form="bulkActions" name="bulk_archive_certificates">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</button>
<?php } ?>
@@ -435,7 +435,7 @@ $export_extra = [
</a>
<?php } ?>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_certificate=<?= $certificate_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<a class="dropdown-item text-danger" href="post.php?archive_certificate=<?= $certificate_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -337,7 +337,7 @@ if (!$can_support) {
<i class="fas fa-fw fa-redo text-secondary me-2"></i>Restore
</a>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_contact=<?= $contact_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<a class="dropdown-item text-danger" href="post.php?archive_contact=<?= $contact_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php if ($can_delete) { ?>

View File

@@ -448,7 +448,7 @@ $search_placeholder = $invites_view ? 'Search invites by email, name or client'
</button>
<?php } ?>
<?php } else { ?>
<button class="dropdown-item text-danger confirm-link"
<button class="dropdown-item text-danger"
type="submit" form="bulkActions" name="bulk_archive_contacts">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</button>
@@ -710,7 +710,7 @@ $search_placeholder = $invites_view ? 'Search invites by email, name or client'
<i class="fas fa-fw fa-redo text-secondary me-2"></i>Restore
</a>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_contact=<?= $contact_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<a class="dropdown-item text-danger" href="post.php?archive_contact=<?= $contact_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php if ($can_delete) { ?>

View File

@@ -289,7 +289,7 @@ $filter_url = function ($changes) use ($client_url) {
</button>
<?php } ?>
<?php } else { ?>
<button class="dropdown-item text-danger confirm-link" type="submit" form="bulkActions" name="bulk_archive_credentials">
<button class="dropdown-item text-danger" type="submit" form="bulkActions" name="bulk_archive_credentials">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</button>
<?php } ?>
@@ -460,7 +460,7 @@ $filter_url = function ($changes) use ($client_url) {
</a>
<?php } ?>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_credential=<?= $credential_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<a class="dropdown-item text-danger" href="post.php?archive_credential=<?= $credential_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -143,7 +143,7 @@ $page_title = $row['document_name'];
<a class="dropdown-item" href="post.php?copy_document_to_kb=<?= $document_id ?>&csrf_token=<?= $csrf ?>" title="A draft article from it, for every client"><i class="fas fa-fw fa-book me-2"></i>Copy to Knowledge Base</a>
<?php } ?>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_document=<?= $document_id ?>&csrf_token=<?= $csrf ?>" data-confirm-text="Archiving unlinks it from everything it is linked to."><i class="fas fa-fw fa-archive me-2"></i>Archive</a>
<a class="dropdown-item text-danger" href="post.php?archive_document=<?= $document_id ?>&csrf_token=<?= $csrf ?>"><i class="fas fa-fw fa-archive me-2"></i>Archive</a>
<?php } else { ?>
<a class="dropdown-item" href="post.php?restore_document=<?= $document_id ?>&csrf_token=<?= $csrf ?>"><i class="fas fa-fw fa-redo me-2"></i>Restore</a>
<?php } ?>

View File

@@ -270,7 +270,7 @@ $bulk_vendor_options = $can_edit ? domainVendorChoices($client_url ? $client_id
</button>
<?php } ?>
<?php } else { ?>
<button class="dropdown-item text-danger confirm-link" type="submit" form="bulkActions" name="bulk_archive_domains">
<button class="dropdown-item text-danger" type="submit" form="bulkActions" name="bulk_archive_domains">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</button>
<?php } ?>
@@ -425,7 +425,7 @@ $bulk_vendor_options = $can_edit ? domainVendorChoices($client_url ? $client_id
</a>
<?php } ?>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_domain=<?= $domain_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<a class="dropdown-item text-danger" href="post.php?archive_domain=<?= $domain_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -275,7 +275,7 @@ function filesItemMenu($item) {
: "<a class=\"dropdown-item text-danger confirm-link\" href=\"post.php?delete_document=$id&amp;csrf_token=$csrf\"><i class=\"fas fa-fw fa-trash me-2\"></i>Delete</a>";
}
} else {
$html .= "<a class=\"dropdown-item text-danger confirm-link\" href=\"post.php?archive_$archive_name=$id&amp;csrf_token=$csrf\"><i class=\"fas fa-fw fa-archive me-2\"></i>Archive</a>";
$html .= "<a class=\"dropdown-item text-danger\" href=\"post.php?archive_$archive_name=$id&amp;csrf_token=$csrf\"><i class=\"fas fa-fw fa-archive me-2\"></i>Archive</a>";
}
}
return $html;
@@ -447,7 +447,7 @@ $preview = []; // the grid's previewer payload
<i class="fas fa-fw fa-file-archive me-2"></i>Download as zip
</button>
<div class="dropdown-divider"></div>
<button class="dropdown-item text-danger confirm-link" type="submit" form="bulkActions" name="bulk_archive_files">
<button class="dropdown-item text-danger" type="submit" form="bulkActions" name="bulk_archive_files">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</button>
<?php } else { ?>

View File

@@ -204,8 +204,7 @@ if (!$license || ($client_url && intval($license['software_client_id']) !== intv
<i class="fas fa-fw fa-users text-secondary me-2"></i>Seats
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_software=<?= $software_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>"
data-confirm-text="It drops off every device and user until it is restored.">
<a class="dropdown-item text-danger" href="post.php?archive_software=<?= $software_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -276,7 +276,7 @@ if (!$location || ($client_url && intval($location['location_client_id']) !== in
</a>
<?php } ?>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_location=<?= $location_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<a class="dropdown-item text-danger" href="post.php?archive_location=<?= $location_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -213,7 +213,7 @@ $locations_counts = locationCounts(array_keys($locations));
</button>
<?php } ?>
<?php } else { ?>
<button class="dropdown-item text-danger confirm-link" type="submit" form="bulkActions" name="bulk_archive_locations">
<button class="dropdown-item text-danger" type="submit" form="bulkActions" name="bulk_archive_locations">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</button>
<?php } ?>
@@ -395,7 +395,7 @@ $locations_counts = locationCounts(array_keys($locations));
</a>
<?php } ?>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_location=<?= $location_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<a class="dropdown-item text-danger" href="post.php?archive_location=<?= $location_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -187,8 +187,7 @@ if (!$network || ($client_url && intval($network['network_client_id']) !== intva
</a>
<?php } ?>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_network=<?= $network_id ?>&csrf_token=<?= $csrf ?>"
data-confirm-text="<?= $network_name ?> moves to Archived, off the lists and pickers, until restored. The devices on it keep it.">
<a class="dropdown-item text-danger" href="post.php?archive_network=<?= $network_id ?>&csrf_token=<?= $csrf ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -261,8 +261,7 @@ $csrf = $_SESSION['csrf_token'];
</button>
<?php } ?>
<?php } else { ?>
<button class="dropdown-item text-danger confirm-link" type="submit" form="bulkActions" name="bulk_archive_networks"
data-confirm-text="They move to Archived, off the lists and pickers, until restored. The devices on them keep them.">
<button class="dropdown-item text-danger" type="submit" form="bulkActions" name="bulk_archive_networks">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</button>
<?php } ?>
@@ -429,8 +428,7 @@ $csrf = $_SESSION['csrf_token'];
</a>
<?php } ?>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_network=<?= $network_id ?>&csrf_token=<?= $csrf ?>"
data-confirm-text="<?= $name ?> moves to Archived, off the lists and pickers, until restored. The devices on it keep it.">
<a class="dropdown-item text-danger" href="post.php?archive_network=<?= $network_id ?>&csrf_token=<?= $csrf ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -203,6 +203,7 @@ if (isset($_GET['archive_asset'])) {
enforceClientAccess();
$undo = undoArchiveBefore('asset', $asset_id); // for Undo on the message
mysqli_query($mysqli,"UPDATE assets SET asset_archived_at = NOW() WHERE asset_id = $asset_id");
// Add to History
@@ -211,6 +212,7 @@ if (isset($_GET['archive_asset'])) {
logAudit("Asset", "Archive", "$session_name archived asset $asset_name", $client_id, $asset_id);
flashAlert("Asset <strong>" . stripslashes($asset_name) . "</strong> archived", 'error');
undoOfferArchive($undo);
redirect();
@@ -438,6 +440,7 @@ if (isset($_POST['bulk_assign_asset_location'])) {
enforceClientAccess();
// Assign Location to Selected Assets
$undo = undoSnapshot('assets', 'asset_id', $_POST['asset_ids'] ?? [], ['asset_location_id'], 'asset_client_id'); // for Undo on the message
if (isset($_POST['asset_ids'])) {
// Only the assets of the location's client are moved
@@ -469,6 +472,7 @@ if (isset($_POST['bulk_assign_asset_location'])) {
logAudit("Asset", "Bulk Edit", "$session_name assigned $asset_count assets to location $location_name", $location_client_id);
flashAlert("<strong>$asset_count</strong> asset" . ($asset_count === 1 ? '' : 's') . " assigned to location <strong>" . stripslashes($location_name) . "</strong>");
undoOfferChanges($undo, "Location put back on <strong>{n}</strong> asset{s}", 'module_support');
}
redirect();
@@ -484,6 +488,7 @@ if (isset($_POST['bulk_assign_asset_physical_location'])) {
$physical_location = escapeSql($_POST['physical_location']);
// Assign Physical Location to Selected Assets
$undo = undoSnapshot('assets', 'asset_id', $_POST['asset_ids'] ?? [], ['asset_physical_location'], 'asset_client_id'); // for Undo on the message
if (isset($_POST['asset_ids'])) {
// Get Selected Assets Count
@@ -509,6 +514,7 @@ if (isset($_POST['bulk_assign_asset_physical_location'])) {
logAudit("Asset", "Bulk Edit", "$session_name set $asset_count assets to physical location $physical_location", $client_id);
flashAlert("Physical location of <strong>$asset_count</strong> asset" . ($asset_count === 1 ? '' : 's') . " set to <strong>" . stripslashes($physical_location) . "</strong>");
undoOfferChanges($undo, "Physical location put back on <strong>{n}</strong> asset{s}", 'module_support');
}
redirect();
@@ -635,6 +641,7 @@ if (isset($_POST['bulk_assign_asset_contact'])) {
enforceClientAccess();
// Assign Contact to Selected Assets
$undo = undoSnapshot('assets', 'asset_id', $_POST['asset_ids'] ?? [], ['asset_contact_id'], 'asset_client_id'); // for Undo on the message
if (isset($_POST['asset_ids'])) {
// Only the assets of the contact's client are assigned
@@ -663,6 +670,7 @@ if (isset($_POST['bulk_assign_asset_contact'])) {
logAudit("Asset", "Bulk Edit", "$session_name assigned $asset_count assets to contact $contact_name", $client_id);
flashAlert("<strong>$asset_count</strong> asset" . ($asset_count === 1 ? '' : 's') . " assigned to <strong>" . stripslashes($contact_name) . "</strong>");
undoOfferChanges($undo, "Contact put back on <strong>{n}</strong> asset{s}", 'module_support');
}
redirect();
@@ -677,6 +685,7 @@ if (isset($_POST['bulk_edit_asset_status'])) {
$status = escapeSql($_POST['bulk_status']);
$undo = undoSnapshot('assets', 'asset_id', $_POST['asset_ids'] ?? [], ['asset_status'], 'asset_client_id'); // for Undo on the message
if (isset($_POST['asset_ids'])) {
$asset_count = count($_POST['asset_ids']);
@@ -704,6 +713,7 @@ if (isset($_POST['bulk_edit_asset_status'])) {
logAudit("Asset", "Bulk Edit", "$session_name set status to $status on $asset_count assets", $client_id);
flashAlert("Status set to <strong>" . stripslashes($status) . "</strong> on <strong>$asset_count</strong> asset" . ($asset_count === 1 ? '' : 's'));
undoOfferChanges($undo, "Status put back on <strong>{n}</strong> asset{s}", 'module_support', 2, 's', 'asset_status');
}
redirect();
@@ -792,6 +802,7 @@ if (isset($_POST['bulk_archive_assets'])) {
enforceUserPermission('module_support', 2);
$undo = undoArchiveBefore('asset', $_POST['asset_ids'] ?? []); // for Undo on the message
if (isset($_POST['asset_ids'])) {
$count = count($_POST['asset_ids']);
@@ -820,6 +831,7 @@ if (isset($_POST['bulk_archive_assets'])) {
logAudit("Asset", "Bulk Archive", "$session_name archived $count assets", $client_id);
flashAlert("Archived <strong>$count</strong> asset(s)", 'error');
undoOfferArchive($undo);
}

View File

@@ -187,11 +187,13 @@ if (isset($_GET['archive_certificate'])) {
$row = certificateForRequest($_GET['archive_certificate'], 2);
$certificate_id = intval($row['certificate_id']);
$undo = undoArchiveBefore('certificate', $certificate_id); // for Undo on the message
mysqli_query($mysqli, "UPDATE certificates SET certificate_archived_at = NOW() WHERE certificate_id = $certificate_id");
logAudit("Certificate", "Archive", "$session_name archived certificate " . escapeSql($row['certificate_name']), $client_id, $certificate_id);
flashAlert("Certificate <strong>" . escapeHtml($row['certificate_name']) . "</strong> archived", 'error');
undoOfferArchive($undo);
redirect();
@@ -288,6 +290,7 @@ if (isset($_POST['bulk_archive_certificates'])) {
validateCSRFToken();
$undo = undoArchiveBefore('certificate', $_POST['certificate_ids'] ?? []); // for Undo on the message
$count = 0;
foreach (certificatesForBulk(2) as $certificate_id => $row) {
mysqli_query($mysqli, "UPDATE certificates SET certificate_archived_at = NOW() WHERE certificate_id = $certificate_id");
@@ -296,6 +299,7 @@ if (isset($_POST['bulk_archive_certificates'])) {
}
flashAlert("Archived <strong>$count</strong> certificate" . ($count === 1 ? '' : 's'), 'error');
undoOfferArchive($undo);
redirect();

View File

@@ -191,6 +191,7 @@ if (isset($_GET['archive_client'])) {
enforceClientAccess();
// Archived, its recurring invoices stopped and contract signing requests withdrawn (functions/client.php)
$undo = undoArchiveBefore('client', $client_id); // for Undo on the message
$contracts_withdrawn = clientArchiveNow($client_id);
// Get Client Name
@@ -199,6 +200,9 @@ if (isset($_GET['archive_client'])) {
logAudit("Client", "Archive", "$session_name archived client $client_name" . ($contracts_withdrawn ? " - $contracts_withdrawn contract signing request" . ($contracts_withdrawn === 1 ? '' : 's') . " withdrawn" : ''), $client_id, $client_id);
flashAlert("Client <strong>" . stripslashes($client_name) . "</strong> archived" . ($contracts_withdrawn ? " - contract signing requests to them were withdrawn" : ''), 'error');
if (!$contracts_withdrawn) {
undoOfferArchive($undo); // a signing request withdrawn can't be put back
}
redirect();
@@ -708,6 +712,7 @@ if (isset($_POST['bulk_edit_client_industry'])) {
$industry = escapeSql($_POST['bulk_industry']);
$undo = undoSnapshot('clients', 'client_id', $_POST['client_ids'] ?? [], ['client_type'], 'client_id'); // for Undo on the message
if (isset($_POST['client_ids'])) {
// Check every selected client before changing any of them
@@ -733,6 +738,7 @@ if (isset($_POST['bulk_edit_client_industry'])) {
logAudit("Client", "Bulk Edit", "$session_name set the industry $industry for $count client(s)", $client_id);
flashAlert("Industry set to <strong>" . stripslashes($industry) . "</strong> on <strong>$count</strong> client" . ($count === 1 ? '' : 's'));
undoOfferChanges($undo, "Industry put back on <strong>{n}</strong> client{s}", 'module_client');
}
redirect();
@@ -747,6 +753,7 @@ if (isset($_POST['bulk_edit_client_referral'])) {
$referral = escapeSql($_POST['bulk_referral']);
$undo = undoSnapshot('clients', 'client_id', $_POST['client_ids'] ?? [], ['client_referral'], 'client_id'); // for Undo on the message
if (isset($_POST['client_ids'])) {
// Check every selected client before changing any of them
@@ -772,6 +779,7 @@ if (isset($_POST['bulk_edit_client_referral'])) {
logAudit("Client", "Bulk Edit", "$session_name set the referral $referral for $count client(s)", $client_id);
flashAlert("Referral set to <strong>" . stripslashes($referral) . "</strong> on <strong>$count</strong> client" . ($count === 1 ? '' : 's'));
undoOfferChanges($undo, "Referral put back on <strong>{n}</strong> client{s}", 'module_client');
}
redirect();
@@ -882,6 +890,7 @@ if (isset($_POST['bulk_archive_clients'])) {
enforceUserPermission('module_client', 2);
$undo = undoArchiveBefore('client', $_POST['client_ids'] ?? []); // for Undo on the message
if (isset($_POST['client_ids'])) {
// Check every selected client before changing any of them
@@ -901,6 +910,7 @@ if (isset($_POST['bulk_archive_clients'])) {
mysqli_query($mysqli,"UPDATE clients SET client_archived_at = NOW() WHERE client_id = $client_id");
$contracts_withdrawn = contractSignatureWithdrawStale($client_id);
$undo_withdrawn = ($undo_withdrawn ?? 0) + $contracts_withdrawn;
logAudit("Client", "Archive", "$session_name archived $client_name" . ($contracts_withdrawn ? " - $contracts_withdrawn contract signing request" . ($contracts_withdrawn === 1 ? '' : 's') . " withdrawn" : ''), $client_id);
@@ -911,6 +921,9 @@ if (isset($_POST['bulk_archive_clients'])) {
logAudit("Client", "Bulk Archive", "$session_name archived $count clients", $client_id);
flashAlert("Archived $count client(s)", 'error');
if (empty($undo_withdrawn)) {
undoOfferArchive($undo); // a signing request withdrawn can't be put back
}
}

View File

@@ -363,6 +363,7 @@ if (isset($_POST['bulk_assign_contact_location'])) {
enforceClientAccess();
// Assign Location to Selected Contacts
$undo = undoSnapshot('contacts', 'contact_id', $_POST['contact_ids'] ?? [], ['contact_location_id'], 'contact_client_id'); // for Undo on the message
if (isset($_POST['contact_ids'])) {
// Only the contacts of the location's client are moved
@@ -389,6 +390,7 @@ if (isset($_POST['bulk_assign_contact_location'])) {
logAudit("Contact", "Bulk Edit", "$session_name assigned $contact_count contacts to location $location_name", $client_id);
flashAlert("<strong>$contact_count</strong> contact" . ($contact_count === 1 ? '' : 's') . " assigned to location <strong>" . stripslashes($location_name) . "</strong>");
undoOfferChanges($undo, "Location put back on <strong>{n}</strong> contact{s}", 'module_client');
}
redirect();
@@ -404,6 +406,7 @@ if (isset($_POST['bulk_edit_contact_phone'])) {
$phone = preg_replace("/[^0-9]/", '', $_POST['bulk_phone']);
// Assign Location to Selected Contacts
$undo = undoSnapshot('contacts', 'contact_id', $_POST['contact_ids'] ?? [], ['contact_phone'], 'contact_client_id'); // for Undo on the message
if (isset($_POST['contact_ids'])) {
// Get Selected Contacts Count
@@ -429,6 +432,7 @@ if (isset($_POST['bulk_edit_contact_phone'])) {
logAudit("Contact", "Bulk Edit", "$session_name set the Phone Number $phone for $contact_count contacts", $client_id);
flashAlert("Phone number set to <strong>" . formatPhoneNumber($phone) . "</strong> on <strong>$contact_count</strong> contact" . ($contact_count === 1 ? '' : 's'));
undoOfferChanges($undo, "Phone number put back on <strong>{n}</strong> contact{s}", 'module_client');
}
redirect();
@@ -444,6 +448,7 @@ if (isset($_POST['bulk_edit_contact_department'])) {
$department = escapeSql($_POST['bulk_department']);
// Assign Location to Selected Contacts
$undo = undoSnapshot('contacts', 'contact_id', $_POST['contact_ids'] ?? [], ['contact_department'], 'contact_client_id'); // for Undo on the message
if (isset($_POST['contact_ids'])) {
// Get Selected Contacts Count
@@ -469,6 +474,7 @@ if (isset($_POST['bulk_edit_contact_department'])) {
logAudit("Contact", "Bulk Edit", "$session_name set the department $department for $contact_count contacts", $client_id);
flashAlert("Department set to <strong>" . stripslashes($department) . "</strong> on <strong>$contact_count</strong> contact" . ($contact_count === 1 ? '' : 's'));
undoOfferChanges($undo, "Department put back on <strong>{n}</strong> contact{s}", 'module_client');
}
redirect();
@@ -486,6 +492,7 @@ if (isset($_POST['bulk_edit_contact_role'])) {
$contact_technical = intval($_POST['bulk_contact_technical']);
// Assign Location to Selected Contacts
$undo = undoSnapshot('contacts', 'contact_id', $_POST['contact_ids'] ?? [], ['contact_important', 'contact_billing', 'contact_technical'], 'contact_client_id'); // for Undo on the message
if (isset($_POST['contact_ids'])) {
// Get Selected Contacts Count
@@ -513,6 +520,7 @@ if (isset($_POST['bulk_edit_contact_role'])) {
logAudit("Contact", "Bulk Edit", "$session_name edited the contact role for $contact_count contacts", $client_id);
flashAlert("Roles updated on <strong>$contact_count</strong> contact" . ($contact_count === 1 ? '' : 's'));
undoOfferChanges($undo, "Roles put back on <strong>{n}</strong> contact{s}", 'module_client');
}
redirect();
@@ -552,6 +560,7 @@ if (isset($_POST['bulk_archive_contacts'])) {
enforceUserPermission('module_client', 2);
$undo = undoArchiveBefore('contact', $_POST['contact_ids'] ?? []); // for Undo on the message
if (isset($_POST['contact_ids'])) {
$count = 0; // Default 0
@@ -591,6 +600,7 @@ if (isset($_POST['bulk_archive_contacts'])) {
logAudit("Contact", "Bulk Archive", "$session_name archived $count contacts", $client_id);
flashAlert("Archived $count contact(s)", 'error');
undoOfferArchive($undo);
}
@@ -1022,6 +1032,7 @@ if (isset($_GET['archive_contact'])) {
enforceClientAccess();
$undo = undoArchiveBefore('contact', $contact_id); // for Undo on the message
// Archive Contact User
if ($contact_user_id > 0) {
mysqli_query($mysqli,"UPDATE users SET user_archived_at = NOW() WHERE user_id = $contact_user_id");
@@ -1032,6 +1043,7 @@ if (isset($_GET['archive_contact'])) {
logAudit("Contact", "Archive", "$session_name archived contact $contact_name", $client_id, $contact_id);
flashAlert("Contact <strong>" . stripslashes($contact_name) . "</strong> archived", 'error');
undoOfferArchive($undo);
redirect();

View File

@@ -246,11 +246,13 @@ if (isset($_GET['archive_credential'])) {
$row = credentialForRequest($_GET['archive_credential'], 2);
$credential_id = intval($row['credential_id']);
$undo = undoArchiveBefore('credential', $credential_id); // for Undo on the message
mysqli_query($mysqli, "UPDATE credentials SET credential_archived_at = NOW() WHERE credential_id = $credential_id");
logAudit("Credential", "Archive", "$session_name archived credential " . escapeSql($row['credential_name']), $client_id, $credential_id);
flashAlert("Credential <strong>{$row['credential_name']}</strong> archived", 'error');
undoOfferArchive($undo);
redirect();
@@ -311,6 +313,7 @@ if (isset($_POST['bulk_archive_credentials'])) {
validateCSRFToken();
$undo = undoArchiveBefore('credential', $_POST['credential_ids'] ?? []); // for Undo on the message
$count = 0;
foreach (credentialsForBulk(2) as $credential_id => $row) {
mysqli_query($mysqli, "UPDATE credentials SET credential_archived_at = NOW() WHERE credential_id = $credential_id");
@@ -319,6 +322,7 @@ if (isset($_POST['bulk_archive_credentials'])) {
}
flashAlert("Archived <strong>$count</strong> credential" . ($count === 1 ? '' : 's'), 'error');
undoOfferArchive($undo);
redirect();

View File

@@ -231,11 +231,13 @@ if (isset($_POST['move_document'])) {
$folder_id = folderOwnedId($_POST['folder'] ?? 0, $client_id);
$folder_name = folderDisplayName($folder_id);
$undo = undoSnapshot('documents', 'document_id', [$document_id], ['document_folder_id'], 'document_client_id'); // for Undo on the message
mysqli_query($mysqli, "UPDATE documents SET document_folder_id = $folder_id, document_updated_at = document_updated_at WHERE document_id = $document_id");
logAudit("Document", "Move", "$session_name moved document " . escapeSql($row['document_name']) . " to folder " . escapeSql($folder_name), $client_id, $document_id);
flashAlert("Document <strong>{$row['document_name']}</strong> moved to <strong>$folder_name</strong>");
undoOfferChanges($undo, "<strong>" . escapeHtml($row['document_name']) . "</strong> moved back", 'module_support');
redirect();
@@ -474,6 +476,7 @@ if (isset($_GET['archive_document'])) {
$row = documentForHandler($_GET['archive_document']);
$document_id = intval($row['document_id']);
$undo = undoArchiveBefore('document', $document_id); // for Undo on the message
mysqli_query($mysqli, "UPDATE documents SET document_archived_at = NOW(), document_updated_at = document_updated_at WHERE document_id = $document_id");
// An archived document drops its links, as it always has
@@ -482,6 +485,7 @@ if (isset($_GET['archive_document'])) {
logAudit("Document", "Archive", "$session_name archived document " . escapeSql($row['document_name']), $client_id, $document_id);
flashAlert("Document <strong>{$row['document_name']}</strong> archived", 'error');
undoOfferArchive($undo);
redirect();

View File

@@ -236,11 +236,13 @@ if (isset($_GET['archive_domain'])) {
$row = domainForRequest($_GET['archive_domain'], 2);
$domain_id = intval($row['domain_id']);
$undo = undoArchiveBefore('domain', $domain_id); // for Undo on the message
mysqli_query($mysqli, "UPDATE domains SET domain_archived_at = NOW() WHERE domain_id = $domain_id");
logAudit("Domain", "Archive", "$session_name archived domain " . escapeSql($row['domain_name']), $client_id, $domain_id);
flashAlert("Domain <strong>{$row['domain_name']}</strong> archived", 'error');
undoOfferArchive($undo);
redirect();
@@ -360,6 +362,7 @@ if (isset($_POST['bulk_archive_domains'])) {
validateCSRFToken();
$undo = undoArchiveBefore('domain', $_POST['domain_ids'] ?? []); // for Undo on the message
$count = 0;
foreach (domainsForBulk(2) as $domain_id => $row) {
mysqli_query($mysqli, "UPDATE domains SET domain_archived_at = NOW() WHERE domain_id = $domain_id");
@@ -368,6 +371,7 @@ if (isset($_POST['bulk_archive_domains'])) {
}
flashAlert("Archived <strong>$count</strong> domain" . ($count === 1 ? '' : 's'), 'error');
undoOfferArchive($undo);
redirect();

View File

@@ -264,11 +264,13 @@ if (isset($_POST['move_file'])) {
$folder_id = folderOwnedId($_POST['folder_id'] ?? 0, $client_id);
$folder_name = folderDisplayName($folder_id);
$undo = undoSnapshot('files', 'file_id', [$file_id], ['file_folder_id'], 'file_client_id'); // for Undo on the message
mysqli_query($mysqli, "UPDATE files SET file_folder_id = $folder_id WHERE file_id = $file_id");
logAudit("File", "Move", "$session_name moved file $file_name to " . escapeSql($folder_name), $client_id, $file_id);
flashAlert("File <strong>{$row['file_name']}</strong> moved to <strong>$folder_name</strong>");
undoOfferChanges($undo, "<strong>" . escapeHtml($row['file_name']) . "</strong> moved back", 'module_support');
redirect();
@@ -291,11 +293,13 @@ if (isset($_GET['archive_file'])) {
enforceClientAccess();
$undo = undoArchiveBefore('file', $file_id); // for Undo on the message
mysqli_query($mysqli, "UPDATE files SET file_archived_at = NOW() WHERE file_id = $file_id");
logAudit("File", "Archive", "$session_name archived file " . escapeSql($row['file_name']), $client_id, $file_id);
flashAlert("File <strong>{$row['file_name']}</strong> archived", 'error');
undoOfferArchive($undo);
redirect();
@@ -361,6 +365,8 @@ if (isset($_POST['bulk_archive_files'])) {
$file_count = 0;
$document_count = 0;
$undo = undoArchiveBefore('file', $_POST['file_ids'] ?? []); // for Undo on the message
$undo_documents = undoArchiveBefore('document', $_POST['document_ids'] ?? []);
foreach (array_map('intval', (array) ($_POST['file_ids'] ?? [])) as $file_id) {
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT file_client_id, file_name FROM files WHERE file_id = $file_id AND file_archived_at IS NULL"));
if (!$row) {
@@ -386,6 +392,7 @@ if (isset($_POST['bulk_archive_files'])) {
}
flashAlert("Archived " . filesCountPhrase($document_count, $file_count), 'error');
undoOfferArchive($undo, $undo_documents);
redirect();
@@ -475,6 +482,10 @@ if (isset($_POST['bulk_move_files'])) {
$file_count = 0;
$document_count = 0;
// For Undo on the message - each back to the folder it came from
$undo = undoSnapshot('files', 'file_id', $_POST['file_ids'] ?? [], ['file_folder_id'], 'file_client_id');
$undo_documents = undoSnapshot('documents', 'document_id', $_POST['document_ids'] ?? [], ['document_folder_id'], 'document_client_id');
// Each item only moves into a folder of its own client - one of another
// client's folders would take it out of sight of both. One already there is left alone.
foreach (array_map('intval', (array) ($_POST['file_ids'] ?? [])) as $file_id) {
@@ -508,6 +519,7 @@ if (isset($_POST['bulk_move_files'])) {
}
flashAlert("Moved " . filesCountPhrase($document_count, $file_count) . " to <strong>$folder_name</strong>");
undoOffer('<strong>{n}</strong> item{s} moved back', array_merge(undoChangedSteps($undo), undoChangedSteps($undo_documents)), 'module_support');
redirect();

View File

@@ -132,6 +132,9 @@ if (isset($_POST['move_folder'])) {
logAudit("Folder", "Move", "$session_name moved folder " . escapeSql($folder_name) . " into " . escapeSql($parent_name), $client_id, $folder_id);
flashAlert("Folder <strong>$folder_name</strong> moved into <strong>$parent_name</strong>");
$parent_before = intval($tree[$folder_id]['parent_folder'] ?? 0);
undoOffer("Folder <strong>" . escapeHtml($folder_name) . "</strong> is back in <strong>" . escapeHtml(folderDisplayName($parent_before)) . "</strong>",
[['folder', $folder_id, $parent_before, $parent_folder, $client_id]], 'module_support');
redirect();

View File

@@ -814,6 +814,7 @@ if (isset($_POST['bulk_edit_invoice_category'])) {
$category_name = escapeSql(getFieldById('categories', $category_id, 'category_name'));
// Assign Income category to Selected Invoices
$undo = undoSnapshot('invoices', 'invoice_id', $_POST['invoice_ids'] ?? [], ['invoice_category_id'], 'invoice_client_id'); // for Undo on the message
if (isset($_POST['invoice_ids'])) {
// Get Selected Count
@@ -841,6 +842,7 @@ if (isset($_POST['bulk_edit_invoice_category'])) {
logAudit("Invoice", "Bulk Edit", "$session_name assigned $count invoices to category $category_name");
flashAlert("Assigned income category <strong>$category_name</strong> to <strong>$count</strong> invoice(s)");
undoOfferChanges($undo, "Income category put back on <strong>{n}</strong> invoice{s}", 'module_sales');
}
redirect();

View File

@@ -213,11 +213,13 @@ if (isset($_GET['archive_location'])) {
redirect();
}
$undo = undoArchiveBefore('location', $location_id); // for Undo on the message
mysqli_query($mysqli, "UPDATE locations SET location_archived_at = NOW() WHERE location_id = $location_id");
logAudit("Location", "Archive", "$session_name archived location " . escapeSql($row['location_name']), $client_id, $location_id);
flashAlert("Location <strong>{$row['location_name']}</strong> archived", 'error');
undoOfferArchive($undo);
redirect();
@@ -275,6 +277,7 @@ if (isset($_POST['bulk_archive_locations'])) {
enforceUserPermission('module_client', 2);
$undo = undoArchiveBefore('location', $_POST['location_ids'] ?? []); // for Undo on the message
$count = 0;
$skipped = [];
foreach (array_unique(array_map('intval', (array) ($_POST['location_ids'] ?? []))) as $location_id) {
@@ -294,6 +297,7 @@ if (isset($_POST['bulk_archive_locations'])) {
}
flashAlert("Archived <strong>$count</strong> location" . ($count === 1 ? '' : 's') . ($skipped ? ' - kept <strong>' . implode(', ', $skipped) . '</strong>, the primary location' : ''), 'error');
undoOfferArchive($undo);
redirect();

View File

@@ -140,9 +140,11 @@ if (isset($_GET['archive_network'])) {
$row = networkForRequest($_GET['archive_network'], 2);
$undo = undoArchiveBefore('network', $row['network_id']); // for Undo on the message
networkArchive($row);
flashAlert("Network <strong>" . $row['network_name'] . "</strong> archived", 'error');
undoOfferArchive($undo);
redirect();
@@ -249,6 +251,7 @@ if (isset($_POST['bulk_archive_networks'])) {
validateCSRFToken();
$undo = undoArchiveBefore('network', $_POST['network_ids'] ?? []); // for Undo on the message
$count = 0;
foreach (networksForBulk(2) as $row) {
if (!$row['network_archived_at']) {
@@ -258,6 +261,7 @@ if (isset($_POST['bulk_archive_networks'])) {
}
flashAlert("Archived <strong>$count</strong> network" . ($count === 1 ? '' : 's'), 'error');
undoOfferArchive($undo);
redirect();

View File

@@ -156,6 +156,7 @@ if (isset($_POST['bulk_ip_type'])) {
redirect();
}
$undo = undoSnapshot('network_ips', 'ip_id', $_POST['network_ip_ids'] ?? [], ['ip_type'], ''); // for Undo on the message
$count = 0;
foreach (networkIpsForBulk(2) as $ip_id => $row) {
mysqli_query($mysqli, "UPDATE network_ips SET ip_type = '$type' WHERE ip_id = $ip_id");
@@ -164,6 +165,7 @@ if (isset($_POST['bulk_ip_type'])) {
}
flashAlert("Made <strong>$count</strong> address" . ($count === 1 ? '' : 'es') . " <strong>" . strtolower(NETWORK_IP_TYPES[$type][3]) . "</strong>");
undoOfferChanges($undo, "Type put back on <strong>{n}</strong> address{s}", 'module_support', 2, 'es', '');
redirect();

View File

@@ -128,11 +128,13 @@ if (isset($_GET['archive_product'])) {
$product_name = escapeSql(getFieldById('products', $product_id, 'product_name'));
$undo = undoArchiveBefore('product', $product_id); // for Undo on the message
mysqli_query($mysqli,"UPDATE products SET product_archived_at = NOW() WHERE product_id = $product_id");
logAudit("Product", "Archive", "$session_name archived product $product_name", 0, $product_id);
flashAlert("Product <strong>" . escapeHtml(stripslashes($product_name)) . "</strong> archived - it is no longer offered on new lines", 'error');
undoOfferArchive($undo);
redirect();
@@ -191,6 +193,7 @@ if (isset($_POST['bulk_edit_product_category'])) {
$category_name = escapeSql(getFieldById('categories', $category_id, 'category_name'));
// Assign category to Selected Products
$undo = undoSnapshot('products', 'product_id', $_POST['product_ids'] ?? [], ['product_category_id'], ''); // for Undo on the message
if (isset($_POST['product_ids'])) {
// Get Count
@@ -211,6 +214,7 @@ if (isset($_POST['bulk_edit_product_category'])) {
logAudit("Product", "Edit", "$session_name assigned category $category_name to $count product(s)");
flashAlert("Assigned category <strong>" . escapeHtml(stripslashes($category_name)) . "</strong> to <strong>$count</strong> product(s)");
undoOfferChanges($undo, "Category put back on <strong>{n}</strong> product{s}", 'module_sales');
}
redirect();
@@ -223,6 +227,7 @@ if (isset($_POST['bulk_archive_products'])) {
enforceUserPermission('module_sales', 2);
$undo = undoArchiveBefore('product', $_POST['product_ids'] ?? []); // for Undo on the message
if (isset($_POST['product_ids'])) {
$count = count($_POST['product_ids']);
@@ -242,6 +247,7 @@ if (isset($_POST['bulk_archive_products'])) {
logAudit("Product", "Bulk Archive", "$session_name archived $count product(s)");
flashAlert("Archived <strong>$count</strong> product(s)", 'error');
undoOfferArchive($undo);
}

View File

@@ -164,9 +164,11 @@ if (isset($_GET['archive_project'])) {
$row = projectForRequest($_GET['archive_project'], 2);
$undo = undoArchiveBefore('project', $row['project_id']); // for Undo on the message
projectArchive($row);
flashAlert("Project <strong>" . escapeHtml(projectReference($row) . ' - ' . $row['project_name']) . "</strong> archived", 'error');
undoOfferArchive($undo);
redirect();
@@ -377,6 +379,7 @@ if (isset($_POST['bulk_archive_projects'])) {
validateCSRFToken();
$done = 0;
$undo = undoArchiveBefore('project', $_POST['project_ids'] ?? []); // for Undo on the message
foreach (projectsForBulk(2) as $row) {
if (!empty($row['project_archived_at'])) {
continue;
@@ -386,6 +389,7 @@ if (isset($_POST['bulk_archive_projects'])) {
}
flashAlert("<strong>$done</strong> project" . ($done === 1 ? '' : 's') . " archived", 'error');
undoOfferArchive($undo);
redirect();
@@ -434,6 +438,7 @@ if (isset($_POST['bulk_edit_project_manager'])) {
$manager_name = $manager_id ? escapeSql((string) getFieldById('users', $manager_id, 'user_name')) : 'No One';
$done = 0;
$undo = undoSnapshot('projects', 'project_id', $_POST['project_ids'] ?? [], ['project_manager'], 'project_client_id'); // for Undo on the message
foreach (projectsForBulk(2) as $row) {
if (!projectIsOpen($row) || intval($row['project_manager']) === $manager_id) {
continue;
@@ -445,6 +450,7 @@ if (isset($_POST['bulk_edit_project_manager'])) {
}
flashAlert("Manager of <strong>$done</strong> project" . ($done === 1 ? '' : 's') . " set to <strong>" . escapeHtml(stripslashes($manager_name)) . "</strong>");
undoOfferChanges($undo, "Manager put back on <strong>{n}</strong> project{s}", 'module_support');
redirect();
@@ -458,6 +464,7 @@ if (isset($_POST['bulk_edit_project_due'])) {
$done = 0;
$skipped = 0;
$undo = undoSnapshot('projects', 'project_id', $_POST['project_ids'] ?? [], ['project_due'], 'project_client_id'); // for Undo on the message
foreach (projectsForBulk(2) as $row) {
if (!projectIsOpen($row)) {
continue;
@@ -474,6 +481,7 @@ if (isset($_POST['bulk_edit_project_due'])) {
flashAlert("Due date of <strong>$done</strong> project" . ($done === 1 ? '' : 's') . ($due === 'NULL' ? ' cleared' : ' set to <strong>' . escapeHtml(date('M j, Y', strtotime(trim($due, "'")))) . '</strong>')
. ($skipped ? ", <strong>$skipped</strong> skipped - they start after it" : ''));
undoOfferChanges($undo, "Due date put back on <strong>{n}</strong> project{s}", 'module_support');
redirect();

View File

@@ -132,9 +132,11 @@ if (isset($_GET['archive_rack']) || isset($_GET['restore_rack'])) {
enforceClientAccess();
if ($is_archive) {
$undo = undoArchiveBefore('rack', $rack_id); // for Undo on the message
mysqli_query($mysqli, "UPDATE racks SET rack_archived_at = NOW() WHERE rack_id = $rack_id");
logAudit("Rack", "Archive", "$session_name archived rack $rack_name", $client_id, $rack_id);
flashAlert("Rack <strong>$rack_name_display</strong> archived", 'error');
undoOfferArchive($undo);
} else {
mysqli_query($mysqli, "UPDATE racks SET rack_archived_at = NULL WHERE rack_id = $rack_id");
logAudit("Rack", "Restore", "$session_name restored rack $rack_name", $client_id, $rack_id);
@@ -351,6 +353,8 @@ if (isset($_POST['move_rack_unit'])) {
logAudit("Rack", "Edit", "$session_name moved " . escapeSql($item_name) . " to $position ($face) in rack $rack_name", $client_id, $rack_id);
flashAlert("<strong>" . strip_tags($item_name) . "</strong> moved to $position" . ($face !== $row['unit_face'] ? " on the $face" : ''));
undoOffer("<strong>" . escapeHtml(strip_tags($item_name)) . "</strong> is back at " . rackPositionLabel($row['unit_start_number'], $row['unit_end_number']) . " on the {$row['unit_face']}",
[['rack', $unit_id, intval($row['unit_start_number']), intval($row['unit_end_number']), $row['unit_face'], $start, $face]], 'module_support');
redirect();

View File

@@ -149,9 +149,11 @@ if (isset($_GET['archive_service'])) {
$row = serviceForRequest($_GET['archive_service'], 2);
$undo = undoArchiveBefore('service', $row['service_id']); // for Undo on the message
serviceArchive($row);
flashAlert("Service <strong>" . escapeHtml($row['service_name']) . "</strong> archived", 'error');
undoOfferArchive($undo);
redirect();
@@ -362,6 +364,7 @@ if (isset($_POST['bulk_archive_services'])) {
validateCSRFToken();
$undo = undoArchiveBefore('service', $_POST['service_ids'] ?? []); // for Undo on the message
$count = 0;
foreach (servicesForBulk(2) as $row) {
if (!$row['service_archived_at']) {
@@ -371,6 +374,7 @@ if (isset($_POST['bulk_archive_services'])) {
}
flashAlert("Archived <strong>$count</strong> service" . ($count === 1 ? '' : 's'), 'error');
undoOfferArchive($undo);
redirect();

View File

@@ -336,11 +336,13 @@ if (isset($_GET['archive_software'])) {
// Seats stay put - an archived license drops off every device and user
// anyway, and comes back with them if it is restored
$undo = undoArchiveBefore('software', $software_id); // for Undo on the message
mysqli_query($mysqli, "UPDATE software SET software_archived_at = NOW() WHERE software_id = $software_id");
logAudit("Software", "Archive", "$session_name archived license " . escapeSql($row['software_name']), $client_id, $software_id);
flashAlert("License <strong>{$row['software_name']}</strong> archived", 'error');
undoOfferArchive($undo);
redirect();
@@ -395,6 +397,7 @@ if (isset($_POST['bulk_archive_software'])) {
enforceUserPermission('module_support', 2);
$undo = undoArchiveBefore('software', $_POST['software_ids'] ?? []); // for Undo on the message
$rows = softwareBulkRows($_POST['software_ids'] ?? []);
foreach ($rows as $software_id => $row) {
$client_id = intval($row['software_client_id']);
@@ -403,6 +406,7 @@ if (isset($_POST['bulk_archive_software'])) {
}
flashAlert("Archived <strong>" . count($rows) . "</strong> license" . (count($rows) === 1 ? '' : 's'), 'error');
undoOfferArchive($undo);
redirect();

View File

@@ -747,6 +747,7 @@ if (isset($_POST['bulk_edit_ticket_priority'])) {
}
// The same change the priority picker makes - history, SLA, audit and the custom action
$undo = undoSnapshot('tickets', 'ticket_id', $_POST['ticket_ids'] ?? [], ['ticket_priority'], 'ticket_client_id'); // for Undo on the message
$count = 0;
foreach (ticketsForBulk(2) as $ticket_id => $row) {
[$ok] = ticketChangePriority($ticket_id, $priority);
@@ -756,6 +757,7 @@ if (isset($_POST['bulk_edit_ticket_priority'])) {
logAudit("Ticket", "Bulk Edit", "$session_name set the priority of $count ticket(s) to $priority");
flashAlert("Priority set to <strong>$priority</strong> on <strong>$count</strong> ticket" . ($count === 1 ? '' : 's'));
undoOfferChanges($undo, "Priority put back on <strong>{n}</strong> ticket{s}", 'module_support', 2, 's', 'ticket_priority');
redirect();
@@ -768,6 +770,7 @@ if (isset($_POST['bulk_edit_ticket_category'])) {
$category_id = ticketCategoryId($_POST['bulk_category'] ?? 0);
$category_name = $category_id ? (string) getFieldById('categories', $category_id, 'category_name') : 'Not categorized';
$undo = undoSnapshot('tickets', 'ticket_id', $_POST['ticket_ids'] ?? [], ['ticket_category'], 'ticket_client_id'); // for Undo on the message
$count = 0;
foreach (ticketsForBulk(2) as $ticket_id => $row) {
$previous = intval($row['ticket_category']) ? (string) getFieldById('categories', intval($row['ticket_category']), 'category_name') : 'Not categorized';
@@ -786,6 +789,7 @@ if (isset($_POST['bulk_edit_ticket_category'])) {
logAudit("Ticket", "Bulk Edit", "$session_name set the category of $count ticket(s) to " . escapeSql($category_name));
flashAlert("Category set to <strong>" . escapeHtml($category_name) . "</strong> on <strong>$count</strong> ticket" . ($count === 1 ? '' : 's'));
undoOfferChanges($undo, "Category put back on <strong>{n}</strong> ticket{s}", 'module_support', 2, 's', 'ticket_category');
redirect();
@@ -970,6 +974,7 @@ if (isset($_POST['bulk_add_ticket_project'])) {
$project_name = $project_input ? (string) getFieldById('projects', $project_input, 'project_name') : '';
$count = $skipped = 0;
$undo = undoSnapshot('tickets', 'ticket_id', $_POST['ticket_ids'] ?? [], ['ticket_project_id'], 'ticket_client_id'); // for Undo on the message
foreach (ticketsForBulk(2) as $ticket_id => $row) {
// The project has to be the ticket's client's, or an internal one
$project_id = ticketClientOwnedId('project', $project_input, $row['ticket_client_id']);
@@ -987,6 +992,7 @@ if (isset($_POST['bulk_add_ticket_project'])) {
// The project is named once a ticket went into it - one that fits none of them may be a client this agent can't see
flashAlert(($project_input ? "<strong>$count</strong> ticket" . ($count === 1 ? '' : 's') . " added to " . ($count ? "project <strong>" . escapeHtml($project_name) . "</strong>" : 'the project') : "<strong>$count</strong> ticket" . ($count === 1 ? '' : 's') . " taken out of their project")
. ($skipped ? ", <strong>$skipped</strong> skipped - the project is another client's" : ''));
undoOfferChanges($undo, "Project put back on <strong>{n}</strong> ticket{s}", 'module_support', 2, 's', 'ticket_project');
redirect();

19
agent/post/undo.php Normal file
View File

@@ -0,0 +1,19 @@
<?php
/*
* ITFlow - Undo on the message after an archive, a bulk change or a move (functions/undo.php)
*/
defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
if (isset($_GET['undo'])) {
validateCSRFToken();
[$ok, $message] = undoApply((string) $_GET['undo']);
flashAlert($message, $ok ? 'success' : 'error');
redirect();
}

View File

@@ -281,11 +281,13 @@ if (isset($_GET['archive_vendor'])) {
$row = vendorForRequest($_GET['archive_vendor'], 2);
$vendor_id = intval($row['vendor_id']);
$undo = undoArchiveBefore('vendor', $vendor_id); // for Undo on the message
mysqli_query($mysqli, "UPDATE vendors SET vendor_archived_at = NOW() WHERE vendor_id = $vendor_id");
logAudit("Vendor", "Archive", "$session_name archived vendor " . escapeSql($row['vendor_name']), $client_id, $vendor_id);
flashAlert("Vendor <strong>{$row['vendor_name']}</strong> archived", 'error');
undoOfferArchive($undo);
redirect();
@@ -337,6 +339,7 @@ if (isset($_POST['bulk_archive_vendors'])) {
validateCSRFToken();
$undo = undoArchiveBefore('vendor', $_POST['vendor_ids'] ?? []); // for Undo on the message
$count = 0;
foreach (array_unique(array_map('intval', (array) ($_POST['vendor_ids'] ?? []))) as $vendor_id) {
$row = vendorRow($vendor_id);
@@ -351,6 +354,7 @@ if (isset($_POST['bulk_archive_vendors'])) {
}
flashAlert("Archived <strong>$count</strong> vendor" . ($count === 1 ? '' : 's'), 'error');
undoOfferArchive($undo);
redirect();

View File

@@ -171,8 +171,7 @@ if (!$product) {
</a>
<?php } ?>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_product=<?= $product_id ?>&csrf_token=<?= $csrf ?>"
data-confirm-text="<?= escapeHtml($product['product_name']) ?> stops being offered on new lines. Lines it is already on stay.">
<a class="dropdown-item text-danger" href="post.php?archive_product=<?= $product_id ?>&csrf_token=<?= $csrf ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -286,7 +286,7 @@ $add_type = in_array($view, ['product', 'hardware', 'stocked', 'reorder'], true)
</button>
<?php } ?>
<?php } else { ?>
<button class="dropdown-item text-danger confirm-link" type="submit" form="bulkActions" name="bulk_archive_products">
<button class="dropdown-item text-danger" type="submit" form="bulkActions" name="bulk_archive_products">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</button>
<?php } ?>
@@ -433,8 +433,7 @@ $add_type = in_array($view, ['product', 'hardware', 'stocked', 'reorder'], true)
</a>
<?php } ?>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_product=<?= $product_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>"
data-confirm-text="<?= escapeHtml($row['product_name']) ?> stops being offered on new lines. Lines it is already on stay.">
<a class="dropdown-item text-danger" href="post.php?archive_product=<?= $product_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -233,7 +233,7 @@ echo agentBannersHtml($project_client_id);
<i class="fas fa-fw fa-box-open text-secondary me-2"></i>Restore
</a>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_project=<?= $project_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>" data-confirm-text="<?= $reference ?> moves to Archived. Its tickets stay as they are.">
<a class="dropdown-item text-danger" href="post.php?archive_project=<?= $project_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -445,7 +445,7 @@ $hidden_filter_count = $date_filter_active ? 1 : 0;
<i class="fas fa-fw fa-box-open text-secondary me-2"></i>Restore
</a>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_project=<?= $project_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>" data-confirm-text="<?= $reference ?> moves to Archived. Its tickets stay as they are.">
<a class="dropdown-item text-danger" href="post.php?archive_project=<?= $project_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -149,7 +149,7 @@ if (mysqli_num_rows($sql) == 0) {
<i class="fas fa-fw fa-redo me-2"></i>Restore
</a>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_rack=<?= $rack_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<a class="dropdown-item text-danger" href="post.php?archive_rack=<?= $rack_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -273,7 +273,7 @@ foreach ($racks as $rack_id => $row) {
<i class="fas fa-fw fa-redo text-secondary me-2"></i>Restore
</a>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_rack=<?= $rack_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<a class="dropdown-item text-danger" href="post.php?archive_rack=<?= $rack_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -235,8 +235,7 @@ if (!$service || ($client_url && intval($service['service_client_id']) !== intva
<i class="<?= $is_favorite ? 'far' : 'fas' ?> fa-fw fa-star text-secondary me-2"></i><?= $is_favorite ? 'Unstar' : 'Star' ?>
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_service=<?= $service_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>"
data-confirm-text="<?= $service_name ?> moves to Archived, off the lists and counts, until restored.">
<a class="dropdown-item text-danger" href="post.php?archive_service=<?= $service_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -241,8 +241,7 @@ $link_icons = ['asset' => ['fa-desktop', 'asset', 'assets'], 'credential' => ['f
</button>
<?php } ?>
<?php } else { ?>
<button class="dropdown-item text-danger confirm-link" type="submit" form="bulkActions" name="bulk_archive_services"
data-confirm-text="They move to Archived, off the lists and counts, until restored.">
<button class="dropdown-item text-danger" type="submit" form="bulkActions" name="bulk_archive_services">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</button>
<?php } ?>
@@ -418,8 +417,7 @@ $link_icons = ['asset' => ['fa-desktop', 'asset', 'assets'], 'credential' => ['f
</a>
<?php } ?>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_service=<?= $service_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>"
data-confirm-text="<?= $name ?> moves to Archived, off the lists and counts, until restored.">
<a class="dropdown-item text-danger" href="post.php?archive_service=<?= $service_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -348,7 +348,7 @@ while ($license_type_row = mysqli_fetch_row($sql_license_types)) {
<i class="fas fa-fw fa-tags me-2"></i>Tags
</a>
<div class="dropdown-divider"></div>
<button class="dropdown-item text-danger confirm-link" type="submit" form="bulkActions" name="bulk_archive_software">
<button class="dropdown-item text-danger" type="submit" form="bulkActions" name="bulk_archive_software">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</button>
<?php } else { ?>
@@ -556,7 +556,7 @@ while ($license_type_row = mysqli_fetch_row($sql_license_types)) {
<i class="fas fa-fw fa-redo-alt text-secondary me-2"></i>Renew
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_software=<?= $software_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<a class="dropdown-item text-danger" href="post.php?archive_software=<?= $software_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } elseif ($can_edit) { ?>

View File

@@ -361,7 +361,7 @@ if (!$vendor || (isset($_GET['client_id']) && $vendor_client_id !== intval($clie
</a>
<?php } ?>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_vendor=<?= $vendor_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<a class="dropdown-item text-danger" href="post.php?archive_vendor=<?= $vendor_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>

View File

@@ -251,7 +251,7 @@ $missing_templates = $view === 'client' && !$archived ? vendorTemplatesMissingFo
</button>
<?php } ?>
<?php } else { ?>
<button class="dropdown-item text-danger confirm-link" type="submit" form="bulkActions" name="bulk_archive_vendors">
<button class="dropdown-item text-danger" type="submit" form="bulkActions" name="bulk_archive_vendors">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</button>
<?php } ?>
@@ -453,7 +453,7 @@ $missing_templates = $view === 'client' && !$archived ? vendorTemplatesMissingFo
</a>
<?php } ?>
<?php } else { ?>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_vendor=<?= $vendor_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<a class="dropdown-item text-danger" href="post.php?archive_vendor=<?= $vendor_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
<?php } ?>