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

START TRANSACTION;



--
-- Database: `jurnalpc_cms`
--

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

--
-- Table structure for table `activity_logs`
--

CREATE TABLE `activity_logs` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `activity` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `activity_logs`
--

INSERT INTO `activity_logs` (`id`, `user_id`, `activity`, `created_at`) VALUES
(22, 1, 'Buka Kas. Modal Awal: 3,460,000', '2026-03-02 21:08:19'),
(23, 1, 'Membuat Transaksi Baru: TRX-20260303040914 Total: 240000', '2026-03-02 21:09:14'),
(28, 1, 'Membuat Transaksi Baru: TRX-20260303041857 Total: 295000', '2026-03-02 21:18:57'),
(33, 1, 'Membuat Transaksi Baru: TRX-20260303043054 Total: 240000', '2026-03-02 21:30:54'),
(36, 1, 'Membuat Transaksi Baru: TRX-20260303043754 Total: 130000', '2026-03-02 21:37:54'),
(49, 1, 'Membuat Transaksi Baru: TRX-20260303092831 Total: 200000', '2026-03-03 02:28:31'),
(50, 1, 'Membuat Transaksi Baru: TRX-20260303093256 Total: 1400000', '2026-03-03 02:32:56'),
(71, 1, 'Membuat Transaksi Baru: TRX-20260303141630 Total: 1380000', '2026-03-03 07:16:30');

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

--
-- Table structure for table `cash_closings`
--

CREATE TABLE `cash_closings` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `opening_amount` int(11) DEFAULT 0,
  `closing_date` datetime DEFAULT NULL,
  `total_transaction` int(11) DEFAULT NULL,
  `total_income` int(11) DEFAULT NULL,
  `actual_cash` int(11) DEFAULT NULL,
  `difference` int(11) DEFAULT NULL,
  `status` enum('open','closed') DEFAULT 'closed',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `cash_closings`
--

INSERT INTO `cash_closings` (`id`, `user_id`, `opening_amount`, `closing_date`, `total_transaction`, `total_income`, `actual_cash`, `difference`, `status`, `created_at`) VALUES
(16, 1, 1000000, '2026-03-02 23:22:04', 1, 2460000, 3460000, 0, 'closed', '2026-03-02 16:00:13'),
(17, 1, 3460000, NULL, NULL, NULL, NULL, NULL, 'open', '2026-03-02 21:08:19');

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

--
-- Table structure for table `categories`
--

CREATE TABLE `categories` (
  `id` int(11) NOT NULL,
  `name` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `categories`
--

INSERT INTO `categories` (`id`, `name`) VALUES
(6, 'Kabel'),
(7, 'Patchcord'),
(8, 'Conduit'),
(9, 'Acc'),
(10, 'Device'),
(11, 'Electric');

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

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

CREATE TABLE `products` (
  `id` int(11) NOT NULL,
  `category_id` int(11) DEFAULT NULL,
  `barcode` varchar(50) DEFAULT NULL,
  `name` varchar(150) DEFAULT NULL,
  `image` varchar(100) DEFAULT NULL,
  `price` int(11) DEFAULT NULL,
  `min_stock` int(11) DEFAULT 5,
  `status` tinyint(4) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `products` (`id`, `category_id`, `barcode`, `name`, `image`, `price`, `min_stock`, `status`, `created_at`) VALUES
(20, 6, NULL, 'Commscope Cat 6', '', NULL, 5, 1, '2026-03-02 15:57:38'),
(21, 7, NULL, 'Panduit Patchcord Cat 6 10Feet', '', NULL, 5, 1, '2026-03-02 15:59:08'),
(22, 7, NULL, 'Panduit Patchcord Cat 5e 10Feet', 'IMG-1772521888.jpg', NULL, 5, 1, '2026-03-02 16:02:29'),
(23, 8, NULL, 'Boss Flexible Conduit', 'IMG-1772521558.jpeg', NULL, 5, 1, '2026-03-02 16:11:28'),
(24, 9, NULL, 'Fischer s6', 'IMG-1772521384.jpg', NULL, 5, 1, '2026-03-02 21:13:20'),
(25, 9, NULL, 'Cage Nut', 'IMG-1772521233.jpg', NULL, 5, 1, '2026-03-02 21:14:35'),
(26, 10, NULL, 'Flextreme Media Converter', 'IMG-1772506030.jpeg', NULL, 5, 1, '2026-03-02 21:16:26'),
(27, 10, NULL, 'Power Adaptor', 'IMG-1772505750.jpg', NULL, 5, 1, '2026-03-02 21:17:32'),
(28, 11, NULL, 'Schneider MCB 16A', 'IMG-1772505402.jpg', NULL, 5, 1, '2026-03-02 21:35:36'),
(29, 11, NULL, 'Uticon 5 Hole', 'IMG-1772504520.jpg', NULL, 5, 1, '2026-03-02 21:36:52'),
(30, 6, NULL, 'Supreme nym 3x2.5', 'IMG-1772503104.jpg', NULL, 5, 1, '2026-03-03 01:26:19'),
(31, 9, NULL, 'Hager Box MCB', 'IMG-1772504801.jpeg', NULL, 5, 1, '2026-03-03 02:26:41');

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

--
-- Table structure for table `product_units`
--

CREATE TABLE `product_units` (
  `id` int(11) NOT NULL,
  `product_id` int(11) DEFAULT NULL,
  `unit_id` int(11) DEFAULT NULL,
  `stock` int(11) DEFAULT 0,
  `conversion_value` int(11) DEFAULT NULL,
  `operator` enum('*','/') NOT NULL DEFAULT '*',
  `unit_price` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `product_units`
--

INSERT INTO `product_units` (`id`, `product_id`, `unit_id`, `stock`, `conversion_value`, `operator`, `unit_price`) VALUES
(50, 20, 10, 99, 1, '*', 2100000),
(51, 21, 11, 994, 1, '*', 60000),
(52, 22, 11, 994, 1, '*', 40000),
(53, 23, 10, 498, 1, '*', 120000),
(54, 24, 12, 1993, 1, '*', 5000),
(55, 25, 11, 9980, 1, '*', 2000),
(56, 26, 13, 199, 1, '*', 150000),
(57, 27, 13, 199, 1, '*', 100000),
(58, 28, 11, 98, 1, '*', 80000),
(59, 29, 11, 196, 1, '*', 25000),
(60, 30, 10, 98, 1, '*', 1350000),
(61, 31, 11, 98, 1, '*', 60000);

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

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

CREATE TABLE `transactions` (
  `id` int(11) NOT NULL,
  `invoice` varchar(50) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `total_before_discount` int(11) DEFAULT NULL,
  `discount_type` enum('percent','nominal') DEFAULT NULL,
  `discount_value` int(11) DEFAULT NULL,
  `total_after_discount` int(11) DEFAULT NULL,
  `payment_amount` int(11) DEFAULT NULL,
  `change_amount` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `transactions`
--

INSERT INTO `transactions` (`id`, `invoice`, `user_id`, `total_before_discount`, `discount_type`, `discount_value`, `total_after_discount`, `payment_amount`, `change_amount`, `created_at`) VALUES
(19, 'TRX-20260302230642', 1, 2460000, NULL, NULL, 2460000, 2500000, 40000, '2026-03-02 16:06:42'),
(20, 'TRX-20260303040914', 1, 240000, NULL, NULL, 240000, 250000, 10000, '2026-03-02 21:09:14'),
(21, 'TRX-20260303041857', 1, 295000, NULL, NULL, 295000, 300000, 5000, '2026-03-02 21:18:57'),
(22, 'TRX-20260303043054', 1, 240000, NULL, NULL, 240000, 250000, 10000, '2026-03-02 21:30:54'),
(23, 'TRX-20260303043754', 1, 130000, NULL, NULL, 130000, 150000, 20000, '2026-03-02 21:37:54'),
(24, 'TRX-20260303092831', 1, 200000, NULL, NULL, 200000, 200000, 0, '2026-03-03 02:28:31'),
(25, 'TRX-20260303093256', 1, 1400000, NULL, NULL, 1400000, 1400000, 0, '2026-03-03 02:32:56'),
(26, 'TRX-20260303141630', 1, 1380000, NULL, NULL, 1380000, 1400000, 20000, '2026-03-03 07:16:30');

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

--
-- Table structure for table `transaction_details`
--

CREATE TABLE `transaction_details` (
  `id` int(11) NOT NULL,
  `transaction_id` int(11) DEFAULT NULL,
  `product_id` int(11) DEFAULT NULL,
  `unit_name` varchar(20) DEFAULT NULL,
  `qty` int(11) DEFAULT NULL,
  `conversion_value` int(11) DEFAULT NULL,
  `price` int(11) DEFAULT NULL,
  `subtotal` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `transaction_details`
--

INSERT INTO `transaction_details` (`id`, `transaction_id`, `product_id`, `unit_name`, `qty`, `conversion_value`, `price`, `subtotal`) VALUES
(30, 19, 20, 'Reel', 1, 1, 2100000, 2100000),
(31, 19, 21, 'Pcs', 4, 1, 60000, 240000),
(32, 19, 22, 'Pcs', 3, 1, 40000, 120000),
(33, 20, 23, 'Reel', 2, 1, 120000, 240000),
(34, 21, 26, 'Unit', 1, 1, 150000, 150000),
(35, 21, 27, 'Unit', 1, 1, 100000, 100000),
(36, 21, 25, 'Pcs', 20, 1, 2000, 40000),
(37, 21, 24, 'Pack', 1, 1, 5000, 5000),
(38, 22, 21, 'Pcs', 2, 1, 60000, 120000),
(39, 22, 22, 'Pcs', 3, 1, 40000, 120000),
(40, 23, 28, 'Pcs', 1, 1, 80000, 80000),
(41, 23, 29, 'Pcs', 2, 1, 25000, 50000),
(42, 24, 31, 'Pcs', 2, 1, 60000, 120000),
(43, 24, 28, 'Pcs', 1, 1, 80000, 80000),
(44, 25, 30, 'Reel', 1, 1, 1350000, 1350000),
(45, 25, 29, 'Pcs', 1, 1, 25000, 25000),
(46, 25, 24, 'Pack', 5, 1, 5000, 25000),
(47, 26, 29, 'Pcs', 1, 1, 25000, 25000),
(48, 26, 24, 'Pack', 1, 1, 5000, 5000),
(49, 26, 30, 'Reel', 1, 1, 1350000, 1350000);

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

--
-- Table structure for table `units`
--

CREATE TABLE `units` (
  `id` int(11) NOT NULL,
  `name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `units`
--

INSERT INTO `units` (`id`, `name`) VALUES
(10, 'Reel'),
(11, 'Pcs'),
(12, 'Pack'),
(13, 'Unit');

--
-- Indexes for dumped tables
--

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

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

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

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

--
-- Indexes for table `product_units`
--
ALTER TABLE `product_units`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_product_units_product_id` (`product_id`),
  ADD KEY `fk_product_units_unit_id` (`unit_id`);

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

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

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

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

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

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

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `product_units`
--
ALTER TABLE `product_units`
  ADD CONSTRAINT `fk_product_units_product_id` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_product_units_unit_id` FOREIGN KEY (`unit_id`) REFERENCES `units` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_pu_product` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE;
COMMIT;

