-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Aug 27, 2025 at 02:17 PM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.2.12

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

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

--
-- Table structure for table `jenis_teh`
--

CREATE TABLE `jenis_teh` (
  `id_teh` int(11) NOT NULL,
  `kelas_mutu` varchar(20) DEFAULT NULL,
  `mutu` varchar(20) DEFAULT NULL,
  `ciri_ciri` text DEFAULT NULL,
  `jumlah_teh` int(50) NOT NULL,
  `jumlah_bagus` float DEFAULT 0,
  `jumlah_rusak` float DEFAULT 0,
  `grade` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `jenis_teh`
--

INSERT INTO `jenis_teh` (`id_teh`, `kelas_mutu`, `mutu`, `ciri_ciri`, `jumlah_teh`, `jumlah_bagus`, `jumlah_rusak`, `grade`) VALUES
(1, 'MUTU I', 'BOP', 'Butiran besar, warna hitam pekat, sedikit menggulung', 318, 270, 48, 'A'),
(2, 'MUTU I', 'BOPF', 'Butiran lebih kecil dari BOP, hitam mengkilap, menggulung halus', 0, 0, 0, 'A'),
(3, 'MUTU I', 'PF', 'Butiran kecil, warna hitam pekat, seragam dan halus', 200, 200, 0, 'A'),
(4, 'MUTU I', 'DUST', 'Bubuk sangat halus, warna hitam kecoklatan, hasil penyaringan akhir', 650, 550, 100, 'A'),
(5, 'MUTU I', 'BT', 'Teh berbentuk potongan batang kecil, warna coklat kehitaman', 350, 250, 100, 'A'),
(6, 'MUTU I', 'BP', 'Butiran agak besar, bentuk serbuk, warna coklat tua', 402, 52, 350, 'A'),
(7, 'MUTU II', 'PF II', 'Butiran kecil tidak seragam, warna coklat kehitaman, kualitas menengah', 50, 0, 50, 'B'),
(8, 'MUTU II', 'DUST II', 'Bubuk halus tidak terlalu pekat, warna coklat muda', 100, 100, 0, 'B'),
(9, 'MUTU II', 'BT II', 'Batang teh lebih kasar, warna coklat pucat', 590, 540, 50, 'B'),
(10, 'MUTU II', 'BP II', 'Butiran besar tidak seragam, warna coklat keabu-abuan', 0, 0, 0, 'B'),
(11, 'MUTU II', 'F II', 'Daun remuk, warna coklat kemerahan, tekstur kasar', 300, 0, 300, 'B'),
(12, 'MUTU II', 'PW DUST', 'Bubuk teh sangat halus, warna pucat, hasil penyaringan akhir kelas bawah', 350, 50, 300, 'B'),
(13, 'MUTU III', 'BM', 'Campuran bubuk dan batang, warna coklat kusam, banyak serat tidak menggulung', 300, 300, 0, 'C');

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

--
-- Table structure for table `lelang`
--

CREATE TABLE `lelang` (
  `id_lelang` int(11) NOT NULL,
  `id_sortasi` int(11) DEFAULT NULL,
  `kelas_mutu` varchar(20) NOT NULL,
  `mutu` varchar(20) NOT NULL,
  `grade` varchar(20) NOT NULL,
  `berat_lelang` int(11) NOT NULL,
  `pembeli` varchar(100) DEFAULT NULL,
  `status` enum('Belum Terjual','Terjual') DEFAULT 'Belum Terjual'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `lelang`
--

INSERT INTO `lelang` (`id_lelang`, `id_sortasi`, `kelas_mutu`, `mutu`, `grade`, `berat_lelang`, `pembeli`, `status`) VALUES
(6, 225, 'MUTU II', 'PW DUST', 'B', 250, 'PT Teh Botol Sosro', 'Terjual'),
(7, 238, 'MUTU I', 'BP', 'A', 350, 'PT Teh Hijau Nusantara', 'Terjual'),
(8, 241, 'MUTU I', 'BOP', 'A', 48, 'PT PJB UP Cirata', 'Terjual');

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

--
-- Table structure for table `oksidasi`
--

CREATE TABLE `oksidasi` (
  `id_oksidasi` int(11) NOT NULL,
  `kode_oksidasi` varchar(20) DEFAULT NULL,
  `id_penggilingan` int(11) DEFAULT NULL,
  `berat_giling` float DEFAULT NULL,
  `id_produksi` int(11) NOT NULL,
  `tanggal_input` timestamp NULL DEFAULT NULL,
  `id_user` int(11) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `jabatan` varchar(100) DEFAULT NULL,
  `berat_oksidasi` float NOT NULL,
  `suhu` float NOT NULL,
  `kelembapan` float NOT NULL,
  `durasi` varchar(10) NOT NULL,
  `standar_oksidasi` text NOT NULL,
  `keterangan` text DEFAULT NULL,
  `status` enum('Belum Diinput','Selesai') NOT NULL DEFAULT 'Belum Diinput'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `oksidasi`
--

INSERT INTO `oksidasi` (`id_oksidasi`, `kode_oksidasi`, `id_penggilingan`, `berat_giling`, `id_produksi`, `tanggal_input`, `id_user`, `name`, `jabatan`, `berat_oksidasi`, `suhu`, `kelembapan`, `durasi`, `standar_oksidasi`, `keterangan`, `status`) VALUES
(133, 'OE-138-133', 133, 700, 138, '2025-08-06 11:35:28', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 600, 20, 80, '120', 'Memenuhi', 'Bagus', 'Selesai'),
(141, 'OE-146-141', 141, 1560, 146, '2025-08-26 04:38:21', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 1290, 20, 80, '45', 'Memenuhi', '-', 'Selesai'),
(142, 'OE-147-142', 142, 650, 147, '2025-08-26 04:44:51', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 520, 20, 80, '40', 'Memenuhi', 'Bagus', 'Selesai'),
(143, 'OE-148-143', 143, 560, 148, '2025-08-26 12:50:54', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 450, 21, 80, '90', 'Memenuhi', '-', 'Selesai'),
(144, 'OE-149-144', 144, 1430, 149, '2025-08-26 13:18:34', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 1110, 22, 80, '40', 'Memenuhi', '-', 'Selesai'),
(145, 'OE-150-145', 145, NULL, 150, NULL, NULL, NULL, NULL, 0, 0, 0, '', '', NULL, 'Belum Diinput');

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

--
-- Table structure for table `pelayuan`
--

CREATE TABLE `pelayuan` (
  `id_pelayuan` int(11) NOT NULL,
  `kode_pelayuan` varchar(20) DEFAULT NULL,
  `id_penerimaan` int(11) DEFAULT NULL,
  `jumlah_pucuk` float DEFAULT NULL,
  `id_produksi` int(11) NOT NULL,
  `tanggal_input` timestamp NULL DEFAULT NULL,
  `id_user` int(11) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `jabatan` varchar(100) DEFAULT NULL,
  `berat_layu` float NOT NULL,
  `lama_pelayuan` int(11) DEFAULT NULL,
  `mc_akhir` float DEFAULT NULL,
  `kerataan` float DEFAULT NULL,
  `standar_pelayuan` text DEFAULT NULL,
  `keterangan` text DEFAULT NULL,
  `status` enum('Belum Diinput','Selesai') NOT NULL DEFAULT 'Belum Diinput'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `pelayuan`
--

INSERT INTO `pelayuan` (`id_pelayuan`, `kode_pelayuan`, `id_penerimaan`, `jumlah_pucuk`, `id_produksi`, `tanggal_input`, `id_user`, `name`, `jabatan`, `berat_layu`, `lama_pelayuan`, `mc_akhir`, `kerataan`, `standar_pelayuan`, `keterangan`, `status`) VALUES
(133, 'PL-138-135', 135, 900, 138, '2025-08-06 11:13:35', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 800, 120, 59, 90, 'Memenuhi Standar MC Akhir 50–60% dan Kerataan ≥ 90%', 'Bagus', 'Selesai'),
(141, 'PL-146-143', 143, 2400, 146, '2025-08-26 04:37:29', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 1870, 120, 50, 91, 'Memenuhi Standar MC Akhir 50–60% dan Kerataan ≥ 90%', '-', 'Selesai'),
(142, 'PL-147-144', 144, 1000, 147, '2025-08-26 04:44:04', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 860, 120, 56, 90, 'Memenuhi Standar MC Akhir 50–60% dan Kerataan ≥ 90%', 'Bagus', 'Selesai'),
(143, 'PL-148-145', 145, 900, 148, '2025-08-26 12:50:21', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 670, 120, 59, 90, 'Memenuhi Standar MC Akhir 50–60% dan Kerataan ≥ 90%', '-', 'Selesai'),
(144, 'PL-149-146', 146, 2000, 149, '2025-08-26 13:18:01', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 1650, 100, 55, 90, 'Memenuhi Standar MC Akhir 50–60% dan Kerataan ≥ 90%', '-', 'Selesai'),
(145, 'PL-150-147', 147, 900, 150, '2025-08-26 13:51:04', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 760, 120, 56, 90, 'Memenuhi Standar MC Akhir 50 - 60% dan Kerataan ≥ 90%', '-', 'Selesai');

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

--
-- Table structure for table `penerimaan_pucuk`
--

CREATE TABLE `penerimaan_pucuk` (
  `id_penerimaan` int(11) NOT NULL,
  `kode_penerimaan` varchar(20) DEFAULT NULL,
  `id_produksi` int(11) NOT NULL,
  `tanggal_input` timestamp NULL DEFAULT NULL,
  `id_user` int(11) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `jabatan` varchar(100) DEFAULT NULL,
  `jumlah_pucuk` float DEFAULT NULL,
  `mc_basah` float DEFAULT NULL,
  `kontaminasi` enum('Ya','Tidak') DEFAULT NULL,
  `standar_pucuk` text DEFAULT NULL,
  `keterangan` text DEFAULT NULL,
  `status` enum('Belum Diinput','Selesai') NOT NULL DEFAULT 'Belum Diinput'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `penerimaan_pucuk`
--

INSERT INTO `penerimaan_pucuk` (`id_penerimaan`, `kode_penerimaan`, `id_produksi`, `tanggal_input`, `id_user`, `name`, `jabatan`, `jumlah_pucuk`, `mc_basah`, `kontaminasi`, `standar_pucuk`, `keterangan`, `status`) VALUES
(135, 'PC-138-1', 138, '2025-08-06 11:13:25', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 900, 60, 'Tidak', 'Memenuhi standar MC ≤ 60% & Bebas Kontaminasi', 'Bagus', 'Selesai'),
(143, 'PC-146-1', 146, '2025-08-26 04:37:03', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 2400, 60, 'Tidak', 'Memenuhi standar MC ≤ 60% & Bebas Kontaminasi', '-', 'Selesai'),
(144, 'PC-147-1', 147, '2025-08-26 04:43:37', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 1000, 56, 'Tidak', 'Memenuhi standar MC ≤ 60% & Bebas Kontaminasi', 'Sedikit Layu', 'Selesai'),
(145, 'PC-148-1', 148, '2025-08-26 12:50:03', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 900, 60, 'Tidak', 'Memenuhi standar MC ≤ 60% & Bebas Kontaminasi', '-', 'Selesai'),
(146, 'PC-149-1', 149, '2025-08-26 13:17:38', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 2000, 55, 'Tidak', 'Memenuhi standar MC ≤ 60% & Bebas Kontaminasi', '-', 'Selesai'),
(147, 'PC-150-1', 150, '2025-08-26 13:50:53', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 900, 56, 'Tidak', 'Memenuhi standar MC ≤ 60% & Bebas Kontaminasi', '-', 'Selesai');

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

--
-- Table structure for table `pengepakan`
--

CREATE TABLE `pengepakan` (
  `id_pengepakan` int(11) NOT NULL,
  `kode_pengepakan` varchar(20) DEFAULT NULL,
  `id_sortasi` int(11) DEFAULT NULL,
  `kelas_mutu` varchar(20) DEFAULT NULL,
  `mutu` varchar(20) DEFAULT NULL,
  `grade` varchar(20) DEFAULT NULL,
  `id_produksi` int(11) NOT NULL,
  `tanggal_input` timestamp NULL DEFAULT NULL,
  `id_user` int(11) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `jabatan` varchar(100) DEFAULT NULL,
  `berat_paket` float NOT NULL,
  `jenis_kemasan` varchar(50) DEFAULT NULL,
  `jumlah_kemasan` int(11) DEFAULT NULL,
  `keterangan` text DEFAULT NULL,
  `status` enum('Belum Diinput','Selesai') NOT NULL DEFAULT 'Belum Diinput'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `pengepakan`
--

INSERT INTO `pengepakan` (`id_pengepakan`, `kode_pengepakan`, `id_sortasi`, `kelas_mutu`, `mutu`, `grade`, `id_produksi`, `tanggal_input`, `id_user`, `name`, `jabatan`, `berat_paket`, `jenis_kemasan`, `jumlah_kemasan`, `keterangan`, `status`) VALUES
(175, 'SO-138-133', 223, 'MUTU III', 'BM', 'C', 138, '2025-08-06 11:54:41', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 250, 'Paper Sak', 5, 'Bagus', 'Selesai'),
(185, 'SO-146-141', 236, 'MUTU I', 'DUST', 'A', 146, '2025-08-26 04:40:24', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 250, 'Paper Sak', 5, '-', 'Selesai'),
(186, 'SO-146-141', 235, 'MUTU II', 'BT II', 'B', 146, '2025-08-26 04:40:38', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 250, 'Karung Plastik', 5, '-', 'Selesai'),
(187, 'SO-146-141', 237, 'MUTU I', 'BT', 'A', 146, '2025-08-26 04:40:58', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 250, 'Carton Box', 5, '-', 'Selesai'),
(189, 'SO-147-142', 240, 'MUTU I', 'BP', 'A', 147, '2025-08-26 04:46:54', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 52, 'Paper Sak', 1, 'Standar Terpenuhi', 'Selesai'),
(190, 'SO-147-142', 239, 'MUTU I', 'PF', 'A', 147, '2025-08-26 04:47:26', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 100, 'Paper Sak', 2, 'Standar Terpenuhi', 'Selesai'),
(192, 'SO-148-143', 244, 'MUTU II', 'BT II', 'B', 148, '2025-08-26 12:52:09', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 140, 'Karung Plastik', 3, '-', 'Selesai'),
(194, 'SO-149-144', 248, 'MUTU I', 'DUST', 'A', 149, '2025-08-26 13:20:11', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 300, 'Karung Plastik', 6, '-', 'Selesai'),
(195, 'SO-149-144', 247, 'MUTU I', 'BOP', 'A', 149, '2025-08-26 13:20:32', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 270, 'Carton Box', 5, '-', 'Selesai'),
(196, 'PN-150-250', 250, NULL, NULL, NULL, 150, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, 'Belum Diinput');

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

--
-- Table structure for table `pengeringan`
--

CREATE TABLE `pengeringan` (
  `id_pengeringan` int(11) NOT NULL,
  `kode_pengeringan` varchar(20) DEFAULT NULL,
  `id_oksidasi` int(11) DEFAULT NULL,
  `berat_oksidasi` float DEFAULT NULL,
  `id_produksi` int(11) NOT NULL,
  `tanggal_input` timestamp NULL DEFAULT NULL,
  `id_user` int(11) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `jabatan` varchar(100) DEFAULT NULL,
  `berat_kering` float NOT NULL,
  `mc_kering` float NOT NULL,
  `suhu_bubuk` float NOT NULL,
  `standar_pengeringan` text DEFAULT NULL,
  `keterangan` text DEFAULT NULL,
  `status` enum('Belum Diinput','Selesai') NOT NULL DEFAULT 'Belum Diinput'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `pengeringan`
--

INSERT INTO `pengeringan` (`id_pengeringan`, `kode_pengeringan`, `id_oksidasi`, `berat_oksidasi`, `id_produksi`, `tanggal_input`, `id_user`, `name`, `jabatan`, `berat_kering`, `mc_kering`, `suhu_bubuk`, `standar_pengeringan`, `keterangan`, `status`) VALUES
(133, 'PE-138-133', 133, 600, 138, '2025-08-06 11:41:52', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 500, 2.5, 60, 'Memenuhi', 'Bagus', 'Selesai'),
(141, 'PE-146-141', 141, 1290, 146, '2025-08-26 04:38:42', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 1100, 2.8, 69, 'Memenuhi', '-', 'Selesai'),
(142, 'PE-147-142', 142, 520, 147, '2025-08-26 04:45:08', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 400, 2.5, 60, 'Memenuhi', 'Bagus', 'Selesai'),
(143, 'PE-148-143', 143, 450, 148, '2025-08-26 12:51:06', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 340, 2.9, 60, 'Memenuhi', '-', 'Selesai'),
(144, 'PE-149-144', 144, 1110, 149, '2025-08-26 13:18:57', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 870, 3, 67, 'Memenuhi', '-', 'Selesai'),
(145, 'PE-150-145', 145, NULL, 150, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, NULL, 'Belum Diinput');

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

--
-- Table structure for table `penggilingan`
--

CREATE TABLE `penggilingan` (
  `id_penggilingan` int(11) NOT NULL,
  `kode_penggilingan` varchar(20) DEFAULT NULL,
  `id_pelayuan` int(11) DEFAULT NULL,
  `berat_layu` float DEFAULT NULL,
  `id_produksi` int(11) NOT NULL,
  `tanggal_input` timestamp NULL DEFAULT NULL,
  `id_user` int(11) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `jabatan` varchar(100) DEFAULT NULL,
  `berat_giling` float DEFAULT NULL,
  `suhu_bubuk` float NOT NULL,
  `kelembapan` float NOT NULL,
  `suhu_ruangan` float NOT NULL,
  `standar_penggilingan` text NOT NULL,
  `keterangan` text DEFAULT NULL,
  `status` enum('Belum Diinput','Selesai') NOT NULL DEFAULT 'Belum Diinput'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `penggilingan`
--

INSERT INTO `penggilingan` (`id_penggilingan`, `kode_penggilingan`, `id_pelayuan`, `berat_layu`, `id_produksi`, `tanggal_input`, `id_user`, `name`, `jabatan`, `berat_giling`, `suhu_bubuk`, `kelembapan`, `suhu_ruangan`, `standar_penggilingan`, `keterangan`, `status`) VALUES
(133, 'PG-138-133', 133, 800, 138, '2025-08-06 11:28:16', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 700, 60, 80, 20, 'Memenuhi', 'Bagus', 'Selesai'),
(141, 'PG-146-141', 141, 1870, 146, '2025-08-26 04:37:55', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 1560, 60, 81, 20, 'Memenuhi', '-', 'Selesai'),
(142, 'PG-147-142', 142, 860, 147, '2025-08-26 04:44:28', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 650, 60, 80, 21, 'Memenuhi', 'Bagus', 'Selesai'),
(143, 'PG-148-143', 143, 670, 148, '2025-08-26 12:50:36', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 560, 60, 80, 20, 'Memenuhi', '-', 'Selesai'),
(144, 'PG-149-144', 144, 1650, 149, '2025-08-26 13:18:16', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 1430, 60, 80, 22, 'Memenuhi', '-', 'Selesai'),
(145, 'PG-150-145', 145, NULL, 150, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, '', NULL, 'Belum Diinput');

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

--
-- Table structure for table `produksi_master`
--

CREATE TABLE `produksi_master` (
  `id_produksi` int(11) NOT NULL,
  `kode_produksi` varchar(20) DEFAULT NULL,
  `tanggal_mulai` date NOT NULL,
  `id_user` int(11) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `jabatan` varchar(100) DEFAULT NULL,
  `status` enum('Berjalan','Selesai') DEFAULT NULL,
  `tanggal_selesai` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `produksi_master`
--

INSERT INTO `produksi_master` (`id_produksi`, `kode_produksi`, `tanggal_mulai`, `id_user`, `name`, `jabatan`, `status`, `tanggal_selesai`) VALUES
(138, 'PR-138', '2025-08-06', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Selesai', '2025-08-06'),
(146, 'PR-146', '2025-08-26', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Selesai', '2025-08-26'),
(147, 'PR-147', '2025-08-26', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Selesai', '2025-08-26'),
(148, 'PR-148', '2025-08-26', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Selesai', '2025-08-26'),
(149, 'PR-149', '2025-08-26', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Selesai', '2025-08-26'),
(150, 'PR-150', '2025-08-26', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Berjalan', NULL);

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

--
-- Table structure for table `sortasi`
--

CREATE TABLE `sortasi` (
  `id_sortasi` int(11) NOT NULL,
  `kode_sortasi` varchar(20) DEFAULT NULL,
  `id_pengeringan` int(11) DEFAULT NULL,
  `berat_kering` float DEFAULT NULL,
  `id_produksi` int(11) NOT NULL,
  `tanggal_input` timestamp NULL DEFAULT NULL,
  `id_teh` int(11) DEFAULT NULL,
  `kelas_mutu` varchar(20) DEFAULT NULL,
  `mutu` varchar(20) DEFAULT NULL,
  `grade` varchar(20) DEFAULT NULL,
  `id_user` int(11) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `jabatan` varchar(100) DEFAULT NULL,
  `kondisi` enum('Bagus','Rusak') DEFAULT NULL,
  `berat_sortasi` int(11) DEFAULT NULL,
  `berat_rusak` int(11) DEFAULT 0,
  `keterangan` text DEFAULT NULL,
  `status` enum('Belum Diinput','Selesai') NOT NULL DEFAULT 'Belum Diinput'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `sortasi`
--

INSERT INTO `sortasi` (`id_sortasi`, `kode_sortasi`, `id_pengeringan`, `berat_kering`, `id_produksi`, `tanggal_input`, `id_teh`, `kelas_mutu`, `mutu`, `grade`, `id_user`, `name`, `jabatan`, `kondisi`, `berat_sortasi`, `berat_rusak`, `keterangan`, `status`) VALUES
(223, 'SO-138-133', 133, 500, 138, '2025-08-06 11:48:28', 13, 'MUTU III', 'BM', 'C', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Bagus', 250, 0, 'Oke', 'Selesai'),
(225, 'SO-138-133', 133, 500, 138, '2025-08-06 11:48:28', 12, 'MUTU II', 'PW DUST', 'B', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Rusak', 0, 250, 'Oke', 'Selesai'),
(235, 'SO-146-141', 141, 1100, 146, '2025-08-26 04:39:53', 9, 'MUTU II', 'BT II', 'B', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Bagus', 250, 0, '-', 'Selesai'),
(236, 'SO-146-141', 141, 1100, 146, '2025-08-26 04:39:53', 4, 'MUTU I', 'DUST', 'A', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Bagus', 250, 0, '-', 'Selesai'),
(237, 'SO-146-141', 141, 1100, 146, '2025-08-26 04:39:53', 5, 'MUTU I', 'BT', 'A', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Bagus', 250, 0, '-', 'Selesai'),
(238, 'SO-146-141', 141, 1100, 146, '2025-08-26 04:39:53', 6, 'MUTU I', 'BP', 'A', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Rusak', 0, 350, '-', 'Selesai'),
(239, 'SO-147-142', 142, 400, 147, '2025-08-26 04:46:06', 3, 'MUTU I', 'PF', 'A', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Bagus', 100, 0, '-', 'Selesai'),
(240, 'SO-147-142', 142, 400, 147, '2025-08-26 04:46:06', 6, 'MUTU I', 'BP', 'A', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Bagus', 52, 0, '-', 'Selesai'),
(241, 'SO-147-142', 142, 400, 147, '2025-08-26 04:46:06', 1, 'MUTU I', 'BOP', 'A', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Rusak', 0, 48, '-', 'Selesai'),
(242, 'SO-147-142', 142, 400, 147, '2025-08-26 04:46:06', 12, 'MUTU II', 'PW DUST', 'B', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Rusak', 0, 50, '-', 'Selesai'),
(243, 'SO-147-142', 142, 400, 147, '2025-08-26 04:46:06', 9, 'MUTU II', 'BT II', 'B', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Rusak', 0, 50, '-', 'Selesai'),
(244, 'SO-148-143', 143, 340, 148, '2025-08-26 12:51:47', 9, 'MUTU II', 'BT II', 'B', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Bagus', 140, 0, '-', 'Selesai'),
(245, 'SO-148-143', 143, 340, 148, '2025-08-26 12:51:47', 4, 'MUTU I', 'DUST', 'A', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Rusak', 0, 100, '-', 'Selesai'),
(246, 'SO-148-143', 143, 340, 148, '2025-08-26 12:51:47', 5, 'MUTU I', 'BT', 'A', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Rusak', 0, 100, '-', 'Selesai'),
(247, 'SO-149-144', 144, 870, 149, '2025-08-26 13:19:39', 1, 'MUTU I', 'BOP', 'A', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Bagus', 270, 0, '-', 'Selesai'),
(248, 'SO-149-144', 144, 870, 149, '2025-08-26 13:19:39', 4, 'MUTU I', 'DUST', 'A', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Bagus', 300, 0, '-', 'Selesai'),
(249, 'SO-149-144', 144, 870, 149, '2025-08-26 13:19:39', 11, 'MUTU II', 'F II', 'B', 29, 'Rezha Fahlevy Ahyen', 'Aspol', 'Rusak', 0, 300, '-', 'Selesai'),
(250, 'SO-150-145', 145, NULL, 150, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL, 'Belum Diinput');

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

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

CREATE TABLE `users` (
  `id_user` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `username` varchar(50) NOT NULL,
  `password` varchar(255) NOT NULL,
  `role` enum('Admin','User') DEFAULT 'User',
  `jabatan` enum('Mandor Penerimaan Pucuk','Mandor Pelayuan','Mandor Penggilingan','Mandor Oksidasi','Mandor Pengeringan','Mandor Sortasi','Mandor Pengepakan','Aspol') DEFAULT NULL,
  `status` tinyint(1) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id_user`, `name`, `username`, `password`, `role`, `jabatan`, `status`, `created_at`) VALUES
(21, 'Rezha Fahlevy Ahyen', 'eja', '$2y$10$Izvkcvs3gPPZhVtVsSiasuIz.14NlS.P/DfqvPmUeNSfycCKE0PZ6', 'User', 'Mandor Penerimaan Pucuk', 1, '2025-07-22 03:45:49'),
(22, 'Dhanie', 'dani', '$2y$10$y8RZWv0YIvipSjDl3UsMS.sOW07pJ9b.DTl0Rr06qsnEsXcXjpe0m', 'User', 'Mandor Pelayuan', 1, '2025-07-22 03:46:02'),
(23, 'Ibnu', 'ibnu', '$2y$10$6bkFPQqqwJObFHKJk3gyeOisbJMPBSm5QcYAg8YYewr.Clp.lmggq', 'User', 'Mandor Penggilingan', 1, '2025-07-22 03:46:27'),
(24, 'Ahmed', 'ahmed', '$2y$10$YnWpFQHGVkHMmTAjSfDuh.YarumoaKzEMSnCY/bk6GBB2aOF//Jxq', 'User', 'Mandor Oksidasi', 1, '2025-07-22 03:46:42'),
(25, 'Yuda', 'yuda', '$2y$10$AWamlkE88oIcN4qeHLmOfu6dVYhTMWK.XHwgjCyd0e4z1Sb/TuOCC', 'User', 'Mandor Pengeringan', 1, '2025-07-22 03:47:05'),
(26, 'Eman', 'eman', '$2y$10$kPXStj1rgcYDy.Fwcgdlg.VRPAs6uMMF1WZaKSCp3BoAYT1AhTlmS', 'User', 'Mandor Sortasi', 1, '2025-07-22 03:47:22'),
(27, 'Udin', 'udin', '$2y$10$Rh7yFZIsKz8YqtrrDLqLxeB6Cx0gvHO3Q4XKlMNhAfQfMQcZHaA3O', 'User', 'Mandor Pengepakan', 1, '2025-07-22 03:47:42'),
(29, 'Rezha Fahlevy Ahyen', 'admin', '$2y$10$LmVAUgT4dFVRsHQodPzkleU9CquiTKA/WEjRGCoHiajy/nzQM.1zm', 'Admin', 'Aspol', 1, '2025-08-05 02:14:18');

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

--
-- Table structure for table `stok_gudang`
--

CREATE TABLE `stok_gudang` (
  `id_stok` int(11) NOT NULL AUTO_INCREMENT,
  `id_pengepakan` int(11) NOT NULL,
  `kode_pengepakan` varchar(20) DEFAULT NULL,
  `kelas_mutu` varchar(20) DEFAULT NULL,
  `mutu` varchar(20) DEFAULT NULL,
  `grade` varchar(20) DEFAULT NULL,
  `berat_paket` float NOT NULL,
  `jenis_kemasan` varchar(50) DEFAULT NULL,
  `jumlah_kemasan` int(11) DEFAULT NULL,
  `total_berat` float NOT NULL,
  `tanggal_masuk` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `status` enum('Tersedia','Terjual','Habis') NOT NULL DEFAULT 'Tersedia',
  PRIMARY KEY (`id_stok`),
  KEY `id_pengepakan` (`id_pengepakan`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `penjualan`
--

CREATE TABLE `penjualan` (
  `id_penjualan` int(11) NOT NULL AUTO_INCREMENT,
  `kode_penjualan` varchar(20) DEFAULT NULL,
  `id_stok` int(11) NOT NULL,
  `id_pengepakan` int(11) NOT NULL,
  `tanggal_jual` date NOT NULL,
  `nama_pembeli` varchar(100) NOT NULL,
  `alamat_pembeli` text DEFAULT NULL,
  `telepon_pembeli` varchar(20) DEFAULT NULL,
  `email_pembeli` varchar(100) DEFAULT NULL,
  `harga_per_kg` decimal(10,2) NOT NULL,
  `quantity_kg` float NOT NULL,
  `total_harga` decimal(10,2) NOT NULL,
  `metode_pembayaran` enum('Tunai','Transfer','Kredit') DEFAULT 'Tunai',
  `status_pembayaran` enum('Lunas','Belum Lunas','Cicilan') DEFAULT 'Lunas',
  `keterangan` text DEFAULT NULL,
  `tanggal_input` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `id_user` int(11) DEFAULT NULL,
  `name` varchar(100) DEFAULT NULL,
  `jabatan` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id_penjualan`),
  KEY `id_stok` (`id_stok`),
  KEY `id_pengepakan` (`id_pengepakan`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `jenis_teh`
--
ALTER TABLE `jenis_teh`
  ADD PRIMARY KEY (`id_teh`);

--
-- Indexes for table `lelang`
--
ALTER TABLE `lelang`
  ADD PRIMARY KEY (`id_lelang`),
  ADD KEY `fk_lelang_sortasi` (`id_sortasi`);

--
-- Indexes for table `oksidasi`
--
ALTER TABLE `oksidasi`
  ADD PRIMARY KEY (`id_oksidasi`),
  ADD KEY `fk_oksidasi_penggilingan` (`id_penggilingan`),
  ADD KEY `fk_oksidasi_produksi` (`id_produksi`),
  ADD KEY `fk_oksidasi_user` (`id_user`);

--
-- Indexes for table `pelayuan`
--
ALTER TABLE `pelayuan`
  ADD PRIMARY KEY (`id_pelayuan`),
  ADD KEY `fk_pelayuan_penerimaan` (`id_penerimaan`),
  ADD KEY `fk_pelayuan_produksi` (`id_produksi`),
  ADD KEY `fk_pelayuan_user` (`id_user`);

--
-- Indexes for table `penerimaan_pucuk`
--
ALTER TABLE `penerimaan_pucuk`
  ADD PRIMARY KEY (`id_penerimaan`),
  ADD KEY `fk_penerimaan_produksi` (`id_produksi`),
  ADD KEY `fk_penerimaan_user` (`id_user`);

--
-- Indexes for table `pengepakan`
--
ALTER TABLE `pengepakan`
  ADD PRIMARY KEY (`id_pengepakan`),
  ADD KEY `fk_pengepakan_sortasi` (`id_sortasi`),
  ADD KEY `fk_pengepakan_produksi` (`id_produksi`),
  ADD KEY `fk_pengepakan_user` (`id_user`);

--
-- Indexes for table `pengeringan`
--
ALTER TABLE `pengeringan`
  ADD PRIMARY KEY (`id_pengeringan`),
  ADD KEY `fk_pengeringan_oksidasi` (`id_oksidasi`),
  ADD KEY `fk_pengeringan_produksi` (`id_produksi`),
  ADD KEY `fk_pengeringan_user` (`id_user`);

--
-- Indexes for table `penggilingan`
--
ALTER TABLE `penggilingan`
  ADD PRIMARY KEY (`id_penggilingan`),
  ADD KEY `fk_penggilingan_pelayuan` (`id_pelayuan`),
  ADD KEY `fk_penggilingan_produksi` (`id_produksi`),
  ADD KEY `fk_penggilingan_user` (`id_user`);

--
-- Indexes for table `produksi_master`
--
ALTER TABLE `produksi_master`
  ADD PRIMARY KEY (`id_produksi`),
  ADD KEY `fk_produksi_user` (`id_user`);

--
-- Indexes for table `sortasi`
--
ALTER TABLE `sortasi`
  ADD PRIMARY KEY (`id_sortasi`),
  ADD KEY `fk_sortasi_pengeringan` (`id_pengeringan`),
  ADD KEY `fk_sortasi_produksi` (`id_produksi`),
  ADD KEY `fk_sortasi_teh` (`id_teh`),
  ADD KEY `fk_sortasi_user` (`id_user`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id_user`),
  ADD UNIQUE KEY `username` (`username`);

--
-- Indexes for table `stok_gudang`
--
ALTER TABLE `stok_gudang`
  ADD PRIMARY KEY (`id_stok`),
  ADD KEY `fk_stok_pengepakan` (`id_pengepakan`);

--
-- Indexes for table `penjualan`
--
ALTER TABLE `penjualan`
  ADD PRIMARY KEY (`id_penjualan`),
  ADD KEY `fk_penjualan_stok` (`id_stok`),
  ADD KEY `fk_penjualan_pengepakan` (`id_pengepakan`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `jenis_teh`
--
ALTER TABLE `jenis_teh`
  MODIFY `id_teh` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;

--
-- AUTO_INCREMENT for table `lelang`
--
ALTER TABLE `lelang`
  MODIFY `id_lelang` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

--
-- AUTO_INCREMENT for table `oksidasi`
--
ALTER TABLE `oksidasi`
  MODIFY `id_oksidasi` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=146;

--
-- AUTO_INCREMENT for table `pelayuan`
--
ALTER TABLE `pelayuan`
  MODIFY `id_pelayuan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=146;

--
-- AUTO_INCREMENT for table `penerimaan_pucuk`
--
ALTER TABLE `penerimaan_pucuk`
  MODIFY `id_penerimaan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=148;

--
-- AUTO_INCREMENT for table `pengepakan`
--
ALTER TABLE `pengepakan`
  MODIFY `id_pengepakan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=197;

--
-- AUTO_INCREMENT for table `pengeringan`
--
ALTER TABLE `pengeringan`
  MODIFY `id_pengeringan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=146;

--
-- AUTO_INCREMENT for table `penggilingan`
--
ALTER TABLE `penggilingan`
  MODIFY `id_penggilingan` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=146;

--
-- AUTO_INCREMENT for table `produksi_master`
--
ALTER TABLE `produksi_master`
  MODIFY `id_produksi` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=151;

--
-- AUTO_INCREMENT for table `sortasi`
--
ALTER TABLE `sortasi`
  MODIFY `id_sortasi` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=251;

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

--
-- AUTO_INCREMENT for table `stok_gudang`
--
ALTER TABLE `stok_gudang`
  MODIFY `id_stok` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `penjualan`
--
ALTER TABLE `penjualan`
  MODIFY `id_penjualan` int(11) NOT NULL AUTO_INCREMENT;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `lelang`
--
ALTER TABLE `lelang`
  ADD CONSTRAINT `fk_lelang_sortasi` FOREIGN KEY (`id_sortasi`) REFERENCES `sortasi` (`id_sortasi`) ON DELETE SET NULL ON UPDATE CASCADE;

--
-- Constraints for table `oksidasi`
--
ALTER TABLE `oksidasi`
  ADD CONSTRAINT `fk_oksidasi_penggilingan` FOREIGN KEY (`id_penggilingan`) REFERENCES `penggilingan` (`id_penggilingan`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_oksidasi_produksi` FOREIGN KEY (`id_produksi`) REFERENCES `produksi_master` (`id_produksi`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_oksidasi_user` FOREIGN KEY (`id_user`) REFERENCES `users` (`id_user`) ON DELETE SET NULL;

--
-- Constraints for table `pelayuan`
--
ALTER TABLE `pelayuan`
  ADD CONSTRAINT `fk_pelayuan_penerimaan` FOREIGN KEY (`id_penerimaan`) REFERENCES `penerimaan_pucuk` (`id_penerimaan`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_pelayuan_produksi` FOREIGN KEY (`id_produksi`) REFERENCES `produksi_master` (`id_produksi`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_pelayuan_user` FOREIGN KEY (`id_user`) REFERENCES `users` (`id_user`) ON DELETE SET NULL;

--
-- Constraints for table `penerimaan_pucuk`
--
ALTER TABLE `penerimaan_pucuk`
  ADD CONSTRAINT `fk_penerimaan_produksi` FOREIGN KEY (`id_produksi`) REFERENCES `produksi_master` (`id_produksi`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_penerimaan_user` FOREIGN KEY (`id_user`) REFERENCES `users` (`id_user`) ON DELETE SET NULL;

--
-- Constraints for table `pengepakan`
--
ALTER TABLE `pengepakan`
  ADD CONSTRAINT `fk_pengepakan_produksi` FOREIGN KEY (`id_produksi`) REFERENCES `produksi_master` (`id_produksi`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_pengepakan_sortasi` FOREIGN KEY (`id_sortasi`) REFERENCES `sortasi` (`id_sortasi`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_pengepakan_user` FOREIGN KEY (`id_user`) REFERENCES `users` (`id_user`) ON DELETE SET NULL;

--
-- Constraints for table `pengeringan`
--
ALTER TABLE `pengeringan`
  ADD CONSTRAINT `fk_pengeringan_oksidasi` FOREIGN KEY (`id_oksidasi`) REFERENCES `oksidasi` (`id_oksidasi`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_pengeringan_produksi` FOREIGN KEY (`id_produksi`) REFERENCES `produksi_master` (`id_produksi`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_pengeringan_user` FOREIGN KEY (`id_user`) REFERENCES `users` (`id_user`) ON DELETE SET NULL;

--
-- Constraints for table `penggilingan`
--
ALTER TABLE `penggilingan`
  ADD CONSTRAINT `fk_penggilingan_pelayuan` FOREIGN KEY (`id_pelayuan`) REFERENCES `pelayuan` (`id_pelayuan`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_penggilingan_produksi` FOREIGN KEY (`id_produksi`) REFERENCES `produksi_master` (`id_produksi`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_penggilingan_user` FOREIGN KEY (`id_user`) REFERENCES `users` (`id_user`) ON DELETE SET NULL;

--
-- Constraints for table `produksi_master`
--
ALTER TABLE `produksi_master`
  ADD CONSTRAINT `fk_produksi_user` FOREIGN KEY (`id_user`) REFERENCES `users` (`id_user`) ON DELETE SET NULL;

--
-- Constraints for table `sortasi`
--
ALTER TABLE `sortasi`
  ADD CONSTRAINT `fk_sortasi_pengeringan` FOREIGN KEY (`id_pengeringan`) REFERENCES `pengeringan` (`id_pengeringan`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_sortasi_produksi` FOREIGN KEY (`id_produksi`) REFERENCES `produksi_master` (`id_produksi`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_sortasi_teh` FOREIGN KEY (`id_teh`) REFERENCES `jenis_teh` (`id_teh`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_sortasi_user` FOREIGN KEY (`id_user`) REFERENCES `users` (`id_user`) ON DELETE SET NULL;

--
-- Constraints for table `stok_gudang`
--
ALTER TABLE `stok_gudang`
  ADD CONSTRAINT `fk_stok_pengepakan` FOREIGN KEY (`id_pengepakan`) REFERENCES `pengepakan` (`id_pengepakan`) ON DELETE CASCADE;

--
-- Constraints for table `penjualan`
--
ALTER TABLE `penjualan`
  ADD CONSTRAINT `fk_penjualan_stok` FOREIGN KEY (`id_stok`) REFERENCES `stok_gudang` (`id_stok`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_penjualan_pengepakan` FOREIGN KEY (`id_pengepakan`) REFERENCES `pengepakan` (`id_pengepakan`) ON DELETE CASCADE;
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 */;
