From 78ae44c3346a2287f1302d17f132878fc8851901 Mon Sep 17 00:00:00 2001 From: johnnyq Date: Wed, 19 Feb 2025 01:22:31 -0500 Subject: [PATCH] Migrated domain and certificate edit to the new AJAX modal function --- ajax.php | 66 ---------- ajax/ajax_certificate_edit.php | 161 +++++++++++++++++++++++ ajax/ajax_domain_edit.php | 2 +- client_certificates.php | 18 ++- client_domains.php | 1 - js/certificate_edit_modal.js | 49 ------- modals/client_certificate_edit_modal.php | 132 ------------------- 7 files changed, 173 insertions(+), 256 deletions(-) create mode 100644 ajax/ajax_certificate_edit.php delete mode 100644 js/certificate_edit_modal.js delete mode 100644 modals/client_certificate_edit_modal.php diff --git a/ajax.php b/ajax.php index 35bc752b..afb622bd 100644 --- a/ajax.php +++ b/ajax.php @@ -40,72 +40,6 @@ if (isset($_GET['certificate_fetch_parse_json_details'])) { } -/* - * Looks up info for a given certificate ID from the database, used to dynamically populate modal fields - */ -if (isset($_GET['certificate_get_json_details'])) { - enforceUserPermission('module_support'); - - $certificate_id = intval($_GET['certificate_id']); - $client_id = intval($_GET['client_id']); - - // Individual certificate lookup - $cert_sql = mysqli_query($mysqli, "SELECT * FROM certificates WHERE certificate_id = $certificate_id AND certificate_client_id = $client_id"); - while ($row = mysqli_fetch_array($cert_sql)) { - $response['certificate'][] = $row; - } - - // Get all domains for this client that could be linked to this certificate - $domains_sql = mysqli_query($mysqli, "SELECT domain_id, domain_name FROM domains WHERE domain_client_id = $client_id"); - while ($row = mysqli_fetch_array($domains_sql)) { - $response['domains'][] = $row; - } - - echo json_encode($response); -} - -/* - * Looks up info for a given domain ID from the database, used to dynamically populate modal fields - */ -if (isset($_GET['domain_get_json_details'])) { - enforceUserPermission('module_support'); - - $domain_id = intval($_GET['domain_id']); - $client_id = intval($_GET['client_id']); - - // Individual domain lookup - $cert_sql = mysqli_query($mysqli, "SELECT * FROM domains WHERE domain_id = $domain_id AND domain_client_id = $client_id"); - while ($row = mysqli_fetch_array($cert_sql)) { - $response['domain'][] = $row; - } - - // Get all registrars/webhosts (vendors) for this client that could be linked to this domain - $vendor_sql = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = $client_id AND vendor_archived_at IS NULL ORDER BY vendor_name ASC"); - while ($row = mysqli_fetch_array($vendor_sql)) { - $response['vendors'][] = $row; - } - - // Get domain history - $history_sql = mysqli_query($mysqli, "SELECT * FROM domain_history WHERE domain_history_domain_id = $domain_id"); - $history_html = ""; - $history_html .= ""; - while ($row = mysqli_fetch_array($history_sql)) { - // Fetch data from the query and create table rows - $history_html .= ""; - $history_html .= ""; - $history_html .= ""; - $history_html .= ""; - $history_html .= ""; - $history_html .= ""; - } - $history_html .= "
DateFieldBeforeAfter
" . htmlspecialchars(date('Y-m-d', strtotime($row['domain_history_modified_at']))) . "" . htmlspecialchars($row['domain_history_column']) . "" . htmlspecialchars($row['domain_history_old_value']) . "" . htmlspecialchars($row['domain_history_new_value']) . "
"; - - // Return the HTML content to JavaScript - $response['history'] = $history_html; - - echo json_encode($response); -} - /* * Looks up info on the ticket number provided, used to populate the ticket merge modal */ diff --git a/ajax/ajax_certificate_edit.php b/ajax/ajax_certificate_edit.php new file mode 100644 index 00000000..2c7ec75d --- /dev/null +++ b/ajax/ajax_certificate_edit.php @@ -0,0 +1,161 @@ + + + +
+ + + + + +
+ + - )" data-target="#editCertificateModal"> +
@@ -173,7 +177,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); - - + - = 0; i--) { - domainDropdown.remove(i); - } - domainDropdown[domainDropdown.length] = new Option('- Domain -', '0'); - - // Populate domain dropdown - domains.forEach(domain => { - if (parseInt(domain.domain_id) == parseInt(certificate.certificate_domain_id)) { - // Selected domain - domainDropdown[domainDropdown.length] = new Option(domain.domain_name, domain.domain_id, true, true); - } - else{ - domainDropdown[domainDropdown.length] = new Option(domain.domain_name, domain.domain_id); - } - }); - } - ); -} diff --git a/modals/client_certificate_edit_modal.php b/modals/client_certificate_edit_modal.php deleted file mode 100644 index c43991ce..00000000 --- a/modals/client_certificate_edit_modal.php +++ /dev/null @@ -1,132 +0,0 @@ -