From a80fddfc0d4008f5ef9d92ab1f5de965dc5eefc8 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sat, 23 Nov 2024 18:18:22 -0500 Subject: [PATCH] Delete Contact Notes when contact is deleted also delete contact references when delting a client --- post/user/client.php | 7 ++++++- post/user/contact.php | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/post/user/client.php b/post/user/client.php index 2da7e8192..afc4f591f 100644 --- a/post/user/client.php +++ b/post/user/client.php @@ -214,11 +214,16 @@ mysqli_query($mysqli, "DELETE FROM certificates WHERE certificate_client_id = $client_id"); mysqli_query($mysqli, "DELETE FROM documents WHERE document_client_id = $client_id"); - // Delete Contacts and contact tags + // Delete Contacts including contact tags, notes $sql = mysqli_query($mysqli, "SELECT contact_id FROM contacts WHERE contact_client_id = $client_id"); while($row = mysqli_fetch_array($sql)) { $contact_id = $row['contact_id']; mysqli_query($mysqli, "DELETE FROM contact_tags WHERE contact_id = $contact_id"); + mysqli_query($mysqli, "DELETE FROM contact_assets WHERE contact_id = $contact_id"); + mysqli_query($mysqli, "DELETE FROM contact_documents WHERE contact_id = $contact_id"); + mysqli_query($mysqli, "DELETE FROM contact_files WHERE contact_id = $contact_id"); + mysqli_query($mysqli, "DELETE FROM contact_logins WHERE contact_id = $contact_id"); + mysqli_query($mysqli, "DELETE FROM contact_notes WHERE contact_note_contact_id = $contact_id"); } mysqli_query($mysqli, "DELETE FROM contacts WHERE contact_client_id = $client_id"); diff --git a/post/user/contact.php b/post/user/contact.php index 566911a00..39af4523e 100644 --- a/post/user/contact.php +++ b/post/user/contact.php @@ -584,6 +584,7 @@ mysqli_query($mysqli, "DELETE FROM contact_documents WHERE contact_id = $contact_id"); mysqli_query($mysqli, "DELETE FROM contact_files WHERE contact_id = $contact_id"); mysqli_query($mysqli, "DELETE FROM contact_logins WHERE contact_id = $contact_id"); + mysqli_query($mysqli, "DELETE FROM contact_notes WHERE contact_note_contact_id = $contact_id"); // Individual Logging logAction("Contact", "Delete", "$session_name deleted $contact_name", $client_id); @@ -787,6 +788,7 @@ mysqli_query($mysqli, "DELETE FROM contact_documents WHERE contact_id = $contact_id"); mysqli_query($mysqli, "DELETE FROM contact_files WHERE contact_id = $contact_id"); mysqli_query($mysqli, "DELETE FROM contact_logins WHERE contact_id = $contact_id"); + mysqli_query($mysqli, "DELETE FROM contact_notes WHERE contact_note_contact_id = $contact_id"); //Logging logAction("Contact", "Delete", "$session_name deleted contact $contact_name", $client_id);