Profile generated letter
This commit is contained in:
parent
2d28fb9ac5
commit
558c53d4d3
|
@ -13,7 +13,7 @@ export class ApiService {
|
||||||
|
|
||||||
public isSSO = false;
|
public isSSO = false;
|
||||||
public versionDeployement = false;
|
public versionDeployement = false;
|
||||||
public versionNumber = `V-${GlobalfunctionExtension.generateVersionNumber(new Date(2025, 0, 9))}-`+"01";
|
public versionNumber = `V-${GlobalfunctionExtension.generateVersionNumber(new Date(2025, 0, 16))}-`+"01";
|
||||||
public static BASE_URL = '';
|
public static BASE_URL = '';
|
||||||
public base_url = '';
|
public base_url = '';
|
||||||
// public currentLink = '';
|
// public currentLink = '';
|
||||||
|
|
|
@ -97,24 +97,32 @@ export class EmployeeProfileReportsComponent implements OnInit {
|
||||||
|
|
||||||
preview(reportType: string) {
|
preview(reportType: string) {
|
||||||
debugger;
|
debugger;
|
||||||
|
if (this.selectedEmployee == undefined || this.selectedEmployee == null) {
|
||||||
|
this.notificationService.showWarning('Please Select and employee!!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.selectedreportType == undefined || this.selectedreportType['value'] == null) {
|
||||||
|
this.notificationService.showWarning('Please select a report!!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const data = {
|
const data = {
|
||||||
reportID: this.selectedreportType['value'],
|
reportID: this.selectedreportType['value'],
|
||||||
personID: this.authorizedPerson.id,
|
personID: this.authorizedPerson != null ? this.authorizedPerson.id : 0,
|
||||||
employeeID: this.selectedEmployee.employeeID,
|
employeeID: this.selectedEmployee.employeeID,
|
||||||
reportType: reportType == 'Download' ? 'PDF' : reportType
|
reportType: reportType == 'Download' ? 'PDF' : reportType
|
||||||
};
|
};
|
||||||
switch(this.selectedreportType['value']){
|
switch (this.selectedreportType['value']) {
|
||||||
case EnumProfileReportType.Print_CV:
|
case EnumProfileReportType.Print_CV:
|
||||||
this.PDFTitle = EnumExtension.getName(EnumProfileReportType, EnumProfileReportType.Print_CV);
|
this.PDFTitle = this.selectedEmployee.employeeNo + '-' + EnumExtension.getName(EnumProfileReportType, EnumProfileReportType.Print_CV);
|
||||||
break;
|
break;
|
||||||
case EnumProfileReportType.Appointment_Letter_Officer:
|
case EnumProfileReportType.Appointment_Letter_Officer:
|
||||||
this.PDFTitle = EnumExtension.getName(EnumProfileReportType, EnumProfileReportType.Appointment_Letter_Officer);
|
this.PDFTitle = this.selectedEmployee.employeeNo + '-' + EnumExtension.getName(EnumProfileReportType, EnumProfileReportType.Appointment_Letter_Officer);
|
||||||
break;
|
break;
|
||||||
case EnumProfileReportType.Appointment_Letter_Staff:
|
case EnumProfileReportType.Appointment_Letter_Staff:
|
||||||
this.PDFTitle = EnumExtension.getName(EnumProfileReportType, EnumProfileReportType.Appointment_Letter_Staff);
|
this.PDFTitle = this.selectedEmployee.employeeNo + '-' + EnumExtension.getName(EnumProfileReportType, EnumProfileReportType.Appointment_Letter_Staff);
|
||||||
break;
|
break;
|
||||||
case EnumProfileReportType.Appointment_Letter_Worker:
|
case EnumProfileReportType.Appointment_Letter_Worker:
|
||||||
this.PDFTitle = EnumExtension.getName(EnumProfileReportType, EnumProfileReportType.Appointment_Letter_Worker);
|
this.PDFTitle = this.selectedEmployee.employeeNo + '-' + EnumExtension.getName(EnumProfileReportType, EnumProfileReportType.Appointment_Letter_Worker);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,9 +142,9 @@ export class EmployeeProfileReportsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
this.loadingPanel.ShowLoadingPanel = false;
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
},
|
},
|
||||||
(err) => {
|
(err: any) => {
|
||||||
this.closeForm();
|
this.closeForm();
|
||||||
console.log(err);
|
// console.log(err);
|
||||||
this.notificationService.showError(err.error);
|
this.notificationService.showError(err.error);
|
||||||
this.loadingPanel.ShowLoadingPanel = false;
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
}
|
}
|
||||||
|
@ -144,25 +152,29 @@ export class EmployeeProfileReportsComponent implements OnInit {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.reportService.getGeneratedProfileReportData(data).subscribe(fileData => {
|
this.reportService.getGeneratedProfileReportData(data).subscribe(fileData => {
|
||||||
|
|
||||||
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
if (reportType == 'PDF') {
|
if (reportType == 'PDF') {
|
||||||
var element = <HTMLIFrameElement>(document.getElementById("pdf-viewer-report"));
|
var element = <HTMLIFrameElement>(document.getElementById("pdf-viewer-report"));
|
||||||
element.src = URL.createObjectURL(new Blob([fileData], { type: 'application/pdf' }));
|
element.src = URL.createObjectURL(new Blob([fileData], { type: 'application/pdf' }));
|
||||||
}
|
}
|
||||||
this.loadingPanel.ShowLoadingPanel = false;
|
if (reportType == 'Download')
|
||||||
|
this.downloadBlob(new Blob([fileData], { type: 'application/pdf' }), 'application/pdf', this.PDFTitle);
|
||||||
|
|
||||||
// if (reportType == 'download')
|
|
||||||
// this.downloadBlob(new Blob([fileData], { type: 'application/pdf' }), 'application/pdf', dataItem.employeeNo + "-" + dataItem.name + "_" + dataItem.year.toString() + "_" + 'Promotion Letter');
|
|
||||||
// this.loadingPanelService.ShowLoadingPanel = false;
|
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
this.closeForm();
|
this.closeForm();
|
||||||
|
console.log(error);
|
||||||
this.notificationService.showError(error.error);
|
this.notificationService.showError(error.error);
|
||||||
|
this.loadingPanel.ShowLoadingPanel = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
downloadFile(blobContent) {
|
downloadFile(blobContent) {
|
||||||
|
//EXCEL
|
||||||
// let blob = new Blob([this.b64toBlob(blobContent, 'application/data:application/vnd.ms-excel', 1024)], {});
|
// let blob = new Blob([this.b64toBlob(blobContent, 'application/data:application/vnd.ms-excel', 1024)], {});
|
||||||
// saveAs(blob, this.PDFTitle + '.xls');
|
// saveAs(blob, this.PDFTitle + '.xls');
|
||||||
|
//PDF
|
||||||
let blob = new Blob([this.b64toBlob(blobContent, 'application/pdf', 1024)], {});
|
let blob = new Blob([this.b64toBlob(blobContent, 'application/pdf', 1024)], {});
|
||||||
saveAs(blob, this.PDFTitle + '.pdf');
|
saveAs(blob, this.PDFTitle + '.pdf');
|
||||||
}
|
}
|
||||||
|
@ -186,6 +198,21 @@ export class EmployeeProfileReportsComponent implements OnInit {
|
||||||
return blob;
|
return blob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private downloadBlob(data: any, type: string, fileName: string): void {
|
||||||
|
const blob: Blob = new Blob([data], { type: type });
|
||||||
|
// const fileName: string = this.workOrderBillReceive.UploadAttachment[0].OriginalFileName;
|
||||||
|
// const fileName: string = fileName;
|
||||||
|
const objectUrl: string = URL.createObjectURL(blob);
|
||||||
|
const a: HTMLAnchorElement = document.createElement('a') as HTMLAnchorElement;
|
||||||
|
|
||||||
|
a.href = objectUrl;
|
||||||
|
a.download = fileName;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
|
||||||
|
document.body.removeChild(a);
|
||||||
|
URL.revokeObjectURL(objectUrl);
|
||||||
|
}
|
||||||
public loadAuthorizedPerson() {
|
public loadAuthorizedPerson() {
|
||||||
this.employeeService.getAuthorizedPerson().subscribe(
|
this.employeeService.getAuthorizedPerson().subscribe(
|
||||||
(resp) => {
|
(resp) => {
|
||||||
|
|
|
@ -1733,40 +1733,8 @@ namespace HRM.UI.Controllers.Report
|
||||||
bytes = new rptEmployee().GetAsstOfficeAndAbove(employeeID, payrollTypeId, reportType);
|
bytes = new rptEmployee().GetAsstOfficeAndAbove(employeeID, payrollTypeId, reportType);
|
||||||
break;
|
break;
|
||||||
case EnumProfileReportType.Appointment_Letter_Worker:
|
case EnumProfileReportType.Appointment_Letter_Worker:
|
||||||
ltemplate.SetObjectID(FixedLetterTemplte.Worker_Appointment_Letter);
|
|
||||||
|
|
||||||
ltemplate.ID = 3;
|
|
||||||
ltemplate.Description = "Letter Template Worker";
|
|
||||||
ltemplate.Subject = "Letter Template Worker";
|
|
||||||
ltemplate.Type = EnumDocType.Desktop_Letter;
|
|
||||||
ltemplate.TypeID = (int)EnumDocType.Desktop_Letter;
|
|
||||||
|
|
||||||
string downloadPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads";
|
|
||||||
string lFileName = "Worker.doc";
|
|
||||||
|
|
||||||
string sFilePath = new rptEmployee().Generate(ltemplate, employeeID, payrollTypeId, downloadPath, lFileName);
|
|
||||||
|
|
||||||
|
|
||||||
byte[] buffer = new byte[16 * 1024];
|
|
||||||
buffer = System.IO.File.ReadAllBytes(sFilePath);
|
|
||||||
string contentType = GetFileType(sFilePath);
|
|
||||||
var name = System.IO.Path.ChangeExtension(lFileName, ".pdf");
|
|
||||||
if (System.IO.File.Exists(sFilePath))
|
|
||||||
{
|
|
||||||
System.IO.File.Delete(sFilePath);
|
|
||||||
}
|
|
||||||
return File(buffer, contentType, name);
|
|
||||||
break;
|
break;
|
||||||
case EnumProfileReportType.Appointment_Letter_Staff:
|
case EnumProfileReportType.Appointment_Letter_Staff:
|
||||||
ltemplate.SetObjectID(FixedLetterTemplte.Staff_Appointment_Letter);
|
|
||||||
|
|
||||||
ltemplate.ID = 2;
|
|
||||||
ltemplate.Description = "Letter Template Staff";
|
|
||||||
ltemplate.Subject = "Letter Template Staff";
|
|
||||||
ltemplate.Type = EnumDocType.Desktop_Letter;
|
|
||||||
ltemplate.TypeID = (int)EnumDocType.Desktop_Letter;
|
|
||||||
|
|
||||||
new rptEmployee().Generate(ltemplate, employeeID, payrollTypeId, "C:\\Users\\mashfiq.EASE\\Downloads", "Staff.doc");
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1804,17 +1772,12 @@ namespace HRM.UI.Controllers.Report
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//string downloadPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads";
|
||||||
|
string downloadPath = System.Environment.CurrentDirectory + "\\Documents\\LetterTempFolder\\";
|
||||||
|
string sFilePath = string.Empty, lFileName = string.Empty;
|
||||||
|
|
||||||
switch (reportid)
|
switch (reportid)
|
||||||
{
|
{
|
||||||
//case EnumProfileReportType.Print_CV:
|
|
||||||
// bytes = new rptEmployee().GetEmployeeCV(employeeID, payrollTypeId, reportType);
|
|
||||||
// break;
|
|
||||||
//case EnumProfileReportType.Employee_Service_Book:
|
|
||||||
// break;
|
|
||||||
//case EnumProfileReportType.Appointment_Letter_Officer:
|
|
||||||
// bytes = new rptEmployee().GetAsstOfficeAndAbove(employeeID, payrollTypeId, reportType);
|
|
||||||
// break;
|
|
||||||
case EnumProfileReportType.Appointment_Letter_Worker:
|
case EnumProfileReportType.Appointment_Letter_Worker:
|
||||||
ltemplate.SetObjectID(FixedLetterTemplte.Worker_Appointment_Letter);
|
ltemplate.SetObjectID(FixedLetterTemplte.Worker_Appointment_Letter);
|
||||||
|
|
||||||
|
@ -1824,21 +1787,9 @@ namespace HRM.UI.Controllers.Report
|
||||||
ltemplate.Type = EnumDocType.Desktop_Letter;
|
ltemplate.Type = EnumDocType.Desktop_Letter;
|
||||||
ltemplate.TypeID = (int)EnumDocType.Desktop_Letter;
|
ltemplate.TypeID = (int)EnumDocType.Desktop_Letter;
|
||||||
|
|
||||||
string downloadPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads";
|
lFileName = "Worker.doc";
|
||||||
string lFileName = "Worker.doc";
|
|
||||||
|
|
||||||
string sFilePath = new rptEmployee().Generate(ltemplate, employeeID, payrollTypeId, downloadPath, lFileName);
|
sFilePath = new rptEmployee().Generate(ltemplate, employeeID, payrollTypeId, downloadPath, lFileName);
|
||||||
|
|
||||||
|
|
||||||
byte[] buffer = new byte[16 * 1024];
|
|
||||||
buffer = System.IO.File.ReadAllBytes(sFilePath);
|
|
||||||
string contentType = GetFileType(sFilePath);
|
|
||||||
var name = System.IO.Path.ChangeExtension(lFileName, ".pdf");
|
|
||||||
if (System.IO.File.Exists(sFilePath))
|
|
||||||
{
|
|
||||||
System.IO.File.Delete(sFilePath);
|
|
||||||
}
|
|
||||||
return File(buffer, contentType, name);
|
|
||||||
break;
|
break;
|
||||||
case EnumProfileReportType.Appointment_Letter_Staff:
|
case EnumProfileReportType.Appointment_Letter_Staff:
|
||||||
ltemplate.SetObjectID(FixedLetterTemplte.Staff_Appointment_Letter);
|
ltemplate.SetObjectID(FixedLetterTemplte.Staff_Appointment_Letter);
|
||||||
|
@ -1849,12 +1800,28 @@ namespace HRM.UI.Controllers.Report
|
||||||
ltemplate.Type = EnumDocType.Desktop_Letter;
|
ltemplate.Type = EnumDocType.Desktop_Letter;
|
||||||
ltemplate.TypeID = (int)EnumDocType.Desktop_Letter;
|
ltemplate.TypeID = (int)EnumDocType.Desktop_Letter;
|
||||||
|
|
||||||
new rptEmployee().Generate(ltemplate, employeeID, payrollTypeId, "C:\\Users\\mashfiq.EASE\\Downloads", "Staff.doc");
|
lFileName = "Staff.doc";
|
||||||
|
|
||||||
|
sFilePath = new rptEmployee().Generate(ltemplate, employeeID, payrollTypeId, downloadPath, lFileName);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte[] buffer = new byte[16 * 1024];
|
||||||
|
buffer = System.IO.File.ReadAllBytes(sFilePath);
|
||||||
|
string contentType = GetFileType(sFilePath);
|
||||||
|
var name = System.IO.Path.ChangeExtension(lFileName, ".pdf");
|
||||||
|
if (System.IO.File.Exists(sFilePath))
|
||||||
|
{
|
||||||
|
System.IO.File.Delete(sFilePath);
|
||||||
|
}
|
||||||
|
if (System.IO.File.Exists(System.IO.Path.ChangeExtension(sFilePath, ".doc")))
|
||||||
|
{
|
||||||
|
System.IO.File.Delete(System.IO.Path.ChangeExtension(sFilePath, ".doc"));
|
||||||
|
}
|
||||||
|
return File(buffer, contentType, name);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user