import { Injectable } from '@angular/core'; import { ConnectorService } from 'src/app/hmg-common/services/connector/connector.service'; import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service"; import { HttpClient, HttpHeaders } from '@angular/common/http'; @Injectable({ providedIn: 'root' }) export class MowadhafiService { public static EMPLOYEE_SHARED_DATA = 'employee'; public static getMyTeam = 'Services/ERP.svc/REST/GET_EMPLOYEE_SUBORDINATES'; public static getSuborinateStatus = 'Services/ERP.svc/REST/GET_SUBORDINATES_ATTD_STATUS'; public static getUserInfo = 'Services/ERP.svc/REST/Get_UserInformation'; public static getTicketTypes = 'Services/COCWS.svc/REST/Mohemm_ITG_GetTicketTypes'; public static getProject = 'Services/COCWS.svc/REST/Mohemm_ITG_GetProjects'; public static getProjectDepartments = 'Services/COCWS.svc/REST/Mohemm_ITG_GetProjectDepartments'; public static getDepartmentSections = 'Services/COCWS.svc/REST/Mohemm_ITG_GetDepartmentSections'; public static getSectionTopics = 'Services/COCWS.svc/REST/Mohemm_ITG_GetSectionTopics'; public static getTicketsByEmployee = 'Services/COCWS.svc/REST/Mohemm_ITG_GetTicketsByEmployee'; public static getTicketStatisticsByEmp = 'Services/COCWS.svc/REST/Mohemm_ITG_GetTicketStatisticsByEmployee'; public static getTicketTransaction = 'Services/COCWS.svc/REST/Mohemm_ITG_GetTicketTransaction'; public static getTicketDetails = 'Services/COCWS.svc/REST/Mohemm_ITG_GetTicketDetails'; public static getCreateTicket = 'Services/COCWS.svc/REST/Mohemm_ITG_CreateTicket'; constructor( public con: ConnectorService, private authService: AuthenticationService, public http: HttpClient ) { } public getEmployeeSubordinates(absence: any, onError?: any, errorLabel?: string) { const request = absence; this.authService.authenticateRequest(request); return this.con.post(MowadhafiService.getMyTeam, request, onError, errorLabel); } public getSuborinatesAttStatus(absence: any, onError?: any, errorLabel?: string) { const request = absence; this.authService.authenticateRequest(request); return this.con.post(MowadhafiService.getSuborinateStatus, request, onError, errorLabel); } public getUserInfo(absence: any, onError?: any, errorLabel?: string) { const request = absence; this.authService.authenticateRequest(request); return this.con.post(MowadhafiService.getUserInfo, request, onError, errorLabel); } public getTicketTypes(absence: any, onError?: any, errorLabel?: string) { const request = absence; this.authService.authenticateRequest(request); request.EmployeeNumber = request.P_USER_NAME; console.log(request); return this.con.post(MowadhafiService.getTicketTypes, request, onError, errorLabel); } public getProject(absence: any, onError?: any, errorLabel?: string) { const request = absence; this.authService.authenticateRequest(request); request.EmployeeNumber = request.P_USER_NAME; // request.ItgProjectCode = request.projectCode; return this.con.post(MowadhafiService.getProject, request, onError, errorLabel); } public getProjectDepartments(absence: any, onError?: any, errorLabel?: string) { const request = absence; this.authService.authenticateRequest(request); request.EmployeeNumber = request.P_USER_NAME; return this.con.post(MowadhafiService.getProjectDepartments, request, onError, errorLabel); } public getDepartmentSections(absence: any, onError?: any, errorLabel?: string) { const request = absence; this.authService.authenticateRequest(request); request.EmployeeNumber = request.P_USER_NAME; return this.con.post(MowadhafiService.getDepartmentSections, request, onError, errorLabel); } public getSectionTopics(absence: any, onError?: any, errorLabel?: string) { const request = absence; this.authService.authenticateRequest(request); request.EmployeeNumber = request.P_USER_NAME; return this.con.post(MowadhafiService.getSectionTopics, request, onError, errorLabel); } public getTicketsByEmployee(absence: any, onError?: any, errorLabel?: string) { let request = absence; this.authService.authenticateRequest(request); request.EmployeeNumber = request.P_USER_NAME; return this.con.post(MowadhafiService.getTicketsByEmployee, request, onError, errorLabel); } public getTicketStatisticsByEmp(absence: any, onError?: any, errorLabel?: string) { const request = absence; this.authService.authenticateRequest(request); return this.con.post(MowadhafiService.getTicketStatisticsByEmp, request, onError, errorLabel); } public getTicketTransaction(absence: any, onError?: any, errorLabel?: string) { const request = absence; this.authService.authenticateRequest(request); request.EmployeeNumber = request.P_USER_NAME; return this.con.post(MowadhafiService.getTicketTransaction, request, onError, errorLabel); } public getTicketDetails(absence: any, onError?: any, errorLabel?: string) { const request = absence; this.authService.authenticateRequest(request); request.EmployeeNumber = request.P_USER_NAME; return this.con.post(MowadhafiService.getTicketDetails, request, onError, errorLabel); } public getCreateTicket(absence: any, onError?: any, errorLabel?: string) { const request = absence; this.authService.authenticateRequest(request); request.EmployeeNumber = request.P_USER_NAME; const HttpUploadOptions = { headers: new HttpHeaders({ "Content-Type": "multipart/form-data", }) } // return this.con.post(MowadhafiService.getCreateTicket, request, onError, errorLabel); return this.http.post(ConnectorService.host + MowadhafiService.getCreateTicket, absence, { reportProgress: true, observe: 'events' } ) } }