
CREATE TABLE `recap_financial_institution` (
  `serial_rfi` INT NOT NULL AUTO_INCREMENT,
  `serial_rcp` INT NULL,
  `serial_fin` INT NULL,
  `status_rfi` ENUM('ACTIVE', 'INACTIVE') NULL,
  INDEX `rfi_rcp_idx` (`serial_rcp` ASC),
  INDEX `rfi_fin_idx` (`serial_fin` ASC),
  PRIMARY KEY (`serial_rfi`),
  CONSTRAINT `rfi_rcp`
    FOREIGN KEY (`serial_rcp`)
    REFERENCES `recap` (`serial_rcp`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `rfi_fin`
    FOREIGN KEY (`serial_fin`)
    REFERENCES `financial_institution` (`serial_fin`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION) ENGINE = InnoDB;

	CREATE TABLE `recap_payment_detail` (
  `serial_rpd` INT NOT NULL AUTO_INCREMENT,
  `serial_rcp` INT NULL,
  `serial_pdt` INT NULL,
  `date_rpd` DATE NULL,
  `status_rpd` ENUM('ACTIVE', 'INACTIVE') NULL DEFAULT 'ACTIVE',
  `rejected_rpd` ENUM('YES', 'NO') NULL DEFAULT 'NO',
  `notes_rpd` TEXT NULL,
  PRIMARY KEY (`serial_rpd`),
  INDEX `rpd_rcp_idx` (`serial_rcp` ASC),
  INDEX `rpd_pdt_idx` (`serial_pdt` ASC),
  CONSTRAINT `rpd_rcp`
    FOREIGN KEY (`serial_rcp`)
    REFERENCES `recap` (`serial_rcp`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `rpd_pdt`
    FOREIGN KEY (`serial_pdt`)
    REFERENCES `payment_detail` (`serial_pdt`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)ENGINE = InnoDB;

	
	
ALTER TABLE `recap_payment_detail` 
CHANGE COLUMN `rejected_rpd` `status_recap_rpd` ENUM('PENDING', 'INDICTED', 'REJECTED') CHARACTER SET 'utf8' NULL DEFAULT 'PENDING' ,
ADD COLUMN `payment_date_rpd` DATE NULL AFTER `notes_rpd`,
ADD COLUMN `number_voucher_rpd` VARCHAR(45) NULL AFTER `payment_date_rpd`,
ADD COLUMN `number_ticket_rpd` VARCHAR(45) NULL AFTER `number_voucher_rpd`;

ALTER TABLE `payment_detail` 
DROP FOREIGN KEY `fk_pdt_rcp`;
ALTER TABLE `payment_detail` 
DROP COLUMN `indicted_pdt`,
DROP COLUMN `number_ticket_pdt`,
DROP COLUMN `notes_pdt`,
DROP COLUMN `payment_date_pdt`,
DROP COLUMN `serial_rcp`,
DROP COLUMN `number_voucher_pdt`,
DROP COLUMN `date_voucher_pdt`,
DROP INDEX `fk_pdt_rcp_idx` ;


ALTER TABLE `recap_header` 
CHANGE COLUMN `serial_rch` `serial_rch` INT(11) NOT NULL AUTO_INCREMENT ;


ALTER TABLE `recap` 
ADD COLUMN `date_month_rcp` DATE NULL DEFAULT NULL AFTER `month_rcp`;

ALTER TABLE `recap` 
ADD COLUMN `way_to_pay_rcp` ENUM('CTA', 'REC') NULL DEFAULT NULL AFTER `status_rcp`;

ALTER TABLE `recap` 
ADD COLUMN `block_rcp` ENUM('YES', 'NO') NULL DEFAULT 'NO' AFTER `way_to_pay_rcp`;

INSERT INTO `process` (`serial_prc`, `prc_serial_prc`, `name_prc`, `link_prc`, `weight_prc`, `status_prc`) VALUES ('609', '156', 'Recap', 'laravel/public/recap', '148.00', 'LOCKABLE');
insert into allowed_pages_by_process values('609','recapcontroller@getindex');
insert into allowed_pages_by_process values('609','recapcontroller@postloadcreterecap');
insert into allowed_pages_by_process values('609','recapcontroller@postloadrecapheader');
insert into allowed_pages_by_process values('609','recapcontroller@poststudents');
insert into allowed_pages_by_process values('609','recapcontroller@postsave');
insert into allowed_pages_by_process values('609','recapcontroller@saverecappaymentdetail');
insert into allowed_pages_by_process values('609','recapcontroller@postloadnumberrecap');
insert into allowed_pages_by_process values('609','recapcontroller@postloadrecaps');
insert into allowed_pages_by_process values('609','recapcontroller@geteditrecap');
insert into allowed_pages_by_process values('609','recapcontroller@getaddstudentsrecap');
insert into allowed_pages_by_process values('609','recapcontroller@postaddleststudents');
insert into allowed_pages_by_process values('609','recapcontroller@postsaveeditrecap');
insert into allowed_pages_by_process values('609','recapcontroller@getrecapfile');
insert into allowed_pages_by_process values('609','recapcontroller@postblockrecap');
insert into allowed_pages_by_process values('609','financialinstitutioncontroller@postfinantialinstitution');
insert into allowed_pages_by_process values('609','financialinstitutioncontroller@getcheckpaymentdetail');



