You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mohemm_srca/Mohem/src/app/mowadhafi/hr-request/hr-request.component.ts

309 lines
10 KiB
TypeScript

import { Component, OnInit } from '@angular/core';
import { Platform, Events, MenuController } from '@ionic/angular';
import { CommonService } from 'src/app/hmg-common/services/common/common.service';
import { TranslatorService } from 'src/app/hmg-common/services/translator/translator.service';
import { AuthenticationService } from 'src/app/hmg-common/services/authentication/authentication.service';
import { AuthenticatedUser } from 'src/app/hmg-common/services/authentication/models/authenticated-user';
import { SharedDataService } from 'src/app/hmg-common/services/shared-data-service/shared-data.service';
5 years ago
import { MowadhafiService } from '../mowadhafi.service';
import { Location } from '@angular/common';
import { MenuResponse } from 'src/app/hmg-common/services/menu/models/menu-response';
import { LoginModel } from 'src/app/authentication/models/LoginModel';
import { SendActivationByType } from 'src/app/authentication/models/sendActivationByType';
5 years ago
import { FileUploader } from 'ng2-file-upload';
@Component({
selector: 'app-hr-request',
templateUrl: './hr-request.component.html',
styleUrls: ['./hr-request.component.scss'],
})
export class HRRequestComponent implements OnInit {
public EmpName : string;
public EmpNum : string;
public EmpGroup : string;
public EmpMobile : string;
public EmpJob : string;
public EmpOrgName : string;
public EmpPayrol : string;
public EmpPosition : string;
public EmpEmail: string;
public EmpCatMeaning:string;
public EmpGRADENAME : string;
public EmpLocation : string;
public EmpImg : string;
public userImage: any = '../assets/imgs/profile.png';
public loginData = new LoginModel();
public searchKeySelect = 'Complaints';
myColor: string = 'secondary';
public showRequestDetails = false;
5 years ago
public proID= "CS"
5 years ago
public inquiry: string;
public HR : string;
public complaints:string;
public Projectresult:any;
public EmpRelations:any;
public Hr:any;
public Payroll:any;
public GovRelation:any;
public projName:any;
public topicName:any;
public departTypeList: any;
public topicTypeList:any;
public sectionTypeList:any;
filterAllowedType: any = ['application/pdf', 'image/jpeg', 'image/png', 'text/plain', 'image/jpg', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];
public direction: string;
constructor(
public ts: TranslatorService,
public cs: CommonService,
public authService: AuthenticationService,
public sharedData: SharedDataService,
public events: Events,
5 years ago
public MowadhafiService: MowadhafiService,
private location: Location,
private menu: MenuController,
) {
5 years ago
this.direction = TranslatorService.getCurrentLanguageName();
}
ngOnInit() {
this.getUserInformation();
5 years ago
this.getTicketTypes();
this.getProject();
this.getProjectDepartments();
this.getDepartmentSections();
this.getSectionTopics();
}
goback() {
this.location.back();
}
getUserInformation(){
const request = {
5 years ago
// P_SELECTED_EMPLOYEE_NUMBER:"121816",
P_SELECTED_RESP_ID:-999,
P_PAGE_NUM:1,
P_PAGE_LIMIT:1
};
5 years ago
this.MowadhafiService.getUserInfo(request, ()=> {} , this.ts.trPK('general', 'retry')).subscribe((result)=>
{
this.handleUserInfoResult(result);
})
}
handleUserInfoResult(result){
this.EmpName = result.MemberInformationList[0].EMPLOYEE_NAME;
console.log("____________" + this.EmpName);
this.EmpNum = result.MemberInformationList[0].EMPLOYEE_NUMBER;
this.EmpGroup = result.MemberInformationList[0].BUSINESS_GROUP_NAME;
this.EmpMobile = result.MemberInformationList[0].EMPLOYEE_MOBILE_NUMBER;
this.EmpJob = result.MemberInformationList[0].JOB_NAME;
this.EmpOrgName = result.MemberInformationList[0].ORGANIZATION_NAME;
this.EmpPayrol = result.MemberInformationList[0].PAYROLL_NAME;
this.EmpPosition = result.MemberInformationList[0].POSITION_NAME;
this.EmpEmail = result.MemberInformationList[0].EMPLOYEE_EMAIL_ADDRESS;
this.EmpCatMeaning = result.MemberInformationList[0].EMPLOYMENT_CATEGORY_MEANING;
this.EmpGRADENAME = result.MemberInformationList[0].GRADE_NAME;
this.EmpLocation = result.MemberInformationList[0].LOCATION_NAME;
this.EmpImg = result.MemberInformationList[0].EMPLOYEE_IMAGE
// console.log("total no "+this.EmpTotal)
}
5 years ago
getTicketTypes(){
const request = {
// TokenID:"xxx",
5 years ago
EmployeeNumber:"121816",
5 years ago
};
this.MowadhafiService.getTicketTypes(request, ()=> {} , this.ts.trPK('general', 'retry')).subscribe((result)=>
{
this.handlegetTicketTypesResult(result);
}) }
handlegetTicketTypesResult(result){
5 years ago
this.HR = result.Mohemm_Itg_TicketTypesList[0].typeName;
this.complaints = result.Mohemm_Itg_TicketTypesList[1].typeName;
this.inquiry = result.Mohemm_Itg_TicketTypesList[2].typeName;
5 years ago
}
getProject(){
const request = {
// TokenID:"xxx",
5 years ago
EmployeeNumber:"121816",
5 years ago
ItgProjectCode:"CS"
};
this.MowadhafiService.getProject(request, ()=> {} , this.ts.trPK('general', 'retry')).subscribe((result)=>
{
this.handlegetProjectResult(result);
}) }
handlegetProjectResult(result){
5 years ago
this.Projectresult=result.Mohemm_Itg_ProjectsList[0];
5 years ago
}
getProjectDepartments(){
const request = {
// TokenID:"xxx",
5 years ago
EmployeeNumber:"121816",
5 years ago
ItgProjectId:11,
};
this.MowadhafiService.getProjectDepartments(request, ()=> {} , this.ts.trPK('general', 'retry')).subscribe((result)=>
{
this.handlegetProjectDepartmentsResult(result);
}) }
handlegetProjectDepartmentsResult(result){
5 years ago
this.departTypeList= result.Mohemm_ITG_ProjectDepartmentsList;
// this.EmpRelations= result .Mohemm_ITG_ProjectDepartmentsList[0].departmentName;
// this.Hr = result .Mohemm_ITG_ProjectDepartmentsList[1].departmentName;
// this.Payroll = result .Mohemm_ITG_ProjectDepartmentsList[2].departmentName;
// this.GovRelation = result .Mohemm_ITG_ProjectDepartmentsList[3].departmentName;
5 years ago
}
getDepartmentSections(){
const request = {
// TokenID:"xxx",
5 years ago
EmployeeNumber:"121816",
5 years ago
ItgProjectDepartmentId:1
};
this.MowadhafiService.getDepartmentSections(request, ()=> {} , this.ts.trPK('general', 'retry')).subscribe((result)=>
{
this.handlegetDepartmentSectionsResult(result);
}) }
handlegetDepartmentSectionsResult(result){
5 years ago
// this.projName=result.Mohemm_ITG_DepartmentSectionsList[0].projectName;
this.sectionTypeList= result.Mohemm_ITG_DepartmentSectionsList;
5 years ago
}
getSectionTopics(){
const request = {
// TokenID:"xxx",
5 years ago
EmployeeNumber:"121816",
5 years ago
ItgDepartmentSectionId:1
};
this.MowadhafiService.getSectionTopics(request, ()=> {} , this.ts.trPK('general', 'retry')).subscribe((result)=>
{
this.handlegetSectionTopicsResult(result);
}) }
handlegetSectionTopicsResult(result){
5 years ago
// this.topicName=result.Mohemm_ITG_SectionTopicsList[0].topicName
this.topicTypeList= result.Mohemm_ITG_SectionTopicsList;
5 years ago
}
createRequest(){
if(this.showRequestDetails){
this.showRequestDetails = false
}else{
this.showRequestDetails = true
}}
public cancelRequest() {
this.cs.openMyRequestPage();
this.menu.toggle();
}
5 years ago
/*******************Add attchement Functions*************/
public uploader: FileUploader = new FileUploader({
allowedMimeType: ['application/pdf', 'image/jpeg', 'image/png', 'text/plain', 'image/jpg', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
maxFileSize: 10 * 1024 * 1024,
formatDataFunctionIsAsync: true,
formatDataFunction: async (item) => {
return new Promise((resolve, reject) => {
resolve({
name: item._file.name,
length: item._file.size,
contentType: item._file.type,
date: new Date()
});
});
}
});
onFileSelectedclick(event){
event.target.value = '';
}
5 years ago
onFileSelected(input) {
// this.uploader.onWhenAddingFileFailed = function (item: any, filter: any, options: any){
if (!(this.filterAllowedType.indexOf(input.target.files[0].type) > -1)) {
let msg: string = "";
msg = this.ts.trPK("general", "notSupport");
this.cs.presentAlert(msg);
return
} // todo: show alert that you tried uploading wrong files
else {
const file = input.target.files[0];
this.getBase64(file).then(
data => this.pushObject(data, file.name, file.type)
);
}
}
getBase64(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
}
5 years ago
pushObject(fileData, name, type) {
// console.log('before push: '+ this.index);
// try {
// let array = name.split('.');
// let attachType: string = array[array.length - 1];
// this.attachListOver.push(
// AttachmentID: this.attachListOver.length,
// P_FILE_CONTENT_TYPE: attachType,//type.split('/')[1],
// P_FILE_DATA: fileData.split(',')[1],
// P_FILE_NAME: name,//.split('.')[0],
// P_TRANSACTION_ID: this.P_TransactionID
// {
// })
// } catch (e) {
// }
}
submitRequest(){}
}