sitelicenseusagereport.component.ts
8.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
import { Component, OnInit, ViewChild,HostListener } from '@angular/core';
import { Router } from '@angular/router';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
//import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/Rx';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/filter';
import { SiteLicenseUsageReports } from '../reports/reportdatamodel';
import { ReportService } from '../reports/report.service';
import { GlobalService } from '../../shared/global';
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
import { DatePipe } from '@angular/common';
import { BsDatepickerModule, BsDatepickerConfig } from 'ngx-bootstrap';
import { Http, Response } from '@angular/http';
import { LoadingService } from '../../shared/loading.service';
import { PagerComponent } from '../../shared/pager/pager.component';
import { ConfirmService } from '../../shared/confirm/confirm.service';
declare var $: any;
@Component({
templateUrl: './sitelicenseusagereport.component.html'
})
export class SiteLicenseUsageReport implements OnInit {
public lstSiteLicenseUsageReport: any;
public lstEdition: any;
SiteLicenseUsageReportForm: FormGroup;
SiteLicenseUsageReports: SiteLicenseUsageReports[];
SiteLicenseUsageReport = new SiteLicenseUsageReports();
numberOfSiteLicenseUsageReport: number;
limit: number;
page: number = 1;
error;
modalAlerts: string;
divClass: string = '';
topPos: string = '2000px';
selectedRow: number = 0;
datePipe: DatePipe = new DatePipe('en-US');
bsValue1: Date = new Date();
bsValue2: Date = new Date();
selectedId: number = 0;
modalRef: BsModalRef;
date = new Date();
previousdate = new Date();
NoRecord: string;
alerts: string;
bsConfig: Partial<BsDatepickerConfig>;
ExportingStart: boolean;
buttonStatus: boolean;
@ViewChild(PagerComponent) pagerComponent: PagerComponent;
recordCount: number;
pageNo: number;
pageLength: number;
DisableAccountNumberControl: boolean;
// Declare height and width variables
scrHeight:any;
scrWidth:any;
@HostListener('window:resize', ['$event'])
getScreenSize(event?) {
var $ua = navigator.userAgent;
if (($ua.match(/(iPod|iPhone|iPad|android)/i))) {
this.scrHeight = window.innerHeight-470;
}
else
{
this.scrHeight = window.innerHeight-400;
}
}
constructor(private router: Router, private reportservice: ReportService, private fb: FormBuilder,
private modalService: BsModalService, public global: GlobalService,
private _loadingService: LoadingService, private _confirmService: ConfirmService) {this.getScreenSize(); }
ngOnInit(): void {
this.ExportingStart = false;
this.buttonStatus = false;
this.bsConfig = Object.assign({}, { containerClass: 'theme-dark-blue' });
this.NoRecord = this.global.NoRecords;
let SiteLicenseUsageReport = new SiteLicenseUsageReports();
this.previousdate.setDate(this.previousdate.getDate());
this.SiteLicenseUsageReportForm = this.fb.group({
sFromDate: [this.previousdate],
sToDate: [this.date],
sAccountNumber:[],
iEdition:[0],
iLoginTypeId:[0]
});
if (this.global.UserTypeName == "Client Admin" || this.global.UserTypeName == "District Admin") {
this.SiteLicenseUsageReportForm.controls['sAccountNumber'].setValue(this.global.AccountNumber)
this.DisableAccountNumberControl = true;
}
this.GetEdition();
this.alerts = '';
$('#fixed_hdr2').fxdHdrCol({
fixedCols: 0,
width: "100%",
height: this.scrHeight,
colModal: [
{ width: 180, align: 'center' },
{ width: 250, align: 'center' },
{ width: 250, align: 'Center' },
{ width: 150, align: 'Center' },
{ width: 350, align: 'Center' },
{ width: 500, align: 'Center' },
{ width: 130, align: 'Center' },
// { width: 120, align: 'center' },
// { width: 280, align: 'Center' },
// { width: 180, align: 'center' },
// { width: 200, align: 'center' },
// { width: 170, align: 'center' },
// { width: 80, align: 'center' },
// { width: 150, align: 'center' },
// { width: 150, align: 'center' },
// { width: 180, align: 'Center' },
],
sort: true
});
this.pageNo = 1;
this.pageLength = 10;
this.NoRecord = this.global.NoRecords;
this.recordCount = 0;
this.pagerComponent = new PagerComponent();
if(document.getElementById("fixed_table_rc") != null){
document.getElementById("fixed_table_rc").remove();
var testScript = document.createElement("script");
testScript.setAttribute("id", "fixed_table_rc");
testScript.setAttribute("src", "../assets/scripts/fixed_table_rc.js");
testScript.setAttribute("type", "text/javascript");
document.body.appendChild(testScript);
}
}
GetEdition() {
this.reportservice.GetEdition().subscribe(st => { this.lstEdition = st; }, error => this.error = <any>error);
}
GetSiteLicenseUsageReport(evt: any) {
this.alerts = '';
this.global.compareTwoDates(this.SiteLicenseUsageReportForm.controls['sToDate'].value, this.SiteLicenseUsageReportForm.controls['sFromDate'].value);
if (this.global.ValidationMsg != '') {
this.alerts = this.global.ValidationMsg
}
if (this.alerts == '') {
this._loadingService.ShowLoading("global-loading");
var tempArr = evt.split(',');
this.pageNo = parseInt(tempArr[0]);
var actulalength=this.pageLength;
this.pageLength = parseInt(tempArr[1]);
this._loadingService.ShowLoading("global-loading");
this.SiteLicenseUsageReport = this.SiteLicenseUsageReportForm.value;
var obj = this.SiteLicenseUsageReport;
if (this.ExportingStart) {
this.reportservice.GetSiteLicenseUsageReport(obj, this.pageNo, this.pageLength).subscribe((SiteLicenseUsageReports: SiteLicenseUsageReports[]) => {
//reset length after csvexport
this.pageLength=actulalength;
this.ExportService(SiteLicenseUsageReports); }, error => this.error = <any>error);
}
else {
this.reportservice.GetSiteLicenseUsageReport(obj, this.pageNo, this.pageLength).subscribe((SiteLicenseUsageReports: SiteLicenseUsageReports[]) => { this.BindFormFields(SiteLicenseUsageReports); }, error => this.error = <any>error);
}
}
}
BindFormFields(data) {
this.recordCount = data.RecordCount;
this.lstSiteLicenseUsageReport = data.SiteLicenseUsageList;
this.numberOfSiteLicenseUsageReport = this.lstSiteLicenseUsageReport.length; this.limit = this.lstSiteLicenseUsageReport.length;
if (this.lstSiteLicenseUsageReport.length > 0) {
this.NoRecord = '';
this.buttonStatus = true;
this._loadingService.HideLoading("global-loading");
}
if (this.lstSiteLicenseUsageReport.length == 0) {
this.NoRecord = this.global.NoRecords;
this._loadingService.HideLoading("global-loading");
this.buttonStatus = false;
}
}
SearchRecords() {
this.ExportingStart = false;
this.GetSiteLicenseUsageReport('1, ' + this.pageLength);
}
ExportEvent() {
if (this.buttonStatus) {
this.ExportingStart = true;
this.GetSiteLicenseUsageReport('1, ' + this.recordCount);
this.ExportingStart = false;
}
}
ExportService(data: any) {
for (let c = 0; c < this.global.RemoveColumns.length; c++) {
for (let i = 0; i < data.SiteLicenseUsageList.length; i++) {
delete data.SiteLicenseUsageList[i][this.global.RemoveColumns[c].toString()];
}
}
this._loadingService.HideLoading("global-loading");
this.global.ExportToCSV(data.SiteLicenseUsageList, "SiteLicenseUsageReport-" + this.date.getDay() + "-" + this.date.getMonth() + "-" + this.date.getSeconds())
}
}