-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jun 16, 2026 at 09:21 PM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.0.30
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: `stock_management`
--
-- --------------------------------------------------------
--
-- Table structure for table `products`
--
CREATE TABLE `products` (
`id` int(11) NOT NULL,
`name` varchar(100) NOT NULL,
`description` text DEFAULT NULL,
`unit` varchar(20) DEFAULT 'pcs',
`current_stock` int(11) NOT NULL DEFAULT 0,
`created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `products`
--
INSERT INTO `products` (`id`, `name`, `description`, `unit`, `current_stock`, `created_at`) VALUES
(1, 'ONU', 'Optical Network Unit for fiber connection', 'pcs', 50, '2026-06-15 17:34:51'),
(2, 'Pascot', 'Network patch cord connector', 'pcs', 120, '2026-06-15 17:34:51'),
(3, 'Cable', 'Fiber optic cable', 'meter', 460, '2026-06-15 17:34:51'),
(4, 'Tie', 'Cable tie for wire management', 'pack', 0, '2026-06-15 17:34:51'),
(5, 'TJ Box', 'Terminal junction box', 'pcs', 20, '2026-06-15 17:34:51');
-- --------------------------------------------------------
--
-- Table structure for table `stock_transactions`
--
CREATE TABLE `stock_transactions` (
`id` int(11) NOT NULL,
`product_id` int(11) NOT NULL,
`user_id` int(11) DEFAULT NULL,
`quantity` int(11) NOT NULL,
`type` enum('added','deducted') NOT NULL,
`notes` text DEFAULT NULL,
`is_edited` tinyint(1) NOT NULL DEFAULT 0,
`edited_at` datetime DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `stock_transactions`
--
INSERT INTO `stock_transactions` (`id`, `product_id`, `user_id`, `quantity`, `type`, `notes`, `is_edited`, `edited_at`, `created_at`) VALUES
(1, 1, NULL, 50, 'added', 'Initial stock', 0, NULL, '2026-06-15 17:34:51'),
(2, 2, NULL, 120, 'added', 'Initial stock', 0, NULL, '2026-06-15 17:34:51'),
(3, 3, NULL, 500, 'added', 'Initial stock', 0, NULL, '2026-06-15 17:34:51'),
(4, 4, NULL, 30, 'added', 'Initial stock', 0, NULL, '2026-06-15 17:34:51'),
(5, 5, NULL, 20, 'added', 'Initial stock', 0, NULL, '2026-06-15 17:34:51'),
(6, 3, 2, 40, 'deducted', 'rahimer bari new line', 1, '2026-06-15 23:43:05', '2026-06-15 17:40:17'),
(7, 4, 1, 30, 'deducted', '', 0, NULL, '2026-06-15 17:46:41');
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`full_name` varchar(100) DEFAULT NULL,
`username` varchar(50) NOT NULL,
`password` varchar(255) NOT NULL,
`role` enum('admin','technician') NOT NULL DEFAULT 'admin',
`created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `full_name`, `username`, `password`, `role`, `created_at`) VALUES
(1, 'Administrator', 'admin', '$2y$10$/Aygqe2ALOmeUc1Abmo3aOhutBXD8b7PLObT2H3nkE2whkmQqSb6i', 'admin', '2026-06-15 17:34:51'),
(2, 'Amir Hamza', 'amirhamza', '$2y$10$zxpsFQPC.mHZlJp71bV2qe/SgfMBoEpLYEAlPA1f0d140X/WRwOVy', 'technician', '2026-06-15 17:38:21');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `products`
--
ALTER TABLE `products`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `stock_transactions`
--
ALTER TABLE `stock_transactions`
ADD PRIMARY KEY (`id`),
ADD KEY `product_id` (`product_id`),
ADD KEY `user_id` (`user_id`);
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `username` (`username`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `stock_transactions`
--
ALTER TABLE `stock_transactions`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `stock_transactions`
--
ALTER TABLE `stock_transactions`
ADD CONSTRAINT `stock_transactions_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `stock_transactions_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
ADD CONSTRAINT `stock_transactions_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
ADD CONSTRAINT `stock_transactions_ibfk_4` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;
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 */;