import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { NotificationService } from '../../../_services/notification.service'; import { StoreService } from '../store.services'; import { Sale_PurchaseMastViewModel, ItemViewModel, VehicleRentMastViewModel } from '../store-model'; import { AuthenticationService } from '../../../_services/authentication.service'; import { LocalService } from '../../../_services/local.service'; @Component({ selector: 'app-view-sp-invoice', templateUrl: './view-sp-invoice.component.html', }) export class ViewSpInvoiceComponent implements OnInit { public P_Mast = new Sale_PurchaseMastViewModel(); public R_Mast = new VehicleRentMastViewModel(); public calingUrl: string; public urlId: number; public isSP = false; public user: any; constructor(private router: Router, public _authenticationServie: AuthenticationService, private activatedRoute: ActivatedRoute, public _notificationService: NotificationService, public _storeService: StoreService, public _localService: LocalService) { } ngOnInit() { this.user = this._authenticationServie.getUser(); this.P_Mast.FK_Inv_Type = new ItemViewModel(); this.calingUrl = this.router.url; this.activatedRoute.queryParams.subscribe(params => { this.urlId = params['id']; }); if (this.calingUrl.startsWith('/store/rent-nvoice')) { this.isSP = false; if (this.urlId != null) { this.getRentInvoiceDtl(this.urlId); } } else { this.isSP = true; if (this.urlId != null) { this.getOdrrDtl(this.urlId); } } } public getOdrrDtl(x) { this._storeService.getOderDtl(x).subscribe((res: any) => { console.log(res); this.P_Mast = res.item; }, err => { this._notificationService.notify("danger", err); }); } public getRentInvoiceDtl(x) { this._storeService.getRentInvoiceDtl(x).subscribe((res: any) => { this.R_Mast = res.item; console.log(this.R_Mast); }, err => { this._notificationService.notify("danger", err); }) } }