import { Injectable } from '@angular/core';
import { AuthenticationService } from '../hmg-common/services/authentication/authentication.service';
import { CommonService } from '../hmg-common/services/common/common.service';
import { ConnectorService } from '../hmg-common/services/connector/connector.service';

@Injectable({
  providedIn: 'root'
})
export class ReportServiceService {
  public static GET_CONCURRENT_PROGRAM = 'Services/ERP.svc/REST/GET_CONCURRENT_PROGRAMS';
  public static GET_CPP_DIFF_STRUCTURE = 'Services/ERP.svc/REST/GET_CCP_DFF_STRUCTURE';
  public static SUBMIT_CPP_REQUEST = 'Services/ERP.svc/REST/SUBMIT_CCP_TRANSACTION';
  public static SUBMIT_CPP_TRANSACTION = 'Services/ERP.svc/REST/GET_CCP_TRANSACTIONS';
  public static GET_CCP_OUTPUT = 'Services/ERP.svc/REST/GET_CCP_OUTPUT';

  public static TRANSACTION_LIST = 'transaction-list';
  public static TEMPLATE = 'template';
  constructor(
    public con: ConnectorService,
    private authService: AuthenticationService,
    public cs: CommonService
  ) { }

  getConcurrentProgram(request, onError, errorLabel) {
    this.authService.authenticateRequest(request);
    request.P_SELECTED_EMPLOYEE_NUMBER = request.UserName;
    return this.con.postNoLoad(
      ReportServiceService.GET_CONCURRENT_PROGRAM,
      request,
      onError,
      errorLabel
    );
  }
  getCPPDiffStructure(request, onError, errorLabel) {
    this.authService.authenticateRequest(request);
    request.P_SELECTED_EMPLOYEE_NUMBER = request.UserName;
    return this.con.postNoLoad(
      ReportServiceService.GET_CPP_DIFF_STRUCTURE,
      request,
      onError,
      errorLabel
    );
  }
  submitTransaction(request, onError, errorLabel) {
    this.authService.authenticateRequest(request);
    request.P_SELECTED_EMPLOYEE_NUMBER = request.UserName;
    return this.con.postNoLoad(
      ReportServiceService.SUBMIT_CPP_REQUEST,
      request,
      onError,
      errorLabel
    );
  }
  getTransaction(request, onError, errorLabel) {
    this.authService.authenticateRequest(request);
    request.P_SELECTED_EMPLOYEE_NUMBER = request.UserName;
    return this.con.postNoLoad(
      ReportServiceService.SUBMIT_CPP_TRANSACTION,
      request,
      onError,
      errorLabel
    );
  }

  getCppOutput(request, onError, errorLabel) {
    this.authService.authenticateRequest(request);
    request.P_SELECTED_EMPLOYEE_NUMBER = request.UserName;
    return this.con.postNoLoad(
      ReportServiceService.GET_CCP_OUTPUT,
      request,
      onError,
      errorLabel
    );
  }

}
