fix: standardize billing order status values and fix expiration lookup

- billing_integration.php: admin-created servers now use status='Active' (was 'installed')
- home_handling_functions.php: expiration query uses status IN ('Active','Invoiced') only
- my_account.php: renewable_statuses includes canonical 'active'/'invoiced'; legacy labels updated
- admin_orders.php: add orphaned home_id diagnostics section
- normalize_billing_order_status.sql: new migration to convert installed/paid→Active, suspended→Invoiced

Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/c56f04bb-ecce-4f1b-9bbd-c5f83107da1d

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-05 15:55:39 +00:00 committed by GitHub
parent edb2f90b4a
commit 2f62bd32c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 116 additions and 14 deletions

View file

@ -197,5 +197,45 @@ function exec_ogp_module()
echo "</tbody></table>";
echo "</div>";
// Orphaned home_id diagnostics —————————————————————————————————————————
// Find billing_orders rows where home_id != 0 but no matching gsp_server_homes
// record exists. These indicate provisioning failures or stale data, and they
// are the reason the game monitor may show "No expiration date found".
$orphans = $db->resultQuery(
"SELECT o.order_id, o.user_id, o.home_name, o.home_id, o.status, o.end_date
FROM OGP_DB_PREFIXbilling_orders o
LEFT JOIN OGP_DB_PREFIXserver_homes sh ON sh.home_id = o.home_id
WHERE o.home_id != '0'
AND o.home_id != ''
AND sh.home_id IS NULL
ORDER BY o.order_id ASC"
);
echo "<div style='margin-top: 30px;'>";
echo "<h3>Orphaned home_id Diagnostics</h3>";
echo "<p style='color:#666;'>Billing orders that reference a <code>home_id</code> which no longer exists in <code>gsp_server_homes</code>. ";
echo "These orders will not show an expiration date on the game monitor. ";
echo "Reset <code>home_id</code> to <code>0</code> or re-provision these orders to fix them. ";
echo "Run <code>normalize_billing_order_status.sql</code> to standardise any legacy status values.</p>";
if (empty($orphans)) {
echo "<p style='color:green;'>&#10003; No orphaned billing orders found.</p>";
} else {
echo "<table class='tablesorter' style='width:100%;'>";
echo "<thead><tr><th>Order ID</th><th>User ID</th><th>Server Name</th><th>home_id (missing)</th><th>Status</th><th>End Date</th></tr></thead><tbody>";
foreach ($orphans as $row) {
echo "<tr>";
echo "<td>".intval($row['order_id'])."</td>";
echo "<td>".intval($row['user_id'])."</td>";
echo "<td>".htmlspecialchars($row['home_name'] ?? '')."</td>";
echo "<td style='color:red;'>".htmlspecialchars($row['home_id'] ?? '')."</td>";
echo "<td>".htmlspecialchars($row['status'] ?? '')."</td>";
echo "<td>".htmlspecialchars($row['end_date'] ?? 'NULL')."</td>";
echo "</tr>";
}
echo "</tbody></table>";
}
echo "</div>";
}
?>