import { Injectable } from "@angular/core"; import { HttpClient, HttpHeaders } from "@angular/common/http"; import { Config } from '../../_helpers/config.class'; import { AuthenticationService } from "../../_services/authentication.service"; import { EMployeeViewModel, VisaexpenseVieModel, EmployePaySlipViewModel, EmployeePostPaySlipsViewModel } from "./employee-class"; import { Observable } from "rxjs"; import { VisaExpense } from "../settings/setting.class"; import { LocalService } from "../../_services/local.service"; @Injectable() export class EmployeeServices { headers: HttpHeaders = new HttpHeaders(); constructor(private http: HttpClient, _authenticationService: AuthenticationService, private _localService:LocalService) { this.headers.set('Content-Type', 'application/x-www-form-urlencoded'); this.headers.set('Authorization', 'Bearer ' + _authenticationService.getToken()); } public saveEmployee(obj: EMployeeViewModel) { return this.http.post(`${Config.getControllerUrl('Employee', 'SaveEmployee')}`, obj); } public getEmployeeList(skip: number, pageSize: number, query: string, hfId: string, geoLvlCode: string, hfType: string, stockId: number) { return this.http.post(`${Config.getControllerUrl('Employee', 'GetEmployeeList')}`, { Skip: skip, PageSize: pageSize, Query: query, HfId: hfId, GeoLvlCode: geoLvlCode, HfType: hfType, StockId: stockId }); } public GetEmployeeListforDashboard() { return this.http.post(`${Config.getControllerUrl('Employee', 'GetEmployeeListforDashboard')}`,{ Id: null}); } public getEmployeeById(id: number) { return this.http.post(`${Config.getControllerUrl('Employee', 'GetEmployeeById')}`, { Id: id }); } public getIssueItems(id: number) { return this.http.post(`${Config.getControllerUrl('Employee', 'GetIssueItems')}`, { Id: id }); } public getEmployeeServicesHistory(id: number) { return this.http.post(`${Config.getControllerUrl('Employee', 'GetEmployeeServicesHistory')}`, { Id: id }); } public changeStatus(id: number) { return this.http.post(`${Config.getControllerUrl('Employee', 'ChangeStatus')}`, { Id: id }); } public getBalanceForEmp(id: number) { return this.http.post(`${Config.getControllerUrl('Reporting', 'GetBalanceForEmp')}`, { Id: id }); } // visa public validateVisaCode(code: string) { return this.http.post(`${Config.getControllerUrl('Visa', 'ValidateVisaCode')}`, { Code: code }); } public getVisaList(): Observable { return this.http.get(`${Config.getControllerUrl('Visa', 'GetVisaList')}`); } public getVisaById(id: number): Observable { return this.http.post(`${Config.getControllerUrl('Visa', 'GetVisaById')}`, { Id: id }); } public saveVisaMasterDetail(obj: any) { return this.http.post(`${Config.getControllerUrl('Visa', 'SaveVisaMasterDetail')}`, obj); } public removeVisaMasterDetail(obj: any) { return this.http.post(`${Config.getControllerUrl('Visa', 'DeleteVisaMasterDetail')}`, obj); } public saveVisaAdjustment(obj: any) { return this.http.post(`${Config.getControllerUrl('Visa', 'SaveVisaAdjustment')}`, obj); } // visa expense public getVisaExpenseList(): Observable { return this.http.get(`${Config.getControllerUrl('VisaExpense', 'GetVisaExpenseList')}`); } public getVisaExpenseListByVisaId(id: number) { return this.http.post(`${Config.getControllerUrl('VisaExpense', 'GetVisaExpenseListByVisaId')}`, { Id: id }); } public saveVisaExpense(obj, file: File) { let fd = new FormData(); fd.append('Attachment', file); fd.append('Obj', JSON.stringify(obj)); return this.http.post(`${Config.getControllerUrl('VisaExpense', 'SaveVisaExpense')}`, fd); } public deleteVisaExpense(obj: any) { return this.http.post(`${Config.getControllerUrl('VisaExpense', 'DeleteVisaExpense')}`, obj); } // visa instalments public validateVisaInstallmentCode(code: string) { return this.http.post(`${Config.getControllerUrl('VisaInstalment', 'ValidateVisaInstallmentCode')}`, { Code: code }); } public saveVisaInstalment(obj: any) { return this.http.post(`${Config.getControllerUrl('VisaInstalment', 'SaveVisaInstallment')}`, obj); } public getVisaInstallmentList() { return this.http.get(`${Config.getControllerUrl('VisaInstalment', 'GetVisaInstallmentList')}`); } public deleteVisaInstallment(obj: any) { return this.http.post(`${Config.getControllerUrl('VisaInstalment', 'DeleteVisaInstallment')}`, obj); } public getAutoVisaList() { return this.http.get(`${Config.getControllerUrl('Visa', 'GetAutoVisaList')}`); } public saveVisaInstallmentAuto(obj: any) { return this.http.post(`${Config.getControllerUrl('VisaInstalment', 'SaveVisaInstallmentAuto')}`, obj); } // Security Deposit public validateSecurityDepositeCode(code: any) { return this.http.post(`${Config.getControllerUrl('DepositSecurity', 'ValidateSecurityDepositeCode')}`, { Code: code }); } public saveSecurityDeposit(obj: any) { return this.http.post(`${Config.getControllerUrl('DepositSecurity', 'SaveSecurityDeposit')}`, obj); } public getDepositListByEmp(obj: any) { return this.http.post(`${Config.getControllerUrl('DepositSecurity', 'GetDepositListByEmp')}`, { Id: obj }); } public getSecurityDepositList() { return this.http.get(`${Config.getControllerUrl('DepositSecurity', 'GetSecurityDepositList')}`); } public deleteSecurityDeposit(obj: any) { return this.http.post(`${Config.getControllerUrl('DepositSecurity', 'DeleteSecurityDeposit')}`, obj); } // payslip public savePaySlip(obj: EmployeePostPaySlipsViewModel) { this._localService.dateTransFuckDatesInObject(obj); const formData = new FormData(); formData.append('file', obj.file); formData.append('Obj', JSON.stringify(obj)); return this.http.post(`${Config.getControllerUrl('Employee', 'SavePaySlips')}`, formData); } public getPaySlipsList() { return this.http.post(`${Config.getControllerUrl('Employee', 'GetPaySlipsList')}`, { Id: 0 }); } public getPaySlipsByEmployeeId(id: any) { return this.http.post(`${Config.getControllerUrl('Employee', 'GetPaySlipsByEmployeeId')}`, { Id: id }); } // event-log public getEventList() { return this.http.post(`${Config.getControllerUrl('Event', 'GetEventList')}`, null); } public getEventListByEmployeId(id) { return this.http.post(`${Config.getControllerUrl('Event', 'GetEventListByEmployeId')}`, {Id:id}); } public saveEventMaster(obj) { this._localService.dateTransFuckDatesInObject(obj); let fd = new FormData(); fd.append('Obj', JSON.stringify(obj)); return this.http.post(`${Config.getControllerUrl('Event', 'SaveEventMaster')}`, fd); } public deleteEventMaster(id) { return this.http.post(`${Config.getControllerUrl('Event', 'DeleteEventMaster')}`, { Id: id }); } // event-log-type public getEventTypeList() { return this.http.post(`${Config.getControllerUrl('Event', 'GetEventTypeList')}`, null); } public saveEventType(obj) { let fd = new FormData(); fd.append('Obj', JSON.stringify(obj)); return this.http.post(`${Config.getControllerUrl('Event', 'SaveEventType')}`, fd); } public deleteEventType(id) { return this.http.post(`${Config.getControllerUrl('Event', 'DeleteEventType')}`, { Id: id }); } // event comment public saveEventComment(obj) { let fd = new FormData(); fd.append('Obj', JSON.stringify(obj)); return this.http.post(`${Config.getControllerUrl('Event', 'SaveEventComment')}`, fd); } public deleteEventComment(id) { return this.http.post(`${Config.getControllerUrl('Event', 'DeleteEventComment')}`, { Id: id }); } public getEventCommentList(id) { return this.http.post(`${Config.getControllerUrl('Event', 'GetEventCommentList')}`, { Id: id }); } }