-- =========================================================================
-- MIGRATION: Tambah jadual konfigurasi susun atur Dashboard
-- Jalankan di phpMyAdmin > tab SQL, pada database SPMS sedia ada anda.
-- =========================================================================

CREATE TABLE IF NOT EXISTS 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 dashboard_widgets (widget_id, label, display_order, col_span) VALUES
('kpi_revenue', 'KPI: Group Revenue', 1, 1),
('kpi_pat', 'KPI: Group PAT', 2, 1),
('kpi_subsidiaries', 'KPI: Subsidiaries Reporting', 3, 1),
('kpi_achievement', 'KPI: Avg Achievement', 4, 1),
('chart_revenue', 'Carta: Revenue Actual vs Budget', 5, 2),
('chart_pat', 'Carta: PAT Actual vs Budget', 6, 2),
('chart_share', 'Carta: Sumbangan Revenue', 7, 2),
('chart_trend', 'Carta: Trend 3 Tahun', 8, 2),
('table_comparison', 'Jadual Perbandingan', 9, 4);
