-- --------------------------------------------------------
-- Host:                         127.0.0.1
-- Server version:               10.4.21-MariaDB - mariadb.org binary distribution
-- Server OS:                    Win64
-- HeidiSQL Version:             11.3.0.6295
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */
;

/*!40101 SET NAMES utf8 */
;

/*!50503 SET NAMES utf8mb4 */
;

/*!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 */
;

DROP TABLE IF EXISTS `al_roster_overtime_cpl`;

CREATE TABLE IF NOT EXISTS `al_roster_overtime_cpl` (
	`id` int(11) NOT NULL AUTO_INCREMENT,
	`cpl` int(11) DEFAULT NULL,
	`overtime` int(11) DEFAULT NULL,
	`approved_hours` int(11) DEFAULT NULL,
	`discard_hours` int(11) DEFAULT NULL,
	`emp_id` int(9) unsigned NOT NULL,
	`client_id` int(11) DEFAULT NULL,
	`created_at` date DEFAULT NULL,
	`created_by` int(11) DEFAULT NULL,
	`deleted_at` date DEFAULT NULL,
	`deleted_by` int(11) DEFAULT 0,
	`modified_by` int(11) DEFAULT NULL,
	`modified_at` date DEFAULT NULL,
	PRIMARY KEY (`id`),
	KEY `FK_al_roster_overtime_cpl_proll_employee` (`emp_id`),
	CONSTRAINT `FK_al_roster_overtime_cpl_proll_employee` FOREIGN KEY (`emp_id`) REFERENCES `proll_employee` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = InnoDB AUTO_INCREMENT = 4 DEFAULT CHARSET = UTF8MB4;

CREATE TABLE IF NOT EXISTS `al_roster_overtime_cpl_log` (
	`id` int(11) NOT NULL AUTO_INCREMENT,
	`emp_id` int(9) unsigned NOT NULL,
	`overtime` int(11) DEFAULT NULL,
	`cpl` int(11) DEFAULT NULL,
	`payment_for_overtime` int(11) NOT NULL DEFAULT 0,
	`duration` enum('Daily', 'Weekly', 'Monthly', 'Custom') DEFAULT NULL,
	`source` enum('CronJob', 'LM') DEFAULT NULL,
	`al_ros` int(11) NOT NULL,
	`start_date` date DEFAULT NULL,
	`end_date` date DEFAULT NULL,
	`created_at` datetime DEFAULT NULL,
	`created_by` int(11) NOT NULL DEFAULT 0,
	`reason` varchar(50) DEFAULT NULL,
	PRIMARY KEY (`id`),
	KEY `FK_al_roster_overtime_cpl_log_proll_employee` (`emp_id`),
	KEY `FK_al_roster_overtime_cpl_log_al_roster_overtime_cpl` (`al_ros`),
	CONSTRAINT `FK_al_roster_overtime_cpl_log_al_roster_overtime_cpl` FOREIGN KEY (`al_ros`) REFERENCES `al_roster_overtime_cpl` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
	CONSTRAINT `FK_al_roster_overtime_cpl_log_proll_employee` FOREIGN KEY (`emp_id`) REFERENCES `proll_employee` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = InnoDB AUTO_INCREMENT = 139 DEFAULT CHARSET = LATIN1;

/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */
;

/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */
;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */
;

/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */
;