query("ALTER TABLE `OGP_DB_PREFIXbilling_orders` ADD `discount_amount` DECIMAL(10,2) NOT NULL DEFAULT 0.00 AFTER `price`")) { return (stripos((string)$db->getError(), 'Duplicate column') !== false); } return true; }, // billing_invoices: add home_id if missing (needed by cron-shop.php join) function($db) { if (!$db->query("ALTER TABLE `OGP_DB_PREFIXbilling_invoices` ADD `home_id` INT(11) NOT NULL DEFAULT 0 AFTER `service_id`")) { return (stripos((string)$db->getError(), 'Duplicate column') !== false); } return true; }, // billing_invoices: add discount_amount if missing function($db) { if (!$db->query("ALTER TABLE `OGP_DB_PREFIXbilling_invoices` ADD `discount_amount` DECIMAL(10,2) NOT NULL DEFAULT 0.00 AFTER `amount`")) { return (stripos((string)$db->getError(), 'Duplicate column') !== false); } return true; }, // billing_invoices: add billing_status (lifecycle: Active/Invoiced/Expired) if missing function($db) { if (!$db->query("ALTER TABLE `OGP_DB_PREFIXbilling_invoices` ADD `billing_status` VARCHAR(16) NOT NULL DEFAULT 'due' AFTER `status`")) { return (stripos((string)$db->getError(), 'Duplicate column') !== false); } return true; }, // billing_invoices: add rate_type enum if missing function($db) { if (!$db->query("ALTER TABLE `OGP_DB_PREFIXbilling_invoices` ADD `rate_type` ENUM('daily','monthly','yearly') NOT NULL DEFAULT 'monthly' AFTER `invoice_duration`")) { return (stripos((string)$db->getError(), 'Duplicate column') !== false); } return true; }, // billing_invoices: add rate_per_player if missing function($db) { if (!$db->query("ALTER TABLE `OGP_DB_PREFIXbilling_invoices` ADD `rate_per_player` DECIMAL(15,4) NOT NULL DEFAULT 0 AFTER `rate_type`")) { return (stripos((string)$db->getError(), 'Duplicate column') !== false); } return true; }, // billing_invoices: add players if missing function($db) { if (!$db->query("ALTER TABLE `OGP_DB_PREFIXbilling_invoices` ADD `players` INT(11) NOT NULL DEFAULT 0 AFTER `rate_per_player`")) { return (stripos((string)$db->getError(), 'Duplicate column') !== false); } return true; }, // billing_invoices: add subtotal if missing function($db) { if (!$db->query("ALTER TABLE `OGP_DB_PREFIXbilling_invoices` ADD `subtotal` DECIMAL(15,2) NOT NULL DEFAULT 0 AFTER `players`")) { return (stripos((string)$db->getError(), 'Duplicate column') !== false); } return true; }, // billing_invoices: add total_due if missing function($db) { if (!$db->query("ALTER TABLE `OGP_DB_PREFIXbilling_invoices` ADD `total_due` DECIMAL(15,2) NOT NULL DEFAULT 0 AFTER `subtotal`")) { return (stripos((string)$db->getError(), 'Duplicate column') !== false); } return true; }, // billing_invoices: add payment_status enum if missing function($db) { if (!$db->query("ALTER TABLE `OGP_DB_PREFIXbilling_invoices` ADD `payment_status` ENUM('unpaid','paid','cancelled','refunded') NOT NULL DEFAULT 'unpaid' AFTER `currency`")) { return (stripos((string)$db->getError(), 'Duplicate column') !== false); } return true; }, // billing_invoices: add coupon_id if missing function($db) { if (!$db->query("ALTER TABLE `OGP_DB_PREFIXbilling_invoices` ADD `coupon_id` INT(11) NOT NULL DEFAULT 0 AFTER `qty`")) { return (stripos((string)$db->getError(), 'Duplicate column') !== false); } return true; }, // Create billing_config table for cron-shop settings if missing "CREATE TABLE IF NOT EXISTS `OGP_DB_PREFIXbilling_config` ( `config_id` INT(11) NOT NULL AUTO_INCREMENT, `game_key` VARCHAR(100) NULL DEFAULT NULL, `enabled` TINYINT(1) NOT NULL DEFAULT 1, `grace_days` INT(11) NOT NULL DEFAULT 0, `delete_after_expired_days` INT(11) NOT NULL DEFAULT 7, `rate_type` ENUM('daily','monthly','yearly') NOT NULL DEFAULT 'monthly', `price_per_player` DECIMAL(10,4) NOT NULL DEFAULT 0.0000, PRIMARY KEY (`config_id`), KEY `game_key` (`game_key`), KEY `enabled` (`enabled`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;", // Create billing_coupons table if missing (older installs using panel.sql may not have it) "CREATE TABLE IF NOT EXISTS `OGP_DB_PREFIXbilling_coupons` ( `coupon_id` INT(11) NOT NULL AUTO_INCREMENT, `code` VARCHAR(50) NOT NULL, `name` VARCHAR(255) NOT NULL DEFAULT '', `description` TEXT NULL, `discount_percent` DECIMAL(5,2) NOT NULL DEFAULT 0.00, `usage_type` ENUM('one_time','permanent') NOT NULL DEFAULT 'one_time', `game_filter_type` ENUM('all_games','specific_games') NOT NULL DEFAULT 'all_games', `game_filter_list` TEXT NULL, `max_uses` INT(11) NULL, `current_uses` INT(11) NOT NULL DEFAULT 0, `expires` DATETIME NULL, `created_date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, `created_by` INT(11) NULL, `is_active` TINYINT(1) NOT NULL DEFAULT 1, PRIMARY KEY (`coupon_id`), UNIQUE KEY `idx_code` (`code`), KEY `idx_active_expires` (`is_active`,`expires`), KEY `idx_created_by` (`created_by`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;" ); ?>