ALTER TABLE `travel_attendance`
ADD COLUMN `register_type` ENUM('ONTRACK', 'PPCARNET', 'PPNOCARNET') NULL AFTER `exit_type`,
ADD COLUMN `ontrack_date_register` datetime NULL AFTER `register_type`,
ADD COLUMN `ontrack_file` text NULL AFTER `ontrack_date_register`;

ALTER TABLE `travel_attendance`
ADD COLUMN `serial_usr_register_ontrack` INT NULL AFTER `serial_trs`,
ADD INDEX `fk_tat_usr_ontrack_idx` (`serial_usr_register_ontrack` ASC);

ALTER TABLE `travel_attendance`
ADD CONSTRAINT `fk_tat_usr`
  FOREIGN KEY (`serial_usr_register_ontrack`)
  REFERENCES `user` (`serial_usr`)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION;

ALTER TABLE `travel_attendance`
CHANGE COLUMN `ontrack_file` `ontrack_file` TEXT NULL DEFAULT NULL ;

-- Pantallas ontrack para transporte
INSERT INTO `process` (`serial_prc`, `prc_serial_prc`, `name_prc`, `link_prc`, `weight_prc`, `status_prc`) VALUES ('722', '438', 'Ontrack', '#', '0.99', 'LOCKABLE');
INSERT INTO `process` (`serial_prc`, `prc_serial_prc`, `name_prc`, `link_prc`, `weight_prc`, `status_prc`) VALUES ('725', '722', 'Importar recorridos ontrack', 'laravel/public/ontrack', '1', 'LOCKABLE');
INSERT INTO `process` (`serial_prc`, `prc_serial_prc`, `name_prc`, `link_prc`, `weight_prc`, `status_prc`) VALUES ('723', '722', 'Autorizar Salida/Entrada sin carnet', 'laravel/public/travelattendancewithoutcarnet/exit', '1.50', 'LOCKABLE');
INSERT INTO `process` (`serial_prc`, `prc_serial_prc`, `name_prc`, `link_prc`, `weight_prc`, `status_prc`) VALUES ('724', '722', 'Resumen ontrack', 'laravel/public/ontrackReport', '4.20', 'LOCKABLE');

-- Allowed pages
INSERT INTO allowed_pages_by_process VALUES (725,'ontrackfilemanagecontroller@getindex');
INSERT INTO allowed_pages_by_process VALUES (725,'ontrackfilemanagecontroller@postproccesfile');

INSERT INTO allowed_pages_by_process VALUES (723,'travelattendancewithoutcarnetcontroller@getexit');
INSERT INTO allowed_pages_by_process VALUES (723,'travelattendancewithoutcarnetcontroller@postexit');
INSERT INTO allowed_pages_by_process VALUES (723,'extracurricularactivitycontroller@getsections');


INSERT INTO allowed_pages_by_process VALUES (724,'ontrackreportcontroller@getindex');
INSERT INTO allowed_pages_by_process VALUES (724,'ontrackreportcontroller@getgeneralreport');
INSERT INTO allowed_pages_by_process VALUES (724,'ontrackreportcontroller@getstudentreport');
INSERT INTO allowed_pages_by_process VALUES (724,'ontrackreportcontroller@postsearchstudent');

SET SQL_SAFE_UPDATES = 0;
update travel_attendance set register_type='PPCARNET' where date >='2019-09-01' and door_time ; -- and serial_trs in(select serial_trs from travel_student where serial_trv in(400,475,476,477));
SET SQL_SAFE_UPDATES = 1;
insert into allowed_pages_by_process values (723,'travelattendancewithoutcarnetcontroller@postsearchstudent');
insert into allowed_pages_by_process values (723,'travelattendancewithoutcarnetcontroller@postsavetravelattendance');