915 lines
34 KiB
TypeScript
915 lines
34 KiB
TypeScript
import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
|
|
import { empFileuploads, HrEmployee } from '../_models/HREmployee/hrEmployee';
|
|
import { EmployeeServices } from '../_services/employee/employee.service';
|
|
import { ApiService } from '../app.api.service';
|
|
import { HRMNotificationService } from '../app.notification.service';
|
|
import { DataTransferService } from '../data.transfer.service';
|
|
import { AppWindowPopUp } from '../app.windowPopup.service';
|
|
import {
|
|
EnumADEmpType,
|
|
EnumAllowOrDeduct,
|
|
EnumBloodGroup,
|
|
enumEmpFileUploadType,
|
|
EnumEntitleType,
|
|
EnumExtension,
|
|
EnumPURequestStatus,
|
|
EnumPURequestType,
|
|
EnumStatus
|
|
} from '../_models/enums';
|
|
import { DatePipe } from '@angular/common';
|
|
import { BasicService } from '../_services/Basic/basic.service';
|
|
import { Occupation } from '../_models/HRBasic/occupation';
|
|
import { EducationLevel } from '../_models/HRBasic/education-level';
|
|
import { EducationType } from '../_models/HRBasic/education-type';
|
|
import { Institution } from '../_models/HRBasic/institution';
|
|
import { Discipline } from '../_models/HRBasic/discipline';
|
|
import { ResultType } from '../_models/HRBasic/result-type';
|
|
import { NominationPurpose } from '../_models/HRBasic/nomination-purpose';
|
|
import { Relation } from '../_models/HRBasic/relation';
|
|
import { Thana } from '../_models/HRBasic/thana';
|
|
import { District } from '../_models/HRBasic/district';
|
|
import { Employee } from '../_models/Employee/employee';
|
|
import { DomSanitizer } from '@angular/platform-browser';
|
|
import { loadingPanelService } from '../hrm-loding panel/loding.panel.service';
|
|
import { Religion } from '../_models/HRBasic/religion';
|
|
import { forkJoin } from 'rxjs';
|
|
import { TrainingType } from '../_models/HRBasic/trainingType';
|
|
import { Designation } from '../_models/Basic/designation';
|
|
import { Country } from '../_models/HRBasic/country';
|
|
import { NatureOfTraining } from '../_models/Training/nature-of-training';
|
|
import { EssService } from '../_services/ess/ess.service';
|
|
import { Router } from '@angular/router';
|
|
import { OrganogramBasic } from '../_models/Payroll/organogramBasic';
|
|
import { OrganogramService } from '../_services/payroll/organogram.service';
|
|
import { ReportServices } from '../_services/reports/report.service';
|
|
import { LabelFn, LabelSettings } from '@progress/kendo-angular-progressbar';
|
|
import { EmpExperience } from '../_models/HREmployee/empExperience';
|
|
import { AdparameterService } from '../_services/payroll/adparameter.service';
|
|
import { ADParameter, ADParameterEmployee } from '../_models/Payroll/adparameter';
|
|
import { AllowanceDeduction } from '../_models/HRBasic/allowanceDeduction';
|
|
|
|
@Component({
|
|
selector: 'app-self-profile',
|
|
templateUrl: './self-profile.component.html',
|
|
styleUrls: ['./self-profile.component.css'],
|
|
changeDetection: ChangeDetectionStrategy.Eager,
|
|
standalone: false,
|
|
})
|
|
export class SelfProfileComponent implements OnInit {
|
|
_adParameters: ADParameter[];
|
|
_indvempAllowance: ADParameterEmployee[];
|
|
_allowdeductType: EnumAllowOrDeduct = EnumAllowOrDeduct.Allowance;
|
|
_IndivididualAllowDeduct: AllowanceDeduction[];
|
|
_allAllowanceDeduction: AllowanceDeduction[];
|
|
hrEmployee: HrEmployee;
|
|
grossAmount = 0;
|
|
occupations: Occupation[] = [];
|
|
educationLevels: EducationLevel[] = [];
|
|
educationTypes: EducationType[] = [];
|
|
institutions: Institution[] = [];
|
|
disciplines: Discipline[] = [];
|
|
resultTypes: ResultType[] = [];
|
|
religions: Religion[] = [];
|
|
trainingTypes: TrainingType[] = [];
|
|
nominationPurposes: NominationPurpose[] = [];
|
|
relations: Relation[] = [];
|
|
designations: Designation[] = [];
|
|
countries: Country[] = [];
|
|
natureOfTrainings: NatureOfTraining[] = [];
|
|
presentThana: Thana;
|
|
permanentThana: Thana;
|
|
presentDistrict: District;
|
|
permanentDistrict: District;
|
|
bloodGroup = '';
|
|
gender = '';
|
|
birthDate = '';
|
|
confirmDate = '';
|
|
joiningDate = '';
|
|
lineManager: Employee;
|
|
employee: Employee;
|
|
employeePhoto: any = "/assets/photos/profile-default.jpg";
|
|
isDisplay = false;
|
|
type = EnumPURequestType;
|
|
selectedType: EnumPURequestType;
|
|
totalRequests: number;
|
|
_selectedogranogram: OrganogramBasic;
|
|
uncompletedFields: string[] = [];
|
|
src: any;
|
|
attachments: empFileuploads[] = [];
|
|
gridAttachment: empFileuploads;
|
|
enumFileUpload: any = EnumExtension.getNamesAndValues(enumEmpFileUploadType);
|
|
attachment: any;
|
|
fileType = '';
|
|
showAttachment = false;
|
|
basicData: any;
|
|
contactData: any;
|
|
academicData: any[] = [];
|
|
achievementData: any[] = [];
|
|
hobbytdata: any[] = [];
|
|
otherTalentsdata: any[] = [];
|
|
curricularActivitysdata: any[] = [];
|
|
spouse: any;
|
|
children: any;
|
|
experiences: EmpExperience[] = [];
|
|
nominees: any[] = [];
|
|
trainings: any[] = [];
|
|
showPopUp = false;
|
|
public formatter: LabelFn = (value: number): string => {
|
|
return `Profile
|
|
Completion: ${value}%`;
|
|
};
|
|
public value = 50;
|
|
isEducation: boolean = true;
|
|
isExperience: boolean = true;
|
|
isTraining: boolean = true;
|
|
isNominee: boolean = true;
|
|
isFamily: boolean = true;
|
|
isAttchments: boolean = true;
|
|
isServiceBook: boolean = false;
|
|
PDFTitle = '';
|
|
|
|
|
|
public label: LabelSettings = {
|
|
visible: true,
|
|
format: this.formatter,
|
|
position: 'start',
|
|
};
|
|
|
|
constructor(public employeeService: EmployeeServices,
|
|
public essService: EssService,
|
|
public apiService: ApiService,
|
|
public router: Router,
|
|
public notificationService: HRMNotificationService,
|
|
public dataTransferService: DataTransferService,
|
|
public basicService: BasicService,
|
|
public WindowPopUp: AppWindowPopUp,
|
|
public datePipe: DatePipe,
|
|
public loadingService: loadingPanelService,
|
|
private sanitizer: DomSanitizer,
|
|
public organogramService: OrganogramService,
|
|
public reportService: ReportServices,
|
|
public adparamService: AdparameterService) {
|
|
this.loadProfilePermission();
|
|
this.apiService.selectedMenuName = 'Profile';
|
|
this.presentThana = new Thana();
|
|
this.permanentThana = new Thana();
|
|
this.presentDistrict = new District();
|
|
this.permanentDistrict = new District();
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.loadData();
|
|
// this.loadBasicData();
|
|
this.loadPURCountByStatus();
|
|
}
|
|
|
|
loadPURCountByStatus() {
|
|
this.essService.getPURCountByEmpIdAndStatus(EnumPURequestStatus.Requested).subscribe(
|
|
(resp) => {
|
|
this.totalRequests = resp;
|
|
},
|
|
(x) => {
|
|
console.log(x);
|
|
},
|
|
() => {
|
|
}
|
|
);
|
|
}
|
|
|
|
loadProfilePermission() {
|
|
this.loadingService.ShowLoadingPanel = true;
|
|
let items: string[] = [];
|
|
this.employeeService.getProfilePermission().subscribe(
|
|
(resp) => {
|
|
items = resp;
|
|
},
|
|
(x) => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
console.log(x);
|
|
},
|
|
() => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
//console.log(items);
|
|
if (items !== null && items.length > 0) {
|
|
items.forEach(x => {
|
|
if (x.toLowerCase() === 'education') {
|
|
this.isEducation = false;
|
|
}
|
|
else if (x.toLowerCase() === 'experience') {
|
|
this.isExperience = false;
|
|
}
|
|
else if (x.toLowerCase() === 'training') {
|
|
this.isTraining = false;
|
|
}
|
|
else if (x.toLowerCase() === 'nominee') {
|
|
this.isNominee = false;
|
|
}
|
|
else if (x.toLowerCase() === 'family') {
|
|
this.isFamily = false;
|
|
}
|
|
else if (x.toLowerCase() === 'myattachments') {
|
|
this.isAttchments = false;
|
|
}
|
|
else if (x.toLowerCase() === 'servicebook') {
|
|
this.isServiceBook = false;
|
|
}
|
|
})
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
|
|
loadBasicData() {
|
|
debugger;
|
|
this.loadingService.ShowLoadingPanel = true;
|
|
this.employeeService.getSelfServiceBasicData().subscribe(
|
|
(resp: any) => {
|
|
if (resp) {
|
|
this.basicData = resp[0];
|
|
}
|
|
},
|
|
(x) => {
|
|
console.log(x);
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
this.notificationService.showError('Error loading data');
|
|
},
|
|
() => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
}
|
|
);
|
|
}
|
|
|
|
loadContactData() {
|
|
this.loadingService.ShowLoadingPanel = true;
|
|
this.employeeService.getSelfServiceContactData().subscribe(
|
|
(resp: any) => {
|
|
this.contactData = resp[0];
|
|
},
|
|
(x) => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
console.log(x);
|
|
this.notificationService.showError('Error loading data');
|
|
},
|
|
() => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
}
|
|
);
|
|
}
|
|
|
|
loadData() {
|
|
const basicData = this.employeeService.getSelfServiceBasicData();
|
|
const contactData = this.employeeService.getSelfServiceContactData();
|
|
const academicData = this.employeeService.getSelfServiceAcademic();
|
|
const allAllowDeduct = this.basicService.getAllAllowanceDeduction(this._allowdeductType, EnumStatus.Regardless);
|
|
const achievementdata = this.employeeService.GetSelfAchievement();
|
|
const hobbytdata = this.employeeService.GetSelfHobbys();
|
|
const curricularActivitysdata = this.employeeService.GetSelfCurricularActivitys();
|
|
const otherTalentsdata = this.employeeService.GetSelfOtherTalents();
|
|
this.loadingService.ShowLoadingPanel = true;
|
|
forkJoin([basicData, contactData, academicData, achievementdata, hobbytdata, curricularActivitysdata, otherTalentsdata]).subscribe(
|
|
([res1, res2, res3, res4, res5, res6, res7]) => {
|
|
this.basicData = res1[0];
|
|
this.contactData = res2[0];
|
|
this.academicData = res3;
|
|
this.achievementData = res4;
|
|
this.hobbytdata = res5;
|
|
this.curricularActivitysdata = res6;
|
|
this.otherTalentsdata = res7;
|
|
//debugger
|
|
},
|
|
(x) => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
console.log(x);
|
|
this.notificationService.showError('Error loading data');
|
|
},
|
|
() => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
//console.log(this.basicData);
|
|
this.showEmpImage();
|
|
this.remainingProfileFields();
|
|
this.loadSalaryData();
|
|
},
|
|
);
|
|
|
|
}
|
|
|
|
loadSalaryData() {
|
|
this.basicService.getAllAllowanceDeduction(this._allowdeductType, EnumStatus.Regardless)
|
|
.subscribe(
|
|
(x) => {
|
|
this._allAllowanceDeduction = x;
|
|
},
|
|
(x) => {
|
|
this.notificationService.showError(x.error);
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
},
|
|
() => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
this.loadADParam();
|
|
});
|
|
}
|
|
|
|
loadADParam() {
|
|
this.loadingService.ShowLoadingPanel = true;
|
|
this.adparamService.GetByGradeNType(this.basicData.gradeId, EnumEntitleType.Regardless, this._allowdeductType)
|
|
.subscribe(
|
|
(x) => {
|
|
this._adParameters = x;
|
|
},
|
|
(x) => {
|
|
this.notificationService.showError(x.error);
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
},
|
|
() => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
this.refreshControl();
|
|
});
|
|
}
|
|
|
|
refreshControl() {
|
|
if (this._adParameters == undefined) {
|
|
return;
|
|
}
|
|
this._indvempAllowance = [];
|
|
|
|
if (this._allowdeductType != EnumAllowOrDeduct.Deduction) {
|
|
var Basicadparam: ADParameterEmployee = new ADParameterEmployee();
|
|
Basicadparam.allowDeductName = 'Basic Salary';
|
|
Basicadparam.adEmpType = EnumADEmpType.AppliedToGrade;
|
|
Basicadparam.monthlyAmount = this.basicData.basicSalary;
|
|
this._indvempAllowance.push(Basicadparam);
|
|
}
|
|
|
|
this._IndivididualAllowDeduct = [];
|
|
this._adParameters.forEach(p => {
|
|
if (p.entitleType == EnumEntitleType.Individual) {
|
|
|
|
if (this._IndivididualAllowDeduct.find(indv => indv.id == p.allowDeductID) == undefined) {
|
|
var newItem = this._allAllowanceDeduction.find(indv => indv.id == p.allowDeductID);
|
|
if (newItem != undefined) {
|
|
this._IndivididualAllowDeduct.push(newItem);
|
|
}
|
|
}
|
|
} else {
|
|
|
|
var asm: ADParameter = new ADParameter();
|
|
p.calculatedAmount = asm.CalculateAmount(p, this.basicData.employeeId, this.basicData.basicSalary, this.basicData.grossSalary);
|
|
var gadparam: ADParameterEmployee = new ADParameterEmployee();
|
|
var alllowance: AllowanceDeduction = this._allAllowanceDeduction.find(x => x.id == p.allowDeductID);
|
|
if (alllowance != undefined) {
|
|
gadparam.allowDeductName = alllowance.name;
|
|
}
|
|
gadparam.adEmpType = EnumADEmpType.AppliedToGrade;
|
|
gadparam.monthlyAmount = p.calculatedAmount;
|
|
this._indvempAllowance.push(gadparam);
|
|
}
|
|
});
|
|
this.grossAmount = 0;
|
|
this._indvempAllowance.forEach(p => this.grossAmount = this.grossAmount + p.monthlyAmount);
|
|
}
|
|
|
|
organogramselected(org: any) {
|
|
if (org === undefined) {
|
|
return;
|
|
}
|
|
|
|
this.organogramService.getOrganogramBasicById(org.id).subscribe(
|
|
(resp: any) => {
|
|
this._selectedogranogram = resp;
|
|
},
|
|
(err: any) => {
|
|
this.notificationService.showError(err);
|
|
},
|
|
() => {
|
|
var item: OrganogramBasic = org;
|
|
/*this._departmentPicker.setItem(this._selectedogranogram.departmentID, '', this.basicDataService);
|
|
this._designationPicker.setItem(this._selectedogranogram.designationID, '', this.basicDataService);
|
|
this._locationPicker.setItem(this._selectedogranogram.locationID, '', this.basicDataService);
|
|
this._gradePicker.setItem(this._selectedogranogram.gradeID == undefined ? 0 : this._selectedogranogram.gradeID, '', this.basicDataService);*/
|
|
});
|
|
}
|
|
|
|
remainingProfileFields() {
|
|
this.uncompletedFields = [];
|
|
if (this.basicData.mobileNo === '') {
|
|
this.uncompletedFields.push('Mobile No');
|
|
}
|
|
if (this.basicData.nid === '') {
|
|
this.uncompletedFields.push('National ID');
|
|
}
|
|
if (this.basicData.bloodGroup === 0) {
|
|
this.uncompletedFields.push('Blood Group');
|
|
}
|
|
if (this.basicData.tin === '') {
|
|
this.uncompletedFields.push('TIN');
|
|
}
|
|
if (this.academicData.length === 0) {
|
|
this.uncompletedFields.push('Education');
|
|
}
|
|
const contact = this.contactData;
|
|
if (contact !== undefined) {
|
|
if (!(contact.presentAddress || contact.presentDistrict || contact.presentThana)) {
|
|
this.uncompletedFields.push('Present Contact');
|
|
}
|
|
if (!(contact.permanentAddress || contact.permanentDistrict || contact.permanentThana)) {
|
|
this.uncompletedFields.push('Permanent Contact');
|
|
}
|
|
if (!(contact.emergencyContactAddress || contact.emergencyContactPerson)) {
|
|
this.uncompletedFields.push('Emergency Contact');
|
|
}
|
|
}
|
|
}
|
|
|
|
/*loadEmployee() {
|
|
this.loadingService.ShowLoadingPanel = true;
|
|
this.employeeService.getHREmployee().subscribe(
|
|
(resp) => {
|
|
this.hrEmployee = resp;
|
|
},
|
|
() => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
},
|
|
() => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
this.showEmpImage();
|
|
this.remainingProfileFields();
|
|
this.employeeService.getEmployeeByID(this.hrEmployee.id).subscribe(
|
|
(resp) => {
|
|
this.employee = resp;
|
|
},
|
|
(x) => {
|
|
console.log(x);
|
|
},
|
|
() => {
|
|
this.employeeService.getEmployeeByID(this.employee.lineManagerID).subscribe(
|
|
(resp) => {
|
|
this.lineManager = resp;
|
|
},
|
|
(x) => {
|
|
console.log(x);
|
|
},
|
|
() => {
|
|
|
|
}
|
|
);
|
|
}
|
|
);
|
|
this.hrEmployee.firstName = this.hrEmployee.name;
|
|
if (this.hrEmployee.bloodGroup !== undefined) {
|
|
this.bloodGroup = GetBloodGroupFriendlyName(this.hrEmployee.bloodGroup); // EnumBloodGroup[this.hrEmployee.bloodGroup];
|
|
}
|
|
if (this.hrEmployee.gender !== undefined) {
|
|
this.gender = EnumGender[this.hrEmployee.gender];
|
|
}
|
|
if (this.hrEmployee.religionID > 0) {
|
|
this.hrEmployee.religionName = this.religions.find(x => x.id === this.hrEmployee.religionID).name;
|
|
}
|
|
if (this.hrEmployee.officialBirthDate !== undefined) {
|
|
this.birthDate = this.datePipe.transform(this.hrEmployee.officialBirthDate, 'dd MMM yyyy');
|
|
}
|
|
if (this.hrEmployee.confirDate !== undefined) {
|
|
this.confirmDate = this.datePipe.transform(this.hrEmployee.confirDate, 'dd MMM yyyy');
|
|
}
|
|
if (this.hrEmployee.joiningDate !== undefined) {
|
|
this.joiningDate = this.datePipe.transform(this.hrEmployee.joiningDate, 'dd MMM yyyy');
|
|
}
|
|
if (this.hrEmployee.spouses !== undefined) {
|
|
this.hrEmployee.spouses.forEach(x => {
|
|
const occupation = this.occupations.find(oc => oc.id === x.occupationID);
|
|
const educationLevel = this.educationLevels.find(oc => oc.educationTypeID === x.educationLevelID);
|
|
if (occupation !== undefined) {
|
|
x.occupation = occupation;
|
|
}
|
|
if (educationLevel !== undefined) {
|
|
x.educationLevel = educationLevel;
|
|
}
|
|
});
|
|
}
|
|
|
|
if (this.hrEmployee.childrenList !== undefined) {
|
|
this.hrEmployee.childrenList.forEach(x => {
|
|
const occupation = this.occupations.find(oc => oc.id === x.occupationID);
|
|
if (occupation !== undefined) {
|
|
x.occupation = occupation;
|
|
}
|
|
x.gender = EnumGender[x.gender];
|
|
x.maritalStatus = EnumMaritalStatus[x.maritalStatus];
|
|
});
|
|
}
|
|
if (this.hrEmployee.academics !== undefined) {
|
|
this.hrEmployee.academics.forEach(x => {
|
|
const educationType = this.educationTypes.find(oc => oc.id === x.educationTypeID);
|
|
if (educationType !== undefined) {
|
|
x.educationType = educationType;
|
|
}
|
|
|
|
const educationLevel = this.educationLevels.find(oc => oc.id === x.educationLevelID);
|
|
if (educationLevel !== undefined) {
|
|
x.educationLevel = educationType;
|
|
}
|
|
|
|
const institution = this.institutions.find(oc => oc.id === x.institutionID);
|
|
if (institution !== undefined) {
|
|
x.institution = institution;
|
|
}
|
|
|
|
const discipline = this.disciplines.find(oc => oc.id === x.disciplineID);
|
|
if (discipline !== undefined) {
|
|
x.discipline = discipline;
|
|
}
|
|
|
|
const resultType = this.resultTypes.find(oc => oc.id === x.resultTypeID);
|
|
if (resultType !== undefined) {
|
|
x.resultType = resultType;
|
|
}
|
|
});
|
|
}
|
|
if (this.hrEmployee.references !== undefined) {
|
|
this.hrEmployee.references.forEach(x => {
|
|
const occupation = this.occupations.find(oc => oc.id === x.occupationID);
|
|
if (occupation !== undefined) {
|
|
x.occupation = occupation;
|
|
}
|
|
});
|
|
}
|
|
/!*if (this.hrEmployee.nominees !== undefined) {
|
|
this.hrEmployee.nominees.forEach(x => {
|
|
const nominationPurpose = this.nominationPurposes.find(oc => oc.id === x.nominationPurposeID);
|
|
const relation = this.relations.find(oc => oc.id === x.relationID);
|
|
if (nominationPurpose !== undefined) {
|
|
x.nominationPurpose = nominationPurpose;
|
|
}
|
|
if (relation !== undefined) {
|
|
x.relation = relation;
|
|
}
|
|
});
|
|
}*!/
|
|
if (this.hrEmployee.contacts !== undefined) {
|
|
this.basicService.getThanaById(this.hrEmployee.contacts[0].presentThanaID).subscribe(
|
|
(resp) => {
|
|
this.presentThana = resp;
|
|
},
|
|
() => {
|
|
},
|
|
() => {
|
|
},
|
|
);
|
|
this.basicService.getThanaById(this.hrEmployee.contacts[0].permanentThanaID).subscribe(
|
|
(resp) => {
|
|
this.permanentThana = resp;
|
|
},
|
|
() => {
|
|
},
|
|
() => {
|
|
},
|
|
);
|
|
this.basicService.getDistrictById(this.hrEmployee.contacts[0].permanentDistrictID).subscribe(
|
|
(resp) => {
|
|
this.permanentDistrict = resp;
|
|
},
|
|
() => {
|
|
},
|
|
() => {
|
|
},
|
|
);
|
|
this.basicService.getDistrictById(this.hrEmployee.contacts[0].presentDistrictID).subscribe(
|
|
(resp) => {
|
|
this.presentDistrict = resp;
|
|
},
|
|
() => {
|
|
},
|
|
() => {
|
|
},
|
|
);
|
|
}
|
|
},
|
|
);
|
|
}*/
|
|
|
|
/**
|
|
* The approved photo is served from the photo folder over a URL, so the browser fetches and
|
|
* caches the image itself instead of us pulling it down as base64 inside a JSON response.
|
|
*/
|
|
showEmpImage() {
|
|
this.employeePhoto = this.apiService.empPhotoUrl(this.basicData?.employeeNo);
|
|
}
|
|
|
|
/** Falls back to the default avatar when the employee has no photo on file. */
|
|
onPhotoError() {
|
|
this.employeePhoto = ApiService.DEFAULT_PHOTO;
|
|
}
|
|
|
|
loadServiceBook() {
|
|
this.loadingService.ShowLoadingPanel = true;
|
|
const data = {
|
|
reportid: 27,
|
|
itemid: 0,
|
|
bankId: 0,
|
|
empIds: this.basicData.employeeId.toString(),
|
|
reportType: 'PDF',
|
|
fromDate: undefined,
|
|
toDate: undefined
|
|
};
|
|
this.showPopUp = true;
|
|
this.reportService.getCommonReportData(data).subscribe(
|
|
(resp: any) => {
|
|
//this.src = URL.createObjectURL(this.b64toBlob(resp, 'data:application/pdf;base64', 1024));
|
|
this.PDFTitle = 'General Service Book';
|
|
this.src = URL.createObjectURL(this.b64toBlob(resp, 'application/pdf', 1024));
|
|
var element = <HTMLIFrameElement>(document.getElementById("pdf-viewer-report"));
|
|
element.src = this.src;
|
|
},
|
|
(err) => {
|
|
console.log(err);
|
|
this.showPopUp = false;
|
|
this.notificationService.showError(err);
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
},
|
|
() => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
}
|
|
);
|
|
}
|
|
loadGovtServiceBook() {
|
|
this.loadingService.ShowLoadingPanel = true;
|
|
const data = {
|
|
reportid: 1000,
|
|
itemid: 0,
|
|
bankId: 0,
|
|
empIds: this.basicData.employeeId.toString(),
|
|
reportType: 'PDF',
|
|
// fromDate: this.selectedMonth,
|
|
fromDate: new Date().toDateString(),
|
|
toDate: new Date().toDateString()
|
|
};
|
|
this.showPopUp = true;
|
|
this.reportService.getCommonReportData(data).subscribe(
|
|
(resp: any) => {
|
|
if (resp === null || resp === undefined) {
|
|
this.notificationService.showError('No data found');
|
|
return;
|
|
}
|
|
this.PDFTitle = 'Government Service Book';
|
|
this.src = URL.createObjectURL(this.b64toBlob(resp, 'application/pdf', 1024));
|
|
var element = <HTMLIFrameElement>(document.getElementById("pdf-viewer-report"));
|
|
element.src = this.src;
|
|
|
|
// if (data.reportType === 'PDF') {
|
|
// this.src = URL.createObjectURL(this.b64toBlob(resp, 'data:application/pdf;base64', 1024));
|
|
// this.showPopUp = true;
|
|
// //console.log(this.src);
|
|
// }
|
|
},
|
|
(err) => {
|
|
console.log(err);
|
|
this.showPopUp = false;
|
|
this.notificationService.showError(err.error);
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
},
|
|
() => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
}
|
|
);
|
|
}
|
|
|
|
b64toBlob(b64Data, contentType, sliceSize) {
|
|
const byteCharacters = atob(b64Data);
|
|
const byteArrays = [];
|
|
|
|
for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
|
|
const slice = byteCharacters.slice(offset, offset + sliceSize);
|
|
|
|
const byteNumbers = new Array(slice.length);
|
|
for (let i = 0; i < slice.length; i++) {
|
|
byteNumbers[i] = slice.charCodeAt(i);
|
|
}
|
|
|
|
const byteArray = new Uint8Array(byteNumbers);
|
|
byteArrays.push(byteArray);
|
|
}
|
|
|
|
const blob = new Blob(byteArrays, { type: contentType });
|
|
return blob;
|
|
}
|
|
|
|
onPopUpClose() {
|
|
this.isDisplay = false;
|
|
}
|
|
|
|
onProfileUpdate(enumType: EnumPURequestType) {
|
|
this.isDisplay = true;
|
|
this.selectedType = enumType;
|
|
}
|
|
|
|
loadAttachments() {
|
|
this.loadingService.ShowLoadingPanel = true;
|
|
this.employeeService.getEmployeeAttachments(this.basicData.employeeId)
|
|
.subscribe(
|
|
(resp) => {
|
|
this.attachments = resp;
|
|
},
|
|
(x) => {
|
|
console.log(x);
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
},
|
|
() => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
}
|
|
);
|
|
}
|
|
|
|
editHandler({ dataItem }) {
|
|
this.showAttachment = true;
|
|
const item = dataItem as empFileuploads;
|
|
this.attachment = item.fileData;
|
|
const type = item.fileName.split('.').pop();
|
|
if (type === 'png' || type === 'jpg' || type === 'jpeg') {
|
|
this.fileType = 'image';
|
|
} else if (type === 'pdf') {
|
|
this.fileType = 'pdf';
|
|
}
|
|
}
|
|
|
|
onClose() {
|
|
this.showAttachment = false;
|
|
}
|
|
|
|
viewProfileUpdate() {
|
|
this.router.navigate(['ess/profile-update']);
|
|
}
|
|
|
|
onSelect(item) {
|
|
this.onProfileUpdate(+EnumPURequestType[item]);
|
|
}
|
|
|
|
getFileUploadName(value: number): string {
|
|
return this.enumFileUpload.find(x => x.value === value).name;
|
|
}
|
|
|
|
onTabSelect(event: any) {
|
|
if (event.index === 3) {
|
|
this.loadExperiences();
|
|
} else if (event.index === 4) {
|
|
this.loadTraining();
|
|
} else if (event.index === 5) {
|
|
this.loadNominee();
|
|
} else if (event.index === 6) {
|
|
this.loadFamilyInfo();
|
|
} else if (event.index === 7) {
|
|
this.loadAttachments();
|
|
} else if (event.index === 8) {
|
|
// this.loadServiceBook();
|
|
}
|
|
}
|
|
|
|
loadTraining() {
|
|
this.employeeService.getTrainingForEss(this.basicData.employeeId).subscribe(
|
|
(resp) => {
|
|
this.trainings = resp;
|
|
},
|
|
(x) => {
|
|
console.log(x);
|
|
this.notificationService.showError('Error loading data');
|
|
},
|
|
() => {
|
|
},
|
|
);
|
|
}
|
|
|
|
loadNominee() {
|
|
this.employeeService.getNomineesForEss(this.basicData.employeeId).subscribe(
|
|
(resp) => {
|
|
this.nominees = resp;
|
|
},
|
|
(x) => {
|
|
console.log(x);
|
|
this.notificationService.showError('Error loading data');
|
|
},
|
|
() => {
|
|
},
|
|
);
|
|
}
|
|
|
|
loadAttachmentForExperience({ dataItem }) {
|
|
this.loadAttachment(dataItem.employeeID, dataItem.id, enumEmpFileUploadType.Experience);
|
|
}
|
|
|
|
loadAttachmentForEducation({ dataItem }) {
|
|
this.loadAttachment(dataItem.employeeId, dataItem.academicId, enumEmpFileUploadType.Education);
|
|
}
|
|
|
|
loadAttachmentForTraining({ dataItem }) {
|
|
this.loadAttachment(dataItem.employeeId, dataItem.emptrainingid, enumEmpFileUploadType.training);
|
|
}
|
|
|
|
loadAttachmentForNominee({ dataItem }) {
|
|
// this.loadAttachment(dataItem, enumEmpFileUploadType.Nominee);
|
|
}
|
|
|
|
loadAttachment(empId: number, referenceId: number, fileType: enumEmpFileUploadType) {
|
|
this.loadingService.ShowLoadingPanel = true;
|
|
this.employeeService.getEmployeeAttachmentByType(empId, referenceId, fileType)
|
|
.subscribe(
|
|
(resp) => {
|
|
this.gridAttachment = resp;
|
|
},
|
|
(x) => {
|
|
console.log(x);
|
|
this.notificationService.showError('Error Loading Attachments');
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
},
|
|
() => {
|
|
this.loadingService.ShowLoadingPanel = false;
|
|
this.showAttachment = true;
|
|
this.attachment = this.gridAttachment.fileData;
|
|
//console.log(this.gridAttachment);
|
|
const type = this.gridAttachment.fileName.split('.').pop();
|
|
if (type === 'png' || type === 'jpg' || type === 'jpeg') {
|
|
this.fileType = 'image';
|
|
} else if (type === 'pdf') {
|
|
this.fileType = 'pdf';
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
loadFamilyInfo() {
|
|
this.employeeService.getSelfServiceFamilyInfo().subscribe(
|
|
(resp: any) => {
|
|
this.spouse = resp.spouse;
|
|
this.children = resp.children;
|
|
},
|
|
(x) => {
|
|
console.log(x);
|
|
this.notificationService.showError('Error loading data');
|
|
},
|
|
() => {
|
|
}
|
|
);
|
|
}
|
|
|
|
private loadExperiences() {
|
|
this.employeeService.getEmpExperiences(this.basicData.employeeId).subscribe(
|
|
(resp) => {
|
|
this.experiences = resp;
|
|
},
|
|
(x) => {
|
|
console.log(x);
|
|
this.notificationService.showError('Error loading data');
|
|
},
|
|
() => {
|
|
},
|
|
);
|
|
}
|
|
|
|
closeForm(): void {
|
|
this.showPopUp = false;
|
|
}
|
|
}
|
|
|
|
function GetBloodGroupFriendlyName(bloodGroup: EnumBloodGroup): string {
|
|
switch (bloodGroup) {
|
|
case EnumBloodGroup.None: {
|
|
return 'N/A';
|
|
break;
|
|
}
|
|
case EnumBloodGroup.APos: {
|
|
return 'A+';
|
|
break;
|
|
}
|
|
case EnumBloodGroup.ANeg: {
|
|
return 'A-';
|
|
break;
|
|
}
|
|
case EnumBloodGroup.BPos: {
|
|
return 'B+';
|
|
break;
|
|
}
|
|
case EnumBloodGroup.BNeg: {
|
|
return 'B-';
|
|
break;
|
|
}
|
|
case EnumBloodGroup.OPos: {
|
|
return 'O+';
|
|
break;
|
|
}
|
|
case EnumBloodGroup.ONeg: {
|
|
return 'O-';
|
|
break;
|
|
}
|
|
case EnumBloodGroup.ABPos: {
|
|
return 'AB+';
|
|
break;
|
|
}
|
|
case EnumBloodGroup.ABNeg: {
|
|
return 'AB-';
|
|
break;
|
|
}
|
|
default: {
|
|
return 'N/A';
|
|
break;
|
|
}
|
|
}
|
|
}
|