From 8b85ae377a6b2a0b960f85a2a1e7c37ffcd3443c Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sat, 27 Jan 2024 13:23:44 -0500 Subject: [PATCH] Updated the way Archived Items are displayed in asset list view and when editing, this will be standard going forward, added Bulk Set Asset Status, further work on improving the archived logic, assets is pretty much gold standard here now --- client_asset_bulk_edit_status_modal.php | 36 ++++++++++++++++++++++ client_asset_details.php | 19 +++++++----- client_asset_edit_modal.php | 40 ++++++++++++------------- client_assets.php | 21 ++++++++----- post/asset.php | 34 +++++++++++++++++++++ 5 files changed, 114 insertions(+), 36 deletions(-) create mode 100644 client_asset_bulk_edit_status_modal.php diff --git a/client_asset_bulk_edit_status_modal.php b/client_asset_bulk_edit_status_modal.php new file mode 100644 index 00000000..910d953c --- /dev/null +++ b/client_asset_bulk_edit_status_modal.php @@ -0,0 +1,36 @@ + \ No newline at end of file diff --git a/client_asset_details.php b/client_asset_details.php index 78e635aa..f95fd002 100644 --- a/client_asset_details.php +++ b/client_asset_details.php @@ -46,17 +46,20 @@ if (isset($_GET['asset_id'])) { $contact_phone = nullable_htmlentities($row['contact_phone']); $contact_mobile = nullable_htmlentities($row['contact_mobile']); $contact_archived_at = nullable_htmlentities($row['contact_archived_at']); - if (empty($contact_archived_at)) { - $contact_archived_display = ""; + if ($contact_archived_at) { + $contact_name_display = "$contact_name"; } else { - $contact_archived_display = "Archived - "; + $contact_name_display = $contact_name; } $location_name = nullable_htmlentities($row['location_name']); + if (empty($location_name)) { + $location_name = "-"; + } $location_archived_at = nullable_htmlentities($row['location_archived_at']); - if (empty($location_archived_at)) { - $location_archived_display = ""; + if ($location_archived_at) { + $location_name_display = "$location_name"; } else { - $location_archived_display = "Archived - "; + $location_name_display = $location_name; } $login_id = intval($row['login_id']); @@ -181,10 +184,10 @@ if (isset($_GET['asset_id'])) {
-
+
-
+
diff --git a/client_asset_edit_modal.php b/client_asset_edit_modal.php index f544693f..45a07833 100644 --- a/client_asset_edit_modal.php +++ b/client_asset_edit_modal.php @@ -134,20 +134,20 @@ '$asset_created_at' OR network_archived_at IS NULL) AND network_client_id = $client_id ORDER BY network_archived_at ASC, network_name ASC"); + $sql_networks = mysqli_query($mysqli, "SELECT * FROM networks WHERE network_id = $asset_network_id OR network_archived_at IS NULL AND network_client_id = $client_id ORDER BY network_name ASC"); while ($row = mysqli_fetch_array($sql_networks)) { $network_id_select = intval($row['network_id']); $network_name_select = nullable_htmlentities($row['network_name']); $network_select = nullable_htmlentities($row['network']); $network_archived_at = nullable_htmlentities($row['network_archived_at']); - if (empty($network_archived_at)) { - $network_archived_display = ""; + if ($network_archived_at) { + $network_name_select_display = "($network_name_select - $network_select) - ARCHIVED"; } else { - $network_archived_display = "Archived - "; + $network_name_select_display = "$network_name_select - $network_select"; } ?> - + @@ -223,18 +223,18 @@ '$asset_created_at' OR location_archived_at IS NULL) AND location_client_id = $client_id ORDER BY location_archived_at ASC, location_name ASC"); + $sql_locations = mysqli_query($mysqli, "SELECT * FROM locations WHERE location_id = $asset_location_id OR location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC"); while ($row = mysqli_fetch_array($sql_locations)) { $location_id_select = intval($row['location_id']); $location_name_select = nullable_htmlentities($row['location_name']); $location_archived_at = nullable_htmlentities($row['location_archived_at']); - if (empty($location_archived_at)) { - $location_archived_display = ""; + if ($location_archived_at) { + $location_name_select_display = "($location_name_select) - ARCHIVED"; } else { - $location_archived_display = "Archived - "; + $location_name_select_display = $location_name_select; } ?> - + @@ -251,19 +251,19 @@ @@ -299,18 +299,18 @@ '$asset_created_at' OR vendor_archived_at IS NULL) AND vendor_client_id = $client_id ORDER BY vendor_archived_at ASC, vendor_name ASC"); + $sql_vendors = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_id = $asset_vendor_id OR vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC"); while ($row = mysqli_fetch_array($sql_vendors)) { $vendor_id_select = intval($row['vendor_id']); $vendor_name_select = nullable_htmlentities($row['vendor_name']); $vendor_archived_at = nullable_htmlentities($row['vendor_archived_at']); - if (empty($vendor_archived_at)) { - $vendor_archived_display = ""; + if ($vendor_archived_at) { + $vendor_name_select_display = "($vendor_name_select) - ARCHIVED"; } else { - $vendor_archived_display = "Archived - "; + $vendor_name_select_display = $vendor_name_select; } ?> - + diff --git a/client_assets.php b/client_assets.php index d57b8540..06de5897 100644 --- a/client_assets.php +++ b/client_assets.php @@ -151,6 +151,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); Assign Location + + + Set Status +
@@ -252,10 +256,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); $contact_name = "-"; } $contact_archived_at = nullable_htmlentities($row['contact_archived_at']); - if (empty($contact_archived_at)) { - $contact_archived_display = ""; + if ($contact_archived_at) { + $contact_name_display = "
$contact_name
"; } else { - $contact_archived_display = " Archived - "; + $contact_name_display = $contact_name; } $location_name = nullable_htmlentities($row['location_name']); @@ -263,10 +267,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); $location_name = "-"; } $location_archived_at = nullable_htmlentities($row['location_archived_at']); - if (empty($location_archived_at)) { - $location_archived_display = ""; + if ($location_archived_at) { + $location_name_display = "
$location_name
"; } else { - $location_archived_display = "Archived - "; + $location_name_display = $location_name; } $login_id = intval($row['login_id']); @@ -355,9 +359,9 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); - + - + + diff --git a/post/asset.php b/post/asset.php index 73f3173a..7a5d4b38 100644 --- a/post/asset.php +++ b/post/asset.php @@ -299,6 +299,40 @@ if (isset($_POST['bulk_assign_asset_contact'])) { } +if (isset($_POST['bulk_edit_asset_status'])) { + + validateTechRole(); + + $status = sanitizeInput($_POST['status']); + + // Get Selected Contacts Count + $asset_count = count($_POST['asset_ids']); + + // Assign Contact to Selected Assets + if (!empty($_POST['asset_ids'])) { + foreach($_POST['asset_ids'] as $asset_id) { + $asset_id = intval($asset_id); + + // Get Asset Details for Logging + $sql = mysqli_query($mysqli,"SELECT asset_name, asset_client_id FROM assets WHERE asset_id = $asset_id"); + $row = mysqli_fetch_array($sql); + $asset_name = sanitizeInput($row['asset_name']); + $client_id = intval($row['asset_client_id']); + + mysqli_query($mysqli,"UPDATE assets SET asset_status = '$status' WHERE asset_id = $asset_id"); + + //Logging + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Asset', log_action = 'Modify', log_description = '$session_name set status $status on $asset_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 = $asset_id"); + + } // End Assign Contact Loop + + $_SESSION['alert_message'] = "You set the status $status on $asset_count assets."; + } + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if (isset($_POST["import_client_assets_csv"])) { validateTechRole();