added generation function for generate pdf
This commit is contained in:
@@ -10,6 +10,8 @@ import {DeliverynotesService, GetDeliveryNoteDto} from "../../services/api";
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {format} from "date-fns";
|
||||
import {HttpResponse} from "@angular/common/http";
|
||||
import {FileService} from "../../services/file.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-deliverery-note-table',
|
||||
@@ -27,7 +29,8 @@ import {format} from "date-fns";
|
||||
})
|
||||
export class DelivereryNoteTable implements OnInit {
|
||||
private deliveryNotesService = inject(DeliverynotesService);
|
||||
private notificationService = inject(NzNotificationService)
|
||||
private notificationService = inject(NzNotificationService);
|
||||
private fileService = inject(FileService);
|
||||
deliveryNotes = signal<GetDeliveryNoteDto[]>([]);
|
||||
deliveryNotesLoading = signal<boolean>(false);
|
||||
|
||||
@@ -95,7 +98,19 @@ export class DelivereryNoteTable implements OnInit {
|
||||
await this.fetchDeliveryNotes()
|
||||
}
|
||||
|
||||
export(deliveryNote: number) {
|
||||
return
|
||||
async export(deliveryNoteId: number) {
|
||||
try {
|
||||
const pdf = await firstValueFrom(
|
||||
this.deliveryNotesService.getDeliveryNotePdfEndpoint(deliveryNoteId, "response")
|
||||
);
|
||||
this.fileService.downloadBlob(pdf)
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Impossible de générer un PDF'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
</div>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<div>
|
||||
<nz-icon nzType="export" nzTheme="outline" (click)="export()" class="cursor-pointer text-green-700"/>
|
||||
<nz-icon nzType="export" nzTheme="outline" (click)="export(purchaseOrder.id)" class="cursor-pointer text-green-700"/>
|
||||
</div>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<div>
|
||||
|
||||
@@ -8,6 +8,7 @@ import {ModalButton} from "../modal-button/modal-button";
|
||||
import {GetPurchaseOrderDto, PurchaseordersService} from "../../services/api";
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {FileService} from "../../services/file.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-purchase-order-table',
|
||||
@@ -24,7 +25,8 @@ import {firstValueFrom} from "rxjs";
|
||||
})
|
||||
export class PurchaseOrderTable implements OnInit {
|
||||
private purchaseOrdersService = inject(PurchaseordersService);
|
||||
private notificationService = inject(NzNotificationService)
|
||||
private notificationService = inject(NzNotificationService);
|
||||
private fileService = inject(FileService);
|
||||
purchaseOrders = signal<GetPurchaseOrderDto[]>([]);
|
||||
purchaseOrdersLoading = signal<boolean>(false);
|
||||
|
||||
@@ -63,8 +65,19 @@ export class PurchaseOrderTable implements OnInit {
|
||||
await this.fetchPurchaseOrder();
|
||||
}
|
||||
|
||||
export(){
|
||||
return
|
||||
async export(purchaseOrderId: number){
|
||||
try {
|
||||
const pdf = await firstValueFrom(
|
||||
this.purchaseOrdersService.getPurchaseOrderPdfEndpoint(purchaseOrderId, "response")
|
||||
);
|
||||
this.fileService.downloadBlob(pdf)
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Impossible de générer un PDF'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
transfer() {
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
</div>
|
||||
<nz-divider nzType="vertical"></nz-divider>
|
||||
<div>
|
||||
<nz-icon nzType="export" nzTheme="outline" class="cursor-pointer text-green-700"/>
|
||||
<nz-icon nzType="export" (click)="export(quotation.id)" nzTheme="outline" class="cursor-pointer text-green-700"/>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -8,6 +8,7 @@ import {QuotationForm} from "../quotation-form/quotation-form";
|
||||
import {GetQuotationDto, QuotationsService} from "../../services/api";
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {FileService} from "../../services/file.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-quotation-table',
|
||||
@@ -25,7 +26,8 @@ import {firstValueFrom} from "rxjs";
|
||||
|
||||
export class QuotationTable implements OnInit {
|
||||
private quotationsService = inject(QuotationsService);
|
||||
private notificationService = inject(NzNotificationService)
|
||||
private notificationService = inject(NzNotificationService);
|
||||
private fileService = inject(FileService);
|
||||
quotations = signal<GetQuotationDto[]>([]);
|
||||
quotationsLoading = signal<boolean>(false);
|
||||
|
||||
@@ -63,5 +65,20 @@ export class QuotationTable implements OnInit {
|
||||
}
|
||||
await this.fetchQuotations();
|
||||
}
|
||||
|
||||
async export(quotationId: number){
|
||||
try {
|
||||
const pdf = await firstValueFrom(
|
||||
this.quotationsService.getQuotationPdfEndpoint(quotationId, "response")
|
||||
);
|
||||
this.fileService.downloadBlob(pdf)
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
this.notificationService.error(
|
||||
'Erreur',
|
||||
'Impossible de générer un PDF'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user