Renamed Report permissions to make more sense

Removed the void and reprints report and added it to the bill settlement report
updated the import to add a new sql to be executed later to update the settlements and report permission names
Export works on all reports
This commit is contained in:
Amritanshu
2019-08-25 15:08:59 +05:30
parent 05860fb0b9
commit 6d0f30503a
98 changed files with 527 additions and 1079 deletions

View File

@ -0,0 +1,94 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import * as moment from 'moment';
import { CashierReportDataSource } from './cashier-report-datasource';
import { CashierReport } from './cashier-report';
import { ToCsvService } from '../shared/to-csv.service';
import { User } from '../core/user';
@Component({
selector: 'app-cashier-report',
templateUrl: './cashier-report.component.html',
styleUrls: ['./cashier-report.component.css']
})
export class CashierReportComponent implements OnInit {
dataSource: CashierReportDataSource;
form: FormGroup;
activeCashiers: User[];
info: CashierReport;
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['name', 'amount'];
constructor(
private route: ActivatedRoute,
private router: Router,
private fb: FormBuilder,
private toCsv: ToCsvService
) {
this.createForm();
}
ngOnInit() {
this.route.data
.subscribe((data: { cashiers: User[], info: CashierReport }) => {
this.activeCashiers = data.cashiers;
this.info = data.info;
this.form.setValue({
cashier: this.info.user.id,
startDate: moment(this.info.startDate, 'DD-MMM-YYYY').toDate(),
finishDate: moment(this.info.finishDate, 'DD-MMM-YYYY').toDate()
});
this.dataSource = new CashierReportDataSource(this.info.amounts);
});
}
show() {
const info = this.getInfo();
const url = ['cashier-report'];
if (!!info.user.id) {
url.push(info.user.id);
}
this.router.navigate(url, {
queryParams: {
startDate: info.startDate,
finishDate: info.finishDate
}
});
}
createForm() {
this.form = this.fb.group({
startDate: '',
finishDate: '',
cashier: ''
});
}
getInfo(): CashierReport {
const formModel = this.form.value;
return {
user: new User({id: formModel.cashier}),
startDate: moment(formModel.startDate).format('DD-MMM-YYYY'),
finishDate: moment(formModel.finishDate).format('DD-MMM-YYYY')
};
}
exportCsv() {
const headers = {
Name: 'name',
Amount: 'amount'
};
const csvData = new Blob([this.toCsv.toCsv(headers, this.dataSource.data)], {type: 'text/csv;charset=utf-8;'});
const link = document.createElement('a');
link.href = window.URL.createObjectURL(csvData);
link.setAttribute('download', 'cashier-report.csv');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
}