diff --git a/admin/database_updates.php b/admin/database_updates.php
index c2b8b2df..567b88ee 100644
--- a/admin/database_updates.php
+++ b/admin/database_updates.php
@@ -3809,6 +3809,18 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.2.6'");
}
+ if (CURRENT_DATABASE_VERSION == '2.2.6') {
+ mysqli_query($mysqli, "ALTER TABLE `credits` DROP `credit_reference`");
+ mysqli_query($mysqli, "ALTER TABLE `credits` ADD `credit_type` ENUM('prepaid', 'manual', 'refund', 'promotion', 'usage') NOT NULL DEFAULT 'manual' AFTER `credit_amount`");
+ mysqli_query($mysqli, "ALTER TABLE `credits` ADD `credit_note` TEXT NULL DEFAULT NULL AFTER `credit_type`");
+ mysqli_query($mysqli, "ALTER TABLE `credits` ADD `credit_invoice_id` INT(11) NULL DEFAULT NULL AFTER `credit_expire_at`");
+ mysqli_query($mysqli, "ALTER TABLE `credits` ADD INDEX (`credit_client_id`)");
+ mysqli_query($mysqli, "ALTER TABLE `credits` ADD INDEX (`credit_invoice_id`)");
+ mysqli_query($mysqli, "ALTER TABLE `credits` ADD INDEX (`credit_created_at`)");
+
+ mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.2.7'");
+ }
+
/* 2025-07-21 - JQ For next release Pauyment Provider Switch Over
if (CURRENT_DATABASE_VERSION == '2.2.4') {
diff --git a/db.sql b/db.sql
index cfa86574..d7bbee53 100644
--- a/db.sql
+++ b/db.sql
@@ -849,12 +849,17 @@ DROP TABLE IF EXISTS `credits`;
CREATE TABLE `credits` (
`credit_id` int(11) NOT NULL AUTO_INCREMENT,
`credit_amount` decimal(15,2) NOT NULL,
- `credit_reference` varchar(250) DEFAULT NULL,
+ `credit_type` enum('prepaid','manual','refund','promotion','usage') NOT NULL DEFAULT 'manual',
+ `credit_note` text DEFAULT NULL,
`credit_created_at` datetime NOT NULL DEFAULT current_timestamp(),
`credit_created_by` int(11) NOT NULL,
`credit_expire_at` date DEFAULT NULL,
+ `credit_invoice_id` int(11) DEFAULT NULL,
`credit_client_id` int(11) NOT NULL,
- PRIMARY KEY (`credit_id`)
+ PRIMARY KEY (`credit_id`),
+ KEY `credit_client_id` (`credit_client_id`),
+ KEY `credit_invoice_id` (`credit_invoice_id`),
+ KEY `credit_created_at` (`credit_created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -2761,4 +2766,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
--- Dump completed on 2025-07-31 15:53:18
+-- Dump completed on 2025-08-01 13:36:16
diff --git a/functions.php b/functions.php
index 4ed87da4..c33cdd38 100644
--- a/functions.php
+++ b/functions.php
@@ -1670,4 +1670,21 @@ function sanitize_url($url) {
// Safe schemes: return escaped original URL
return htmlspecialchars($url ?? '', ENT_QUOTES, 'UTF-8');
+}
+
+function redirect($url = null, $permanent = false) {
+ // Use referer if no URL is provided
+ if (!$url) {
+ $url = $_SERVER['HTTP_REFERER'] ?? 'index.php';
+ }
+
+ if (!headers_sent()) {
+ header('Location: ' . $url, true, $permanent ? 301 : 302);
+ exit;
+ } else {
+ // Fallback for headers already sent
+ echo "";
+ echo '';
+ exit;
+ }
}
\ No newline at end of file
diff --git a/includes/database_version.php b/includes/database_version.php
index 78866f8a..b960dc1f 100644
--- a/includes/database_version.php
+++ b/includes/database_version.php
@@ -5,4 +5,4 @@
* It is used in conjunction with database_updates.php
*/
-DEFINE("LATEST_DATABASE_VERSION", "2.2.6");
+DEFINE("LATEST_DATABASE_VERSION", "2.2.7");
diff --git a/setup/index.php b/setup/index.php
index 8e1de673..1ba35516 100644
--- a/setup/index.php
+++ b/setup/index.php
@@ -626,7 +626,7 @@ if (isset($_POST['add_telemetry'])) {