diff --git a/domain_tool.php b/domain_tool.php new file mode 100644 index 0000000..cfe7511 --- /dev/null +++ b/domain_tool.php @@ -0,0 +1,139 @@ + 'Active Domains List', + 'description' => 'An addon to list all active domains with client name, domain name, renewal period, recurring amount, and renewal price.', + 'version' => '1.0', + 'author' => 'Your Name', + 'language' => 'english', + 'fields' => [] + ]; +} + +function domain_tool_activate() { + return [ + 'status' => 'success', + 'description' => 'The Active Domains List module has been activated successfully.' + ]; +} + +function domain_tool_deactivate() { + return [ + 'status' => 'success', + 'description' => 'The Active Domains List module has been deactivated successfully.' + ]; +} + +function domain_tool_output($vars) { + $query = " +SELECT + tblclients.id AS client_id, + tblclients.firstname, + tblclients.lastname, + tbldomains.id AS domain_id, + tbldomains.domain, + tbldomains.registrationperiod, + tbldomains.recurringamount, + rp.renewalprice, + (rp.renewalprice - tbldomains.recurringamount) AS pricedifference +FROM + tbldomains +JOIN + tblclients ON tblclients.id = tbldomains.userid +JOIN ( + SELECT + tbldomains.id AS domain_id, + CASE tbldomains.registrationperiod + WHEN 1 THEN tblpricing.msetupfee + WHEN 2 THEN tblpricing.qsetupfee + WHEN 3 THEN tblpricing.ssetupfee + WHEN 4 THEN tblpricing.asetupfee + WHEN 5 THEN tblpricing.bsetupfee + WHEN 6 THEN tblpricing.monthly + WHEN 7 THEN tblpricing.quarterly + WHEN 8 THEN tblpricing.semiannually + WHEN 9 THEN tblpricing.annually + ELSE 0 + END AS renewalprice + FROM tbldomains + JOIN tbldomainpricing ON tbldomainpricing.extension = CONCAT('.', SUBSTRING_INDEX(tbldomains.domain, '.', -1)) + JOIN tblpricing ON tblpricing.relid = tbldomainpricing.id + WHERE tblpricing.type = 'domainrenew' + AND tblpricing.currency = 1 +) rp ON rp.domain_id = tbldomains.id +WHERE + tbldomains.status = 'Active' + AND tbldomains.recurringamount > 0 + AND (rp.renewalprice - tbldomains.recurringamount) != 0; + "; + + // Handling the update action + if (isset($_POST['update_recurringamount']) && isset($_POST['domain_id'])) { + $domainId = (int) $_POST['domain_id']; + $price = (float) $_POST['price']; + + $updateQuery = "UPDATE tbldomains + SET recurringamount = {$price} + -- SET recurringamount = (SELECT renewalprice FROM tbldomains + -- JOIN tblpricing ON tblpricing.relid = tbldomains.id + -- WHERE tbldomains.id = {$domainId} LIMIT 1) + WHERE id = {$domainId}"; + + // Execute the query to update the recurring amount + full_query($updateQuery); + + // Optional: show a message indicating success + echo "
| ID | +Domain | +Client Name | +Renewal Period | +Recurring Amount | +Renewal Price | +Price Difference | +Actions | +
|---|---|---|---|---|---|---|---|
| {$domain_id} | +{$domainName} | +{$clientName} | +{$renewalPeriod} | +{$recurringAmount} | +{$renewalPrice} | +{$priceDifference} | ++ + | +