CREATE TABLE `date_to_pay_current` (
  `serial_dts` INT NOT NULL,
  `serial_scy` INT NULL,
  `month_to_pay_dts` DATE NULL,
  `start_date_dts` DATE NULL,
  `end_date_dts` DATE NULL,
  `month_to_check_paid_dts` DATE NULL,
  `status_dts` ENUM('ACTIVE', 'INACTIVE') NULL,
  PRIMARY KEY (`serial_dts`),
  INDEX `fk_dts_scy_idx` (`serial_scy` ASC),
  CONSTRAINT `fk_dts_scy`
    FOREIGN KEY (`serial_scy`)
    REFERENCES `school_year` (`serial_scy`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION);

ALTER TABLE `date_to_pay_current` 
RENAME TO  `date_to_current_payments` ;

ALTER TABLE `date_to_current_payments` 
RENAME TO  `dates_to_current_payments` ;

ALTER TABLE `dates_to_current_payments` 
CHANGE COLUMN `serial_dts` `serial_dts` INT(11) NOT NULL AUTO_INCREMENT ;


INSERT INTO `dates_to_current_payments` (`serial_scy`, `month_to_pay_dts`, `start_date_dts`, `end_date_dts`, `month_to_check_paid_dts`, `status_dts`) VALUES ('10', '2021-04-01', '2021-03-20', '2020-04-08', '2021-03-01', 'ACTIVE');

CREATE TABLE `student_current_deferred_dates_to_pay_payment_concep` (
  `serial_scr` INT NOT NULL AUTO_INCREMENT,
  `serial_std` INT NULL,
  `serial_dts` INT NULL,
  `serial_ypc` INT NULL,
  `status_scd` ENUM('ACTIVE', 'INACTIVE') NULL,
  PRIMARY KEY (`serial_scr`),
  INDEX `fk_scd_dts_idx` (`serial_std` ASC),
  INDEX `fk_scd_dts_idx1` (`serial_dts` ASC),
  INDEX `fk_scd_ypc_idx` (`serial_ypc` ASC),
  CONSTRAINT `fk_scd_std`
    FOREIGN KEY (`serial_std`)
    REFERENCES `student` (`serial_std`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_scd_dts`
    FOREIGN KEY (`serial_dts`)
    REFERENCES `dates_to_current_payments` (`serial_dts`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_scd_ypc`
    FOREIGN KEY (`serial_ypc`)
    REFERENCES `year_level_specialty_payment_concept` (`serial_ypc`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION);
	
	ALTER TABLE `student_current_deferred_dates_to_pay_payment_concep` 
RENAME TO  `student_current_deferred_dates_to_pay_payment_concept` ;

ALTER TABLE `student_current_deferred_dates_to_pay_payment_concept` 
ADD COLUMN `created_at` DATETIME NULL AFTER `status_scd`,
ADD COLUMN `updated_at` DATETIME NULL AFTER `created_at`;

ALTER TABLE `student_current_deferred_dates_to_pay_payment_concept` 
CHANGE COLUMN `status_scd` `status_scr` ENUM('ACTIVE', 'INACTIVE') NULL DEFAULT NULL ;

INSERT INTO `payment_button` (`serial_pbn`, `serial_crr`, `merchant_name_pbn`, `service_pbn`, `path_logo`, `url_web_page_bank`, `path_terms_conditions`, `info_pbn`, `vpos_url_pbn`, `url_return`, `login`, `trankey`, `type_pbn`, `partner_pbn`) VALUES ('18', '47', 'U.E. Tomas Moro - Sitio web - Corriente 1 de 10', 'RUBROS ACADEMICOS CORRIENTE', 'img/payment_button/placetopaylogoae.png', 'https://placetopay.ec/', 'files/TCUETM.txt', '<h4>Placetopay</h>', 'https://test.placetopay.ec/redirection/', 'https://learnbox.tomasmoro.k12.ec/learnbox/modules/registration_process_wizard/payment_buttons/placetopay/fReturn', '3fa7434289f4b95fe1235ed5614dc783', 'zJ4A1Gby5I46zC61', 'WALLET_P2P', 'Placetopay');

ALTER TABLE `group_payment_button` 
CHANGE COLUMN `type_gpb` `type_gpb` ENUM('currentDefered', 'current', 'register', 'CURRENTPAYMENTS') NULL DEFAULT 'currentDefered' ;

INSERT INTO `group_payment_button` (`serial_gpb`, `serial_pcg`, `serial_pbn`, `serial_pmw`, `type_gpb`, `status_gpb`) VALUES ('11', '1', '18', '2', 'CURRENTPAYMENTS', 'ACTIVE');

ALTER TABLE `level_section_year` 
ADD COLUMN `virtual_lsy` ENUM('YES', 'NO') NULL DEFAULT 'NO' AFTER `extracurricular_available_for_parents`;


ALTER TABLE `student_current_deferred_dates_to_pay_payment_concept` 
ADD COLUMN `serial_cdf` INT NULL AFTER `serial_ypc`,
ADD INDEX `fk_scd_cdf_idx` (`serial_cdf` ASC);
ALTER TABLE `student_current_deferred_dates_to_pay_payment_concept` 
ADD CONSTRAINT `fk_scd_cdf`
  FOREIGN KEY (`serial_cdf`)
  REFERENCES `current_deferred` (`serial_cdf`)
  ON DELETE NO ACTION
  ON UPDATE NO ACTION;


insert into year_level_specialty_payment_concept_tax_invoice select  null as serial_ylt, serial_ypc, 1 as serial_txn, 'ACTIVE' as status_ylt from year_level_specialty_payment_concept where serial_scy=10 and type_payment_concept_ypc='TRANSPORT';


ALTER TABLE `current_deferred` 
ADD COLUMN `id_cdf` VARCHAR(200) NULL AFTER `last_digits_card_cdf`;


ALTER TABLE `current_deferred` 
CHANGE COLUMN `id_cdf` `document_cdf` VARCHAR(200) NULL DEFAULT NULL ;

CREATE TABLE `travel_payment_concept` (
  `serial_tpc` INT NOT NULL AUTO_INCREMENT,
  `serial_trv` INT NULL,
  `serial_pct` INT NULL,
  `status_tpc` ENUM('ACTIVE', 'INACTIVE') NULL,
  PRIMARY KEY (`serial_tpc`),
  INDEX `rk_tpc_trv_idx` (`serial_trv` ASC),
  INDEX `fk_tpc_pct_idx` (`serial_pct` ASC),
  CONSTRAINT `fk_tpc_trv`
    FOREIGN KEY (`serial_trv`)
    REFERENCES `travel` (`serial_trv`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_tpc_pct`
    FOREIGN KEY (`serial_pct`)
    REFERENCES `payment_concept` (`serial_pct`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION);


ALTER TABLE `travel_payment_concept` 
ADD COLUMN `created_at` DATETIME NULL AFTER `status_tpc`,
ADD COLUMN `updated_at` DATETIME NULL AFTER `created_at`;

INSERT INTO `process` (`serial_prc`, `prc_serial_prc`, `name_prc`, `link_prc`, `weight_prc`, `status_prc`) VALUES ('810', '156', 'Pago de transporte', 'laravel/public/currentpayments', '135.6', 'LOCKABLE');

insert into allowed_pages_by_process values(810,'currentpayementscontroller@getindex');
insert into allowed_pages_by_process values(810,'currentpayementscontroller@posttotal');
insert into allowed_pages_by_process values(810,'currentpayementscontroller@postpayemtnbuttons');
insert into allowed_pages_by_process values(810,'currentpayementscontroller@postcreatcurrentdeferred');
insert into allowed_pages_by_process values(810,'currentpayementscontroller@getreturn');
insert into allowed_pages_by_process values(810,'currentpayementscontroller@gethistory');
insert into allowed_pages_by_process values(810,'currentpayementscontroller@getreceipt');
insert into allowed_pages_by_process values(810,'currentpayementscontroller@getnotification');

ALTER TABLE `payment_method` 
ADD COLUMN `name_acount_pym` VARCHAR(200) NULL AFTER `status_pym`,
ADD COLUMN `acount_type_pym` VARCHAR(45) NULL AFTER `name_acount_pym`,
ADD COLUMN `acount_number_pym` VARCHAR(45) NULL AFTER `acount_type_pym`,
ADD COLUMN `acount_ruc_pym` VARCHAR(45) NULL AFTER `acount_number_pym`;
ALTER TABLE `payment_method` 
ADD COLUMN `acount_banck_pym` VARCHAR(45) NULL AFTER `acount_ruc_pym`;

INSERT INTO `payment_method` (`serial_pym`, `serial_ptm`, `name_pym`, `requires_owner_info_pym`, `requires_financial_pym`, `requires_credit_card_pym`, `avalible_preaproved_pym`, `status_pym`, `name_acount_pym`, `acount_type_pym`, `acount_number_pym`, `acount_ruc_pym`, `acount_banck_pym`) VALUES (NULL, '3', 'Transferencia', 'YES', 'NO', 'NO', 'NO', 'ACTIVE', 'UNIDAD EDUCATIVA TOMAS MORO', 'CUENTA CORRIENTE', 'No: 3421017104', 'RUC:1791862864001', 'BANCO PICHINCHA');
UPDATE `payment_method` SET `acount_number_pym`='3421017104', `acount_ruc_pym`='1791862864001', `acount_banck_pym`='PICHINCHA' WHERE `serial_pym`='26';
UPDATE `payment_method` SET `acount_type_pym`='CORRIENTE' WHERE `serial_pym`='26';
UPDATE `payment_method` SET `type_pym`='TRANSFER' WHERE `serial_pym`='26';

insert into allowed_pages_by_process values(717,'paymentmanagecontroller@postsendmailtoguardians');

ALTER TABLE `payment_detail_total_invoice` 
CHANGE COLUMN `comment_pdt` `comment_pdt` TEXT NULL AFTER `description_pdt`;