diff --git a/client_contact_details.php b/client_contact_details.php index 97d44331..2685a3a3 100644 --- a/client_contact_details.php +++ b/client_contact_details.php @@ -98,6 +98,16 @@ if (isset($_GET['contact_id'])) { $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 + $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" + ); + $service_count = mysqli_num_rows($sql_linked_services); + + $linked_services = array(); + // Linked Documents $sql_linked_documents = mysqli_query($mysqli, "SELECT * FROM contact_documents, documents LEFT JOIN users ON document_created_by = user_id @@ -240,7 +250,7 @@ if (isset($_GET['contact_id'])) { Credential - + Service @@ -696,6 +706,64 @@ if (isset($_GET['contact_id'])) { +
"> +
+

Linked Services

+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
ServiceCategoryImportanceAction
+
+
+
+ +
+
+
+
+
">

Linked Documents

@@ -963,6 +1031,7 @@ require_once "client_contact_create_note_modal.php"; require_once "ticket_add_modal.php"; require_once "client_contact_link_asset_modal.php"; require_once "client_contact_link_credential_modal.php"; +require_once "client_contact_link_service_modal.php"; require_once "client_contact_link_document_modal.php"; require_once "client_contact_link_file_modal.php"; diff --git a/client_contact_link_service_modal.php b/client_contact_link_service_modal.php new file mode 100644 index 00000000..74a4b51d --- /dev/null +++ b/client_contact_link_service_modal.php @@ -0,0 +1,56 @@ + diff --git a/post/user/contact.php b/post/user/contact.php index 0697162e..6f3cdfcc 100644 --- a/post/user/contact.php +++ b/post/user/contact.php @@ -997,6 +997,65 @@ if (isset($_GET['unlink_credential_from_contact'])) { } +if (isset($_POST['link_service_to_contact'])) { + + enforceUserPermission('module_support', 2); + + $service_id = intval($_POST['service_id']); + $contact_id = intval($_POST['contact_id']); + + // Get service Name and Client ID for logging + $sql_service = mysqli_query($mysqli,"SELECT service_name, service_client_id FROM services WHERE service_id = $service_id"); + $row = mysqli_fetch_array($sql_service); + $service_name = sanitizeInput($row['service_name']); + $client_id = intval($row['service_client_id']); + + // Get Contact Name for logging + $sql_contact = mysqli_query($mysqli,"SELECT contact_name FROM contacts WHERE contact_id = $contact_id"); + $row = mysqli_fetch_array($sql_contact); + $contact_name = sanitizeInput($row['contact_name']); + + mysqli_query($mysqli,"INSERT INTO service_contacts SET contact_id = $contact_id, service_id = $service_id"); + + // Logging + logAction("Service", "Link", "$session_name linked contact $contact_name to service $service_name", $client_id, $service_id); + + $_SESSION['alert_message'] = "service $service_name linked with contact $contact_name"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + +if (isset($_GET['unlink_service_from_contact'])) { + + enforceUserPermission('module_support', 2); + + $contact_id = intval($_GET['contact_id']); + $service_id = intval($_GET['service_id']); + + // Get service Name and Client ID for logging + $sql_service = mysqli_query($mysqli,"SELECT service_name, service_client_id FROM services WHERE service_id = $service_id"); + $row = mysqli_fetch_array($sql_service); + $service_name = sanitizeInput($row['service_name']); + $client_id = intval($row['service_client_id']); + + // Get Contact Name for logging + $sql_contact = mysqli_query($mysqli,"SELECT contact_name FROM contacts WHERE contact_id = $contact_id"); + $row = mysqli_fetch_array($sql_contact); + $contact_name = sanitizeInput($row['contact_name']); + + mysqli_query($mysqli,"DELETE FROM service_contacts WHERE contact_id = $contact_id AND service_id = $service_id"); + + //Logging + logAction("service", "Unlink", "$session_name unlinked contact $contact_name from service $service_name", $client_id, $service_id); + + $_SESSION['alert_type'] = "error"; + $_SESSION['alert_message'] = "Contact $contact_name unlinked from service $service_name"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if (isset($_POST['link_contact_to_file'])) { enforceUserPermission('module_support', 2); @@ -1019,7 +1078,7 @@ if (isset($_POST['link_contact_to_file'])) { mysqli_query($mysqli,"INSERT INTO contact_files SET contact_id = $contact_id, file_id = $file_id"); // Logging - logAction("Document", "Link", "$session_name linked contact $contact_name to document $file_name", $client_id, $file_id); + logAction("File", "Link", "$session_name linked contact $contact_name to file $file_name", $client_id, $file_id); $_SESSION['alert_message'] = "Contact $contact_name linked with File $file_name";