diff --git a/database/migrations/004_gamification_whatsapp.sql b/database/migrations/004_gamification_whatsapp.sql index eadd298..c9a6e42 100644 --- a/database/migrations/004_gamification_whatsapp.sql +++ b/database/migrations/004_gamification_whatsapp.sql @@ -1,5 +1,4 @@ -- Gamification Tables for Musadaq --- Run this migration on your production database -- Points tracking CREATE TABLE IF NOT EXISTS user_points ( @@ -26,6 +25,7 @@ CREATE TABLE IF NOT EXISTS user_badges ( INDEX idx_user_badges_tenant (tenant_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; --- WhatsApp link code column (add to users table) -ALTER TABLE users ADD COLUMN IF NOT EXISTS whatsapp_link_code VARCHAR(10) DEFAULT NULL; -ALTER TABLE users ADD COLUMN IF NOT EXISTS whatsapp_linked TINYINT(1) DEFAULT 0; +-- WhatsApp columns on users table +-- Run these one at a time. If column already exists, it will error — just skip it. +ALTER TABLE users ADD COLUMN whatsapp_link_code VARCHAR(10) DEFAULT NULL; +ALTER TABLE users ADD COLUMN whatsapp_linked TINYINT(1) DEFAULT 0; diff --git a/database/migrations/006_sms_bank.sql b/database/migrations/006_sms_bank.sql index 54c8fd6..20150fc 100644 --- a/database/migrations/006_sms_bank.sql +++ b/database/migrations/006_sms_bank.sql @@ -1,5 +1,4 @@ -- SMS Bank Integration Tables --- Run this migration on your production database CREATE TABLE IF NOT EXISTS raw_sms_log ( id VARCHAR(36) PRIMARY KEY, @@ -16,6 +15,7 @@ CREATE TABLE IF NOT EXISTS raw_sms_log ( INDEX idx_sms_date (received_at) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; --- Add sms_log_id to payment_requests if not exists -ALTER TABLE payment_requests ADD COLUMN IF NOT EXISTS sms_log_id VARCHAR(36) DEFAULT NULL; -ALTER TABLE payment_requests ADD COLUMN IF NOT EXISTS confirmed_at DATETIME DEFAULT NULL; +-- Add columns to payment_requests +-- Run these one at a time. If column already exists, just skip the error. +ALTER TABLE payment_requests ADD COLUMN sms_log_id VARCHAR(36) DEFAULT NULL; +ALTER TABLE payment_requests ADD COLUMN confirmed_at DATETIME DEFAULT NULL; diff --git a/public/shell.php b/public/shell.php index e4705f7..d13cecc 100644 --- a/public/shell.php +++ b/public/shell.php @@ -2313,8 +2313,14 @@ } : { total: 0, pending: 0, approved: 0 }; this.companies = await this.apiRequest('v1/companies') || []; this.subscription = await this.apiRequest('v1/subscriptions/current'); - if (this.page === 'users') this.users = await this.apiRequest('v1/users') || []; - if (this.page === 'invoices') this.invoices = await this.apiRequest('v1/invoices') || []; + if (this.page === 'users') { + const usersRes = await this.apiRequest('v1/users'); + this.users = usersRes?.items || usersRes || []; + } + if (this.page === 'invoices') { + const invRes = await this.apiRequest('v1/invoices'); + this.invoices = invRes?.items || invRes || []; + } if (this.page === 'subscription') this.plans = await this.apiRequest('v1/subscriptions/plans') || []; if (this.user.role === 'super_admin') this.tenants = await this.apiRequest('v1/tenants') || []; },