-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `warung_ajib`
--

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

--
-- Table structure for table `orders`
--

CREATE TABLE `orders` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `order_number` varchar(50) NOT NULL,
  `total_price` decimal(10,2) NOT NULL,
  `shipping_cost` decimal(10,2) DEFAULT 0.00,
  `grand_total` decimal(10,2) NOT NULL,
  `shipping_address` text NOT NULL,
  `shipping_method` varchar(100) DEFAULT NULL,
  `payment_proof` varchar(255) DEFAULT NULL,
  `status` enum('pending','paid','processing','shipped','delivered','cancelled') DEFAULT 'pending',
  `notes` text DEFAULT NULL,
  `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 `orders`
--

INSERT INTO `orders` (`id`, `user_id`, `order_number`, `total_price`, `shipping_cost`, `grand_total`, `shipping_address`, `shipping_method`, `payment_proof`, `status`, `notes`, `created_at`, `updated_at`) VALUES
(1, 2, 'ORD20260112210810124', 5000.00, 10000.00, 15000.00, 'hajaa\nKota: Semarang\nKode Pos: 64646', 'Regular', NULL, 'delivered', NULL, '2026-01-12 20:08:10', '2026-01-12 20:09:57'),
(2, 2, 'ORD20260112233004314', 30000.00, 10000.00, 40000.00, 'jalan\nKota: Semarang\nKode Pos: 45466', 'Regular', NULL, 'delivered', NULL, '2026-01-12 22:30:04', '2026-01-12 22:37:11'),
(3, 3, 'ORD20260113012251660', 20000.00, 10000.00, 30000.00, 'haja\nKota: Semarang\nKode Pos: 46616', 'Regular', NULL, 'delivered', NULL, '2026-01-13 00:22:51', '2026-01-13 00:27:45'),
(4, 3, 'ORD20260113013837590', 20000.00, 10000.00, 30000.00, 'kito\nKota: Semarang\nKode Pos: 94646', 'Regular', NULL, 'delivered', NULL, '2026-01-13 00:38:37', '2026-01-13 00:39:48');

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

--
-- Table structure for table `order_details`
--

CREATE TABLE `order_details` (
  `id` int(11) NOT NULL,
  `order_id` int(11) NOT NULL,
  `product_id` int(11) NOT NULL,
  `product_name` varchar(255) NOT NULL,
  `product_price` decimal(10,2) NOT NULL,
  `quantity` int(11) NOT NULL,
  `subtotal` decimal(10,2) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `order_details`
--

INSERT INTO `order_details` (`id`, `order_id`, `product_id`, `product_name`, `product_price`, `quantity`, `subtotal`, `created_at`) VALUES
(1, 1, 1, 'Es Teh Ajib', 5000.00, 1, 5000.00, '2026-01-12 20:08:10'),
(2, 2, 2, 'Lumpia Semarang', 15000.00, 2, 30000.00, '2026-01-12 22:30:04'),
(3, 3, 15, 'Mie Goreng', 20000.00, 1, 20000.00, '2026-01-13 00:22:51'),
(4, 4, 15, 'Mie Goreng', 20000.00, 1, 20000.00, '2026-01-13 00:38:37');

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

--
-- Table structure for table `payments`
--

CREATE TABLE `payments` (
  `id` int(11) NOT NULL,
  `order_id` int(11) NOT NULL,
  `payment_proof` varchar(255) DEFAULT NULL,
  `payment_method` varchar(100) DEFAULT NULL,
  `payment_date` timestamp NOT NULL DEFAULT current_timestamp(),
  `verified_by` int(11) DEFAULT NULL,
  `verified_at` timestamp NULL DEFAULT NULL,
  `status` enum('pending','verified','rejected') DEFAULT 'pending',
  `notes` text DEFAULT NULL,
  `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 `payments`
--

INSERT INTO `payments` (`id`, `order_id`, `payment_proof`, `payment_method`, `payment_date`, `verified_by`, `verified_at`, `status`, `notes`, `created_at`, `updated_at`) VALUES
(1, 1, 'payment_1_1768248496.jpg', 'transfer', '2026-01-12 20:08:16', NULL, NULL, 'verified', NULL, '2026-01-12 20:08:16', '2026-01-12 20:09:16'),
(2, 2, 'payment_2_1768257013.jpg', 'transfer', '2026-01-12 22:30:13', NULL, NULL, 'verified', NULL, '2026-01-12 22:30:13', '2026-01-12 22:36:32'),
(3, 3, 'payment_3_1768263786.jpg', 'qris', '2026-01-13 00:23:06', NULL, NULL, 'verified', NULL, '2026-01-13 00:23:06', '2026-01-13 00:23:46'),
(4, 4, 'payment_4_1768264725.jpg', 'transfer', '2026-01-13 00:38:45', NULL, NULL, 'verified', NULL, '2026-01-13 00:38:45', '2026-01-13 00:39:22');

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

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

CREATE TABLE `products` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `description` text DEFAULT NULL,
  `price` decimal(10,2) NOT NULL,
  `stock` int(11) DEFAULT 0,
  `image` varchar(255) DEFAULT NULL,
  `category` varchar(100) DEFAULT NULL,
  `total_sold` int(11) DEFAULT 0,
  `is_active` tinyint(1) 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`, `description`, `price`, `stock`, `image`, `category`, `total_sold`, `is_active`, `created_at`, `updated_at`) VALUES
(1, 'Es Teh Jumbo', 'Es teh segar dengan rasa yang nikmat, cocok untuk menemani hari Anda', 5000.00, 99, 'uploads/products/696589fb06292_1.jpg', 'MINUMAN', 1, 1, '2026-01-12 20:06:12', '2026-01-12 23:55:39'),
(2, 'Lumpia Semarang', 'Lumpia Semarang isi rebung dan ayam yang gurih', 15000.00, 48, 'uploads/products/696587f08470a_2.jpg', 'JAJANAN', 2, 1, '2026-01-12 20:06:12', '2026-01-12 23:46:56'),
(3, 'Sate Padang', 'Sate padang', 10000.00, 75, 'uploads/products/69658964a1792_3.jpg', 'MAM KENYANG', 0, 1, '2026-01-12 20:06:12', '2026-01-12 23:53:08'),
(4, 'Es Jeruk', 'Normalnya Es jeruk', 12000.00, 80, 'uploads/products/696589b16510a_4.jpg', 'MINUMAN', 0, 1, '2026-01-12 20:06:12', '2026-01-12 23:54:25'),
(5, 'Es Matcha', 'Es matcha teh jepang', 18000.00, 40, 'uploads/products/696589e556113_5.jpg', 'MINUMAN', 0, 1, '2026-01-12 20:06:12', '2026-01-12 23:55:52'),
(6, 'Jus Mangga', 'Jus alpukat segar tanpa tambahan gula', 15000.00, 60, 'uploads/products/6965897987d32_6.jpg', 'MINUMAN', 0, 1, '2026-01-12 20:06:12', '2026-01-12 23:53:29'),
(7, 'Bakwan', 'Bakwan adalah makanan gorengan khas Indonesia yang terbuat dari adonan tepung terigu yang dicampur dengan sayuran', 2000.00, 100, 'uploads/products/696587905e41f_Bakwan.jpg', 'JAJANAN', 0, 1, '2026-01-12 23:45:20', '2026-01-12 23:45:20'),
(8, 'KuePukis', 'Kue pukis adalah jajanan tradisional Indonesia yang terbuat dari adonan tepung terigu, telur, gula, santan, dan ragi, lalu dipanggang menggunakan cetakan setengah lingkaran hingga mengembang dan lembut.', 5000.00, 100, 'uploads/products/696587e00ec83_KuePukis.jpg', 'JAJANAN', 0, 1, '2026-01-12 23:46:40', '2026-01-12 23:46:40'),
(9, 'Martabak Bandung', 'Martabak Bandung adalah jajanan manis khas Indonesia yang terbuat dari adonan tepung terigu dengan ragi, dipanggang hingga berongga, lalu diberi topping manis melimpah dan dilipat.', 20000.00, 100, 'uploads/products/6965883632c68_Martabak Bandung.jpg', 'JAJANAN', 0, 1, '2026-01-12 23:48:06', '2026-01-12 23:48:06'),
(10, 'Pempek Palembang', 'Pempek Palembang adalah makanan khas Palembang, Sumatera Selatan, yang terbuat dari daging ikan (umumnya ikan tenggiri) dan tepung sagu, lalu disajikan dengan kuah cuko yang khas.', 20000.00, 100, 'uploads/products/6965886ebe83f_Pempek Palembang.jpg', 'JAJANAN', 0, 1, '2026-01-12 23:49:02', '2026-01-12 23:49:02'),
(11, 'Ayam Goreng', 'Ayam goreng adalah hidangan olahan ayam yang dibumbui dengan rempah-rempah, kemudian digoreng dalam minyak panas hingga bagian luar renyah dan bagian dalam matang serta gurih.', 13000.00, 100, 'uploads/products/696588be4999f_Ayam Goreng.jpg', 'MAM KENYANG', 0, 1, '2026-01-12 23:50:22', '2026-01-12 23:50:22'),
(12, 'Mie Ayam Bakso', 'Mie ayam bakso adalah hidangan khas Indonesia berupa mie telur yang disajikan dengan potongan ayam berbumbu kecap, bakso, serta kuah kaldu gurih.', 15000.00, 100, 'uploads/products/6965890df1311_Mie Ayam Bakso.jpg', 'MAM KENYANG', 0, 1, '2026-01-12 23:51:41', '2026-01-12 23:51:41'),
(13, 'Mie Ceker', 'Mie ceker adalah hidangan mie khas Indonesia yang disajikan dengan ceker ayam (kaki ayam) yang dimasak hingga empuk, dipadukan dengan mie dan kuah kaldu gurih.', 15000.00, 100, 'uploads/products/6965893c8c642_Mie Ceker.jpg', 'MAM KENYANG', 0, 1, '2026-01-12 23:52:28', '2026-01-12 23:52:28'),
(14, 'Nasi Uduk', 'Nasi Uduk Asli Malaysia', 20000.00, 100, 'uploads/products/69658a41841fd_Nasi Uduk.jpg', 'MAM KENYANG', 0, 1, '2026-01-12 23:56:49', '2026-01-12 23:56:49'),
(15, 'Mie Goreng', 'Indomie seleraku', 20000.00, 98, 'uploads/products/69658a9d69872_Mie Goreng.jpg', 'MAM KENYANG', 2, 1, '2026-01-12 23:58:21', '2026-01-13 00:38:37');

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

--
-- Table structure for table `settings`
--

CREATE TABLE `settings` (
  `id` int(11) NOT NULL,
  `setting_key` varchar(100) NOT NULL,
  `setting_value` text DEFAULT NULL,
  `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 `settings`
--

INSERT INTO `settings` (`id`, `setting_key`, `setting_value`, `created_at`, `updated_at`) VALUES
(1, 'call_center', '082137783251', '2026-01-12 20:06:12', '2026-01-12 20:15:37'),
(2, 'sms_center', '082137783251', '2026-01-12 20:06:12', '2026-01-12 20:15:49'),
(3, 'whatsapp', '082137783251', '2026-01-12 20:06:12', '2026-01-12 20:15:54'),
(4, 'email', '111202214754@mhs.dinus.ac.id', '2026-01-12 20:06:12', '2026-01-12 20:16:06'),
(5, 'address', 'Bandungrejo, Mranggen, Demak, Jawa Tengah', '2026-01-12 20:06:12', '2026-01-12 20:06:12'),
(6, 'maps_latitude', '-6.983919', '2026-01-12 20:06:12', '2026-01-12 20:44:41'),
(7, 'maps_longitude', '110.409374', '2026-01-12 20:06:12', '2026-01-12 20:44:49'),
(8, 'shipping_cost_per_km', '2000', '2026-01-12 20:06:12', '2026-01-12 20:06:12'),
(9, 'app_name', 'Warung Ajib', '2026-01-12 20:06:12', '2026-01-12 20:06:12'),
(10, 'app_tagline', 'Belanja Mudah, Hasil Nikmat', '2026-01-12 20:06:12', '2026-01-12 20:06:12');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `order_number` (`order_number`),
  ADD KEY `user_id` (`user_id`);

--
-- Indexes for table `order_details`
--
ALTER TABLE `order_details`
  ADD PRIMARY KEY (`id`),
  ADD KEY `order_id` (`order_id`),
  ADD KEY `product_id` (`product_id`);

--
-- Indexes for table `payments`
--
ALTER TABLE `payments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `order_id` (`order_id`),
  ADD KEY `verified_by` (`verified_by`);

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

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

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `orders`
--
ALTER TABLE `orders`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `order_details`
--
ALTER TABLE `order_details`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `payments`
--
ALTER TABLE `payments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;

--
-- AUTO_INCREMENT for table `settings`
--
ALTER TABLE `settings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `orders`
--
ALTER TABLE `orders`
  ADD CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `order_details`
--
ALTER TABLE `order_details`
  ADD CONSTRAINT `order_details_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `order_details_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `payments`
--
ALTER TABLE `payments`
  ADD CONSTRAINT `payments_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `payments_ibfk_2` FOREIGN KEY (`verified_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;
COMMIT;

