-- =========================================================================
-- MIGRATION: Widget Susun Atur untuk Dashboard Syarikat (subsidiary-dashboard.php)
-- Berasingan daripada dashboard_widgets (Dashboard utama Investment Performance).
-- Jalankan di phpMyAdmin > tab SQL, pada database SPMS sedia ada anda.
-- =========================================================================

CREATE TABLE IF NOT EXISTS subsidiary_dashboard_widgets (
    widget_id         VARCHAR(50) PRIMARY KEY,
    label             VARCHAR(100) NOT NULL,
    display_order     SMALLINT NOT NULL,
    col_span          TINYINT NOT NULL DEFAULT 2,
    updated_at        DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO subsidiary_dashboard_widgets (widget_id, label, display_order, col_span) VALUES
('kpi_revenue', 'KPI: Revenue', 1, 1),
('kpi_pat', 'KPI: PAT', 2, 1),
('kpi_staff', 'KPI: Active Staff', 3, 1),
('kpi_achievement', 'KPI: Achievement', 4, 1),
('chart_trend', 'Carta: Trend Revenue & PAT', 5, 2),
('chart_income', 'Carta: Income Statement', 6, 2),
('chart_balance', 'Carta: Balance Sheet', 7, 4)
ON DUPLICATE KEY UPDATE label = VALUES(label);
