-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `event_management`
--

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

--
-- Table structure for table `company_car`
--

CREATE TABLE `company_car` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `car_model` varchar(255) NOT NULL,
  `date` date NOT NULL,
  `pickup_time` time NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `company_car`
--

INSERT INTO `company_car` (`id`, `name`, `car_model`, `date`, `pickup_time`) VALUES
(1, 'nurul', 'fortuner', '2025-03-23', '02:48:00'),
(2, 'adlina', 'fortuner', '2025-03-23', '03:55:00'),
(3, 'adlina', 'fortuner', '2025-03-24', '15:19:00'),
(4, 'amira', 'fortuner', '2025-04-03', '11:13:00'),
(5, 'nurul', 'fortuner', '2025-04-03', '11:13:00');

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

--
-- Table structure for table `events`
--

CREATE TABLE `events` (
  `id` int(11) NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `date_from` date DEFAULT NULL,
  `date_until` date DEFAULT NULL,
  `time` time DEFAULT NULL,
  `details` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `events`
--

INSERT INTO `events` (`id`, `name`, `date_from`, `date_until`, `time`, `details`) VALUES
(1, 'campaign', '2025-04-15', '2025-04-15', '09:00:00', 'campaign');

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

--
-- Table structure for table `event_tasks`
--

CREATE TABLE `event_tasks` (
  `id` int(11) NOT NULL,
  `event_id` int(11) DEFAULT NULL,
  `staff_name` varchar(255) DEFAULT NULL,
  `task` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `event_tasks`
--

INSERT INTO `event_tasks` (`id`, `event_id`, `staff_name`, `task`) VALUES
(1, 1, 'amira', 'pendaftaran');

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

--
-- Table structure for table `leave_requests`
--

CREATE TABLE `leave_requests` (
  `id` int(11) NOT NULL,
  `user_id` int(11) DEFAULT NULL,
  `leave_date_start` date DEFAULT NULL,
  `leave_date_end` date DEFAULT NULL,
  `reason` text DEFAULT NULL,
  `status` enum('Pending','Approved by Leader','Rejected by Leader','Approved','Rejected') DEFAULT 'Pending',
  `leader_approval_by` int(11) DEFAULT NULL,
  `leader_approval_date` datetime DEFAULT NULL,
  `boss_approval_by` int(11) DEFAULT NULL,
  `boss_approval_date` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `leave_requests`
--

INSERT INTO `leave_requests` (`id`, `user_id`, `leave_date_start`, `leave_date_end`, `reason`, `status`, `leader_approval_by`, `leader_approval_date`, `boss_approval_by`, `boss_approval_date`) VALUES
(1, NULL, '2025-04-13', '2025-04-14', 'sick', 'Pending', NULL, NULL, NULL, NULL),
(2, 1, '2025-04-14', '2025-04-14', 'sick', 'Pending', NULL, NULL, NULL, NULL),
(3, 1, '2025-04-15', '2025-04-17', 'appointment dr', 'Pending', NULL, NULL, NULL, NULL),
(4, 1, '2025-04-15', '2025-04-17', 'appointment dr', 'Pending', NULL, NULL, NULL, NULL),
(5, 1, '2025-04-14', '2025-04-17', 'appointment', 'Pending', NULL, NULL, NULL, NULL),
(6, 1, '2025-04-14', '2025-04-17', 'appointment', 'Pending', NULL, NULL, NULL, NULL),
(7, 1, '2025-04-14', '2025-04-17', 'appointment', 'Pending', NULL, NULL, NULL, NULL),
(8, 1, '2025-04-14', '2025-04-17', 'appointment', 'Pending', NULL, NULL, NULL, NULL);

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

--
-- Table structure for table `meeting_room`
--

CREATE TABLE `meeting_room` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `date` date NOT NULL,
  `time` time NOT NULL,
  `reason` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `meeting_room`
--

INSERT INTO `meeting_room` (`id`, `name`, `date`, `time`, `reason`) VALUES
(1, 'nurul', '2025-03-23', '02:39:00', 'meeting'),
(2, 'adlina', '2025-03-23', '03:37:00', 'meeting'),
(3, 'adlina', '2025-03-23', '05:49:00', 'meeting'),
(4, 'adlina', '2025-03-24', '14:06:00', 'meeting'),
(5, 'amira', '2025-04-03', '13:12:00', 'meeting');

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

--
-- Table structure for table `profiles`
--

CREATE TABLE `profiles` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `department` varchar(50) DEFAULT NULL,
  `position` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `profiles`
--

INSERT INTO `profiles` (`id`, `user_id`, `phone`, `department`, `position`) VALUES
(1, 1, '0123456789', 'ENFORCEMENT', 'INTERN');

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

--
-- Table structure for table `staff_exit`
--

CREATE TABLE `staff_exit` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
  `date` date NOT NULL,
  `time` time NOT NULL,
  `location` varchar(255) DEFAULT NULL,
  `reason` text NOT NULL,
  `return_time` time DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `staff_exit`
--

INSERT INTO `staff_exit` (`id`, `name`, `date`, `time`, `location`, `reason`, `return_time`) VALUES
(2, 'adlina', '2025-03-22', '14:30:00', NULL, 'out', NULL),
(3, 'adlina', '2025-03-22', '14:38:00', NULL, 'out', NULL),
(4, 'adlina', '2025-03-15', '14:44:00', NULL, 'out', NULL),
(5, 'nurul', '2025-03-22', '10:51:00', NULL, 'out', NULL),
(6, 'nurul', '2025-03-22', '21:56:00', NULL, 'out', NULL),
(7, 'adlina', '2025-03-15', '21:58:00', NULL, 'out', NULL),
(8, 'adlina', '2025-03-22', '22:08:00', NULL, 'out', NULL),
(9, 'AA', '2025-03-22', '22:29:00', NULL, 'OUT', NULL),
(10, 'aa', '2025-03-22', '22:33:00', NULL, 'out', NULL),
(11, 'bb', '2025-03-22', '22:38:00', NULL, 'out', NULL),
(12, 'ss', '2025-03-15', '22:42:00', NULL, 'out', NULL),
(13, 'aa', '2025-03-16', '22:47:00', NULL, 'out', NULL),
(14, 'hg', '2025-03-22', '22:55:00', NULL, 'out', NULL),
(15, 'adlina', '2025-03-22', '23:12:00', NULL, 'out', NULL),
(16, 'adlina', '2025-03-22', '23:18:00', NULL, 'meeting', NULL),
(17, 'adlina', '2025-03-16', '00:34:00', NULL, 'out', NULL),
(18, 'aa', '2025-03-16', '00:58:00', NULL, 'out', NULL),
(19, 'adlina', '2025-03-16', '01:04:00', NULL, 'out', NULL),
(20, 'adlina', '2025-03-16', '01:53:00', NULL, 'out', NULL),
(21, 'adlina', '2025-03-17', '01:18:00', NULL, 'out for sps', NULL),
(22, 'adlina', '2025-03-17', '01:25:00', NULL, 'meeting', NULL),
(24, 'adlina', '2025-03-17', '01:38:00', NULL, 'meeting', NULL),
(25, 'adlina', '2025-03-17', '01:53:00', NULL, 'out', NULL),
(26, 'adlina', '2025-03-18', '08:42:00', NULL, 'out', NULL),
(27, 'adlina', '2025-03-18', '16:25:00', NULL, 'out', NULL),
(28, 'nurul', '2025-03-19', '16:26:00', NULL, 'out', NULL),
(29, 'adlina', '2025-03-23', '02:18:00', NULL, 'out', NULL),
(30, 'adlina', '2025-03-23', '03:32:00', NULL, 'out', NULL),
(31, 'nurul', '2025-03-23', '08:54:00', NULL, 'out', NULL),
(32, 'nurul', '2025-03-24', '00:47:00', NULL, 'emergency', NULL),
(33, 'athirah', '2025-03-24', '12:13:00', NULL, 'operasi', NULL),
(34, 'adlina', '2025-03-25', '12:13:00', NULL, 'MEETING', NULL),
(35, 'NURUL', '2025-03-25', '13:08:00', NULL, 'operasi', NULL),
(36, 'athirah', '2025-03-25', '14:59:00', NULL, 'ops', NULL),
(37, 'adlina', '2025-03-25', '15:42:00', NULL, 'MEETING', NULL),
(38, 'athirah', '2025-03-30', '02:44:00', NULL, 'operasi', NULL),
(39, 'athirah', '2025-03-30', '02:55:00', 'Taman Mutiara, Kulim, Kedah, Malaysia', 'operasi', NULL),
(40, 'nurul', '2025-04-02', '08:49:00', 'Anakku, Jalan Kemuning 1, Taman Seraya Indah II, Kulim, Kedah, 09000, Malaysia', 'emergency', NULL),
(41, 'amira', '2025-04-03', '10:11:00', 'Anakku, Jalan Kemuning 1, Taman Seraya Indah II, Kulim, Kedah, 09000, Malaysia', 'ops', NULL),
(42, 'hamim', '2025-04-08', '12:12:00', 'Anakku, Jalan Kemuning 1, Taman Seraya Indah II, Kulim, Kedah, 09000, Malaysia', 'operasi', NULL),
(43, 'aisyah', '2025-04-12', '16:11:00', 'Jalan Raja, Kuala Lumpur, 50050, Malaysia', 'jemaah doktor', NULL),
(44, 'aisyah', '2025-04-13', '21:24:00', 'Taman Mutiara, Kulim, Kedah, Malaysia', 'operasi', NULL),
(45, 'athirah', '2025-04-15', '04:49:00', 'Jalan Raja, Kuala Lumpur, 50050, Malaysia', 'operasi ops cegah', NULL),
(46, 'aisyah', '2025-04-15', '15:32:00', 'Jalan Raja, Kuala Lumpur, 50050, Malaysia', 'ops', NULL);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `company_car`
--
ALTER TABLE `company_car`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `events`
--
ALTER TABLE `events`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `event_tasks`
--
ALTER TABLE `event_tasks`
  ADD PRIMARY KEY (`id`),
  ADD KEY `event_id` (`event_id`);

--
-- Indexes for table `leave_requests`
--
ALTER TABLE `leave_requests`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `leader_approval_by` (`leader_approval_by`),
  ADD KEY `boss_approval_by` (`boss_approval_by`);

--
-- Indexes for table `meeting_room`
--
ALTER TABLE `meeting_room`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `profiles`
--
ALTER TABLE `profiles`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indexes for table `staff_exit`
--
ALTER TABLE `staff_exit`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

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

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

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

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

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

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `event_tasks`
--
ALTER TABLE `event_tasks`
  ADD CONSTRAINT `event_tasks_ibfk_1` FOREIGN KEY (`event_id`) REFERENCES `events` (`id`);

--
-- Constraints for table `leave_requests`
--
ALTER TABLE `leave_requests`
  ADD CONSTRAINT `leave_requests_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `leave_requests_ibfk_2` FOREIGN KEY (`leader_approval_by`) REFERENCES `users` (`id`),
  ADD CONSTRAINT `leave_requests_ibfk_3` FOREIGN KEY (`boss_approval_by`) REFERENCES `users` (`id`);

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

