

-- Bahan baku (nama + stok, tanpa harga)
CREATE TABLE IF NOT EXISTS bahan_baku (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(100) NOT NULL,
  category VARCHAR(100) DEFAULT '',
  stock INT NOT NULL DEFAULT 0,
  is_active TINYINT NOT NULL DEFAULT 1,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Order dari outlet
CREATE TABLE IF NOT EXISTS outlet_orders (
  id INT AUTO_INCREMENT PRIMARY KEY,
  order_number INT NOT NULL DEFAULT 1,
  outlet_id INT NOT NULL DEFAULT 1,
  outlet_name VARCHAR(100) DEFAULT '',
  kasir_name VARCHAR(100) DEFAULT '',
  status ENUM('pending','diproses','selesai','dibatalkan') NOT NULL DEFAULT 'pending',
  total_item INT NOT NULL DEFAULT 0,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Item dari tiap order outlet
CREATE TABLE IF NOT EXISTS outlet_order_items (
  id INT AUTO_INCREMENT PRIMARY KEY,
  order_id INT NOT NULL,
  bahan_baku_id INT DEFAULT NULL,
  item_name VARCHAR(100) DEFAULT '',
  quantity INT NOT NULL DEFAULT 1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Contoh bahan baku
INSERT INTO bahan_baku (name, category, stock) VALUES
('Beras', 'Bahan Pokok', 120),
('Ayam', 'Protein', 60),
('Minyak Goreng', 'Bahan Pokok', 35),
('Bawang Merah', 'Bumbu', 45),
('Bawang Putih', 'Bumbu', 40),
('Gula Pasir', 'Bahan Pokok', 30),
('Tepung Terigu', 'Bahan Pokok', 50),
('Telur', 'Protein', 80),
('Kecap Manis', 'Saus', 25),
('Cabai', 'Bumbu', 30);
