CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id VARCHAR(20) UNIQUE,
username VARCHAR(50),
password VARCHAR(255),
foto VARCHAR(200) DEFAULT 'default.png',
bank VARCHAR(50),
rekening VARCHAR(50),
nama_rekening VARCHAR(100),
metode VARCHAR(50),
saldo DECIMAL(12,2) DEFAULT 0,
saldo_beku DECIMAL(12,2) DEFAULT 0
);

-- Tabel untuk history login/register
CREATE TABLE history (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50),
action VARCHAR(50), -- register / login
date_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE ranking (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50),
foto VARCHAR(200),
pendapatan INT
);

CREATE TABLE transaksi (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50),
jenis VARCHAR(20),
jumlah DECIMAL(12,2),
status VARCHAR(20),
date_time DATETIME
);

CREATE TABLE agent_balance (
id INT AUTO_INCREMENT PRIMARY KEY,
balance DECIMAL(12,2) NOT NULL
);

INSERT INTO agent_balance (balance) VALUES (10000000);

CREATE TABLE admin (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50),
password VARCHAR(255),
nama_lengkap VARCHAR(100)
);

INSERT INTO admin (username,password,nama_lengkap)
VALUES
('admin',MD5('admin123'),'Administrator Website');

CREATE TABLE IF NOT EXISTS setting (
id INT(11) PRIMARY KEY AUTO_INCREMENT,
tema VARCHAR(20) NOT NULL
);

INSERT INTO setting (id,tema) VALUES (1,'pink')
ON DUPLICATE KEY UPDATE tema='pink';


CREATE TABLE deposit (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(50),
jumlah DECIMAL(12,2),
rekening_admin VARCHAR(100),
metode VARCHAR(50),
status ENUM('pending','paid','cancel') DEFAULT 'pending',
tanggal TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);