-- phpMyAdmin SQL Dump
-- version 5.2.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Apr 06, 2026 at 08:33 AM
-- Server version: 10.4.27-MariaDB
-- PHP Version: 7.4.33

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: `atk_inventory`
--

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

--
-- Table structure for table `ai_predictions`
--

CREATE TABLE `ai_predictions` (
  `id` int(11) NOT NULL,
  `atk_id` int(11) NOT NULL,
  `monthly_avg_usage` decimal(10,2) DEFAULT NULL COMMENT 'Rata-rata penggunaan per bulan',
  `usage_trend` varchar(50) DEFAULT NULL COMMENT 'Trend: increasing, decreasing, stable',
  `fast_moving` tinyint(1) DEFAULT 0 COMMENT 'Barang cepat habis (high usage)',
  `slow_moving` tinyint(1) DEFAULT 0 COMMENT 'Barang jarang dipakai (low usage)',
  `estimated_days_to_empty` int(11) DEFAULT NULL COMMENT 'Estimasi berapa hari stok akan habis',
  `recommended_reorder_qty` int(11) DEFAULT NULL COMMENT 'Jumlah rekomendasi pemesanan',
  `confidence_level` decimal(3,2) DEFAULT NULL COMMENT 'Tingkat kepercayaan prediksi (0-1)',
  `recommendation` varchar(255) DEFAULT NULL COMMENT 'Rekomendasi sistem',
  `priority_level` varchar(20) DEFAULT NULL COMMENT 'Priority: high, medium, low',
  `analysis_data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'Data analisis detail (trend history, dll)' CHECK (json_valid(`analysis_data`)),
  `generated_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 `ai_predictions`
--

INSERT INTO `ai_predictions` (`id`, `atk_id`, `monthly_avg_usage`, `usage_trend`, `fast_moving`, `slow_moving`, `estimated_days_to_empty`, `recommended_reorder_qty`, `confidence_level`, `recommendation`, `priority_level`, `analysis_data`, `generated_at`, `updated_at`) VALUES
(4, 3, '0.00', 'stable', 0, 0, NULL, NULL, '0.00', NULL, NULL, NULL, '2026-03-28 11:32:05', '2026-03-28 11:32:05'),
(5, 4, '0.00', 'stable', 0, 0, NULL, NULL, '0.00', NULL, NULL, NULL, '2026-03-28 11:32:44', '2026-03-28 11:32:44');

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

--
-- Table structure for table `alerts`
--

CREATE TABLE `alerts` (
  `id` int(11) NOT NULL,
  `atk_id` int(11) NOT NULL,
  `alert_type` varchar(100) DEFAULT NULL COMMENT 'Tipe: LOW_STOCK, FAST_MOVING, SLOW_MOVING, REORDER_NEEDED',
  `severity` varchar(20) DEFAULT 'medium' COMMENT 'critical, high, medium, low',
  `message` varchar(500) DEFAULT NULL,
  `is_read` tinyint(1) DEFAULT 0,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `atk_items`
--

CREATE TABLE `atk_items` (
  `id` int(11) NOT NULL,
  `code` varchar(50) NOT NULL COMMENT 'Kode unik ATK (ATK-001, ATK-002, dst)',
  `name` varchar(255) NOT NULL COMMENT 'Nama Alat Tulis Kantor',
  `category` varchar(100) DEFAULT NULL COMMENT 'Kategori: Pensil, Kertas, Pena, Buku, Klip, dll',
  `description` text DEFAULT NULL COMMENT 'Deskripsi detail ATK',
  `unit` varchar(50) NOT NULL COMMENT 'Satuan: pcs, rim, box, pak, dll',
  `stock` int(11) DEFAULT 0 COMMENT 'Jumlah stok saat ini',
  `min_stock` int(11) DEFAULT 10 COMMENT 'Minimum stok untuk alert',
  `reorder_point` int(11) DEFAULT 20 COMMENT 'Titik pemesanan ulang',
  `average_monthly_usage` int(11) DEFAULT 0 COMMENT 'Rata-rata penggunaan per bulan (AI calculated)',
  `lifespan_days` int(11) DEFAULT 0 COMMENT 'Estimasi berapa hari barang akan habis',
  `last_stockin` date DEFAULT NULL COMMENT 'Tanggal stok masuk terakhir',
  `last_stockout` date DEFAULT NULL COMMENT 'Tanggal stok keluar terakhir',
  `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 `atk_items`
--

INSERT INTO `atk_items` (`id`, `code`, `name`, `category`, `description`, `unit`, `stock`, `min_stock`, `reorder_point`, `average_monthly_usage`, `lifespan_days`, `last_stockin`, `last_stockout`, `created_at`, `updated_at`) VALUES
(3, 'ATK-001', 'Kertas A4', 'Kertas', 'kertas', 'rim', 7, 10, 15, 0, 0, '2026-03-28', NULL, '2026-03-28 11:32:05', '2026-03-28 11:33:35'),
(4, 'ATK-002', 'Pensil 2B', 'Pensil', 'pensil', 'box', 2, 6, 19, 0, 0, '2026-03-28', '2026-03-28', '2026-03-28 11:32:44', '2026-03-28 11:45:48');

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

--
-- Table structure for table `atk_usage`
--

CREATE TABLE `atk_usage` (
  `id` int(11) NOT NULL,
  `atk_id` int(11) NOT NULL,
  `quantity_used` int(11) NOT NULL COMMENT 'Jumlah yang digunakan',
  `used_by` varchar(100) DEFAULT NULL COMMENT 'Siapa yang menggunakan (nama/NIP)',
  `purpose` varchar(255) DEFAULT NULL COMMENT 'Keperluan penggunaan',
  `date_used` date NOT NULL COMMENT 'Tanggal penggunaan',
  `time_used` time DEFAULT NULL COMMENT 'Jam penggunaan',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `atk_usage`
--

INSERT INTO `atk_usage` (`id`, `atk_id`, `quantity_used`, `used_by`, `purpose`, `date_used`, `time_used`, `created_at`) VALUES
(1, 3, 2, 'Mike', 'Ujian', '2026-03-28', '20:33:00', '2026-03-28 11:33:55');

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

--
-- Table structure for table `ip_whitelist`
--

CREATE TABLE `ip_whitelist` (
  `id` int(11) NOT NULL,
  `ip_address` varchar(45) NOT NULL,
  `description` varchar(255) DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `added_by` int(11) 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;

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

--
-- Table structure for table `loans`
--

CREATE TABLE `loans` (
  `id` int(11) NOT NULL,
  `product_id` int(11) NOT NULL,
  `borrower_name` varchar(255) NOT NULL,
  `borrower_email` varchar(255) DEFAULT NULL,
  `borrower_phone` varchar(20) DEFAULT NULL,
  `quantity` int(11) NOT NULL DEFAULT 1,
  `loan_date` date NOT NULL DEFAULT curdate(),
  `expected_return_date` date NOT NULL,
  `actual_return_date` date DEFAULT NULL,
  `status` enum('active','returned','overdue','damaged') DEFAULT 'active',
  `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;

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

--
-- Table structure for table `login_history`
--

CREATE TABLE `login_history` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `login_time` timestamp NOT NULL DEFAULT current_timestamp(),
  `logout_time` timestamp NULL DEFAULT NULL,
  `duration_seconds` int(11) DEFAULT 0,
  `ip_address` varchar(45) DEFAULT NULL,
  `user_agent` varchar(500) DEFAULT NULL,
  `login_status` enum('success','failed') DEFAULT 'success',
  `failure_reason` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `login_history`
--

INSERT INTO `login_history` (`id`, `user_id`, `login_time`, `logout_time`, `duration_seconds`, `ip_address`, `user_agent`, `login_status`, `failure_reason`) VALUES
(4, 1, '2026-03-28 11:25:41', '2026-04-06 05:43:50', 411, '127.0.0.1', 'Test Browser', 'success', NULL),
(5, 1, '2026-03-28 11:26:31', '2026-04-06 05:36:55', 413, '::1', 'unknown', 'success', NULL),
(6, 1, '2026-03-28 11:27:02', '2026-04-06 05:29:52', 71, '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', 'success', NULL),
(7, 1, '2026-04-06 05:28:42', '2026-04-06 05:29:52', 71, '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', 'success', NULL),
(8, 4, '2026-04-06 05:29:59', '2026-04-06 05:44:34', 37, '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', 'failed', 'Password tidak sesuai'),
(9, 1, '2026-04-06 05:30:02', '2026-04-06 05:36:55', 413, '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', 'success', NULL),
(10, 1, '2026-04-06 05:36:59', '2026-04-06 05:43:50', 411, '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', 'success', NULL),
(11, 4, '2026-04-06 05:43:57', '2026-04-06 05:44:34', 37, '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', 'success', NULL),
(12, 1, '2026-04-06 05:50:30', '2026-04-06 06:11:08', 1238, '::1', 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Mobile/15E148 Safari/604.1', 'success', NULL),
(13, 4, '2026-04-06 06:01:17', '2026-04-06 06:16:16', 11, '192.168.5.49', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:149.0) Gecko/20100101 Firefox/149.0', 'failed', 'IP tidak dalam whitelist'),
(14, 4, '2026-04-06 06:01:29', '2026-04-06 06:10:39', 13, '192.168.5.12', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:149.0) Gecko/20100101 Firefox/149.0', 'success', NULL),
(15, 4, '2026-04-06 06:10:26', '2026-04-06 06:10:39', 13, '192.168.5.9', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:149.0) Gecko/20100101 Firefox/149.0', 'success', NULL),
(16, 4, '2026-04-06 06:16:05', '2026-04-06 06:16:16', 11, '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', 'success', NULL),
(17, 1, '2026-04-06 06:23:33', '2026-04-06 06:27:49', 256, '::1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36', 'success', NULL);

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

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

CREATE TABLE `products` (
  `id` int(11) NOT NULL,
  `code` varchar(50) NOT NULL,
  `name` varchar(255) NOT NULL,
  `category` varchar(100) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `stock` int(11) DEFAULT 0,
  `min_stock` int(11) DEFAULT 10,
  `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;

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

--
-- Table structure for table `stock_in_records`
--

CREATE TABLE `stock_in_records` (
  `id` int(11) NOT NULL,
  `date_in` date NOT NULL,
  `total_items_in` int(11) DEFAULT NULL,
  `supplier_notes` varchar(255) DEFAULT NULL,
  `recorded_by` varchar(100) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `stock_in_records`
--

INSERT INTO `stock_in_records` (`id`, `date_in`, `total_items_in`, `supplier_notes`, `recorded_by`, `created_at`) VALUES
(1, '2026-03-28', 3, 'Indojaya, 0242419', 'Mike', '2026-03-28 11:33:35'),
(2, '2026-03-28', 2, 'Indojaya, 0242419', 'Mike', '2026-03-28 11:39:26');

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

--
-- Table structure for table `stock_movements`
--

CREATE TABLE `stock_movements` (
  `id` int(11) NOT NULL,
  `atk_id` int(11) NOT NULL,
  `type` enum('in','out','adjust','damage','return') NOT NULL COMMENT 'Tipe gerakan',
  `quantity` int(11) NOT NULL COMMENT 'Jumlah unit',
  `reason` varchar(100) DEFAULT NULL COMMENT 'Alasan: restock, penggunaan rutin, dll',
  `notes` varchar(500) DEFAULT NULL COMMENT 'Catatan gerakan',
  `recorded_by` varchar(100) DEFAULT NULL COMMENT 'Siapa yang catat (nama/NIP)',
  `recorded_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `stock_movements`
--

INSERT INTO `stock_movements` (`id`, `atk_id`, `type`, `quantity`, `reason`, `notes`, `recorded_by`, `recorded_at`) VALUES
(1, 3, 'in', 3, 'restock', 'Indojaya, 0242419', 'Mike', '2026-03-28 11:33:35'),
(2, 4, 'out', 2, 'penggunaan_rutin', 'stok habis', 'Mike', '2026-03-28 11:34:17'),
(3, 4, 'in', 2, 'restock', 'Indojaya, 0242419', 'Mike', '2026-03-28 11:39:26');

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

--
-- Table structure for table `system_settings`
--

CREATE TABLE `system_settings` (
  `id` int(11) NOT NULL,
  `setting_name` varchar(100) NOT NULL,
  `setting_value` varchar(255) DEFAULT NULL,
  `setting_type` enum('boolean','string','integer','json') DEFAULT 'string',
  `description` 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 `system_settings`
--

INSERT INTO `system_settings` (`id`, `setting_name`, `setting_value`, `setting_type`, `description`, `created_at`, `updated_at`) VALUES
(1, 'IP_WHITELIST_ENABLED', '0', 'string', NULL, '2026-04-06 05:50:38', '2026-04-06 06:09:52');

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

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

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `username` varchar(100) NOT NULL,
  `email` varchar(150) NOT NULL,
  `name` varchar(255) NOT NULL,
  `role` varchar(50) DEFAULT NULL COMMENT 'admin, staff, viewer',
  `password` varchar(255) DEFAULT NULL,
  `is_active` int(11) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `last_login` timestamp NULL DEFAULT NULL,
  `last_logout` timestamp NULL DEFAULT NULL,
  `login_duration` int(11) DEFAULT 0,
  `ip_address` varchar(45) 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 `users`
--

INSERT INTO `users` (`id`, `username`, `email`, `name`, `role`, `password`, `is_active`, `created_at`, `last_login`, `last_logout`, `login_duration`, `ip_address`, `updated_at`) VALUES
(1, 'admin', 'admin@gmail.com', 'admin', 'admin', '$2y$10$mbf6SECF6JL2dI/yve6YwOfx/BQX7005Ifx7UqhVShv911zsrPj2.', 1, '2026-03-18 04:54:02', '2026-04-06 06:23:33', NULL, 0, '::1', '2026-04-06 06:23:33'),
(4, 'operator', 'operator@gmail.com', 'OP', 'operator', '$2y$10$YpwmuSl.fzII7jtnwkrvZeqTGpgpSRg2RPzfWPTIZzIbHTM/MUEEq', 1, '2026-03-28 11:27:36', '2026-04-06 06:16:05', NULL, 0, '::1', '2026-04-06 06:16:05');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `ai_predictions`
--
ALTER TABLE `ai_predictions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_prediction_atk` (`atk_id`),
  ADD KEY `idx_prediction_fast_moving` (`fast_moving`),
  ADD KEY `idx_prediction_slow_moving` (`slow_moving`);

--
-- Indexes for table `alerts`
--
ALTER TABLE `alerts`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_alert_atk` (`atk_id`),
  ADD KEY `idx_alert_type` (`alert_type`),
  ADD KEY `idx_alert_severity` (`severity`),
  ADD KEY `idx_alert_read` (`is_read`);

--
-- Indexes for table `atk_items`
--
ALTER TABLE `atk_items`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`),
  ADD KEY `idx_atk_code` (`code`),
  ADD KEY `idx_atk_category` (`category`),
  ADD KEY `idx_atk_stock` (`stock`);

--
-- Indexes for table `atk_usage`
--
ALTER TABLE `atk_usage`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_usage_atk` (`atk_id`),
  ADD KEY `idx_usage_date` (`date_used`),
  ADD KEY `idx_usage_user` (`used_by`);

--
-- Indexes for table `ip_whitelist`
--
ALTER TABLE `ip_whitelist`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `ip_address` (`ip_address`),
  ADD KEY `added_by` (`added_by`),
  ADD KEY `idx_ip` (`ip_address`),
  ADD KEY `idx_active` (`is_active`);

--
-- Indexes for table `loans`
--
ALTER TABLE `loans`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_borrower` (`borrower_name`),
  ADD KEY `idx_product` (`product_id`),
  ADD KEY `idx_status` (`status`),
  ADD KEY `idx_dates` (`loan_date`,`expected_return_date`);

--
-- Indexes for table `login_history`
--
ALTER TABLE `login_history`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_user_login` (`user_id`,`login_time`),
  ADD KEY `idx_login_time` (`login_time`);

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

--
-- Indexes for table `stock_in_records`
--
ALTER TABLE `stock_in_records`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_date_in` (`date_in`);

--
-- Indexes for table `stock_movements`
--
ALTER TABLE `stock_movements`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_movement_atk` (`atk_id`),
  ADD KEY `idx_movement_type` (`type`),
  ADD KEY `idx_movement_date` (`recorded_at`);

--
-- Indexes for table `system_settings`
--
ALTER TABLE `system_settings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `setting_name` (`setting_name`),
  ADD KEY `idx_setting_name` (`setting_name`);

--
-- 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 `ai_predictions`
--
ALTER TABLE `ai_predictions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

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

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

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

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

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

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

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

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

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `ai_predictions`
--
ALTER TABLE `ai_predictions`
  ADD CONSTRAINT `ai_predictions_ibfk_1` FOREIGN KEY (`atk_id`) REFERENCES `atk_items` (`id`);

--
-- Constraints for table `alerts`
--
ALTER TABLE `alerts`
  ADD CONSTRAINT `alerts_ibfk_1` FOREIGN KEY (`atk_id`) REFERENCES `atk_items` (`id`);

--
-- Constraints for table `atk_usage`
--
ALTER TABLE `atk_usage`
  ADD CONSTRAINT `atk_usage_ibfk_1` FOREIGN KEY (`atk_id`) REFERENCES `atk_items` (`id`);

--
-- Constraints for table `ip_whitelist`
--
ALTER TABLE `ip_whitelist`
  ADD CONSTRAINT `ip_whitelist_ibfk_1` FOREIGN KEY (`added_by`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `loans`
--
ALTER TABLE `loans`
  ADD CONSTRAINT `loans_ibfk_1` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE;

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

--
-- Constraints for table `stock_movements`
--
ALTER TABLE `stock_movements`
  ADD CONSTRAINT `stock_movements_ibfk_1` FOREIGN KEY (`atk_id`) REFERENCES `atk_items` (`id`);
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 */;
