import { Component, Inject, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { PreventiveWorkOrdersActive, PreventiveWorkOrdersActiveResponse } from '../../../../../interfaces/preventive-work-orders-active.interface';
import { lastValueFrom, map, Observable, startWith } from 'rxjs';
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
import { ActivityEmployee, DataDialogFormScheduleActivity, ResponseDataActivityEmployee } from '../../../../../interfaces/personal-managment/employee.interface';
import { ResourcesService, ResponseData } from '../../../../../services/resources.service';
import { EncService } from '../../../../../services/enc.service';
import { EmployeeService } from '../../../../../services/personal-management/employee.service';
import { PreventiveMaintenanceService } from '../../../../../services/preventive-maintenance.service';
import { validColorValidator } from 'ngx-colors';
import { HttpErrorResponse } from '@angular/common/http';
import { CustomRepeatComponent } from '../../../../preventive-maintenance/work-orders/custom-repeat/custom-repeat.component';
import { ClockSelectComponent } from '../../../../resources/clock-select/clock-select.component';
import { AlertComponent } from '../../../../resources/dialogs/alert/alert.component';

@Component({
    selector: 'app-form-schedule-activity',
    templateUrl: './form-schedule-activity.component.html',
    styleUrl: './form-schedule-activity.component.css',
    standalone: false
})
export class FormScheduleActivityComponent implements OnInit {
  public titleForm: string;
  public typeForm!: 'REG' | 'UPD';
  public isLoading: boolean;
  public isLoadingForm: boolean;
  public isLoadingMaintenance: boolean;
  public formGroup: FormGroup;

  public idEmployee: string;
  public idActivity: string;

  public arrPreventiveMaintenance: Array<PreventiveWorkOrdersActive>;
  public preventiveMaintenanceStr: Array<string>;
  public arrCorrectiveMaintenance: Array<any>;
  public correctiveMaintenanceStr: Array<string>;
  
  public filteredMaintenance!: Observable<Array<string>>;

  public arrTypeActivity: Array<{type:string,activity:string}>;
  public hintPernsonality: string;

  constructor(
    @Inject(MAT_DIALOG_DATA) public dataDialog: DataDialogFormScheduleActivity,
    public resourcesService: ResourcesService,
    private _dialog: MatDialog,
    private _routerRef: MatDialogRef<boolean>,
    private _encService: EncService,
    private _employeeService: EmployeeService,
    private _preventiveMaintenanceService: PreventiveMaintenanceService,
  ) {
    this.titleForm = '';
    this.isLoading = false;
    this.isLoadingForm = false;
    this.isLoadingMaintenance = false;
    this.formGroup = this.createFormGroup();

    this.idEmployee = '';
    this.idActivity = '';

    this.arrPreventiveMaintenance = [];
    this.preventiveMaintenanceStr = [];

    this.arrCorrectiveMaintenance = [];
    this.correctiveMaintenanceStr = [];

    this.arrTypeActivity = [{type:'MC', activity: 'Orden de Mantenimiento Correctivo'},{type:'MP', activity: 'Orden de Mantenimiento Preventivo'},{type:'NA', activity: 'Ninguno'}];
    this.hintPernsonality = '';
  }

  private createFormGroup() {
    return new FormGroup({
      'ACTIVIDAD': new FormControl( { value: '', disabled: false }, Validators.required ),
      'CLASIFICACION': new FormControl( { value: '', disabled: false }, Validators.required ),
      'DESCRIPCION': new FormControl( { value: '', disabled: false }, Validators.required ),
      'TIPO_ACTIVIDAD': new FormControl( { value: '', disabled: false }, Validators.required ),
      'ID_ORDEN': new FormControl( { value: '', disabled: true } ),
      'PERIODICIDAD': new FormControl( { value: '', disabled: true } ),
      'FECHA_INICIO': new FormControl( { value: '', disabled: false }, Validators.required ),
      'HORA_INICIO': new FormControl( { value: '', disabled: false }, Validators.required ),
      'FECHA_FINAL': new FormControl( { value: '', disabled: true }, ),
      'HORA_FINAL': new FormControl( { value: '', disabled: true }, ),
      'PERIODICIDAD_PERSONALIZADA': new FormControl( { value: '', disabled: false }, ),
      'COLOR': new FormControl( { value: 'rgb(79, 195, 255)', disabled: false }, validColorValidator()),
    });
  }
  
  async ngOnInit() {
    this.isLoading = true;    
    await this.getDataDialog();
    this.isLoading = false;

    this.filteredMaintenance = this.formGroup.controls['ID_ORDEN'].valueChanges.pipe(
      startWith(''),
      map((value) => {
        value = value === null || value === undefined ? '' : value;
        const filterValue: string = value.toLowerCase();

        let typeActivity: string = this.formGroup.controls['TIPO_ACTIVIDAD'].value;
        if (typeActivity === 'MP') {
          return this.preventiveMaintenanceStr.filter((element:string) => element.toLowerCase().includes(filterValue) );
        } else if (typeActivity === 'MC') {
          return this.correctiveMaintenanceStr.filter((element:string) => element.toLowerCase().includes(filterValue) );
        } else {
          return [];
        }
      })
    )
    this.formGroup.controls['TIPO_ACTIVIDAD'].valueChanges.subscribe(async (type) => {
      let validate: boolean = this.arrTypeActivity.some((typeActivity) => typeActivity.type ===  type);
      if ( !validate ) {
        return;
      }
      if (type === 'NA') {
        this.formGroup.controls['ID_ORDEN'].disable();
        this.formGroup.controls['ID_ORDEN'].clearValidators();
          
        this.formGroup.updateValueAndValidity();

        let dateStart = this.formGroup.controls['FECHA_INICIO'].value;
        if (dateStart !== null && dateStart !== undefined && dateStart !== '') {
          this.formGroup.controls['PERIODICIDAD'].enable();
        }
      } else {
        this.formGroup.controls['ID_ORDEN'].enable();
        this.formGroup.controls['ID_ORDEN'].addValidators(Validators.required);
        this.formGroup.controls['PERIODICIDAD'].disable();
        this.formGroup.controls['PERIODICIDAD'].clearValidators();
        this.formGroup.updateValueAndValidity();

        if (type === 'MP' && this.arrPreventiveMaintenance.length === 0 && this.preventiveMaintenanceStr.length === 0) {
          await this.getPreventiveMaintenance();
        } else if (type === 'MC ') {
          this.resourcesService.openSnackBar(`Falta implementación de módulo de mantenimiento correctivo`);
        }
      }
    });
    this.formGroup.controls['FECHA_INICIO'].valueChanges.subscribe((date) => {
      if ( typeof date === 'string' || date === null || date === undefined) {
        return;
      }

      let typeActivityForm = this.formGroup.controls['TIPO_ACTIVIDAD'].value;
      let validate: boolean = this.arrTypeActivity.some((typeActivity) => typeActivity.type === typeActivityForm);
      if ( validate ) {
        this.formGroup.controls['PERIODICIDAD'].enable();
        this.formGroup.controls['PERIODICIDAD'].addValidators(Validators.required);
        this.formGroup.updateValueAndValidity();
      }
    
    });
    this.formGroup.controls['PERIODICIDAD'].valueChanges.subscribe((periodicidad) => {
      if (periodicidad === 'PE') {
        this.repeatChanges();
      }
      if (periodicidad === 'NR') {
        this.formGroup.controls['FECHA_FINAL'].enable();
        this.formGroup.controls['FECHA_FINAL'].addValidators(Validators.required);
        this.formGroup.controls['HORA_FINAL'].enable();
        this.formGroup.controls['HORA_FINAL'].addValidators(Validators.required);
        this.formGroup.updateValueAndValidity();
      } else {
        this.formGroup.controls['FECHA_FINAL'].disable();
        this.formGroup.controls['FECHA_FINAL'].clearValidators();
        this.formGroup.controls['FECHA_FINAL'].setValue('');
        this.formGroup.controls['HORA_FINAL'].disable();
        this.formGroup.controls['HORA_FINAL'].clearValidators();
        this.formGroup.controls['HORA_FINAL'].setValue('');
        this.formGroup.updateValueAndValidity();
      }
      
    });


    this.formGroup.controls['COLOR'].valueChanges.subscribe((color) => {
      if (this.formGroup.controls['COLOR'].valid) {
        this.formGroup.controls['COLOR'].setValue(color);
      }
    });
  }

  private async getDataDialog() {
    this.typeForm = this.dataDialog.typeForm;
    this.idEmployee = this.dataDialog.idEmployee;

    if ( this.typeForm === 'REG' ) {
      this.titleForm = 'Registro de Actividad';
    } else if ( this.typeForm === 'UPD' && this.dataDialog.idActivity !== null ) {
      this.titleForm = 'Modificación de Actividad';
      this.idActivity = this.dataDialog.idActivity;
      await this.getDataActivity();
    } else {
      this.resourcesService.openSnackBar(`El tipo de formulario no es válido.`);
      this._routerRef.close(false);
    }
  }

  private async getPreventiveMaintenance() {
    this.isLoadingForm = true;
    this.isLoadingMaintenance = true;
    const idUser:string = this.resourcesService.getUser();
    const line:number = this.resourcesService.getLineNumber();
    await lastValueFrom(this._preventiveMaintenanceService.getActiveWorkOrders(idUser, line)).then(
      (responseData: PreventiveWorkOrdersActiveResponse) => {
        if ( !responseData.error ) {
          this.arrPreventiveMaintenance = responseData.response;          
          this.preventiveMaintenanceStr = responseData.response.map(
            (preventiveWorkOrdersActive:PreventiveWorkOrdersActive) => `#${preventiveWorkOrdersActive.IDORDEN} - ${preventiveWorkOrdersActive.EQUIPAMIENTO}` )
        } else {
          this.resourcesService.openSnackBar(responseData.msg);
        }
      }, async (httpErrorResponse: HttpErrorResponse) => {
        let response = this.resourcesService.checkErrors(httpErrorResponse)
        if (response !== null && response.reload) {
          await this.getPreventiveMaintenance();
        }
      }
    );
    this.isLoadingMaintenance = false;
    this.isLoadingForm = false;
  }

  private repeatChanges(){
    let dateStart = this.formGroup.controls['FECHA_INICIO'].value;
    if (typeof dateStart === 'string' || dateStart === null || dateStart === undefined) {
      this.resourcesService.openSnackBar('Ocurrió un error al obtener la fecha inicial.');
      return;
    }
    
    this._dialog.open(CustomRepeatComponent, {
      data: {
        date: dateStart,
        repeat: null,
      },
      width: '540px',
      disableClose: true,
    }).afterClosed().subscribe(res => {
      if(res != null && res != undefined && res != ""){
        this.customRepeat(res);
      } else {
        this.formGroup.controls['PERIODICIDAD'].setValue('NR');
      }
    })
  }

  private async getDataActivity() {
    this.isLoading = true;
    
    const encActivity: string = await this._encService.encrypt(this.idActivity.toString());
    const USER: string = this.resourcesService.getUser();
    const LINE: number = this.resourcesService.getLineNumber();
    await lastValueFrom(this._employeeService.getScheduleActivitiesByActivity(encActivity, USER, LINE)).then(
      async ( responseData: ResponseDataActivityEmployee ) => {
        if (!responseData.error) {
          
          if (Object.keys(responseData.response).length > 0) {

            let actividad = responseData.response.ACTIVIDAD;
            let descripcion = responseData.response.DESCRIPCION;
            let tipoActividad = responseData.response.TIPO_ACTIVIDAD;
            let clasificacion = responseData.response.CLASIFICACION;

            let idOrden = '';            
            if (
              tipoActividad === 'MP' && 
              responseData.response.ID_ORDEN_PREVENTIVO !== null && responseData.response.ID_ORDEN_PREVENTIVO !== undefined  
            ) {
              await this.getPreventiveMaintenance();
              let orden: string = responseData.response.ID_ORDEN_PREVENTIVO;
              this.formGroup.controls['PERIODICIDAD'].disable();
              this.formGroup.controls['ID_ORDEN'].enable();
              
              let preventiveWorkOrdersActive = this.arrPreventiveMaintenance.find((preventiveWorkOrdersActive: PreventiveWorkOrdersActive) => preventiveWorkOrdersActive.IDORDEN === orden);
              if (preventiveWorkOrdersActive !== undefined) {
                idOrden = `#${preventiveWorkOrdersActive.IDORDEN} - ${preventiveWorkOrdersActive.EQUIPAMIENTO}`;
              } else {
                idOrden = responseData.response.ID_ORDEN_PREVENTIVO;
              }
            } else if (
              tipoActividad === 'MC' && 
              responseData.response.ID_ORDEN_CORRECTIVO !== null && responseData.response.ID_ORDEN_CORRECTIVO !== undefined 
            ) {
              this.formGroup.controls['PERIODICIDAD'].disable();
              this.formGroup.controls['ID_ORDEN'].enable();
              idOrden = responseData.response.ID_ORDEN_CORRECTIVO;
            } else {
              this.formGroup.controls['PERIODICIDAD'].enable();
              if (clasificacion === 'SE' || clasificacion === 'ME' || clasificacion === 'AN' || clasificacion === 'TD') {
                this.showPeriodicity(clasificacion);
                this.formGroup.updateValueAndValidity();
              }
            }
            let periodicidad = responseData.response.PERIODICIDAD;
            if (periodicidad === 'NR') {
              this.formGroup.controls['FECHA_FINAL'].enable();
              this.formGroup.controls['HORA_FINAL'].enable();
            } else {
              this.formGroup.controls['FECHA_FINAL'].disable();
              this.formGroup.controls['HORA_FINAL'].disable();
            }
            let fechaInicio = this.resourcesService.formatStrDateToDate(responseData.response.FECHA_INICIO);
            let horaInicio = responseData.response.HORA_INICIO;
            let fechaFinal = null;
            if (responseData.response.FECHA_FINAL !== null) {  
              fechaFinal = this.resourcesService.formatStrDateToDate(responseData.response.FECHA_FINAL);
            }
            let horaFinal = responseData.response.HORA_FINAL;
            let periodicidadPersonalizada = responseData.response.PERIODICIDAD_PERSONALIZADA;
            let color = responseData.response.COLOR;
            

            this.formGroup.controls['ACTIVIDAD'].setValue(actividad);
            this.formGroup.controls['DESCRIPCION'].setValue(descripcion);
            this.formGroup.controls['TIPO_ACTIVIDAD'].setValue(tipoActividad);
            this.formGroup.controls['CLASIFICACION'].setValue(clasificacion);
            this.formGroup.controls['ID_ORDEN'].setValue(idOrden);
            this.formGroup.controls['PERIODICIDAD'].setValue(periodicidad);
            this.formGroup.controls['FECHA_INICIO'].setValue(fechaInicio);
            this.formGroup.controls['HORA_INICIO'].setValue(horaInicio);
            this.formGroup.controls['FECHA_FINAL'].setValue(fechaFinal);
            this.formGroup.controls['HORA_FINAL'].setValue(horaFinal);
            this.formGroup.controls['PERIODICIDAD_PERSONALIZADA'].setValue(periodicidadPersonalizada);
            this.formGroup.controls['COLOR'].setValue(color);

          }

        } else {
          this.resourcesService.openSnackBar(`${responseData.msg}`);
        }
      }, async (httpErrorResponse: HttpErrorResponse) => {
        let response = this.resourcesService.checkErrors(httpErrorResponse)
        if (response !== null && response.reload) {
          await this.getDataActivity();
        }
      }
    );
    this.isLoading = false;
  }

  private customRepeat(value: string){
    if(value == '') return;
    
    let resObj = JSON.parse(value);
    let repeatEvery = resObj.repeatEvery.split('|');
    let customRepeat = 'Repetir cada ';

    if(repeatEvery[0] != "1"){
      customRepeat += repeatEvery[0];
    }

    switch(repeatEvery[1]){
      case "0": customRepeat += repeatEvery[0] != "1" ? ' días' : ' día'; break;
      case "1": customRepeat += repeatEvery[0] != "1" ? ' semanas' : ' semana'; break;
      case "2": customRepeat += repeatEvery[0] != "1" ? ' meses' : ' mes'; break;
      case "3": customRepeat += repeatEvery[0] != "1" ? ' años' : ' año'; break;
    }

    let days = 0;
    let daysValues = Object.values(resObj.repeatOn);
    let daysStr = '';
    let cont = 0;
    
    daysValues.forEach(val => {
      if(val){
        daysStr += `${this.resourcesService.weekDays[cont]}, `; 
        days++;
      }

      cont++;
    });

    daysStr = daysStr.substring(0, daysStr.length - 2);
    
    if(days > 1){
      customRepeat += ' los días: ';
    }else{
      customRepeat += ' el día: ';
    }

    customRepeat += daysStr;

    let endsAt = resObj.endsAt.split('|');
    if(endsAt[0] == 'O'){
      let dateArr = endsAt[1].split('-').reverse();
      customRepeat += '. Finaliza el ' + dateArr[0] + ' de ' + this.resourcesService.arrMonthLabel[parseInt(dateArr[1])] + ' del ' + dateArr[2] + '.';
    }else if(endsAt[0] == 'A'){
      let after = endsAt[2];
      customRepeat += '. Finaliza después de ' + after + ' repeti';

      if(after == '1'){
        customRepeat += 'ción.';
      }else{
        customRepeat += 'ciones.';
      }
    }
    
    this.hintPernsonality = customRepeat.replace('  ', ' ');
    this.formGroup.controls['PERIODICIDAD_PERSONALIZADA'].setValue(value);
  }

  public showPeriodicity(type: 'SE'|'ME'|'AN'|'TD'):string{
    let periodicity: string = '';
    const dateStart: Date | string = this.formGroup.controls['FECHA_INICIO'].value;
    if (dateStart === null || dateStart === undefined || typeof dateStart === 'string') {
      return '';
    }
    switch(type) {
      case 'SE': 
        let week: number = dateStart.getDay();
        periodicity = this.resourcesService.weekDays[week];
      break;
      case 'ME': 
        let monthlyDate: number = dateStart.getDate();
        periodicity = `${monthlyDate}`;
      break;
      case 'AN': 
        let day: number = dateStart.getDate();
        let mount: number = dateStart.getMonth();
        periodicity = `${day} de ${this.resourcesService.arrMonthLabel[mount]}`;
      break;
      case 'TD': 
        let weekTD: number = dateStart.getDay();
        let dayTD: number = dateStart.getDate();
        let mountTD: number = dateStart.getMonth();
        let yearTD: number = dateStart.getFullYear();
        periodicity = `${this.resourcesService.weekDays[weekTD]} ${dayTD} de ${this.resourcesService.arrMonthLabel[mountTD]} del ${yearTD}`;
      break;
    }
    return periodicity;
  }

  public openClock(typeClock: 'HORA_INICIO' | 'HORA_FINAL') {
    let valueClock = this.formGroup.controls[typeClock].value;
    valueClock = valueClock === null || valueClock === undefined ? '' : valueClock;
    this._dialog.open(ClockSelectComponent, {
      disableClose: true,
      data: valueClock,
    }).afterClosed().subscribe((result) => {
      if (result) {
        this.formGroup.controls[typeClock].setValue(result);
      } 
    })
  }

  public save() {
    let strDescription: string = '';
    if (this.typeForm === 'REG') {
      strDescription = `¿Está seguro de registrar la actividad?`;
    } else if (this.typeForm === 'UPD') {
      strDescription = `¿Está seguro de modificar la actividad?`;
    }

    this._dialog.open(AlertComponent,{
      disableClose: true,
      data: {
        title: `Confirmación`,
        description: strDescription,
        icon: 'warning'
      }
    }).afterClosed().subscribe((result) => {
      if (result && this.typeForm === 'REG') {
        this.registerActivity();
      } else if (result && this.typeForm === 'UPD') {
        this.updateActivity();
      }
    })
  }

  private async registerActivity() {
    const requestDataForm = this.createDataForm();
    if (requestDataForm !== false) {
      await lastValueFrom(this._employeeService.registerActivity(requestDataForm)).then(
        (responseData: ResponseData) => {
          if (!responseData.error) {
            this.resourcesService.openSnackBar(`¡Registro exitoso!`);
            this._routerRef.close(true);          
          } else {
            this.resourcesService.openSnackBar(`${responseData.msg}`);
          }
        }, async (httpErrorResponse: HttpErrorResponse) => {
            let response = this.resourcesService.checkErrors(httpErrorResponse)
            if (response !== null && response.reload) {
              await this.registerActivity();
            }
          }
      );
    }   
  }

  private async updateActivity() {
    const requestDataForm = this.createDataForm();
    if (requestDataForm !== false) {

      const encActivity = await this._encService.encrypt(this.idActivity.toString());
      await lastValueFrom(this._employeeService.updateActivity(requestDataForm, encActivity)).then(
        (responseData: ResponseData) => {
          if (!responseData.error) {
            this.resourcesService.openSnackBar(`¡Modificación exitosa!`);
            this._routerRef.close(true);          
          } else {
            this.resourcesService.openSnackBar(`${responseData.msg}`);
          }
        }, async (httpErrorResponse: HttpErrorResponse) => {
            let response = this.resourcesService.checkErrors(httpErrorResponse)
            if (response !== null && response.reload) {
              await this.updateActivity();
            }
          }
      );
    }
  }

  private createDataForm(): ActivityEmployee | false{

    let actividad = this.formGroup.controls['ACTIVIDAD'].value;
    actividad = actividad.toString().trim();
    let clasificacion = this.formGroup.controls['CLASIFICACION'].value;
    let descripcion = this.formGroup.controls['DESCRIPCION'].value;
    let tipoActividad = this.formGroup.controls['TIPO_ACTIVIDAD'].value;
    let idOrden = this.formGroup.controls['ID_ORDEN'].value;
    idOrden = idOrden === '' || idOrden === undefined ? null : idOrden;
    if (tipoActividad !== 'NA' && idOrden !== null) {
      
      if (!idOrden.includes('-')) {
        this.resourcesService.openSnackBar(`El formato del valor de la orden no es correcto.`);
        return false;
      }

      let arrOrder = idOrden.split('-');
      let strIdOrder = arrOrder[0].trim();

      if (!strIdOrder.includes('#')) {
        this.resourcesService.openSnackBar(`El formato del valor de la orden no es correcto.`);
        return false;
      }

      idOrden = strIdOrder.replace('#', '').trim();

      if (tipoActividad === 'MC') {
        // this.arrCorrectiveMaintenance.some(() => {});

      } else if (tipoActividad === 'MP') {
        let validatePreventive = this.arrPreventiveMaintenance.some(( preventiveWorkOrdersActive:PreventiveWorkOrdersActive ) => preventiveWorkOrdersActive.IDORDEN.toString() === idOrden.toString());
        if (!validatePreventive) {
          this.resourcesService.openSnackBar(`El ID de la orden no se encuentra en la lista de mantenimiento preventivo.`);
          return false;
        } 
      }

    }
    let periodicidad = this.formGroup.controls['PERIODICIDAD'].value;
    periodicidad = periodicidad === '' || periodicidad === undefined ? null : periodicidad;
    let fechaInicio = this.formGroup.controls['FECHA_INICIO'].value;
    let dateStart:Date = fechaInicio;
    
    fechaInicio = `${dateStart.getFullYear()}-${this.resourcesService.arrMonth[dateStart.getMonth()]}-${dateStart.getDate()}`;
    
    let horaInicio = this.formGroup.controls['HORA_INICIO'].value;
    let fechaFinal = this.formGroup.controls['FECHA_FINAL'].value;
    fechaFinal = fechaFinal === '' || fechaFinal === undefined ? null : fechaFinal;
    if (fechaFinal !== null) {
      let dateEnd: Date =fechaFinal;
      fechaFinal = `${dateEnd.getFullYear()}-${this.resourcesService.arrMonth[dateEnd.getMonth()]}-${dateEnd.getDate()}`;
    }

    let horaFinal = this.formGroup.controls['HORA_FINAL'].value;
    horaFinal = horaFinal === '' || horaFinal === undefined ? null : horaFinal;
    let periodicidadPersonalizada = this.formGroup.controls['PERIODICIDAD_PERSONALIZADA'].value;
    let color = this.formGroup.controls['COLOR'].value;

    const dataForm: ActivityEmployee = {
      ID_EMPLEADO: this.idEmployee,
      ACTIVIDAD: actividad,
      CLASIFICACION: clasificacion,
      DESCRIPCION: descripcion,
      TIPO_ACTIVIDAD: tipoActividad,
      ID_ORDEN: idOrden,
      PERIODICIDAD: periodicidad,
      FECHA_INICIO: fechaInicio,
      HORA_INICIO: horaInicio,
      FECHA_FINAL: fechaFinal,
      HORA_FINAL: horaFinal,
      PERIODICIDAD_PERSONALIZADA: periodicidadPersonalizada,
      COLOR: color,
      USUARIO: this.resourcesService.getUser(),
      NUMERO_LINEA: this.resourcesService.getLineNumber(),
    }
    return dataForm;
  }
}
