From 64499fa734499b953184b8a9c1d4b30f1cb09ba0 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Sat, 1 Jun 2024 14:39:14 -0400 Subject: [PATCH] Also Delete Location Tags when a Client is deleted --- post/client.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/post/client.php b/post/client.php index e8cf5fad..151c772a 100644 --- a/post/client.php +++ b/post/client.php @@ -218,6 +218,7 @@ if (isset($_GET['delete_client'])) { $contact_id = $row['contact_id']; mysqli_query($mysqli, "DELETE FROM contact_tags WHERE contact_id = $contact_id"); } + mysqli_query($mysqli, "DELETE FROM contacts WHERE contact_client_id = $client_id"); // Delete Domains and associated records $sql = mysqli_query($mysqli, "SELECT domain_id FROM domains WHERE domain_client_id = $client_id"); @@ -241,7 +242,14 @@ if (isset($_GET['delete_client'])) { } mysqli_query($mysqli, "DELETE FROM invoices WHERE invoice_client_id = $client_id"); + // Delete Locations and location tags + $sql = mysqli_query($mysqli, "SELECT location_id FROM locations WHERE location_client_id = location_id"); + while($row = mysqli_fetch_array($sql)) { + $location_id = $row['location_id']; + mysqli_query($mysqli, "DELETE FROM location_tags WHERE location_id = $location_id"); + } mysqli_query($mysqli, "DELETE FROM locations WHERE location_client_id = $client_id"); + mysqli_query($mysqli, "DELETE FROM logins WHERE login_client_id = $client_id"); mysqli_query($mysqli, "DELETE FROM logs WHERE log_client_id = $client_id"); mysqli_query($mysqli, "DELETE FROM networks WHERE network_client_id = $client_id");