diff --git a/modules/billing/adminserverlist.php b/modules/billing/adminserverlist.php index 58b53adf..860bd438 100644 --- a/modules/billing/adminserverlist.php +++ b/modules/billing/adminserverlist.php @@ -6,16 +6,18 @@ Admin Service Configuration - GSP @@ -41,7 +43,7 @@ * home_cfg_id ← home_cfg_id (sync key) * * Columns that are admin-editable and NEVER overwritten by sync: - * enabled, out_of_stock, slot_min_qty, slot_max_qty, + * enabled, slot_min_qty, slot_max_qty, * price_daily, price_monthly, price_year, * remote_server_id, description, img_url */ @@ -78,7 +80,6 @@ function sync_billing_services(mysqli $db, string $prefix): array 'home_cfg_id' => "ADD COLUMN `home_cfg_id` INT(11) NOT NULL DEFAULT 0", 'description' => "ADD COLUMN `description` VARCHAR(1000) NOT NULL DEFAULT ''", 'img_url' => "ADD COLUMN `img_url` VARCHAR(255) NOT NULL DEFAULT ''", - 'out_of_stock' => "ADD COLUMN `out_of_stock` TINYINT(1) NOT NULL DEFAULT 0", 'slot_min_qty' => "ADD COLUMN `slot_min_qty` INT(11) NOT NULL DEFAULT 1", 'slot_max_qty' => "ADD COLUMN `slot_max_qty` INT(11) NOT NULL DEFAULT 100", 'price_daily' => "ADD COLUMN `price_daily` FLOAT(15,4) NOT NULL DEFAULT 0", @@ -126,7 +127,7 @@ function sync_billing_services(mysqli $db, string $prefix): array // Load existing billing_services indexed by home_cfg_id. $existing = []; $svcRes = $db->query( - "SELECT service_id, home_cfg_id, enabled, out_of_stock + "SELECT service_id, home_cfg_id, enabled FROM `{$tableName}`" ); if ($svcRes) { @@ -149,13 +150,13 @@ function sync_billing_services(mysqli $db, string $prefix): array $db->query( "INSERT INTO `{$tableName}` (home_cfg_id, mod_cfg_id, service_name, description, - remote_server_id, enabled, out_of_stock, + remote_server_id, enabled, price_daily, price_monthly, price_year, slot_min_qty, slot_max_qty, img_url, ftp, install_method, manual_url, access_rights) VALUES ({$homeCfgId}, 0, '{$svcName}', '{$svcName}', - '', 0, 0, + '', 0, 0.00, 0.00, 0.00, 1, 100, '', '', 'steamcmd', '', '')" @@ -169,7 +170,7 @@ function sync_billing_services(mysqli $db, string $prefix): array $sid = (int)$svcRow['service_id']; $db->query( "UPDATE `{$tableName}` - SET enabled = 0, out_of_stock = 1 + SET enabled = 0 WHERE service_id = {$sid} AND enabled = 1" ); if ($db->affected_rows > 0) { @@ -206,10 +207,9 @@ if (isset($_POST['save_services'])) { foreach ((array)$postedServices as $sid => $svcData) { $sid = (int)$sid; $enabled = isset($svcData['enabled']) ? 1 : 0; - $outOfStock = isset($svcData['out_of_stock']) ? 1 : 0; - $priceDaily = number_format((float)($svcData['price_daily'] ?? 0), 4, '.', ''); - $priceMonthly = number_format((float)($svcData['price_monthly'] ?? 0), 4, '.', ''); - $priceYear = number_format((float)($svcData['price_year'] ?? 0), 4, '.', ''); + $priceDaily = number_format((float)($svcData['price_daily'] ?? 0), 2, '.', ''); + $priceMonthly = number_format((float)($svcData['price_monthly'] ?? 0), 2, '.', ''); + $priceYear = number_format((float)($svcData['price_year'] ?? 0), 2, '.', ''); $slotMin = max(1, (int)($svcData['slot_min_qty'] ?? 1)); $slotMax = max(1, (int)($svcData['slot_max_qty'] ?? 1)); if ($slotMax < $slotMin) { $slotMax = $slotMin; } @@ -229,7 +229,6 @@ if (isset($_POST['save_services'])) { $db->query( "UPDATE `{$table_prefix}billing_services` SET enabled = {$enabled}, - out_of_stock = {$outOfStock}, price_daily = '{$priceDaily}', price_monthly = '{$priceMonthly}', price_year = '{$priceYear}', @@ -260,7 +259,7 @@ while ($rsRes && ($row = $rsRes->fetch_assoc())) { $services = []; $svcRes = $db->query( - "SELECT bs.service_id, bs.service_name, bs.enabled, bs.out_of_stock, + "SELECT bs.service_id, bs.service_name, bs.enabled, bs.price_daily, bs.price_monthly, bs.price_year, bs.slot_min_qty, bs.slot_max_qty, bs.remote_server_id, bs.description, bs.img_url, @@ -301,7 +300,6 @@ while ($svcRes && ($row = $svcRes->fetch_assoc())) { Game Name Config XML Enabled - Out of Stock Min Slots Max Slots Price / Day ($) @@ -316,7 +314,6 @@ while ($svcRes && ($row = $svcRes->fetch_assoc())) { fetch_assoc())) { > - - - > - - fetch_assoc())) { - + value=""> - + value=""> - + value=""> diff --git a/modules/billing/serverlist.php b/modules/billing/serverlist.php index 92095542..4dcf900d 100644 --- a/modules/billing/serverlist.php +++ b/modules/billing/serverlist.php @@ -39,16 +39,25 @@ if (isset($_POST['save']) && !empty($_POST['description'])) { // Fetch services $service_id = isset($_REQUEST['service_id']) ? intval($_REQUEST['service_id']) : 0; -$where_service_id = $service_id !== 0 ? "WHERE enabled = 1 AND service_id = $service_id AND remote_server_id != ''" : "WHERE enabled = 1 AND remote_server_id != ''"; +$where_service_id = $service_id !== 0 + ? "WHERE enabled = 1 AND service_id = $service_id AND remote_server_id != '' AND remote_server_id IS NOT NULL" + : "WHERE enabled = 1 AND remote_server_id != '' AND remote_server_id IS NOT NULL"; $qry_services = "SELECT * FROM {$table_prefix}billing_services $where_service_id ORDER BY service_name"; -$services = $db->query($qry_services); +$result_services = $db->query($qry_services); -if (!$services) { +if (!$result_services) { echo ""; billing_maybe_close_db($db); return; } +// Fetch all service rows into an array so the template foreach works correctly +$serviceRows = []; +while ($row = $result_services->fetch_assoc()) { + $serviceRows[] = $row; +} +$result_services->free(); + // Include top bar and menu include(__DIR__ . '/includes/top.php'); include(__DIR__ . '/includes/menu.php'); @@ -56,7 +65,7 @@ include(__DIR__ . '/includes/menu.php');
- +