diff --git a/agent/asset_details.php b/agent/asset_details.php index 26fa998f1..2ade057b0 100644 --- a/agent/asset_details.php +++ b/agent/asset_details.php @@ -21,525 +21,649 @@ LEFT JOIN asset_interfaces ON interface_asset_id = asset_id AND interface_primary = 1 WHERE asset_id = $asset_id $client_query + LIMIT 1 "); - $row = mysqli_fetch_array($sql); - $client_id = intval($row['client_id']); - $client_name = nullable_htmlentities($row['client_name']); - $asset_id = intval($row['asset_id']); - $asset_type = nullable_htmlentities($row['asset_type']); - $asset_name = nullable_htmlentities($row['asset_name']); - $asset_description = nullable_htmlentities($row['asset_description']); - $asset_make = nullable_htmlentities($row['asset_make']); - $asset_model = nullable_htmlentities($row['asset_model']); - $asset_serial = nullable_htmlentities($row['asset_serial']); - $asset_os = nullable_htmlentities($row['asset_os']); - $asset_uri = sanitize_url($row['asset_uri']); - $asset_uri_2 = sanitize_url($row['asset_uri_2']); - $asset_uri_client = sanitize_url($row['asset_uri_client']); - $asset_status = nullable_htmlentities($row['asset_status']); - $asset_purchase_reference = nullable_htmlentities($row['asset_purchase_reference']); - $asset_purchase_date = nullable_htmlentities($row['asset_purchase_date']); - $asset_warranty_expire = nullable_htmlentities($row['asset_warranty_expire']); - $asset_install_date = nullable_htmlentities($row['asset_install_date']); - $asset_photo = nullable_htmlentities($row['asset_photo']); - $asset_physical_location = nullable_htmlentities($row['asset_physical_location']); - $asset_notes = nullable_htmlentities($row['asset_notes']); - $asset_created_at = nullable_htmlentities($row['asset_created_at']); - $asset_vendor_id = intval($row['asset_vendor_id']); - $asset_location_id = intval($row['asset_location_id']); - $asset_contact_id = intval($row['asset_contact_id']); - - $asset_ip = nullable_htmlentities($row['interface_ip']); - $asset_ipv6 = nullable_htmlentities($row['interface_ipv6']); - $asset_nat_ip = nullable_htmlentities($row['interface_nat_ip']); - $asset_mac = nullable_htmlentities($row['interface_mac']); - $asset_network_id = intval($row['interface_network_id']); - - $device_icon = getAssetIcon($asset_type); - - $contact_name = nullable_htmlentities($row['contact_name']); - $contact_email = nullable_htmlentities($row['contact_email']); - $contact_phone = nullable_htmlentities($row['contact_phone']); - $contact_mobile = nullable_htmlentities($row['contact_mobile']); - $contact_archived_at = nullable_htmlentities($row['contact_archived_at']); - if ($contact_archived_at) { - $contact_name_display = "$contact_name"; - } else { - $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 ($location_archived_at) { - $location_name_display = "$location_name"; - } else { - $location_name_display = $location_name; - } - - // Override Tab Title // No Sanitizing needed as this var will opnly be used in the tab title - $page_title = $row['asset_name']; - - $sql_related_tickets = mysqli_query($mysqli, " - SELECT tickets.*, users.*, ticket_statuses.* - FROM tickets - LEFT JOIN users ON ticket_assigned_to = user_id - LEFT JOIN ticket_statuses ON ticket_status_id = ticket_status - LEFT JOIN ticket_assets ON tickets.ticket_id = ticket_assets.ticket_id - WHERE ticket_asset_id = $asset_id OR ticket_assets.asset_id = $asset_id - GROUP BY tickets.ticket_id - ORDER BY ticket_number DESC - "); - $ticket_count = mysqli_num_rows($sql_related_tickets); - - // Related Recurring Tickets Query - $sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT recurring_tickets.* FROM recurring_tickets - LEFT JOIN recurring_ticket_assets ON recurring_tickets.recurring_ticket_id = recurring_ticket_assets.recurring_ticket_id - WHERE recurring_ticket_asset_id = $asset_id OR recurring_ticket_assets.asset_id = $asset_id - GROUP BY recurring_tickets.recurring_ticket_id - ORDER BY recurring_ticket_next_run DESC" - ); - $recurring_ticket_count = mysqli_num_rows($sql_related_recurring_tickets); - - // Related Documents - $sql_related_documents = mysqli_query($mysqli, "SELECT * FROM asset_documents - LEFT JOIN documents ON asset_documents.document_id = documents.document_id - WHERE asset_documents.asset_id = $asset_id - AND document_archived_at IS NULL - ORDER BY document_name DESC" - ); - $document_count = mysqli_num_rows($sql_related_documents); - - // Network Interfaces - $sql_related_interfaces = mysqli_query($mysqli, " - SELECT - ai.interface_id, - ai.interface_name, - ai.interface_description, - ai.interface_type, - ai.interface_mac, - ai.interface_ip, - ai.interface_nat_ip, - ai.interface_ipv6, - ai.interface_primary, - ai.interface_notes, - n.network_name, - n.network_id, - connected_interfaces.interface_id AS connected_interface_id, - connected_interfaces.interface_name AS connected_interface_name, - connected_assets.asset_name AS connected_asset_name, - connected_assets.asset_id AS connected_asset_id, - connected_assets.asset_type AS connected_asset_type - FROM asset_interfaces AS ai - LEFT JOIN networks AS n - ON n.network_id = ai.interface_network_id - LEFT JOIN asset_interface_links AS ail - ON (ail.interface_a_id = ai.interface_id OR ail.interface_b_id = ai.interface_id) - LEFT JOIN asset_interfaces AS connected_interfaces - ON ( - (ail.interface_a_id = ai.interface_id AND ail.interface_b_id = connected_interfaces.interface_id) - OR - (ail.interface_b_id = ai.interface_id AND ail.interface_a_id = connected_interfaces.interface_id) - ) - LEFT JOIN assets AS connected_assets - ON connected_assets.asset_id = connected_interfaces.interface_asset_id - WHERE - ai.interface_asset_id = $asset_id - AND ai.interface_archived_at IS NULL - ORDER BY ai.interface_name ASC - "); + if (mysqli_num_rows($sql) == 0) { + echo "

Nothing to see here

Go Back
"; - $interface_count = mysqli_num_rows($sql_related_interfaces); - - // Related Files - $sql_related_files = mysqli_query($mysqli, "SELECT * FROM asset_files - LEFT JOIN files ON asset_files.file_id = files.file_id - WHERE asset_files.asset_id = $asset_id - AND file_archived_at IS NULL - ORDER BY file_name DESC" - ); - $files_count = mysqli_num_rows($sql_related_files); - // View Mode -- 0 List, 1 Thumbnail - if (!empty($_GET['view'])) { - $view = intval($_GET['view']); - } else { - $view = 0; - } - if ($view == 1) { - $query_images = "AND (file_ext LIKE 'JPG' OR file_ext LIKE 'jpg' OR file_ext LIKE 'JPEG' OR file_ext LIKE 'jpeg' OR file_ext LIKE 'png' OR file_ext LIKE 'PNG' OR file_ext LIKE 'webp' OR file_ext LIKE 'WEBP')"; } else { - $query_images = ''; - } - - // Related Documents - $sql_related_documents = mysqli_query($mysqli, "SELECT * FROM asset_documents, documents - LEFT JOIN users ON document_created_by = user_id - WHERE asset_documents.asset_id = $asset_id - AND asset_documents.document_id = documents.document_id - AND document_archived_at IS NULL - ORDER BY document_name ASC" - ); - $document_count = mysqli_num_rows($sql_related_documents); - - - // Related Credentials Query - $sql_related_credentials = mysqli_query($mysqli, " - SELECT - credentials.credential_id AS credential_id, - credentials.credential_name, - credentials.credential_description, - credentials.credential_uri, - credentials.credential_username, - credentials.credential_password, - credentials.credential_otp_secret, - credentials.credential_note, - credentials.credential_important, - credentials.credential_contact_id, - credentials.credential_asset_id - FROM credentials - LEFT JOIN credential_tags ON credential_tags.credential_id = credentials.credential_id - LEFT JOIN tags ON tags.tag_id = credential_tags.tag_id - WHERE credential_asset_id = $asset_id - AND credential_archived_at IS NULL - GROUP BY credentials.credential_id - ORDER BY credential_name DESC - "); - $credential_count = mysqli_num_rows($sql_related_credentials); - - // Related Software Query - $sql_related_software = mysqli_query( - $mysqli, - "SELECT * FROM software_assets - LEFT JOIN software ON software_assets.software_id = software.software_id - WHERE software_assets.asset_id = $asset_id - AND software_archived_at IS NULL - ORDER BY software_name DESC" - ); - - $software_count = mysqli_num_rows($sql_related_software); - - // Linked Services - $sql_linked_services = mysqli_query($mysqli, "SELECT * FROM service_assets, services - WHERE service_assets.asset_id = $asset_id - AND service_assets.service_id = services.service_id - ORDER BY service_name ASC" - ); - $service_count = mysqli_num_rows($sql_linked_services); - - $linked_services = array(); - - ?> - -
- -
- -
-
- -

- - asset_photo"> - - -
- -
-
- -
- -
- -
- -
- -
- -
- -
- -
-
-
-
-
Primary Network Interface
-
-
- -
- - -
- -
- -
- -
- - -
Client URI:
- + $row = mysqli_fetch_array($sql); + $client_id = intval($row['client_id']); + $client_name = nullable_htmlentities($row['client_name']); + $asset_id = intval($row['asset_id']); + $asset_type = nullable_htmlentities($row['asset_type']); + $asset_name = nullable_htmlentities($row['asset_name']); + $asset_description = nullable_htmlentities($row['asset_description']); + $asset_make = nullable_htmlentities($row['asset_make']); + $asset_model = nullable_htmlentities($row['asset_model']); + $asset_serial = nullable_htmlentities($row['asset_serial']); + $asset_os = nullable_htmlentities($row['asset_os']); + $asset_uri = sanitize_url($row['asset_uri']); + $asset_uri_2 = sanitize_url($row['asset_uri_2']); + $asset_uri_client = sanitize_url($row['asset_uri_client']); + $asset_status = nullable_htmlentities($row['asset_status']); + $asset_purchase_reference = nullable_htmlentities($row['asset_purchase_reference']); + $asset_purchase_date = nullable_htmlentities($row['asset_purchase_date']); + $asset_warranty_expire = nullable_htmlentities($row['asset_warranty_expire']); + $asset_install_date = nullable_htmlentities($row['asset_install_date']); + $asset_photo = nullable_htmlentities($row['asset_photo']); + $asset_physical_location = nullable_htmlentities($row['asset_physical_location']); + $asset_notes = nullable_htmlentities($row['asset_notes']); + $asset_created_at = nullable_htmlentities($row['asset_created_at']); + $asset_vendor_id = intval($row['asset_vendor_id']); + $asset_location_id = intval($row['asset_location_id']); + $asset_contact_id = intval($row['asset_contact_id']); + + $asset_ip = nullable_htmlentities($row['interface_ip']); + $asset_ipv6 = nullable_htmlentities($row['interface_ipv6']); + $asset_nat_ip = nullable_htmlentities($row['interface_nat_ip']); + $asset_mac = nullable_htmlentities($row['interface_mac']); + $asset_network_id = intval($row['interface_network_id']); + + $device_icon = getAssetIcon($asset_type); + + $contact_name = nullable_htmlentities($row['contact_name']); + $contact_email = nullable_htmlentities($row['contact_email']); + $contact_phone = nullable_htmlentities($row['contact_phone']); + $contact_mobile = nullable_htmlentities($row['contact_mobile']); + $contact_archived_at = nullable_htmlentities($row['contact_archived_at']); + if ($contact_archived_at) { + $contact_name_display = "$contact_name"; + } else { + $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 ($location_archived_at) { + $location_name_display = "$location_name"; + } else { + $location_name_display = $location_name; + } + + // Override Tab Title // No Sanitizing needed as this var will opnly be used in the tab title + $page_title = $row['asset_name']; + + $sql_related_tickets = mysqli_query($mysqli, " + SELECT tickets.*, users.*, ticket_statuses.* + FROM tickets + LEFT JOIN users ON ticket_assigned_to = user_id + LEFT JOIN ticket_statuses ON ticket_status_id = ticket_status + LEFT JOIN ticket_assets ON tickets.ticket_id = ticket_assets.ticket_id + WHERE ticket_asset_id = $asset_id OR ticket_assets.asset_id = $asset_id + GROUP BY tickets.ticket_id + ORDER BY ticket_number DESC + "); + $ticket_count = mysqli_num_rows($sql_related_tickets); + + // Related Recurring Tickets Query + $sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT recurring_tickets.* FROM recurring_tickets + LEFT JOIN recurring_ticket_assets ON recurring_tickets.recurring_ticket_id = recurring_ticket_assets.recurring_ticket_id + WHERE recurring_ticket_asset_id = $asset_id OR recurring_ticket_assets.asset_id = $asset_id + GROUP BY recurring_tickets.recurring_ticket_id + ORDER BY recurring_ticket_next_run DESC" + ); + $recurring_ticket_count = mysqli_num_rows($sql_related_recurring_tickets); + + // Related Documents + $sql_related_documents = mysqli_query($mysqli, "SELECT * FROM asset_documents + LEFT JOIN documents ON asset_documents.document_id = documents.document_id + WHERE asset_documents.asset_id = $asset_id + AND document_archived_at IS NULL + ORDER BY document_name DESC" + ); + $document_count = mysqli_num_rows($sql_related_documents); + + // Network Interfaces + $sql_related_interfaces = mysqli_query($mysqli, " + SELECT + ai.interface_id, + ai.interface_name, + ai.interface_description, + ai.interface_type, + ai.interface_mac, + ai.interface_ip, + ai.interface_nat_ip, + ai.interface_ipv6, + ai.interface_primary, + ai.interface_notes, + n.network_name, + n.network_id, + connected_interfaces.interface_id AS connected_interface_id, + connected_interfaces.interface_name AS connected_interface_name, + connected_assets.asset_name AS connected_asset_name, + connected_assets.asset_id AS connected_asset_id, + connected_assets.asset_type AS connected_asset_type + FROM asset_interfaces AS ai + LEFT JOIN networks AS n + ON n.network_id = ai.interface_network_id + LEFT JOIN asset_interface_links AS ail + ON (ail.interface_a_id = ai.interface_id OR ail.interface_b_id = ai.interface_id) + LEFT JOIN asset_interfaces AS connected_interfaces + ON ( + (ail.interface_a_id = ai.interface_id AND ail.interface_b_id = connected_interfaces.interface_id) + OR + (ail.interface_b_id = ai.interface_id AND ail.interface_a_id = connected_interfaces.interface_id) + ) + LEFT JOIN assets AS connected_assets + ON connected_assets.asset_id = connected_interfaces.interface_asset_id + WHERE + ai.interface_asset_id = $asset_id + AND ai.interface_archived_at IS NULL + ORDER BY ai.interface_name ASC + "); + + $interface_count = mysqli_num_rows($sql_related_interfaces); + + // Related Files + $sql_related_files = mysqli_query($mysqli, "SELECT * FROM asset_files + LEFT JOIN files ON asset_files.file_id = files.file_id + WHERE asset_files.asset_id = $asset_id + AND file_archived_at IS NULL + ORDER BY file_name DESC" + ); + $files_count = mysqli_num_rows($sql_related_files); + // View Mode -- 0 List, 1 Thumbnail + if (!empty($_GET['view'])) { + $view = intval($_GET['view']); + } else { + $view = 0; + } + if ($view == 1) { + $query_images = "AND (file_ext LIKE 'JPG' OR file_ext LIKE 'jpg' OR file_ext LIKE 'JPEG' OR file_ext LIKE 'jpeg' OR file_ext LIKE 'png' OR file_ext LIKE 'PNG' OR file_ext LIKE 'webp' OR file_ext LIKE 'WEBP')"; + } else { + $query_images = ''; + } + + // Related Documents + $sql_related_documents = mysqli_query($mysqli, "SELECT * FROM asset_documents, documents + LEFT JOIN users ON document_created_by = user_id + WHERE asset_documents.asset_id = $asset_id + AND asset_documents.document_id = documents.document_id + AND document_archived_at IS NULL + ORDER BY document_name ASC" + ); + $document_count = mysqli_num_rows($sql_related_documents); + + + // Related Credentials Query + $sql_related_credentials = mysqli_query($mysqli, " + SELECT + credentials.credential_id AS credential_id, + credentials.credential_name, + credentials.credential_description, + credentials.credential_uri, + credentials.credential_username, + credentials.credential_password, + credentials.credential_otp_secret, + credentials.credential_note, + credentials.credential_important, + credentials.credential_contact_id, + credentials.credential_asset_id + FROM credentials + LEFT JOIN credential_tags ON credential_tags.credential_id = credentials.credential_id + LEFT JOIN tags ON tags.tag_id = credential_tags.tag_id + WHERE credential_asset_id = $asset_id + AND credential_archived_at IS NULL + GROUP BY credentials.credential_id + ORDER BY credential_name DESC + "); + $credential_count = mysqli_num_rows($sql_related_credentials); + + // Related Software Query + $sql_related_software = mysqli_query( + $mysqli, + "SELECT * FROM software_assets + LEFT JOIN software ON software_assets.software_id = software.software_id + WHERE software_assets.asset_id = $asset_id + AND software_archived_at IS NULL + ORDER BY software_name DESC" + ); + + $software_count = mysqli_num_rows($sql_related_software); + + // Linked Services + $sql_linked_services = mysqli_query($mysqli, "SELECT * FROM service_assets, services + WHERE service_assets.asset_id = $asset_id + AND service_assets.service_id = services.service_id + ORDER BY service_name ASC" + ); + $service_count = mysqli_num_rows($sql_linked_services); + + $linked_services = array(); + + ?> + +
+ +
+ +
+
+ +

+ + asset_photo"> + + +
+ +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
-
- -
-
-
Assignment
-
-
- -
- -
- -
- -
- -
- - +
+
+
Primary Network Interface
+
+
+ +
+ + +
+ +
+ +
+ +
+ + +
Client URI:
+ +
-
-
-
-
Additional Notes
-
- -
-
+
+
+
Assignment
+
+
+ +
+ +
+ +
+ +
+ +
+ -
- - - -
- - -
"> -
-

Documents

-
- +
"> +
+

Documents

+
+ +
-
-
-
- - - - - - - - - - - - - +
+
+
Document TitleByCreatedUpdatedAction
+ - - - - - + + + + + - + + + $linked_documents[] = $document_id; - -
-
-
-
- - - - - Document TitleByCreatedUpdatedAction
-
-
-
+ ?> + + + +
+
+ + + + + + + + + + + + + "> -
-

Files

-
-
- - - - - - - + + ?> + + +
-
-
-
- - - - - - - - - - "> +
+

Files

+
+
+ + + + + + + +
+ +
+
+
+
+
NameUploadedAction
+ - - - + + + - + + + $linked_files[] = $file_id; - -
" target="_blank" >$file_description"; ?> - - NameUploadedAction
-
-
-
+ ?> + + " target="_blank" >$file_description"; ?> + + + + + -
"> -
-

Recurring Tickets

+ + + + +
+
-
-
- - - - - - - - - - - +
"> +
+

Recurring Tickets

+
+
+
+
SubjectPriorityFrequencyNext Run
+ - + + + + + + + + + + + - + - + - + - - + + - + - -
- - - - SubjectPriorityFrequencyNext Run
+ + + + - + - - -
+ + +
-
-
"> -
-

Tickets

-
-
-
- - - - - - - - - - - - - - Never

"; +
"> +
+

Tickets

+
+
+
+
NumberSubjectPriorityStatusAssignedLast ResponseCreated
+ + + + + + + + + + + + + Never

"; + } else { + $ticket_updated_at_display = "

Never

"; + } } else { - $ticket_updated_at_display = "

Never

"; + $ticket_updated_at_display = $ticket_updated_at; } - } else { - $ticket_updated_at_display = $ticket_updated_at; - } - $ticket_closed_at = nullable_htmlentities($row['ticket_closed_at']); - - if ($ticket_priority == "High") { - $ticket_priority_display = "$ticket_priority"; - } elseif ($ticket_priority == "Medium") { - $ticket_priority_display = "$ticket_priority"; - } elseif ($ticket_priority == "Low") { - $ticket_priority_display = "$ticket_priority"; - } else { - $ticket_priority_display = "-"; - } - $ticket_assigned_to = intval($row['ticket_assigned_to']); - if (empty($ticket_assigned_to)) { - if ($ticket_status_id == 5) { - $ticket_assigned_to_display = "

Not Assigned

"; + $ticket_closed_at = nullable_htmlentities($row['ticket_closed_at']); + + if ($ticket_priority == "High") { + $ticket_priority_display = "$ticket_priority"; + } elseif ($ticket_priority == "Medium") { + $ticket_priority_display = "$ticket_priority"; + } elseif ($ticket_priority == "Low") { + $ticket_priority_display = "$ticket_priority"; } else { - $ticket_assigned_to_display = "

Not Assigned

"; + $ticket_priority_display = "-"; + } + $ticket_assigned_to = intval($row['ticket_assigned_to']); + if (empty($ticket_assigned_to)) { + if ($ticket_status_id == 5) { + $ticket_assigned_to_display = "

Not Assigned

"; + } else { + $ticket_assigned_to_display = "

Not Assigned

"; + } + } else { + $ticket_assigned_to_display = nullable_htmlentities($row['user_name']); } - } else { - $ticket_assigned_to_display = nullable_htmlentities($row['user_name']); - } - ?> + ?> - - - - - - - - - + + + + + + + + + - + ?> - -
NumberSubjectPriorityStatusAssignedLast ResponseCreated
- -
+ +
+ + +
-
-
"> -
-

Linked Services

-
- +
"> +
+

Linked Services

+
+ +
-
-
-
- - - - - - - - - - - - +
+
+
ServiceCategoryImportanceAction
+ - - - - + + + + - + + + + + + + + + + + + } - -
-
-
-
- - ServiceCategoryImportanceAction
+
+
+
+ +
+ ?> + + + +
+
-
- - - - - - - + + + + - - + + - + -