diff --git a/agent/modals/contact/contact_details.php b/agent/modals/contact/contact_details.php index 596c6b22..90e6f3e1 100644 --- a/agent/modals/contact/contact_details.php +++ b/agent/modals/contact/contact_details.php @@ -13,6 +13,7 @@ $sql = mysqli_query($mysqli, "SELECT * FROM contacts "); $row = mysqli_fetch_assoc($sql); + $client_id = intval($row['client_id']); $client_name = nullable_htmlentities($row['client_name']); $contact_name = nullable_htmlentities($row['contact_name']); @@ -34,6 +35,7 @@ $contact_billing = intval($row['contact_billing']); $contact_technical = intval($row['contact_technical']); $contact_created_at = nullable_htmlentities($row['contact_created_at']); $contact_location_id = intval($row['contact_location_id']); + $location_name = nullable_htmlentities($row['location_name']); $location_country = nullable_htmlentities($row['location_country']); $location_address = nullable_htmlentities($row['location_address']); @@ -42,11 +44,8 @@ $location_state = nullable_htmlentities($row['location_state']); $location_zip = nullable_htmlentities($row['location_zip']); $location_phone_country_code = nullable_htmlentities($row['location_phone_country_code']); $location_phone = nullable_htmlentities(formatPhoneNumber($row['location_phone'], $location_phone_country_code)); -if (empty($location_phone)) { - $location_phone_display = "-"; -} else { - $location_phone_display = $location_phone; -} +$location_phone_display = empty($location_phone) ? "-" : $location_phone; + $auth_method = nullable_htmlentities($row['user_auth_method']); $contact_client_id = intval($row['contact_client_id']); @@ -69,16 +68,15 @@ $sql_linked_software = mysqli_query($mysqli, "SELECT * FROM software_contacts, s ORDER BY software_name ASC" ); $software_count = mysqli_num_rows($sql_linked_software); - $linked_software = array(); // Related Credentials Query 1 to 1 relationship $sql_related_credentials = mysqli_query($mysqli, " SELECT - credentials.credential_id AS credentials_credential_id, -- Alias for credentials.credential_id - credentials.*, -- All other columns from credentials - credential_tags.*, -- All columns from credential_tags - tags.* -- All columns from tags + credentials.credential_id AS credentials_credential_id, + credentials.*, + credential_tags.*, + tags.* 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 @@ -92,7 +90,9 @@ $credential_count = mysqli_num_rows($sql_related_credentials); $sql_related_tickets = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN users ON ticket_assigned_to = user_id LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id - WHERE ticket_contact_id = $contact_id ORDER BY ticket_id DESC"); + WHERE ticket_contact_id = $contact_id + ORDER BY ticket_id DESC +"); $ticket_count = mysqli_num_rows($sql_related_tickets); // Related Recurring Tickets Query @@ -102,11 +102,14 @@ $sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM recurring_ ); $recurring_ticket_count = mysqli_num_rows($sql_related_recurring_tickets); - // Tags - many to many relationship $contact_tag_name_display_array = array(); $contact_tag_id_array = array(); -$sql_contact_tags = mysqli_query($mysqli, "SELECT * FROM contact_tags LEFT JOIN tags ON contact_tags.tag_id = tags.tag_id WHERE contact_id = $contact_id ORDER BY tag_name ASC"); +$sql_contact_tags = mysqli_query($mysqli, "SELECT * FROM contact_tags + LEFT JOIN tags ON contact_tags.tag_id = tags.tag_id + WHERE contact_id = $contact_id + ORDER BY tag_name ASC +"); while ($row = mysqli_fetch_assoc($sql_contact_tags)) { $contact_tag_id = intval($row['tag_id']); @@ -126,17 +129,21 @@ while ($row = mysqli_fetch_assoc($sql_contact_tags)) { $contact_tags_display = implode('', $contact_tag_name_display_array); // Notes - 1 to 1 relationship -$sql_related_notes = mysqli_query($mysqli, "SELECT * FROM contact_notes LEFT JOIN users ON contact_note_created_by = user_id WHERE contact_note_contact_id = $contact_id AND contact_note_archived_at IS NULL ORDER BY contact_note_created_at DESC"); +$sql_related_notes = mysqli_query($mysqli, "SELECT * FROM contact_notes + LEFT JOIN users ON contact_note_created_by = user_id + WHERE contact_note_contact_id = $contact_id + AND contact_note_archived_at IS NULL + ORDER BY contact_note_created_at DESC +"); $note_count = mysqli_num_rows($sql_related_notes); - // Linked Services +// Linked Services $sql_linked_services = mysqli_query($mysqli, "SELECT * FROM service_contacts, services WHERE service_contacts.contact_id = $contact_id AND service_contacts.service_id = services.service_id ORDER BY service_name ASC" ); $services_count = mysqli_num_rows($sql_linked_services); - $linked_services = array(); // Linked Documents @@ -148,7 +155,6 @@ $sql_linked_documents = mysqli_query($mysqli, "SELECT * FROM contact_documents, ORDER BY document_name ASC" ); $document_count = mysqli_num_rows($sql_linked_documents); - $linked_documents = array(); // Linked Files @@ -159,7 +165,6 @@ $sql_linked_files = mysqli_query($mysqli, "SELECT * FROM contact_files, files ORDER BY file_name ASC" ); $file_count = mysqli_num_rows($sql_linked_files); - $linked_files = array(); if (isset($_GET['client_id'])) { @@ -168,6 +173,17 @@ if (isset($_GET['client_id'])) { $client_url = ''; } +// Pick first available tab (Details tab removed) +$first_tab = null; +if ($asset_count) { $first_tab = "assets"; } +elseif ($credential_count) { $first_tab = "credentials"; } +elseif ($software_count) { $first_tab = "licenses"; } +elseif ($ticket_count) { $first_tab = "tickets"; } +elseif ($recurring_ticket_count) { $first_tab = "recurring"; } +elseif ($document_count) { $first_tab = "documents"; } +elseif ($file_count) { $first_tab = "files"; } +elseif ($note_count) { $first_tab = "notes"; } + // Generate the HTML form content using output buffering. ob_start(); ?> @@ -196,704 +212,674 @@ ob_start();
| Name/Description | -Type | -Make/Model | -Serial Number | -Install Date | -Status | -
|---|---|---|---|---|---|
|
-
-
- = $asset_name ?>
-
-
- = $asset_description ?>
+
+
+
+
+ Location
+
+ = $location_name ?>
+
+ = $location_address ?>
-
- + = "$location_city $location_state $location_zip" ?> + = $location_country ?>
- = $asset_tags_display ?>
-
-
- |
- = $asset_type ?> | -
- = $asset_make ?>
-
- = $asset_model ?>
-
- |
- = $asset_serial_display ?> | -= $asset_install_date_display ?> | -= $asset_status ?> | -
| Name | -Description | -Username | -Password | -OTP | -URI | -
|---|---|---|---|---|---|
| = $credential_name ?> | -= $credential_description ?> | -= $credential_username_display ?> | -- - - - | -= $otp_display ?> | -= $credential_uri_display ?> | -
| Number | -Subject | -Priority | -Status | -Assigned | -Last Response | -Created | -
|---|---|---|---|---|---|---|
| = "$ticket_prefix$ticket_number" ?> | -= $ticket_subject ?> | -= $ticket_priority_display ?> | -= $ticket_status_name ?> | -= $ticket_assigned_to_display ?> | -= $ticket_updated_at_display ?> | -= $ticket_created_at ?> | -
| Subject | -Priority | -Frequency | -Next Run | -
|---|---|---|---|
| = $recurring_ticket_subject ?> | -= $recurring_ticket_priority ?> | -= $recurring_ticket_frequency ?> | -= $recurring_ticket_next_run ?> | -
| Software | -Type | -Key | -Seats | -
|---|
| Name/Description | +Type | +Make/Model | +Serial Number | +Install Date | +Status | +
|---|---|---|---|---|---|
| = "$software_name $software_version" ?> | -= $software_type ?> | -= $software_key ?> | -= "$seat_count / $software_seats" ?> | -||
|
+
+
+ = $asset_name ?>
+
+
+ = $asset_description ?>
+
+
+
+ = $asset_tags_display ?>
+
+
+ |
+ = $asset_type ?> | +
+ = $asset_make ?>
+
+ = $asset_model ?>
+
+ |
+ = $asset_serial_display ?> | += $asset_install_date_display ?> | += $asset_status ?> | +
| Name | +Description | +Username | +Password | +OTP | +URI | +
|---|---|---|---|---|---|
| = $credential_name ?> | += $credential_description ?> | += $credential_username_display ?> | ++ + + | += $otp_display ?> | += $credential_uri_display ?> | +
| Number | +Subject | +Priority | +Status | +Assigned | +Last Response | +Created | +
|---|---|---|---|---|---|---|
| + + = "$ticket_prefix$ticket_number" ?> + + | += $ticket_subject ?> | += $ticket_priority_display ?> | += $ticket_status_name ?> | += $ticket_assigned_to_display ?> | += $ticket_updated_at_display ?> | += $ticket_created_at ?> | +
| Subject | +Priority | +Frequency | +Next Run | +
|---|---|---|---|
| = $recurring_ticket_subject ?> | += $recurring_ticket_priority ?> | += $recurring_ticket_frequency ?> | += $recurring_ticket_next_run ?> | +
| Software | +Type | +Key | +Seats | +
|---|---|---|---|
| = "$software_name $software_version" ?> | += $software_type ?> | += $software_key ?> | += "$seat_count / $software_seats" ?> | +
| Document Title | +By | +Created | +Updated | +
|---|---|---|---|
|
+
+ = $document_name ?>
+
+ = $document_description ?>
+ |
+ = $document_created_by ?> | += $document_created_at ?> | += $document_updated_at ?> | +
| File Name | +Type | +Size | +Uploaded | +
|---|---|---|---|
|
+
+ = $file_description ?>
+ |
+ = $file_mime_type ?> | += $file_size_KB ?> KB | += $file_created_at ?> | +
| Type | +Note | +By | +Created | +
|---|---|---|---|
| = $contact_note_type ?> | += $contact_note ?> | += $note_by ?> | += $contact_note_created_at ?> | +
| Document Title | -By | -Created | -Updated | -
|---|---|---|---|
|
-
-
-
- = $document_description ?>
- |
- = $document_created_by ?> | -= $document_created_at ?> | -= $document_updated_at ?> | -
| File Name | -Type | -Size | -Uploaded | -
|---|---|---|---|
|
-
- = $file_description ?>
- |
- = $file_mime_type ?> | -= $file_size_KB ?> KB | -= $file_created_at ?> | -
| Type | -Note | -By | -Created | -
|---|---|---|---|
| = $contact_note_type ?> | -= $contact_note ?> | -= $note_by ?> | -= $contact_note_created_at ?> | -