From 88a96e30440d9e580d6309c3afca5ad4aca6164e Mon Sep 17 00:00:00 2001 From: johnnyq Date: Wed, 10 Apr 2024 13:21:45 -0400 Subject: [PATCH] Reworked Client Domains, added mail host and dns host, made all the host columns sortable by reworking the logic and optimized the code further --- client_domain_add_modal.php | 42 +++++++++++++++++++++++++++ client_domain_edit_modal.php | 22 +++++++++++++++ client_domains.php | 55 ++++++++++++++++++++++-------------- database_updates.php | 13 +++++++-- database_version.php | 2 +- db.sql | 4 ++- js/domain_edit_modal.js | 41 +++++++++++++++++++++++++++ post/domain.php | 8 ++++-- 8 files changed, 159 insertions(+), 28 deletions(-) diff --git a/client_domain_add_modal.php b/client_domain_add_modal.php index f705e50c..abe56508 100644 --- a/client_domain_add_modal.php +++ b/client_domain_add_modal.php @@ -89,6 +89,48 @@ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
diff --git a/client_domain_edit_modal.php b/client_domain_edit_modal.php index 57a4a3a1..e36f1c0e 100644 --- a/client_domain_edit_modal.php +++ b/client_domain_edit_modal.php @@ -72,6 +72,28 @@
+
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+
diff --git a/client_domains.php b/client_domains.php index 215b8083..ecf1df7b 100644 --- a/client_domains.php +++ b/client_domains.php @@ -10,11 +10,19 @@ require_once "inc_all_client.php"; //Rebuild URL $url_query_strings_sort = http_build_query($get_copy); -$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM domains - LEFT JOIN vendors ON domain_registrar = vendor_id - WHERE domain_client_id = $client_id +$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS domains.*, + registrar.vendor_name AS registrar_name, + dnshost.vendor_name AS dnshost_name, + mailhost.vendor_name AS mailhost_name, + webhost.vendor_name AS webhost_name + FROM domains + LEFT JOIN vendors AS registrar ON domains.domain_registrar = registrar.vendor_id + LEFT JOIN vendors AS dnshost ON domains.domain_dnshost = dnshost.vendor_id + LEFT JOIN vendors AS mailhost ON domains.domain_mailhost = mailhost.vendor_id + LEFT JOIN vendors AS webhost ON domains.domain_webhost = webhost.vendor_id + WHERE domain_client_id = $client_id AND domain_archived_at IS NULL - AND (domain_name LIKE '%$q%' OR vendor_name LIKE '%$q%') + AND (domains.domain_name LIKE '%$q%' OR domains.domain_description LIKE '%$q%' OR registrar.vendor_name LIKE '%$q%' OR dnshost.vendor_name LIKE '%$q%' OR mailhost.vendor_name LIKE '%$q%' OR webhost.vendor_name LIKE '%$q%') ORDER BY $sort $order LIMIT $record_from, $record_to"); $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); @@ -83,8 +91,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
Domain - Registrar - Web Host + Registrar + Web Host + DNS Host + Mail Host Expires Action @@ -96,21 +106,22 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); $domain_id = intval($row['domain_id']); $domain_name = nullable_htmlentities($row['domain_name']); $domain_description = nullable_htmlentities($row['domain_description']); - $domain_registrar = intval($row['domain_registrar']); - $domain_webhost = intval($row['domain_webhost']); $domain_expire = nullable_htmlentities($row['domain_expire']); - $domain_registrar_name = nullable_htmlentities($row['vendor_name']); + $domain_registrar_name = nullable_htmlentities($row['registrar_name']); + if($domain_registrar_name) { + $domain_registrar_name_display = $domain_registrar_name; + } else { + $domain_registrar_name_display = "-"; + } + $domain_webhost_name = nullable_htmlentities($row['webhost_name']); + $domain_dnshost_name = nullable_htmlentities($row['dnshost_name']); + $domain_mailhost_name = nullable_htmlentities($row['mailhost_name']); $domain_created_at = nullable_htmlentities($row['domain_created_at']); - if (empty($domain_registrar_name)) { - $domain_registrar_name = "-"; - } - - $sql_domain_webhost = mysqli_query($mysqli, "SELECT vendor_name FROM vendors WHERE vendor_id = $domain_webhost"); - $row = mysqli_fetch_array($sql_domain_webhost); - $domain_webhost_name = "-"; - if ($row) { - $domain_webhost_name = nullable_htmlentities($row['vendor_name']); - } + // Add - if empty on the table + $domain_registrar_name_display = $domain_registrar_name ? $domain_registrar_name : "-"; + $domain_webhost_name_display = $domain_webhost_name ? $domain_webhost_name : "-"; + $domain_dnshost_name_display = $domain_dnshost_name ? $domain_dnshost_name : "-"; + $domain_mailhost_name_display = $domain_mailhost_name ? $domain_mailhost_name : "-"; ?> @@ -131,8 +142,10 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
- - + + + +