From 54c5efe0a888ece8e5abcc651789e4459c200fe2 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 29 Oct 2025 11:02:40 +0000
Subject: [PATCH] Add coupon discount display to my_servers and admin_invoices
pages
Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
---
modules/billing/admin_invoices.php | 20 +++++++++++++++++---
modules/billing/my_servers.php | 27 +++++++++++++++++++++++++--
2 files changed, 42 insertions(+), 5 deletions(-)
diff --git a/modules/billing/admin_invoices.php b/modules/billing/admin_invoices.php
index 3bb2143f..f087c8c4 100644
--- a/modules/billing/admin_invoices.php
+++ b/modules/billing/admin_invoices.php
@@ -21,10 +21,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
}
-// Fetch all orders
-$orders = mysqli_query($db, "SELECT o.*, u.user_name
+// Fetch all orders with coupon information
+$orders = mysqli_query($db, "SELECT o.*, u.user_name, c.code AS coupon_code, c.discount_percent AS coupon_discount
FROM ogp_billing_orders o
LEFT JOIN ogp_users u ON o.user_id = u.user_id
+ LEFT JOIN ogp_billing_coupons c ON o.coupon_id = c.coupon_id
ORDER BY o.order_id DESC");
function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); }
@@ -88,7 +89,20 @@ function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); }
|
|
|
- $ |
+
+ 0 && !empty($row['coupon_code'])) {
+ echo '$' . number_format($price + $discount, 2) . ' ';
+ echo '$' . number_format($price, 2) . '';
+ echo ' (' . h($row['coupon_code']) . ' -' . number_format($row['coupon_discount'], 0) . '%)';
+ } else {
+ echo '$' . number_format($price, 2);
+ }
+ ?>
+ |
|
diff --git a/modules/billing/my_servers.php b/modules/billing/my_servers.php
index 9e257da6..51fe4d15 100644
--- a/modules/billing/my_servers.php
+++ b/modules/billing/my_servers.php
@@ -43,12 +43,18 @@ $query = "SELECT
-- use end_date as the expiration marker (set when order is paid/created)
o.end_date AS expiration_date,
bs.service_name,
- bs.price_monthly
+ bs.price_monthly,
+ o.price,
+ o.discount_amount,
+ o.coupon_id,
+ bc.code AS coupon_code,
+ bc.discount_percent AS coupon_discount_percent
FROM ogp_home h
LEFT JOIN ogp_remote_servers rs ON h.remote_server_id = rs.remote_server_id
LEFT JOIN ogp_game_configs gc ON h.home_cfg_id = gc.home_cfg_id
LEFT JOIN ogp_billing_orders o ON h.user_id = o.user_id
LEFT JOIN ogp_billing_services bs ON o.service_id = bs.service_id
+ LEFT JOIN ogp_billing_coupons bc ON o.coupon_id = bc.coupon_id
WHERE h.user_id = $user_id
ORDER BY h.home_id DESC";
@@ -91,7 +97,24 @@ $result = mysqli_query($db, $query);
| |
|
|
- |
+
+ 0 && $server['coupon_code']) {
+ echo '$' . number_format($price + $discount, 2) . ' ';
+ echo '$' . number_format($price, 2) . '';
+ echo ' (' . htmlspecialchars($server['coupon_code']) . ' -' . number_format($server['coupon_discount_percent'], 0) . '%)';
+ } else {
+ echo '$' . number_format($price, 2);
+ }
+ } else {
+ echo 'N/A';
+ }
+ ?>
+ |
Renew
|