-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: May 09, 2026 at 11:01 AM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.1.25

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `kasir_pos`
--

-- --------------------------------------------------------

--
-- Table structure for table `payment_banks`
--

CREATE TABLE `payment_banks` (
  `id` int(10) UNSIGNED NOT NULL,
  `bank_name` varchar(100) NOT NULL,
  `account_number` varchar(50) NOT NULL,
  `account_name` varchar(150) NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `sort_order` int(11) NOT NULL DEFAULT 0,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `payment_banks`
--

INSERT INTO `payment_banks` (`id`, `bank_name`, `account_number`, `account_name`, `is_active`, `sort_order`, `created_at`) VALUES
(1, 'BCA', '123', 'KYKY KECE', 1, 0, '2026-05-09 08:57:18');

-- --------------------------------------------------------

--
-- Table structure for table `payment_settings`
--

CREATE TABLE `payment_settings` (
  `id` int(10) UNSIGNED NOT NULL,
  `key_name` varchar(100) NOT NULL,
  `value` text DEFAULT NULL,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `payment_settings`
--

INSERT INTO `payment_settings` (`id`, `key_name`, `value`, `updated_at`) VALUES
(1, 'tunai_enabled', '1', '2026-05-09 08:56:46'),
(2, 'qris_enabled', '0', '2026-05-09 08:56:46'),
(3, 'qris_merchant_name', 'GoldenWok Resto', '2026-05-09 08:56:46'),
(4, 'qris_image', '', '2026-05-09 08:56:46');

-- --------------------------------------------------------

--
-- Table structure for table `products`
--

CREATE TABLE `products` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(150) NOT NULL,
  `price` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `category` enum('food','drink') NOT NULL DEFAULT 'food',
  `img` varchar(255) NOT NULL DEFAULT 'uploads/default.jpg',
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `products`
--

INSERT INTO `products` (`id`, `name`, `price`, `category`, `img`, `is_active`, `created_at`, `updated_at`) VALUES
(1, 'Nasi Goreng Spesial', 35000, 'food', 'uploads/default.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:26'),
(2, 'Mie Goreng Seafood', 32000, 'food', 'uploads/default.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:26'),
(3, 'Kwetiau Goreng', 30000, 'food', 'uploads/default.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:26'),
(4, 'Nasi Tim Ayam', 28000, 'food', 'uploads/default.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:26'),
(5, 'Capcay Kuah', 25000, 'food', 'uploads/default.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:26'),
(6, 'Ayam Kung Pao', 38000, 'food', 'uploads/1778313870_99fe0eb6692b33ec.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:30'),
(7, 'Udang Saus Tiram', 45000, 'food', 'uploads/default.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:26'),
(8, 'Cumi Goreng Crispy', 40000, 'food', 'uploads/default.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:26'),
(9, 'Dimsum 4pcs', 22000, 'food', 'uploads/default.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:26'),
(10, 'Wonton Soup', 20000, 'food', 'uploads/default.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:26'),
(11, 'Es Teh Manis', 8000, 'drink', 'uploads/default.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:26'),
(12, 'Es Jeruk', 10000, 'drink', 'uploads/default.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:26'),
(13, 'Jus Alpukat', 18000, 'drink', 'uploads/default.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:26'),
(14, 'Thai Tea', 20000, 'drink', 'uploads/default.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:26'),
(15, 'Kopi Es', 15000, 'drink', 'uploads/default.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:26'),
(16, 'Air Mineral', 5000, 'drink', 'uploads/default.jpg', 1, '2026-05-09 07:40:15', '2026-05-09 08:04:26');

-- --------------------------------------------------------

--
-- Table structure for table `transactions`
--

CREATE TABLE `transactions` (
  `id` int(10) UNSIGNED NOT NULL,
  `invoice` varchar(30) NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `customer_name` varchar(150) NOT NULL DEFAULT 'Umum',
  `customer_phone` varchar(20) DEFAULT NULL,
  `order_type` enum('dinein','takeaway','catering') NOT NULL DEFAULT 'dinein',
  `cart` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`cart`)),
  `subtotal` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `discount` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `voucher_code` varchar(50) DEFAULT NULL,
  `voucher_discount` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `service_charge` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `takeaway_fee` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `total` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `status` enum('paid','void','pending') NOT NULL DEFAULT 'paid',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(100) NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL,
  `role` enum('admin','kasir') NOT NULL DEFAULT 'kasir',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `name`, `username`, `password`, `role`, `created_at`) VALUES
(1, 'Administrator', 'admin', '$2y$10$NFhG9iqq43IUzCfm1AtjPuBCaUxqNhrajaPysMye4nFXNs.CA7nvu', 'admin', '2026-05-09 07:40:15'),
(2, 'Kasir 1', 'kasir1', '$2y$12$JmIqxQ/RvJrAXi/aMBxzuexE.zVEd8R4VU7f0SiNHm7d/6aGQjzEi', 'kasir', '2026-05-09 07:40:15');

-- --------------------------------------------------------

--
-- Table structure for table `vouchers`
--

CREATE TABLE `vouchers` (
  `id` int(10) UNSIGNED NOT NULL,
  `code` varchar(50) NOT NULL,
  `description` varchar(255) NOT NULL DEFAULT '',
  `discount_type` enum('percent','flat') NOT NULL DEFAULT 'flat',
  `discount_value` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `min_order` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `max_discount` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `quota` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `used_count` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `valid_from` date NOT NULL,
  `valid_until` date NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `vouchers`
--

INSERT INTO `vouchers` (`id`, `code`, `description`, `discount_type`, `discount_value`, `min_order`, `max_discount`, `quota`, `used_count`, `valid_from`, `valid_until`, `is_active`, `created_at`) VALUES
(1, 'WELCOME10', 'Diskon 10% untuk pelanggan baru', 'percent', 10, 0, 20000, 100, 0, '2025-01-01', '2026-12-31', 1, '2026-05-09 07:40:15'),
(2, 'HEMAT20K', 'Potongan Rp 20.000 min. order Rp 100.000', 'flat', 20000, 100000, 0, 50, 0, '2025-01-01', '2026-12-31', 1, '2026-05-09 07:40:15'),
(3, 'GOKIL50K', 'Potongan Rp 50.000 min. order Rp 200.000', 'flat', 50000, 200000, 0, 20, 0, '2025-01-01', '2026-12-31', 1, '2026-05-09 07:40:15'),
(4, 'WEEKEND15', 'Diskon 15% setiap weekend', 'percent', 15, 50000, 30000, 0, 0, '2025-01-01', '2026-12-31', 1, '2026-05-09 07:40:15'),
(5, 'FREESHIP', 'Gratis catering fee Rp 25.000', 'flat', 25000, 0, 0, 0, 0, '2025-01-01', '2026-12-31', 1, '2026-05-09 07:40:15'),
(6, 'VIP30', 'Diskon 30% untuk member VIP', 'percent', 30, 150000, 75000, 10, 0, '2025-01-01', '2026-12-31', 1, '2026-05-09 07:40:15');

-- --------------------------------------------------------

--
-- Stand-in structure for view `v_laporan_harian`
-- (See below for the actual view)
--
CREATE TABLE `v_laporan_harian` (
`tanggal` date
,`total_transaksi` bigint(21)
,`total_subtotal` decimal(32,0)
,`total_diskon` decimal(33,0)
,`total_service` decimal(32,0)
,`total_fee` decimal(32,0)
,`total_omzet` decimal(32,0)
);

-- --------------------------------------------------------

--
-- Structure for view `v_laporan_harian`
--
DROP TABLE IF EXISTS `v_laporan_harian`;

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_laporan_harian`  AS SELECT cast(`transactions`.`created_at` as date) AS `tanggal`, count(0) AS `total_transaksi`, sum(`transactions`.`subtotal`) AS `total_subtotal`, sum(`transactions`.`discount` + `transactions`.`voucher_discount`) AS `total_diskon`, sum(`transactions`.`service_charge`) AS `total_service`, sum(`transactions`.`takeaway_fee`) AS `total_fee`, sum(`transactions`.`total`) AS `total_omzet` FROM `transactions` WHERE `transactions`.`status` = 'paid' GROUP BY cast(`transactions`.`created_at` as date) ORDER BY cast(`transactions`.`created_at` as date) DESC ;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `payment_banks`
--
ALTER TABLE `payment_banks`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `payment_settings`
--
ALTER TABLE `payment_settings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `key_name` (`key_name`);

--
-- Indexes for table `products`
--
ALTER TABLE `products`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `transactions`
--
ALTER TABLE `transactions`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `invoice` (`invoice`),
  ADD KEY `idx_invoice` (`invoice`),
  ADD KEY `idx_created_at` (`created_at`),
  ADD KEY `idx_user` (`user_id`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`);

--
-- Indexes for table `vouchers`
--
ALTER TABLE `vouchers`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`),
  ADD KEY `idx_code` (`code`),
  ADD KEY `idx_valid` (`valid_from`,`valid_until`,`is_active`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `payment_banks`
--
ALTER TABLE `payment_banks`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `payment_settings`
--
ALTER TABLE `payment_settings`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;

--
-- AUTO_INCREMENT for table `transactions`
--
ALTER TABLE `transactions`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `vouchers`
--
ALTER TABLE `vouchers`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
