/*
SQLyog Community v13.2.0 (64 bit)
MySQL - 10.4.32-MariaDB : Database - db_penggajian_jig
*********************************************************************
*/

/*!40101 SET NAMES utf8 */;

/*!40101 SET SQL_MODE=''*/;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
/*Table structure for table `tb_absensi` */

DROP TABLE IF EXISTS `tb_absensi`;

CREATE TABLE `tb_absensi` (
  `id_absensi` bigint(20) NOT NULL AUTO_INCREMENT,
  `id_import` int(11) DEFAULT NULL,
  `id_pegawai` int(11) NOT NULL,
  `tanggal` date NOT NULL,
  `jam_masuk` time DEFAULT NULL,
  `jam_keluar` time DEFAULT NULL,
  `status` enum('MASUK','ALPHA','SAKIT','CUTI','LIBUR','LEMBUR','IZIN','TERLAMBAT') NOT NULL DEFAULT 'MASUK',
  `keterangan` varchar(255) DEFAULT NULL,
  `is_terlambat` tinyint(1) NOT NULL DEFAULT 0,
  `menit_terlambat` int(5) NOT NULL DEFAULT 0,
  `sumber` enum('IMPORT','MANUAL','AUTO') NOT NULL DEFAULT 'MANUAL',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id_absensi`),
  UNIQUE KEY `uq_absensi_pegawai_tanggal` (`id_pegawai`,`tanggal`),
  KEY `idx_absensi_tanggal` (`tanggal`),
  KEY `idx_absensi_status` (`status`),
  KEY `idx_import` (`id_import`),
  CONSTRAINT `fk_absensi_pegawai` FOREIGN KEY (`id_pegawai`) REFERENCES `tb_pegawai` (`id_pegawai`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_absensi` */

/*Table structure for table `tb_ai_chat_message` */

DROP TABLE IF EXISTS `tb_ai_chat_message`;

CREATE TABLE `tb_ai_chat_message` (
  `id_message` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `id_session` bigint(20) unsigned NOT NULL,
  `id_user` int(10) unsigned NOT NULL,
  `role` enum('user','assistant','system') NOT NULL,
  `message_text` longtext NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`id_message`),
  KEY `idx_ai_chat_message_session` (`id_session`),
  KEY `idx_ai_chat_message_user` (`id_user`),
  KEY `idx_ai_chat_message_created` (`created_at`),
  CONSTRAINT `fk_ai_chat_message_session` FOREIGN KEY (`id_session`) REFERENCES `tb_ai_chat_session` (`id_session`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=61 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

/*Data for the table `tb_ai_chat_message` */

/*Table structure for table `tb_ai_chat_session` */

DROP TABLE IF EXISTS `tb_ai_chat_session`;

CREATE TABLE `tb_ai_chat_session` (
  `id_session` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `id_user` int(10) unsigned NOT NULL,
  `judul` varchar(120) NOT NULL,
  `last_message_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id_session`),
  KEY `idx_ai_chat_session_user` (`id_user`),
  KEY `idx_ai_chat_session_last_message` (`last_message_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

/*Data for the table `tb_ai_chat_session` */

/*Table structure for table `tb_assignment_shift` */

DROP TABLE IF EXISTS `tb_assignment_shift`;

CREATE TABLE `tb_assignment_shift` (
  `id_assignment` int(11) NOT NULL AUTO_INCREMENT,
  `tipe` enum('PEGAWAI','DIVISI') NOT NULL COMMENT 'PEGAWAI override DIVISI',
  `id_referensi` int(11) NOT NULL COMMENT 'id_pegawai jika PEGAWAI, id_divisi jika DIVISI',
  `hari_ke` tinyint(1) NOT NULL DEFAULT 0 COMMENT '0=semua hari, 1=Senin ... 7=Minggu',
  `is_hari_kerja` tinyint(1) NOT NULL DEFAULT 1 COMMENT '0=off/libur, 1=hari kerja',
  `id_shift` int(11) DEFAULT NULL,
  `berlaku_mulai` date NOT NULL,
  `berlaku_selesai` date DEFAULT NULL COMMENT 'NULL = berlaku selamanya',
  `keterangan` varchar(255) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id_assignment`),
  KEY `idx_asgn_tipe_ref` (`tipe`,`id_referensi`),
  KEY `idx_asgn_shift` (`id_shift`),
  KEY `idx_asgn_berlaku` (`berlaku_mulai`,`berlaku_selesai`),
  KEY `idx_asgn_ref_hari` (`tipe`,`id_referensi`,`hari_ke`,`berlaku_mulai`,`berlaku_selesai`),
  CONSTRAINT `fk_asgn_shift` FOREIGN KEY (`id_shift`) REFERENCES `tb_shift` (`id_shift`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_assignment_shift` */

/*Table structure for table `tb_audit_log` */

DROP TABLE IF EXISTS `tb_audit_log`;

CREATE TABLE `tb_audit_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `id_user` int(11) DEFAULT NULL,
  `username` varchar(50) DEFAULT NULL,
  `aksi` varchar(100) NOT NULL,
  `modul` varchar(50) NOT NULL,
  `keterangan` text DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_modul` (`modul`),
  KEY `idx_user` (`id_user`),
  KEY `idx_created` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_audit_log` */

/*Table structure for table `tb_divisi` */

DROP TABLE IF EXISTS `tb_divisi`;

CREATE TABLE `tb_divisi` (
  `id_divisi` int(11) NOT NULL AUTO_INCREMENT,
  `kode_divisi` varchar(10) NOT NULL,
  `nama_divisi` varchar(100) NOT NULL,
  `keterangan` text DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id_divisi`),
  UNIQUE KEY `kode_divisi` (`kode_divisi`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_divisi` */

insert  into `tb_divisi`(`id_divisi`,`kode_divisi`,`nama_divisi`,`keterangan`,`is_active`,`created_at`,`updated_at`) values 
(1,'PROD','Produksi',NULL,1,'2026-05-06 19:18:50','2026-05-06 19:18:50'),
(2,'FARM','Peternakan',NULL,1,'2026-05-06 19:18:50','2026-05-06 19:18:50'),
(3,'ADM','Administrasi','',1,'2026-05-06 19:18:50','2026-05-06 19:25:07'),
(4,'HRD','Human Resource Development',NULL,1,'2026-05-06 19:18:50','2026-05-06 19:18:50'),
(5,'FIN','Keuangan',NULL,1,'2026-05-06 19:18:50','2026-05-06 19:18:50'),
(6,'MKT','Pemasaran',NULL,1,'2026-05-06 19:18:50','2026-05-06 19:18:50'),
(7,'MAINT','Pemeliharaan & Teknik',NULL,1,'2026-05-06 19:18:50','2026-05-06 19:18:50');

/*Table structure for table `tb_hari_libur` */

DROP TABLE IF EXISTS `tb_hari_libur`;

CREATE TABLE `tb_hari_libur` (
  `id_libur` int(11) NOT NULL AUTO_INCREMENT,
  `tanggal` date NOT NULL,
  `nama_libur` varchar(100) NOT NULL,
  `jenis` enum('NASIONAL','PERUSAHAAN') NOT NULL DEFAULT 'NASIONAL',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id_libur`),
  UNIQUE KEY `uk_tanggal` (`tanggal`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

/*Data for the table `tb_hari_libur` */

insert  into `tb_hari_libur`(`id_libur`,`tanggal`,`nama_libur`,`jenis`,`created_at`) values 
(1,'2026-01-01','Hari Tahun Baru','NASIONAL','2026-05-11 13:37:42'),
(2,'2026-01-16','Isra Mikraj Nabi Muhammad','NASIONAL','2026-05-11 13:37:42'),
(3,'2026-02-17','Tahun Baru Imlek','NASIONAL','2026-05-11 13:37:42'),
(4,'2026-03-19','Hari Suci Nyepi (Tahun Baru Saka)','NASIONAL','2026-05-11 13:37:42'),
(5,'2026-03-21','Hari Idul Fitri','NASIONAL','2026-05-11 13:37:42'),
(6,'2026-03-22','Hari Idul Fitri','NASIONAL','2026-05-11 13:37:42'),
(7,'2026-04-03','Wafat Isa Almasih','NASIONAL','2026-05-11 13:37:42'),
(8,'2026-04-05','Hari Paskah','NASIONAL','2026-05-11 13:37:42'),
(9,'2026-05-01','Hari Buruh Internasional / Pekerja','NASIONAL','2026-05-11 13:37:42'),
(10,'2026-05-14','Kenaikan Isa Al Masih','NASIONAL','2026-05-11 13:37:42'),
(11,'2026-05-27','Idul Adha (Lebaran Haji) (belum pasti)','NASIONAL','2026-05-11 13:37:42'),
(12,'2026-05-28','Idul Adha (Lebaran Haji)','NASIONAL','2026-05-11 13:37:42'),
(13,'2026-05-31','Hari Raya Waisak (belum pasti)','NASIONAL','2026-05-11 13:37:42'),
(14,'2026-06-01','Hari Lahir Pancasila','NASIONAL','2026-05-11 13:37:42'),
(15,'2026-06-16','Satu Muharam / Tahun Baru Hijriah (belum pasti)','NASIONAL','2026-05-11 13:37:42'),
(16,'2026-08-17','Hari Proklamasi Kemerdekaan R.I.','NASIONAL','2026-05-11 13:37:42'),
(17,'2026-08-25','Maulid Nabi Muhammad (belum pasti)','NASIONAL','2026-05-11 13:37:42'),
(18,'2026-12-25','Hari Raya Natal','NASIONAL','2026-05-11 13:37:42');

/*Table structure for table `tb_import_absensi_log` */

DROP TABLE IF EXISTS `tb_import_absensi_log`;

CREATE TABLE `tb_import_absensi_log` (
  `id_import` int(11) NOT NULL AUTO_INCREMENT,
  `nama_file` varchar(255) NOT NULL,
  `total_baris` int(11) NOT NULL DEFAULT 0,
  `berhasil` int(11) NOT NULL DEFAULT 0,
  `gagal` int(11) NOT NULL DEFAULT 0,
  `status` enum('SUCCESS','PARTIAL','FAILED','DELETED') DEFAULT 'SUCCESS',
  `detail_log` text DEFAULT NULL,
  `id_user` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id_import`),
  KEY `idx_import_absensi_created` (`created_at`),
  KEY `fk_import_absensi_user` (`id_user`),
  CONSTRAINT `fk_import_absensi_user` FOREIGN KEY (`id_user`) REFERENCES `tb_users` (`id_user`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_import_absensi_log` */

/*Table structure for table `tb_import_pegawai_log` */

DROP TABLE IF EXISTS `tb_import_pegawai_log`;

CREATE TABLE `tb_import_pegawai_log` (
  `id_import` int(11) NOT NULL AUTO_INCREMENT,
  `nama_file` varchar(255) NOT NULL,
  `total_baris` int(11) NOT NULL DEFAULT 0,
  `berhasil` int(11) NOT NULL DEFAULT 0,
  `gagal` int(11) NOT NULL DEFAULT 0,
  `status` enum('SUCCESS','PARTIAL','FAILED') NOT NULL DEFAULT 'SUCCESS',
  `detail_log` text DEFAULT NULL,
  `id_user` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id_import`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;

/*Data for the table `tb_import_pegawai_log` */

/*Table structure for table `tb_izin_cuti` */

DROP TABLE IF EXISTS `tb_izin_cuti`;

CREATE TABLE `tb_izin_cuti` (
  `id_izin` bigint(20) NOT NULL AUTO_INCREMENT,
  `id_pegawai` int(11) NOT NULL,
  `tipe` enum('IZIN','SAKIT','CUTI_TAHUNAN','CUTI_BERSAMA','CUTI_KHUSUS') NOT NULL,
  `tanggal_mulai` date NOT NULL,
  `tanggal_selesai` date NOT NULL,
  `durasi_hari` int(11) NOT NULL DEFAULT 1,
  `alasan` text NOT NULL,
  `status` enum('DRAFT','APPROVED','REJECTED') NOT NULL DEFAULT 'DRAFT',
  `catatan` text DEFAULT NULL,
  `approved_by` int(11) DEFAULT NULL,
  `approved_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id_izin`),
  KEY `idx_izin_pegawai` (`id_pegawai`),
  KEY `idx_izin_status` (`status`),
  KEY `idx_izin_tanggal` (`tanggal_mulai`,`tanggal_selesai`),
  KEY `fk_izin_approved_by` (`approved_by`),
  CONSTRAINT `fk_izin_approved_by` FOREIGN KEY (`approved_by`) REFERENCES `tb_users` (`id_user`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `fk_izin_pegawai` FOREIGN KEY (`id_pegawai`) REFERENCES `tb_pegawai` (`id_pegawai`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_izin_cuti` */

/*Table structure for table `tb_jabatan` */

DROP TABLE IF EXISTS `tb_jabatan`;

CREATE TABLE `tb_jabatan` (
  `id_jabatan` int(11) NOT NULL AUTO_INCREMENT,
  `id_divisi` int(11) NOT NULL,
  `kode_jabatan` varchar(10) NOT NULL,
  `nama_jabatan` varchar(100) NOT NULL,
  `level_jabatan` tinyint(1) NOT NULL DEFAULT 3 COMMENT '1=Manager 2=Supervisor 3=Staff',
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id_jabatan`),
  UNIQUE KEY `kode_jabatan` (`kode_jabatan`),
  KEY `idx_divisi` (`id_divisi`),
  CONSTRAINT `fk_jabatan_divisi` FOREIGN KEY (`id_divisi`) REFERENCES `tb_divisi` (`id_divisi`) ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_jabatan` */

insert  into `tb_jabatan`(`id_jabatan`,`id_divisi`,`kode_jabatan`,`nama_jabatan`,`level_jabatan`,`is_active`,`created_at`,`updated_at`) values 
(1,1,'KPROD','Kepala Produksi',1,1,'2026-05-06 19:18:50','2026-05-06 19:18:50'),
(2,1,'SPVPROD','Supervisor Produksi',2,1,'2026-05-06 19:18:50','2026-05-06 19:18:50'),
(3,1,'STPROD','Staff Produksi',3,1,'2026-05-06 19:18:50','2026-05-06 19:18:50'),
(4,2,'KFARM','Kepala Peternakan',1,1,'2026-05-06 19:18:50','2026-05-06 19:18:50'),
(5,2,'STFARM','Staff Peternakan',3,1,'2026-05-06 19:18:50','2026-05-06 19:18:50'),
(6,3,'KADM','Kepala Administrasi',1,1,'2026-05-06 19:18:50','2026-05-07 07:52:11'),
(7,3,'STADM','Staff Administrasi',3,1,'2026-05-06 19:18:50','2026-05-06 19:18:50'),
(8,4,'MHRD','Manager HRD',1,1,'2026-05-06 19:18:50','2026-05-06 19:18:50'),
(9,4,'STHRD','Staff HRD',3,1,'2026-05-06 19:18:50','2026-05-06 19:18:50'),
(10,5,'MFIN','Manager Keuangan',1,1,'2026-05-06 19:18:50','2026-05-06 19:18:50'),
(11,5,'STFIN','Staff Keuangan',3,1,'2026-05-06 19:18:50','2026-05-06 19:18:50');

/*Table structure for table `tb_komponen_gaji` */

DROP TABLE IF EXISTS `tb_komponen_gaji`;

CREATE TABLE `tb_komponen_gaji` (
  `id_komponen` int(11) NOT NULL AUTO_INCREMENT,
  `kode_komponen` varchar(20) NOT NULL,
  `nama_komponen` varchar(100) NOT NULL,
  `jenis` enum('TUNJANGAN','POTONGAN') NOT NULL,
  `tipe_nilai` enum('NOMINAL','PERSEN') NOT NULL DEFAULT 'NOMINAL',
  `cara_hitung` enum('FLAT','PER_HARI','FORMULA') NOT NULL DEFAULT 'FLAT',
  `nilai_default` decimal(15,2) NOT NULL DEFAULT 0.00,
  `formula_expression` text DEFAULT NULL,
  `tipe_periode` enum('SEMUA','REGULER','THR') NOT NULL DEFAULT 'SEMUA',
  `is_wajib` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1=otomatis, 0=manual',
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `urutan` tinyint(3) NOT NULL DEFAULT 10,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id_komponen`),
  UNIQUE KEY `kode_komponen` (`kode_komponen`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_komponen_gaji` */

insert  into `tb_komponen_gaji`(`id_komponen`,`kode_komponen`,`nama_komponen`,`jenis`,`tipe_nilai`,`cara_hitung`,`nilai_default`,`formula_expression`,`tipe_periode`,`is_wajib`,`is_active`,`urutan`,`created_at`) values 
(1,'GAPOK','Gaji Pokok','TUNJANGAN','NOMINAL','FLAT',0.00,NULL,'SEMUA',1,1,1,'2026-05-06 19:18:51'),
(2,'TJ_MAKAN','Tunjangan Makan','TUNJANGAN','NOMINAL','FLAT',0.00,NULL,'SEMUA',0,1,2,'2026-05-06 19:18:51'),
(3,'TJ_TRANS','Tunjangan Transport','TUNJANGAN','NOMINAL','FLAT',0.00,NULL,'SEMUA',0,1,3,'2026-05-06 19:18:51'),
(4,'TJ_POSISI','Tunjangan Jabatan','TUNJANGAN','NOMINAL','FLAT',0.00,NULL,'SEMUA',0,1,4,'2026-05-06 19:18:51'),
(5,'LEMBUR','Upah Lembur','TUNJANGAN','NOMINAL','FLAT',0.00,NULL,'SEMUA',0,1,5,'2026-05-06 19:18:51'),
(10,'THR','Tunjangan Hari Raya (THR)','TUNJANGAN','NOMINAL','FORMULA',0.00,'ROUND((GAPOK + TJ_POSISI) / 12 * MIN(MASA_KERJA_BULAN, 12), 0)','THR',0,1,7,'2026-05-08 17:52:27'),
(11,'BPJS_KES_KRY','BPJS Kesehatan Karyawan (1%)','POTONGAN','NOMINAL','FORMULA',0.00,'ROUND(GAPOK * 0.01, 0)','REGULER',0,1,8,'2026-05-08 17:52:27'),
(12,'BPJS_KES_PRS','BPJS Kesehatan Perusahaan (4%)','TUNJANGAN','NOMINAL','FORMULA',0.00,'ROUND(GAPOK * 0.04, 0)','REGULER',0,1,9,'2026-05-08 17:52:27'),
(13,'BPJS_JHT_KRY','BPJS JHT Karyawan (2%)','POTONGAN','NOMINAL','FORMULA',0.00,'ROUND(GAPOK * 0.02, 0)','REGULER',0,1,10,'2026-05-08 17:52:27'),
(14,'BPJS_JHT_PRS','BPJS JHT Perusahaan (3.7%)','TUNJANGAN','NOMINAL','FORMULA',0.00,'ROUND(GAPOK * 0.037, 0)','REGULER',0,1,11,'2026-05-08 17:52:27'),
(15,'BPJS_JP_KRY','BPJS Pensiun Karyawan (1%)','POTONGAN','NOMINAL','FORMULA',0.00,'ROUND(GAPOK * 0.01, 0)','REGULER',0,1,12,'2026-05-08 17:52:27'),
(16,'BPJS_JP_PRS','BPJS Pensiun Perusahaan (2%)','TUNJANGAN','NOMINAL','FORMULA',0.00,'ROUND(GAPOK * 0.02, 0)','REGULER',0,1,13,'2026-05-08 17:52:27');

/*Table structure for table `tb_komponen_kehadiran_rule` */

DROP TABLE IF EXISTS `tb_komponen_kehadiran_rule`;

CREATE TABLE `tb_komponen_kehadiran_rule` (
  `id_komponen` int(11) NOT NULL,
  `status_absensi` varchar(20) NOT NULL,
  PRIMARY KEY (`id_komponen`,`status_absensi`),
  CONSTRAINT `fk_kkr_komponen` FOREIGN KEY (`id_komponen`) REFERENCES `tb_komponen_gaji` (`id_komponen`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_komponen_kehadiran_rule` */

/*Table structure for table `tb_konfigurasi` */

DROP TABLE IF EXISTS `tb_konfigurasi`;

CREATE TABLE `tb_konfigurasi` (
  `kunci` varchar(50) NOT NULL,
  `nilai` text NOT NULL,
  `keterangan` varchar(200) DEFAULT NULL,
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`kunci`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_konfigurasi` */

insert  into `tb_konfigurasi`(`kunci`,`nilai`,`keterangan`,`updated_at`) values 
('ai_api_key','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',NULL,'2026-05-16 11:14:50'),
('ai_chat_page_size','30','Jumlah pesan per halaman riwayat chat AI','2026-05-14 13:42:21'),
('ai_chat_retention_messages','400','Batas jumlah pesan per sesi chat AI, pesan terlama akan dihapus otomatis','2026-05-14 13:42:21'),
('ai_connection_checked_at','2026-05-14 06:23:31',NULL,'2026-05-14 06:23:31'),
('ai_connection_message','Koneksi API berhasil.',NULL,'2026-05-14 06:23:31'),
('ai_connection_status','CONNECTED',NULL,'2026-05-14 06:23:31'),
('ai_enabled','1',NULL,'2026-05-16 11:14:50'),
('ai_model','',NULL,'2026-05-16 11:14:50'),
('ai_provider','groq',NULL,'2026-05-16 11:14:50'),
('alamat_perusahaan','Jl. Contoh No. 1, Kota','Alamat perusahaan','2026-05-16 11:14:50'),
('default_shift_id','1','ID shift yang digunakan sebagai fallback jika pegawai tidak punya assignment shift','2026-05-11 10:32:24'),
('favicon_aplikasi','assets/uploads/settings/favicon-aplikasi-20260516111450.png',NULL,'2026-05-16 16:14:50'),
('jam_kerja_per_hari','8','Jam kerja normal per hari','2026-05-07 09:30:02'),
('logo_perusahaan','','Path file logo','2026-05-06 19:18:51'),
('minimum_lembur_menit','30','Minimum menit lembur yang dihitung otomatis dari selisih jam_keluar aktual vs shift','2026-05-11 10:32:24'),
('nama_aplikasi','PAYROLL JIG',NULL,'2026-05-16 11:14:50'),
('nama_perusahaan','PT JATINOM INDAH GROUP','Nama perusahaan di slip gaji','2026-05-16 11:14:50'),
('payroll_mode_periode','CUSTOM','Mode periode payroll: CALENDAR atau CUSTOM','2026-05-16 11:14:50'),
('payroll_tanggal_gajian','25','Tanggal gajian untuk mode CUSTOM (1-31; nilai 1 = mode bulanan penuh)','2026-05-16 11:14:50'),
('tarif_lembur_per_jam','0','Nominal lembur per jam (0=otomatis dari gaji pokok)','2026-05-07 09:30:02');

/*Table structure for table `tb_lembur` */

DROP TABLE IF EXISTS `tb_lembur`;

CREATE TABLE `tb_lembur` (
  `id_lembur` bigint(20) NOT NULL AUTO_INCREMENT,
  `id_pegawai` int(11) NOT NULL,
  `tanggal` date NOT NULL,
  `jam_mulai` time NOT NULL,
  `jam_selesai` time NOT NULL,
  `durasi_jam` decimal(5,2) NOT NULL DEFAULT 0.50,
  `alasan` text NOT NULL,
  `sumber` enum('MANUAL','AUTO') NOT NULL DEFAULT 'MANUAL',
  `status` enum('DRAFT','APPROVED','REJECTED') NOT NULL DEFAULT 'DRAFT',
  `catatan` text DEFAULT NULL,
  `approved_by` int(11) DEFAULT NULL,
  `approved_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id_lembur`),
  KEY `idx_lembur_pegawai` (`id_pegawai`),
  KEY `idx_lembur_status` (`status`),
  KEY `idx_lembur_tanggal` (`tanggal`),
  KEY `fk_lembur_approved_by` (`approved_by`),
  CONSTRAINT `fk_lembur_approved_by` FOREIGN KEY (`approved_by`) REFERENCES `tb_users` (`id_user`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `fk_lembur_pegawai` FOREIGN KEY (`id_pegawai`) REFERENCES `tb_pegawai` (`id_pegawai`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_lembur` */

/*Table structure for table `tb_login_attempts` */

DROP TABLE IF EXISTS `tb_login_attempts`;

CREATE TABLE `tb_login_attempts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `identifier` varchar(100) NOT NULL COMMENT 'username or IP',
  `ip_address` varchar(45) NOT NULL,
  `attempt_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_identifier` (`identifier`),
  KEY `idx_ip` (`ip_address`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_login_attempts` */

insert  into `tb_login_attempts`(`id`,`identifier`,`ip_address`,`attempt_at`) values 
(1,'superdamin','::1','2026-05-07 00:39:04'),
(2,'superdamin','::1','2026-05-07 00:39:19'),
(3,'superdamin','::1','2026-05-07 00:39:34'),
(4,'superdamin','::1','2026-05-07 00:40:38');

/*Table structure for table `tb_payroll` */

DROP TABLE IF EXISTS `tb_payroll`;

CREATE TABLE `tb_payroll` (
  `id_payroll` bigint(20) NOT NULL AUTO_INCREMENT,
  `id_periode` int(11) NOT NULL,
  `id_pegawai` int(11) NOT NULL,
  `gaji_pokok` decimal(15,2) NOT NULL DEFAULT 0.00,
  `total_tunjangan` decimal(15,2) NOT NULL DEFAULT 0.00,
  `total_potongan` decimal(15,2) NOT NULL DEFAULT 0.00,
  `total_lembur` decimal(15,2) NOT NULL DEFAULT 0.00,
  `gaji_bruto` decimal(15,2) NOT NULL DEFAULT 0.00,
  `gaji_neto` decimal(15,2) NOT NULL DEFAULT 0.00,
  `status` enum('PROCESSED','APPROVED','LOCKED') NOT NULL DEFAULT 'PROCESSED',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id_payroll`),
  UNIQUE KEY `uq_payroll_periode_pegawai` (`id_periode`,`id_pegawai`),
  KEY `idx_payroll_periode` (`id_periode`),
  KEY `idx_payroll_pegawai` (`id_pegawai`),
  CONSTRAINT `fk_payroll_pegawai` FOREIGN KEY (`id_pegawai`) REFERENCES `tb_pegawai` (`id_pegawai`) ON UPDATE CASCADE,
  CONSTRAINT `fk_payroll_periode` FOREIGN KEY (`id_periode`) REFERENCES `tb_payroll_periode` (`id_periode`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_payroll` */

/*Table structure for table `tb_payroll_adjustment_audit` */

DROP TABLE IF EXISTS `tb_payroll_adjustment_audit`;

CREATE TABLE `tb_payroll_adjustment_audit` (
  `id_audit` bigint(20) NOT NULL AUTO_INCREMENT,
  `id_adjustment` bigint(20) DEFAULT NULL,
  `id_periode` int(11) NOT NULL,
  `id_payroll` bigint(20) NOT NULL,
  `id_pegawai` int(11) NOT NULL,
  `aksi` enum('CREATE','UPDATE','DELETE','RECALCULATE') NOT NULL,
  `before_payload` longtext DEFAULT NULL,
  `after_payload` longtext DEFAULT NULL,
  `performed_by` int(11) DEFAULT NULL,
  `performed_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id_audit`),
  KEY `idx_adjustment_audit_payroll` (`id_periode`,`id_payroll`),
  KEY `idx_adjustment_audit_pegawai` (`id_pegawai`),
  KEY `fk_adjustment_audit_payroll` (`id_payroll`),
  CONSTRAINT `fk_adjustment_audit_payroll` FOREIGN KEY (`id_payroll`) REFERENCES `tb_payroll` (`id_payroll`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_adjustment_audit_pegawai` FOREIGN KEY (`id_pegawai`) REFERENCES `tb_pegawai` (`id_pegawai`) ON UPDATE CASCADE,
  CONSTRAINT `fk_adjustment_audit_periode` FOREIGN KEY (`id_periode`) REFERENCES `tb_payroll_periode` (`id_periode`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_payroll_adjustment_audit` */

/*Table structure for table `tb_payroll_komponen` */

DROP TABLE IF EXISTS `tb_payroll_komponen`;

CREATE TABLE `tb_payroll_komponen` (
  `id_detail` bigint(20) NOT NULL AUTO_INCREMENT,
  `id_payroll` bigint(20) NOT NULL,
  `id_komponen` int(11) DEFAULT NULL,
  `nama_komponen` varchar(100) NOT NULL,
  `jenis` enum('TUNJANGAN','POTONGAN') NOT NULL,
  `tipe_nilai` enum('NOMINAL','PERSEN') NOT NULL DEFAULT 'NOMINAL',
  `nilai` decimal(15,2) NOT NULL DEFAULT 0.00,
  `jumlah_hari` smallint(6) DEFAULT NULL,
  `sumber` varchar(30) NOT NULL DEFAULT 'SYSTEM_DEFAULT',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id_detail`),
  KEY `idx_payroll_detail_payroll` (`id_payroll`),
  KEY `idx_payroll_detail_komponen` (`id_komponen`),
  CONSTRAINT `fk_payroll_detail_komponen` FOREIGN KEY (`id_komponen`) REFERENCES `tb_komponen_gaji` (`id_komponen`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `fk_payroll_detail_payroll` FOREIGN KEY (`id_payroll`) REFERENCES `tb_payroll` (`id_payroll`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_payroll_komponen` */

/*Table structure for table `tb_payroll_komponen_adjustment` */

DROP TABLE IF EXISTS `tb_payroll_komponen_adjustment`;

CREATE TABLE `tb_payroll_komponen_adjustment` (
  `id_adjustment` bigint(20) NOT NULL AUTO_INCREMENT,
  `id_periode` int(11) NOT NULL,
  `id_payroll` bigint(20) NOT NULL,
  `id_pegawai` int(11) NOT NULL,
  `nama_komponen` varchar(100) NOT NULL,
  `jenis` enum('TUNJANGAN','POTONGAN') NOT NULL,
  `tipe_nilai` enum('NOMINAL') NOT NULL DEFAULT 'NOMINAL',
  `nilai` decimal(15,2) NOT NULL DEFAULT 0.00,
  `catatan` varchar(255) DEFAULT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_by` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_by` int(11) DEFAULT NULL,
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id_adjustment`),
  KEY `idx_adjustment_periode_payroll` (`id_periode`,`id_payroll`),
  KEY `idx_adjustment_pegawai` (`id_pegawai`),
  KEY `idx_adjustment_active` (`is_active`),
  KEY `fk_adjustment_payroll` (`id_payroll`),
  CONSTRAINT `fk_adjustment_payroll` FOREIGN KEY (`id_payroll`) REFERENCES `tb_payroll` (`id_payroll`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_adjustment_pegawai` FOREIGN KEY (`id_pegawai`) REFERENCES `tb_pegawai` (`id_pegawai`) ON UPDATE CASCADE,
  CONSTRAINT `fk_adjustment_periode` FOREIGN KEY (`id_periode`) REFERENCES `tb_payroll_periode` (`id_periode`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_payroll_komponen_adjustment` */

/*Table structure for table `tb_payroll_periode` */

DROP TABLE IF EXISTS `tb_payroll_periode`;

CREATE TABLE `tb_payroll_periode` (
  `id_periode` int(11) NOT NULL AUTO_INCREMENT,
  `kode_periode` varchar(10) NOT NULL,
  `tipe_periode` enum('REGULER','THR') NOT NULL DEFAULT 'REGULER',
  `bulan` tinyint(2) NOT NULL,
  `tahun` smallint(4) NOT NULL,
  `tanggal_mulai` date NOT NULL,
  `tanggal_selesai` date NOT NULL,
  `status` enum('DRAFT','PROCESSED','APPROVED','LOCKED') NOT NULL DEFAULT 'DRAFT',
  `catatan` varchar(255) DEFAULT NULL,
  `processed_by` int(11) DEFAULT NULL,
  `processed_at` datetime DEFAULT NULL,
  `approved_by` int(11) DEFAULT NULL,
  `approved_at` datetime DEFAULT NULL,
  `locked_by` int(11) DEFAULT NULL,
  `locked_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id_periode`),
  UNIQUE KEY `uq_payroll_periode_kode` (`kode_periode`),
  UNIQUE KEY `uq_payroll_periode_bulan_tahun_tipe` (`bulan`,`tahun`,`tipe_periode`),
  KEY `idx_payroll_periode_status` (`status`),
  KEY `fk_periode_processed_by` (`processed_by`),
  KEY `fk_periode_approved_by` (`approved_by`),
  KEY `fk_periode_locked_by` (`locked_by`),
  CONSTRAINT `fk_periode_approved_by` FOREIGN KEY (`approved_by`) REFERENCES `tb_users` (`id_user`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `fk_periode_locked_by` FOREIGN KEY (`locked_by`) REFERENCES `tb_users` (`id_user`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `fk_periode_processed_by` FOREIGN KEY (`processed_by`) REFERENCES `tb_users` (`id_user`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_payroll_periode` */

/*Table structure for table `tb_pegawai` */

DROP TABLE IF EXISTS `tb_pegawai`;

CREATE TABLE `tb_pegawai` (
  `id_pegawai` int(11) NOT NULL AUTO_INCREMENT,
  `nip` varchar(20) NOT NULL,
  `nik` varchar(16) DEFAULT NULL,
  `nama_lengkap` varchar(150) NOT NULL,
  `jenis_kelamin` enum('L','P') NOT NULL DEFAULT 'L',
  `tempat_lahir` varchar(100) DEFAULT NULL,
  `tanggal_lahir` date DEFAULT NULL,
  `alamat` text DEFAULT NULL,
  `no_telepon` varchar(20) DEFAULT NULL,
  `email` varchar(100) DEFAULT NULL,
  `id_divisi` int(11) NOT NULL,
  `id_jabatan` int(11) NOT NULL,
  `tanggal_masuk` date NOT NULL,
  `tanggal_keluar` date DEFAULT NULL,
  `status_pegawai` enum('AKTIF','NONAKTIF','CUTI_PANJANG') NOT NULL DEFAULT 'AKTIF',
  `npwp` varchar(20) DEFAULT NULL,
  `no_bpjs_kesehatan` varchar(30) DEFAULT NULL,
  `no_bpjs_ketenagakerjaan` varchar(30) DEFAULT NULL,
  `no_rekening` varchar(30) DEFAULT NULL,
  `nama_bank` varchar(50) DEFAULT NULL,
  `ptkp_status` enum('TK0','TK1','TK2','TK3','K0','K1','K2','K3','K_I0','K_I1','K_I2','K_I3') NOT NULL DEFAULT 'TK0',
  `gaji_pokok` decimal(15,2) NOT NULL DEFAULT 0.00,
  `foto` varchar(255) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id_pegawai`),
  UNIQUE KEY `nip` (`nip`),
  KEY `idx_divisi` (`id_divisi`),
  KEY `idx_jabatan` (`id_jabatan`),
  KEY `idx_status` (`status_pegawai`),
  KEY `idx_nip` (`nip`),
  CONSTRAINT `fk_pegawai_divisi` FOREIGN KEY (`id_divisi`) REFERENCES `tb_divisi` (`id_divisi`) ON UPDATE CASCADE,
  CONSTRAINT `fk_pegawai_jabatan` FOREIGN KEY (`id_jabatan`) REFERENCES `tb_jabatan` (`id_jabatan`) ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_pegawai` */

/*Table structure for table `tb_pegawai_histori` */

DROP TABLE IF EXISTS `tb_pegawai_histori`;

CREATE TABLE `tb_pegawai_histori` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `id_pegawai` int(11) NOT NULL,
  `jenis_perubahan` varchar(50) NOT NULL COMMENT 'JABATAN|DIVISI|GAJI|STATUS|DATA_POKOK',
  `nilai_lama` text DEFAULT NULL,
  `nilai_baru` text DEFAULT NULL,
  `keterangan` varchar(255) DEFAULT NULL,
  `id_user` int(11) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_pegawai` (`id_pegawai`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_pegawai_histori` */

/*Table structure for table `tb_pegawai_komponen` */

DROP TABLE IF EXISTS `tb_pegawai_komponen`;

CREATE TABLE `tb_pegawai_komponen` (
  `id_pegawai_komponen` int(11) NOT NULL AUTO_INCREMENT,
  `id_pegawai` int(11) NOT NULL,
  `id_komponen` int(11) NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `nilai_override` decimal(15,2) DEFAULT NULL,
  `catatan` varchar(255) DEFAULT NULL,
  `updated_at` datetime NOT NULL,
  `updated_by` int(11) DEFAULT NULL,
  PRIMARY KEY (`id_pegawai_komponen`),
  UNIQUE KEY `uk_pegawai_komponen` (`id_pegawai`,`id_komponen`),
  KEY `idx_pk_pegawai` (`id_pegawai`),
  KEY `idx_pk_komponen` (`id_komponen`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

/*Data for the table `tb_pegawai_komponen` */

/*Table structure for table `tb_shift` */

DROP TABLE IF EXISTS `tb_shift`;

CREATE TABLE `tb_shift` (
  `id_shift` int(11) NOT NULL AUTO_INCREMENT,
  `kode_shift` varchar(20) NOT NULL,
  `nama_shift` varchar(100) NOT NULL,
  `jam_masuk` time NOT NULL,
  `jam_keluar` time NOT NULL,
  `toleransi_menit` int(3) NOT NULL DEFAULT 15 COMMENT 'Menit toleransi sebelum dianggap terlambat',
  `lintas_tengah_malam` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1 jika jam_keluar < jam_masuk (shift malam)',
  `is_default` tinyint(1) NOT NULL DEFAULT 0 COMMENT 'Hanya 1 boleh default=1 sebagai fallback',
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id_shift`),
  UNIQUE KEY `kode_shift` (`kode_shift`),
  KEY `idx_shift_active` (`is_active`),
  KEY `idx_shift_default` (`is_default`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_shift` */

insert  into `tb_shift`(`id_shift`,`kode_shift`,`nama_shift`,`jam_masuk`,`jam_keluar`,`toleransi_menit`,`lintas_tengah_malam`,`is_default`,`is_active`,`created_at`,`updated_at`) values 
(1,'DEFAULT','Normal (08:00 - 17:00)','08:00:00','17:00:00',15,0,1,1,'2026-05-11 10:32:24','2026-05-11 10:32:24'),
(2,'NORMAL_SABTU','Normal Sabtu','08:00:00','12:00:00',15,0,0,1,'2026-05-11 13:54:22','2026-05-11 13:54:22');

/*Table structure for table `tb_users` */

DROP TABLE IF EXISTS `tb_users`;

CREATE TABLE `tb_users` (
  `id_user` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(50) NOT NULL,
  `password_hash` varchar(255) NOT NULL,
  `nama_lengkap` varchar(100) NOT NULL,
  `role` enum('SUPERADMIN','ADMIN_PAYROLL','VIEWER') NOT NULL DEFAULT 'ADMIN_PAYROLL',
  `is_active` tinyint(1) NOT NULL DEFAULT 1,
  `last_login` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id_user`),
  UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

/*Data for the table `tb_users` */

insert  into `tb_users`(`id_user`,`username`,`password_hash`,`nama_lengkap`,`role`,`is_active`,`last_login`,`created_at`,`updated_at`) values 
(1,'superadmin','$2y$10$QuUpzlVAipvCabax7Mbl6u2dVslUdu93Oj8TIdnv60Z0ZpnGxW4KO','Super Admin','SUPERADMIN',1,'2026-05-20 07:43:15','2026-05-06 19:18:50','2026-05-20 12:43:15'),
(2,'admin','$2y$10$QuUpzlVAipvCabax7Mbl6u2dVslUdu93Oj8TIdnv60Z0ZpnGxW4KO','Admin Payroll','ADMIN_PAYROLL',1,'2026-05-19 07:26:06','2026-05-06 19:18:50','2026-05-19 12:26:06');

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
