-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Sep 13, 2025 at 03:41 AM
-- Server version: 8.0.30
-- 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: `inventori`
--

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

--
-- Table structure for table `barang`
--

CREATE TABLE `barang` (
  `id_barang` char(7) NOT NULL,
  `nama_barang` varchar(255) NOT NULL,
  `batas` int NOT NULL,
  `satuan_id` int NOT NULL,
  `jenis_id` int NOT NULL,
  `tgl` date NOT NULL,
  `stokawal` bigint NOT NULL,
  `date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `barang`
--

INSERT INTO `barang` (`id_barang`, `nama_barang`, `batas`, `satuan_id`, `jenis_id`, `tgl`, `stokawal`, `date_created`) VALUES
('B000001', 'CCTV Dahua', 0, 4, 5, '2025-09-10', 10, '2025-09-10 12:31:14'),
('B000002', 'AC Daikin', 0, 1, 1, '2025-09-10', 4, '2025-09-10 15:09:18');

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

--
-- Table structure for table `barang_keluar`
--

CREATE TABLE `barang_keluar` (
  `id_barang_keluar` char(16) NOT NULL,
  `user_id` int NOT NULL,
  `tanggal_keluar` date NOT NULL,
  `cabang_id` int DEFAULT NULL,
  `ket` text NOT NULL,
  `date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `date_updated` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `barang_keluar`
--

INSERT INTO `barang_keluar` (`id_barang_keluar`, `user_id`, `tanggal_keluar`, `cabang_id`, `ket`, `date_created`, `date_updated`) VALUES
('BK-25091200003', 1, '2025-09-12', 3, '', '2025-09-12 13:19:37', NULL),
('BK-25091200004', 1, '2025-09-12', 3, '', '2025-09-12 14:30:07', NULL);

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

--
-- Table structure for table `barang_masuk`
--

CREATE TABLE `barang_masuk` (
  `id_barang_masuk` char(16) NOT NULL,
  `user_id_pemilik` int NOT NULL,
  `user_id` int NOT NULL,
  `tanggal_masuk` date NOT NULL,
  `cabang_id` int DEFAULT NULL,
  `stts_perolehan` text NOT NULL,
  `stts_penggunaan` text NOT NULL,
  `ket` text NOT NULL,
  `date_created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `date_updated` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `barang_masuk`
--

INSERT INTO `barang_masuk` (`id_barang_masuk`, `user_id_pemilik`, `user_id`, `tanggal_masuk`, `cabang_id`, `stts_perolehan`, `stts_penggunaan`, `ket`, `date_created`, `date_updated`) VALUES
('BM-25091000001', 18, 1, '2025-09-10', 3, 'Tes', 'Tes', '', '2025-09-10 15:45:55', '2025-09-12 21:13:31'),
('BM-25091200001', 19, 1, '2025-09-12', 3, 'Tes', 'Tes', '', '2025-09-12 16:02:10', '2025-09-12 21:00:46');

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

--
-- Table structure for table `cabang`
--

CREATE TABLE `cabang` (
  `id_cabang` int NOT NULL,
  `nama_cabang` varchar(100) DEFAULT NULL,
  `alamat_cabang` text,
  `flag_pusat` smallint DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `cabang`
--

INSERT INTO `cabang` (`id_cabang`, `nama_cabang`, `alamat_cabang`, `flag_pusat`) VALUES
(3, 'Office', 'Magetan', 0),
(4, 'Logistik', 'Magetan', 0),
(10, 'Gudang 1', 'Magetan', 0),
(11, 'Gudang 2', 'Magetan', 0),
(12, 'Gudang 3', 'Magetan', 0);

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

--
-- Table structure for table `cabang_detail`
--

CREATE TABLE `cabang_detail` (
  `id_cabang_detail` int NOT NULL,
  `id_cabang` int DEFAULT NULL,
  `id_barang` char(7) NOT NULL,
  `stok` int DEFAULT '0',
  `stok_awal` int DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

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

--
-- Table structure for table `customer`
--

CREATE TABLE `customer` (
  `id_customer` int NOT NULL,
  `cabang_id` int NOT NULL,
  `nama_customer` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
  `no_telp` varchar(15) COLLATE utf8mb4_general_ci NOT NULL,
  `alamat` text COLLATE utf8mb4_general_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `departemen`
--

CREATE TABLE `departemen` (
  `id_depart` int NOT NULL,
  `nama_depart` varchar(288) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `departemen`
--

INSERT INTO `departemen` (`id_depart`, `nama_depart`) VALUES
(1, 'Accounting'),
(2, 'BM'),
(3, 'Finance'),
(4, 'HR'),
(5, 'INPP'),
(6, 'IT'),
(7, 'Leasing'),
(8, 'LEGALOG'),
(9, 'Marcomm'),
(10, 'Operational'),
(11, 'Purchasing'),
(12, 'RDD'),
(13, 'Safety'),
(15, 'TCR');

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

--
-- Table structure for table `detail_barang_keluar`
--

CREATE TABLE `detail_barang_keluar` (
  `id_detail` int NOT NULL,
  `id_detail_masuk` int NOT NULL,
  `user_id_pemilik` int NOT NULL,
  `id_barang_keluar` char(16) DEFAULT NULL,
  `id_barang` char(7) DEFAULT NULL,
  `jumlah` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `detail_barang_keluar`
--

INSERT INTO `detail_barang_keluar` (`id_detail`, `id_detail_masuk`, `user_id_pemilik`, `id_barang_keluar`, `id_barang`, `jumlah`) VALUES
(6, 2, 18, 'BK-25091200003', 'B000001', 2),
(7, 3, 18, 'BK-25091200004', 'B000002', 1);

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

--
-- Table structure for table `detail_barang_masuk`
--

CREATE TABLE `detail_barang_masuk` (
  `id_detail` int NOT NULL,
  `id_barang_masuk` char(16) DEFAULT NULL,
  `id_barang` char(7) DEFAULT NULL,
  `jumlah` int DEFAULT NULL,
  `merk` varchar(288) NOT NULL,
  `spesifikasi` text NOT NULL,
  `barcode` varchar(288) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  `sn` varchar(288) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `detail_barang_masuk`
--

INSERT INTO `detail_barang_masuk` (`id_detail`, `id_barang_masuk`, `id_barang`, `jumlah`, `merk`, `spesifikasi`, `barcode`, `sn`) VALUES
(8, 'BM-25091200001', 'B000001', 3, 'Dahua', 'CCTV IP Camera', '123', '1123131'),
(9, 'BM-25091000001', 'B000001', 4, 'Hixvision', 'Camera 2MP', '', ''),
(10, 'BM-25091000001', 'B000002', 3, 'Daikin', 'Freon R35', '', '');

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

--
-- Table structure for table `detail_retur`
--

CREATE TABLE `detail_retur` (
  `id_detail` int NOT NULL,
  `id_retur` char(16) DEFAULT NULL,
  `id_barang` char(7) DEFAULT NULL,
  `jumlah` double DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

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

--
-- Table structure for table `detail_stock_op_name`
--

CREATE TABLE `detail_stock_op_name` (
  `id_detail` int NOT NULL,
  `id_stock_op_name` char(16) DEFAULT NULL,
  `id_detail_masuk` int NOT NULL,
  `id_barang` char(7) DEFAULT NULL,
  `jumlah` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

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

--
-- Table structure for table `detail_transfer_barang`
--

CREATE TABLE `detail_transfer_barang` (
  `id_detail_transfer` int NOT NULL,
  `id_transfer` int NOT NULL,
  `id_detail_masuk` int NOT NULL,
  `id_barang` char(7) NOT NULL,
  `jumlah_detail` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `detail_transfer_barang`
--

INSERT INTO `detail_transfer_barang` (`id_detail_transfer`, `id_transfer`, `id_detail_masuk`, `id_barang`, `jumlah_detail`) VALUES
(1, 1, 0, 'B000001', 1);

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

--
-- Table structure for table `jenis`
--

CREATE TABLE `jenis` (
  `id_jenis` int NOT NULL,
  `nama_jenis` varchar(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `jenis`
--

INSERT INTO `jenis` (`id_jenis`, `nama_jenis`) VALUES
(1, 'AC'),
(2, 'AHU'),
(3, 'APAR'),
(4, 'Blower'),
(5, 'CCTV'),
(6, 'Chiller');

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

--
-- Table structure for table `retur`
--

CREATE TABLE `retur` (
  `id_retur` char(16) NOT NULL,
  `tanggal` date DEFAULT NULL,
  `tujuan_cabang` int DEFAULT NULL,
  `asal_cabang` int DEFAULT NULL,
  `keterangan` text,
  `id_user` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

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

--
-- Table structure for table `satuan`
--

CREATE TABLE `satuan` (
  `id_satuan` int NOT NULL,
  `nama_satuan` varchar(15) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `satuan`
--

INSERT INTO `satuan` (`id_satuan`, `nama_satuan`) VALUES
(1, 'Unit'),
(4, 'Pcs'),
(5, 'Box'),
(6, 'Roll');

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

--
-- Table structure for table `sa_barang`
--

CREATE TABLE `sa_barang` (
  `id_sa` int NOT NULL,
  `barang_id` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
  `cabang_id` int NOT NULL,
  `tgl` date NOT NULL,
  `user_id` int NOT NULL,
  `saldo` bigint NOT NULL,
  `hpp` float NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `stock_op_name`
--

CREATE TABLE `stock_op_name` (
  `id_stock_op_name` char(16) NOT NULL,
  `user_id` int NOT NULL,
  `jumlah_keluar` int DEFAULT '0',
  `tanggal_stock_op_name` date NOT NULL,
  `cabang_id` int DEFAULT NULL,
  `ket` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

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

--
-- Table structure for table `supplier`
--

CREATE TABLE `supplier` (
  `id_supplier` int NOT NULL,
  `cabang_id` int NOT NULL,
  `nama_supplier` varchar(50) NOT NULL,
  `no_telp` varchar(15) NOT NULL,
  `alamat` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

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

--
-- Table structure for table `transfer_barang`
--

CREATE TABLE `transfer_barang` (
  `id_transfer` int NOT NULL,
  `kode_transfer` char(16) DEFAULT NULL,
  `tgl_transfer` date DEFAULT NULL,
  `keterangan` text,
  `asal_cabang` int DEFAULT NULL,
  `tujuan_cabang` int DEFAULT NULL,
  `jumlah` int DEFAULT NULL,
  `user_id` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `transfer_barang`
--

INSERT INTO `transfer_barang` (`id_transfer`, `kode_transfer`, `tgl_transfer`, `keterangan`, `asal_cabang`, `tujuan_cabang`, `jumlah`, `user_id`) VALUES
(1, 'TR-25091000001', '2025-09-10', '', 3, 4, NULL, 1);

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

--
-- Table structure for table `user`
--

CREATE TABLE `user` (
  `id_user` int NOT NULL,
  `cabang_id` int NOT NULL,
  `nama` varchar(50) NOT NULL,
  `username` varchar(50) NOT NULL,
  `email` varchar(100) NOT NULL,
  `no_telp` varchar(15) NOT NULL,
  `jabatan` varchar(288) NOT NULL,
  `role` enum('pemilik','admin','user') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `id_depart` int NOT NULL,
  `password` varchar(255) NOT NULL,
  `created_at` int NOT NULL,
  `foto` text NOT NULL,
  `is_active` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Dumping data for table `user`
--

INSERT INTO `user` (`id_user`, `cabang_id`, `nama`, `username`, `email`, `no_telp`, `jabatan`, `role`, `id_depart`, `password`, `created_at`, `foto`, `is_active`) VALUES
(1, 3, 'Administrator', 'administrator', 'administrator@admin.com', '025123456789', 'Web App Developer', 'pemilik', 6, '$2y$10$JodvxUjmwLX/Z0QgM6JbE.HRVk5qNS0KVVDyH3BB6fIwSTDmq02mq', 1568689561, 'admin.png', 1),
(18, 3, 'Andi', 'andi', 'andi@gmail.com', '1234567891011', 'Staff Finance', 'user', 3, '$2y$10$iP16dGFY2LSjd2HxfgXKaOwmMIMdyJzF2umROu7h48wUB0uQ4JLtK', 1728015878, 'admin.png', 1),
(19, 3, 'Budi', 'budi', 'budi@gmail.com', '1234567891011', 'Staff Accounting', 'user', 1, '$2y$10$ytqdCSk5nslH0B0CH2csgORJIWBeXWjzzSZG5b5rrY4qDxz0M8Rfy', 1748501288, 'admin.png', 1);

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

--
-- Table structure for table `user_access`
--

CREATE TABLE `user_access` (
  `id_user_access` int NOT NULL,
  `id_role` int NOT NULL,
  `id_sub_menu` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

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

--
-- Table structure for table `user_menu`
--

CREATE TABLE `user_menu` (
  `id_menu` int NOT NULL,
  `nama` varchar(288) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

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

--
-- Table structure for table `user_role`
--

CREATE TABLE `user_role` (
  `id_role` int NOT NULL,
  `role` varchar(288) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

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

--
-- Table structure for table `user_sub_menu`
--

CREATE TABLE `user_sub_menu` (
  `id_sub_menu` int NOT NULL,
  `nama` varchar(288) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `barang`
--
ALTER TABLE `barang`
  ADD PRIMARY KEY (`id_barang`),
  ADD KEY `satuan_id` (`satuan_id`),
  ADD KEY `kategori_id` (`jenis_id`);

--
-- Indexes for table `barang_keluar`
--
ALTER TABLE `barang_keluar`
  ADD PRIMARY KEY (`id_barang_keluar`),
  ADD KEY `id_user` (`user_id`),
  ADD KEY `id_cabang` (`cabang_id`);

--
-- Indexes for table `barang_masuk`
--
ALTER TABLE `barang_masuk`
  ADD PRIMARY KEY (`id_barang_masuk`),
  ADD KEY `id_user` (`user_id`),
  ADD KEY `id_cabang` (`cabang_id`);

--
-- Indexes for table `cabang`
--
ALTER TABLE `cabang`
  ADD PRIMARY KEY (`id_cabang`);

--
-- Indexes for table `cabang_detail`
--
ALTER TABLE `cabang_detail`
  ADD PRIMARY KEY (`id_cabang_detail`),
  ADD KEY `id_cabang` (`id_cabang`),
  ADD KEY `id_barang` (`id_barang`);

--
-- Indexes for table `customer`
--
ALTER TABLE `customer`
  ADD PRIMARY KEY (`id_customer`);

--
-- Indexes for table `departemen`
--
ALTER TABLE `departemen`
  ADD PRIMARY KEY (`id_depart`);

--
-- Indexes for table `detail_barang_keluar`
--
ALTER TABLE `detail_barang_keluar`
  ADD PRIMARY KEY (`id_detail`),
  ADD KEY `detail_barang_keluar_ibfk_1` (`id_barang_keluar`);

--
-- Indexes for table `detail_barang_masuk`
--
ALTER TABLE `detail_barang_masuk`
  ADD PRIMARY KEY (`id_detail`),
  ADD KEY `id_barang_masuk` (`id_barang_masuk`);

--
-- Indexes for table `detail_retur`
--
ALTER TABLE `detail_retur`
  ADD PRIMARY KEY (`id_detail`),
  ADD KEY `detail_retur_beli_ibfk_1` (`id_retur`),
  ADD KEY `detail_retur_beli_ibfk_2` (`id_barang`);

--
-- Indexes for table `detail_stock_op_name`
--
ALTER TABLE `detail_stock_op_name`
  ADD PRIMARY KEY (`id_detail`),
  ADD KEY `detail_stock_op_name_ibfk_1` (`id_stock_op_name`);

--
-- Indexes for table `detail_transfer_barang`
--
ALTER TABLE `detail_transfer_barang`
  ADD PRIMARY KEY (`id_detail_transfer`),
  ADD KEY `id_transfer` (`id_transfer`),
  ADD KEY `id_barang` (`id_barang`);

--
-- Indexes for table `jenis`
--
ALTER TABLE `jenis`
  ADD PRIMARY KEY (`id_jenis`);

--
-- Indexes for table `retur`
--
ALTER TABLE `retur`
  ADD PRIMARY KEY (`id_retur`),
  ADD KEY `retur_beli_ibfk_2` (`id_user`),
  ADD KEY `retur_beli_ibfk_1` (`asal_cabang`),
  ADD KEY `tujuan_cabang` (`tujuan_cabang`);

--
-- Indexes for table `satuan`
--
ALTER TABLE `satuan`
  ADD PRIMARY KEY (`id_satuan`);

--
-- Indexes for table `sa_barang`
--
ALTER TABLE `sa_barang`
  ADD PRIMARY KEY (`id_sa`);

--
-- Indexes for table `stock_op_name`
--
ALTER TABLE `stock_op_name`
  ADD PRIMARY KEY (`id_stock_op_name`),
  ADD KEY `id_user` (`user_id`),
  ADD KEY `id_cabang` (`cabang_id`);

--
-- Indexes for table `supplier`
--
ALTER TABLE `supplier`
  ADD PRIMARY KEY (`id_supplier`);

--
-- Indexes for table `transfer_barang`
--
ALTER TABLE `transfer_barang`
  ADD PRIMARY KEY (`id_transfer`),
  ADD KEY `asal_cabang` (`asal_cabang`),
  ADD KEY `tujuan_cabang` (`tujuan_cabang`),
  ADD KEY `transfer_barang_ibfk_3` (`user_id`);

--
-- Indexes for table `user`
--
ALTER TABLE `user`
  ADD PRIMARY KEY (`id_user`);

--
-- Indexes for table `user_access`
--
ALTER TABLE `user_access`
  ADD PRIMARY KEY (`id_user_access`);

--
-- Indexes for table `user_menu`
--
ALTER TABLE `user_menu`
  ADD PRIMARY KEY (`id_menu`);

--
-- Indexes for table `user_role`
--
ALTER TABLE `user_role`
  ADD PRIMARY KEY (`id_role`);

--
-- Indexes for table `user_sub_menu`
--
ALTER TABLE `user_sub_menu`
  ADD PRIMARY KEY (`id_sub_menu`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `cabang`
--
ALTER TABLE `cabang`
  MODIFY `id_cabang` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;

--
-- AUTO_INCREMENT for table `cabang_detail`
--
ALTER TABLE `cabang_detail`
  MODIFY `id_cabang_detail` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `customer`
--
ALTER TABLE `customer`
  MODIFY `id_customer` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `departemen`
--
ALTER TABLE `departemen`
  MODIFY `id_depart` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;

--
-- AUTO_INCREMENT for table `detail_barang_keluar`
--
ALTER TABLE `detail_barang_keluar`
  MODIFY `id_detail` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `detail_barang_masuk`
--
ALTER TABLE `detail_barang_masuk`
  MODIFY `id_detail` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;

--
-- AUTO_INCREMENT for table `detail_retur`
--
ALTER TABLE `detail_retur`
  MODIFY `id_detail` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `detail_stock_op_name`
--
ALTER TABLE `detail_stock_op_name`
  MODIFY `id_detail` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `detail_transfer_barang`
--
ALTER TABLE `detail_transfer_barang`
  MODIFY `id_detail_transfer` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `jenis`
--
ALTER TABLE `jenis`
  MODIFY `id_jenis` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `satuan`
--
ALTER TABLE `satuan`
  MODIFY `id_satuan` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

--
-- AUTO_INCREMENT for table `sa_barang`
--
ALTER TABLE `sa_barang`
  MODIFY `id_sa` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `supplier`
--
ALTER TABLE `supplier`
  MODIFY `id_supplier` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `transfer_barang`
--
ALTER TABLE `transfer_barang`
  MODIFY `id_transfer` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
  MODIFY `id_user` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22;

--
-- AUTO_INCREMENT for table `user_access`
--
ALTER TABLE `user_access`
  MODIFY `id_user_access` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `user_menu`
--
ALTER TABLE `user_menu`
  MODIFY `id_menu` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `user_role`
--
ALTER TABLE `user_role`
  MODIFY `id_role` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `user_sub_menu`
--
ALTER TABLE `user_sub_menu`
  MODIFY `id_sub_menu` int NOT NULL AUTO_INCREMENT;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `barang`
--
ALTER TABLE `barang`
  ADD CONSTRAINT `barang_ibfk_1` FOREIGN KEY (`satuan_id`) REFERENCES `satuan` (`id_satuan`),
  ADD CONSTRAINT `barang_ibfk_2` FOREIGN KEY (`jenis_id`) REFERENCES `jenis` (`id_jenis`);

--
-- Constraints for table `barang_keluar`
--
ALTER TABLE `barang_keluar`
  ADD CONSTRAINT `barang_keluar_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id_user`),
  ADD CONSTRAINT `barang_keluar_ibfk_3` FOREIGN KEY (`cabang_id`) REFERENCES `cabang` (`id_cabang`);

--
-- Constraints for table `barang_masuk`
--
ALTER TABLE `barang_masuk`
  ADD CONSTRAINT `barang_masuk_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id_user`),
  ADD CONSTRAINT `barang_masuk_ibfk_6` FOREIGN KEY (`cabang_id`) REFERENCES `cabang` (`id_cabang`);

--
-- Constraints for table `cabang_detail`
--
ALTER TABLE `cabang_detail`
  ADD CONSTRAINT `cabang_detail_ibfk_1` FOREIGN KEY (`id_cabang`) REFERENCES `cabang` (`id_cabang`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `cabang_detail_ibfk_2` FOREIGN KEY (`id_barang`) REFERENCES `barang` (`id_barang`);

--
-- Constraints for table `detail_barang_keluar`
--
ALTER TABLE `detail_barang_keluar`
  ADD CONSTRAINT `detail_barang_keluar_ibfk_1` FOREIGN KEY (`id_barang_keluar`) REFERENCES `barang_keluar` (`id_barang_keluar`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `detail_barang_masuk`
--
ALTER TABLE `detail_barang_masuk`
  ADD CONSTRAINT `detail_barang_masuk_ibfk_1` FOREIGN KEY (`id_barang_masuk`) REFERENCES `barang_masuk` (`id_barang_masuk`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `detail_retur`
--
ALTER TABLE `detail_retur`
  ADD CONSTRAINT `detail_retur_ibfk_1` FOREIGN KEY (`id_retur`) REFERENCES `retur` (`id_retur`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `detail_retur_ibfk_2` FOREIGN KEY (`id_barang`) REFERENCES `barang` (`id_barang`);

--
-- Constraints for table `detail_stock_op_name`
--
ALTER TABLE `detail_stock_op_name`
  ADD CONSTRAINT `detail_stock_op_name_ibfk_1` FOREIGN KEY (`id_stock_op_name`) REFERENCES `stock_op_name` (`id_stock_op_name`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Constraints for table `detail_transfer_barang`
--
ALTER TABLE `detail_transfer_barang`
  ADD CONSTRAINT `detail_transfer_barang_ibfk_1` FOREIGN KEY (`id_transfer`) REFERENCES `transfer_barang` (`id_transfer`),
  ADD CONSTRAINT `detail_transfer_barang_ibfk_2` FOREIGN KEY (`id_barang`) REFERENCES `barang` (`id_barang`);

--
-- Constraints for table `retur`
--
ALTER TABLE `retur`
  ADD CONSTRAINT `retur_ibfk_2` FOREIGN KEY (`id_user`) REFERENCES `user` (`id_user`),
  ADD CONSTRAINT `retur_ibfk_4` FOREIGN KEY (`tujuan_cabang`) REFERENCES `cabang` (`id_cabang`),
  ADD CONSTRAINT `retur_ibfk_5` FOREIGN KEY (`asal_cabang`) REFERENCES `cabang` (`id_cabang`);

--
-- Constraints for table `stock_op_name`
--
ALTER TABLE `stock_op_name`
  ADD CONSTRAINT `stock_op_name_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id_user`),
  ADD CONSTRAINT `stock_op_name_ibfk_3` FOREIGN KEY (`cabang_id`) REFERENCES `cabang` (`id_cabang`);

--
-- Constraints for table `transfer_barang`
--
ALTER TABLE `transfer_barang`
  ADD CONSTRAINT `transfer_barang_ibfk_1` FOREIGN KEY (`asal_cabang`) REFERENCES `cabang` (`id_cabang`),
  ADD CONSTRAINT `transfer_barang_ibfk_2` FOREIGN KEY (`tujuan_cabang`) REFERENCES `cabang` (`id_cabang`),
  ADD CONSTRAINT `transfer_barang_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `user` (`id_user`);
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 */;
