|
|
@@ -1,6 +1,6 @@ |
|
|
import {ChangeDetectorRef, Component, OnInit, ViewChild} from '@angular/core'; |
|
|
|
|
|
|
|
|
import {ChangeDetectorRef, Component, LOCALE_ID, OnInit, ViewChild} from '@angular/core'; |
|
|
import { |
|
|
import { |
|
|
PartnerJsonld, ProductJsonld, |
|
|
|
|
|
|
|
|
ProductJsonld, |
|
|
SaleJsonld, |
|
|
SaleJsonld, |
|
|
SaleService, |
|
|
SaleService, |
|
|
SaleSummaryJsonld, |
|
|
SaleSummaryJsonld, |
|
|
@@ -17,17 +17,26 @@ import {MatTableDataSource} from "@angular/material/table"; |
|
|
import {OrderFilter} from "@app/_models/orderFilter"; |
|
|
import {OrderFilter} from "@app/_models/orderFilter"; |
|
|
import {ApiConverter} from "@app/_helpers/api.converter"; |
|
|
import {ApiConverter} from "@app/_helpers/api.converter"; |
|
|
import {Router} from "@angular/router"; |
|
|
import {Router} from "@angular/router"; |
|
|
|
|
|
import {registerLocaleData} from "@angular/common"; |
|
|
|
|
|
import localeDe from '@angular/common/locales/de'; |
|
|
|
|
|
|
|
|
|
|
|
registerLocaleData(localeDe); |
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
selector: 'app-sales', |
|
|
|
|
|
templateUrl: './sales.component.html', |
|
|
|
|
|
styleUrl: './sales.component.scss' |
|
|
|
|
|
|
|
|
selector: 'app-sales', |
|
|
|
|
|
templateUrl: './sales.component.html', |
|
|
|
|
|
styleUrl: './sales.component.scss', |
|
|
|
|
|
providers: [ |
|
|
|
|
|
{ |
|
|
|
|
|
provide: LOCALE_ID, |
|
|
|
|
|
useValue: 'de-DE', |
|
|
|
|
|
}, |
|
|
|
|
|
], |
|
|
}) |
|
|
}) |
|
|
export class SalesComponent implements OnInit { |
|
|
export class SalesComponent implements OnInit { |
|
|
@ViewChild(MatSort) sort; |
|
|
@ViewChild(MatSort) sort; |
|
|
@ViewChild(MatPaginator) paginator: MatPaginator; |
|
|
@ViewChild(MatPaginator) paginator: MatPaginator; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected displayedColumns: string[]; |
|
|
protected displayedColumns: string[]; |
|
|
protected salesSub: Subscription; |
|
|
protected salesSub: Subscription; |
|
|
protected sales: Array<SaleJsonld>; |
|
|
protected sales: Array<SaleJsonld>; |
|
|
@@ -40,6 +49,8 @@ export class SalesComponent implements OnInit { |
|
|
protected pageSize: number; |
|
|
protected pageSize: number; |
|
|
protected pageIndex: number; |
|
|
protected pageIndex: number; |
|
|
|
|
|
|
|
|
|
|
|
protected saleSummaryMaxTurnover: number; |
|
|
|
|
|
|
|
|
protected modalOptions: NgbModalOptions = { |
|
|
protected modalOptions: NgbModalOptions = { |
|
|
centered: true |
|
|
centered: true |
|
|
}; |
|
|
}; |
|
|
@@ -50,7 +61,6 @@ export class SalesComponent implements OnInit { |
|
|
private translateService: TranslateService, |
|
|
private translateService: TranslateService, |
|
|
private modalService: NgbModal, |
|
|
private modalService: NgbModal, |
|
|
private router: Router, |
|
|
private router: Router, |
|
|
|
|
|
|
|
|
) { |
|
|
) { |
|
|
this.sort = new MatSort(); |
|
|
this.sort = new MatSort(); |
|
|
this.displayedColumns = ['pos', 'user', 'partner', 'product', 'turnover', 'profit', 'date']; |
|
|
this.displayedColumns = ['pos', 'user', 'partner', 'product', 'turnover', 'profit', 'date']; |
|
|
@@ -65,6 +75,8 @@ export class SalesComponent implements OnInit { |
|
|
this.pageEvent = new PageEvent(); |
|
|
this.pageEvent = new PageEvent(); |
|
|
this.pageSize = 10; |
|
|
this.pageSize = 10; |
|
|
this.pageIndex = 0; |
|
|
this.pageIndex = 0; |
|
|
|
|
|
|
|
|
|
|
|
this.saleSummaryMaxTurnover = 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ngOnInit() { |
|
|
ngOnInit() { |
|
|
@@ -95,10 +107,20 @@ export class SalesComponent implements OnInit { |
|
|
data => { |
|
|
data => { |
|
|
this.saleSummaries = data["hydra:member"]; |
|
|
this.saleSummaries = data["hydra:member"]; |
|
|
console.log(this.saleSummaries); |
|
|
console.log(this.saleSummaries); |
|
|
|
|
|
if (this.saleSummaries.length > 0) { |
|
|
|
|
|
this.saleSummaryMaxTurnover = Number(this.saleSummaries[0].turnover); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
calculateWidthPercentage(turnover: number, maxTurnOver: number): number { |
|
|
|
|
|
if (turnover && maxTurnOver && maxTurnOver !== 0) { |
|
|
|
|
|
return (turnover / maxTurnOver) * 100; |
|
|
|
|
|
} |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
onSortChange(sortState: Sort) { |
|
|
onSortChange(sortState: Sort) { |
|
|
// Reset page index to first page |
|
|
// Reset page index to first page |
|
|
this.pageIndex = 0; |
|
|
this.pageIndex = 0; |
|
|
@@ -136,8 +158,8 @@ export class SalesComponent implements OnInit { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
navigateToSaleDetails(element: any) { |
|
|
navigateToSaleDetails(element: any) { |
|
|
const product: ProductJsonld = element as ProductJsonld; |
|
|
|
|
|
this.router.navigate(['/products', ApiConverter.extractId(product.id)]); |
|
|
|
|
|
|
|
|
// const product: ProductJsonld = element as ProductJsonld; |
|
|
|
|
|
// this.router.navigate(['/products', ApiConverter.extractId(product.id)]); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
openModalNewSale() { |
|
|
openModalNewSale() { |
|
|
@@ -151,4 +173,6 @@ export class SalesComponent implements OnInit { |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected readonly Number = Number; |
|
|
} |
|
|
} |