print and param updates
This commit is contained in:
parent
5d140b0171
commit
6dbcff7271
@ -71,7 +71,9 @@ export class CarnetService {
|
||||
P_HEADERID: headerid,
|
||||
P_PRINTGL: 'N'
|
||||
}
|
||||
return this.http.post(`${this.apiUrl}/${this.apiDb}/PrintCarnet`, data);
|
||||
return this.http.post(`${this.apiUrl}/${this.apiDb}/PrintCarnet`, data, {
|
||||
responseType: 'blob', // Important: Set responseType to 'blob'
|
||||
});
|
||||
}
|
||||
|
||||
printGeneralList(headerid: number): Observable<any> {
|
||||
@ -89,9 +91,7 @@ export class CarnetService {
|
||||
P_USERID: this.userService.getUser(),
|
||||
P_CARNETNO: carnetNumber
|
||||
}
|
||||
return this.http.patch(`${this.apiUrl}/${this.apiDb}/DuplicateCarnet`, data, {
|
||||
responseType: 'blob', // Important: Set responseType to 'blob'
|
||||
});
|
||||
return this.http.patch(`${this.apiUrl}/${this.apiDb}/DuplicateCarnet`, data);
|
||||
}
|
||||
|
||||
extendCarnet(carnetNumber: string): Observable<any> {
|
||||
|
||||
@ -116,7 +116,7 @@
|
||||
<mat-icon>print</mat-icon>
|
||||
<span>Print GL</span>
|
||||
</button>
|
||||
<button mat-menu-item (click)="printCarnet(item.headerid)"
|
||||
<button mat-menu-item (click)="printCarnet(item.headerid, item.carnetNumber)"
|
||||
*ngIf="getCarnetStatusLabel(item.carnetStatus) === 'Valid'">
|
||||
<mat-icon>print</mat-icon>
|
||||
<span>Print</span>
|
||||
|
||||
@ -212,10 +212,14 @@ export class HomeComponent {
|
||||
}
|
||||
}
|
||||
|
||||
printCarnet(headerId: number): void {
|
||||
printCarnet(headerId: number, carnetNumber: string): void {
|
||||
if (headerId) {
|
||||
this.carnetService.printCarnet(headerId).subscribe({
|
||||
next: () => {
|
||||
next: (blob: Blob) => {
|
||||
let filename = `${carnetNumber}.pdf`;
|
||||
|
||||
// Initiate download
|
||||
this.saveFile(blob, filename);
|
||||
},
|
||||
error: (error) => {
|
||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to print carnet');
|
||||
@ -231,7 +235,12 @@ export class HomeComponent {
|
||||
printGeneralList(headerId: number): void {
|
||||
if (headerId) {
|
||||
this.carnetService.printGeneralList(headerId).subscribe({
|
||||
next: () => {
|
||||
next: (blob: Blob) => {
|
||||
|
||||
let filename = `${headerId}-GL.pdf`;
|
||||
|
||||
// Initiate download
|
||||
this.saveFile(blob, filename);
|
||||
},
|
||||
error: (error) => {
|
||||
let errorMessage = this.errorHandler.handleApiError(error, 'Failed to print general list');
|
||||
@ -343,4 +352,15 @@ export class HomeComponent {
|
||||
navigateTo(route: any[], extras?: any): void {
|
||||
this.navigationService.navigate(route, extras);
|
||||
}
|
||||
|
||||
private saveFile(blob: Blob, filename: string): void {
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
document.body.appendChild(a); // Append to body to make it clickable in some browsers
|
||||
a.click();
|
||||
document.body.removeChild(a); // Clean up
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
}
|
||||
@ -153,7 +153,7 @@ export class ManageCountryComponent {
|
||||
}
|
||||
|
||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '350px',
|
||||
width: '500px',
|
||||
data: {
|
||||
title: 'Inactivate Country Message',
|
||||
message: 'Are you sure you want to inactivate this message?',
|
||||
@ -187,7 +187,7 @@ export class ManageCountryComponent {
|
||||
return;
|
||||
}
|
||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '350px',
|
||||
width: '500px',
|
||||
data: {
|
||||
title: 'Reactivate Country Message',
|
||||
message: 'Are you sure you want to reactivate this message?',
|
||||
@ -222,7 +222,7 @@ export class ManageCountryComponent {
|
||||
acc[message.paramValue] = {
|
||||
messages: [],
|
||||
// paramId: message.paramId, // Store one paramid from messages
|
||||
isInactive: message.inactiveCodeFlag === 'N',
|
||||
isInactive: message.inactiveCodeFlag === 'Y',
|
||||
addlParamValue1: message.addlParamValue1,
|
||||
addlParamValue2: message.addlParamValue2
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user