CREATE TABLE `course_employee` (
`serial_cem` INT NOT NULL AUTO_INCREMENT,
  `serial_emp` INT NOT NULL,
  `serial_crs` INT NOT NULL,
  `employee_type` ENUM('INSPECTOR','COURSE_AUXILIAR') NULL,
  `status_cem` ENUM('ACTIVE','INACTIVE') NULL,  
  PRIMARY KEY (`serial_cem`),
  CONSTRAINT `fk_serial_emp_cem`
    FOREIGN KEY (`serial_emp`)
    REFERENCES `employee` (`serial_emp`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_serial_crs_cem`
    FOREIGN KEY (`serial_crs`)
    REFERENCES `course` (`serial_crs`)
   );


ALTER TABLE `attendance` 
CHANGE COLUMN `type_ace` `type_ace` ENUM('UNEXCUSED_ABSENCE','EXCUSED_ABSENCE','DELAY','ESCAPE','PERMISSION') NOT NULL ,
ADD COLUMN `permission` TINYINT(1) NULL AFTER `status_ace`,
ADD COLUMN `observation` VARCHAR(200) NULL AFTER `permission`,
ADD COLUMN `review` VARCHAR(200) NULL AFTER `observation`;
ADD COLUMN `serial_usr` INT NULL AFTER `review`,
ADD CONSTRAINT `fk_serial_usr_ace`
  FOREIGN KEY (`serial_usr`)
  REFERENCES `user` (`serial_usr`)
;


ALTER TABLE `attendance` 
ADD COLUMN `serial_usr` INT NULL AFTER `review`,
ADD INDEX `fk_serial_usr_ace_idx` (`serial_usr` ASC);
ALTER TABLE `attendance` 
ADD CONSTRAINT `fk_serial_usr_ace`
  FOREIGN KEY (`serial_usr`)
  REFERENCES `user` (`serial_usr`)
;

INSERT INTO `process` (`prc_serial_prc`, `name_prc`, `link_prc`, `weight_prc`, `status_prc`) VALUES ('56', 'Asignar Cursos a Inspector', 'laravel/public/courseemployee/create-inspector', '65.01', 'LOCKABLE');
INSERT INTO `process` (`prc_serial_prc`, `name_prc`, `link_prc`, `weight_prc`, `status_prc`) VALUES ('56', 'Asignar Cursos a Auxiliar de Curso', 'laravel/public/courseemployee/create-auxiliar', '65.02', 'LOCKABLE');
INSERT INTO `process` (`prc_serial_prc`, `name_prc`, `link_prc`, `weight_prc`, `status_prc`) VALUES ('365', 'Ver historial de estudiante', 'laravel/public/attendance/index', '2.01', 'LOCKABLE');
INSERT INTO `process` (`prc_serial_prc`, `name_prc`, `link_prc`, `weight_prc`, `status_prc`) VALUES ('39', 'Calendario', 'laravel/public/calendar/index', '211.10', 'LOCKABLE');
INSERT INTO `process` (`serial_prc`, `prc_serial_prc`, `name_prc`, `link_prc`, `weight_prc`, `status_prc`) VALUES ('', '307', 'Cargar desde Excel', 'laravel/public/schedule/index', '212.01', 'LOCKABLE');allowed_pages_by_process
INSERT INTO `process` (`prc_serial_prc`, `name_prc`, `link_prc`, `weight_prc`, `status_prc`) VALUES ('365', 'Leccionario', 'laravel/public/lectionary/index', '2.01', 'LOCKABLE');

//allowed_pages_by_process cambiar 398 por el codigo asignado al proceso 'Calendario', 'laravel/public/calendar/index'
insert into allowed_pages_by_process values(398,'datedayconfigurationcontroller@getindex');
insert into allowed_pages_by_process values(398,'datedayconfigurationcontroller@getcreate');
insert into allowed_pages_by_process values(398,'datedayconfigurationcontroller@postconfigurationbyday');
insert into allowed_pages_by_process values(398,'datedayconfigurationcontroller@getupdate');
insert into allowed_pages_by_process values(398,'datedayconfigurationcontroller@postcreate');
insert into allowed_pages_by_process values(398,'datedayconfigurationcontroller@getdatesfromrange');
insert into allowed_pages_by_process values(398,'datedayconfigurationcontroller@postdayupdateconfiguration');
insert into allowed_pages_by_process values(398,'datedayconfigurationcontroller@postyearconfiguration');

//allowed_pages_by_process cambiar 403 por el codigo asignado al proceso 'Ver historial de estudiante', 'laravel/public/attendance/index'
insert into allowed_pages_by_process values(398,'attendancecontroller@getindex');
insert into allowed_pages_by_process values(398,'attendancecontroller@getstudents');
insert into allowed_pages_by_process values(398,'attendancecontroller@postperiods');
insert into allowed_pages_by_process values(398,'attendancecontroller@postperiods');
insert into allowed_pages_by_process values(398,'attendancecontroller@postdatesperiod');
insert into allowed_pages_by_process values(398,'attendancecontroller@postsubperiodsbyperiod');
insert into allowed_pages_by_process values(398,'attendancecontroller@postdatessubperiod');
insert into allowed_pages_by_process values(398,'attendancecontroller@poststudentsattendancerecord');


//allowed_pages_by_process cambiar 402 por el codigo asignado al proceso 'Asignar Cursos a Auxiliar de Curso', 'laravel/public/courseemployee/create-auxiliar'
insert into allowed_pages_by_process values(402,'coureseEmloyeecontroller@getcreateauxiliar');
insert into allowed_pages_by_process values(402,'coureseEmloyeecontroller@postsections');
insert into allowed_pages_by_process values(402,'coureseEmloyeecontroller@postlevels');
insert into allowed_pages_by_process values(402,'coureseEmloyeecontroller@getemployees');
insert into allowed_pages_by_process values(402,'coureseEmloyeecontroller@postcoursesbyemployee');
insert into allowed_pages_by_process values(402,'coureseEmloyeecontroller@postcreate');

//allowed_pages_by_process cambiar 401 por el codigo asignado al proceso 'Asignar Cursos a Inspector', 'laravel/public/courseemployee/create-inspector'
insert into allowed_pages_by_process values(401,'coureseEmloyeecontroller@getcreateinspector');
insert into allowed_pages_by_process values(401,'coureseEmloyeecontroller@postsections');
insert into allowed_pages_by_process values(401,'coureseEmloyeecontroller@postlevels');
insert into allowed_pages_by_process values(401,'coureseEmloyeecontroller@getemployees');
insert into allowed_pages_by_process values(401,'coureseEmloyeecontroller@postcoursesbyemployee');
insert into allowed_pages_by_process values(401,'coureseEmloyeecontroller@postcreate');

//allowed_pages_by_process cambiar 404 por el codigo asignado al proceso 'Cargar desde Excel', 'laravel/public/schedule/index'
insert into allowed_pages_by_process values(404,'loadschedulecontroller@getindex');
insert into allowed_pages_by_process values(404,'loadschedulecontroller@postfile');
insert into allowed_pages_by_process values(404,'loadschedulecontroller@postspecialtybyscy');

//allowed_pages_by_process cambiar 407 por el codigo asignado al proceso 'Cargar desde Excel', 'laravel/public/schedule/index'
insert into allowed_pages_by_process values(407,'lectionarycontroller@getindex');
insert into allowed_pages_by_process values(407,'lectionarycontroller@postfullschedule');
insert into allowed_pages_by_process values(407,'lectionarycontroller@postschedulebyversion');
insert into allowed_pages_by_process values(407,'lectionarycontroller@postgetlectionary');
insert into allowed_pages_by_process values(407,'lectionarycontroller@postlectionary');

