expiringsubscriptionreport.component.ts 5.92 KB
import { Component, OnInit } 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 { ExpiringSubscriptionReports } 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 } from 'ngx-bootstrap';
import { Http, Response } from '@angular/http';
import { LoadingService } from '../../shared/loading.service';

declare var $: any;

@Component({
    templateUrl: './expiringsubscriptionreport.component.html'
})

export class ExpiringSubscriptionReport implements OnInit {
    public lstExpiringSubscriptionReport: any;
    public lstCountry: any;
    public lstState: any;
    public lstLicenceType: any;
    public lstAccountType: any;
    ExpiringSubscriptionReportForm: FormGroup;
    ExpiringSubscriptionReports: ExpiringSubscriptionReports[];
    numberOfExpiringSubscriptionReport: 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;
    constructor(private router: Router, private reportservice: ReportService,
      private fb: FormBuilder, private modalService: BsModalService,
      private global: GlobalService, private _loadingService: LoadingService) { }

    ngOnInit(): void {
      this.NoRecord = this.global.NoRecords;
        let ExpiringSubscriptionReport = new ExpiringSubscriptionReports();
        this.previousdate.setDate(this.previousdate.getDate() - 365);
        this.ExpiringSubscriptionReportForm = this.fb.group({
            sFromDate: [this.previousdate],
            sToDate: [this.date],
            sZip: [''],
            iLicenseTypeId: [0],
            iAccountTypeId: [0],
            iStateId: [0],
            iStartPrice: [0.00],
            iEndPrice: [0.00],
            iCountryId: [0]
        });
        this._loadingService.ShowLoading("global-loading");
        this.GetCountry();
        this.GetState();
        this.GetAccountType();
        this.GetLicenceType();
        this._loadingService.HideLoading("global-loading");
        //this.GetCustomerSummeryReport();
        $('#fixed_hdr2').fxdHdrCol({
            fixedCols: 0,
            width: "100%",
            height: 300,
            colModal: [
                { width: 180, align: 'center' },
                { width: 230, align: 'center' },
                { width: 150, 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' },
                //{ width: 400, align: 'Center' },
                //{ width: 150, align: 'center' },
                //{ width: 110, align: 'center' },
            ],
            sort: true
        });
        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);
        //this.GetUsageReport();
    }


    GetCountry() {
        this.reportservice.GetCountry().subscribe(y => { this.lstCountry = y; }, error => this.error = <any>error);
    }

    GetState() {
        this.reportservice.GetState().subscribe(st => { this.lstState = st; }, error => this.error = <any>error);
    }
    GetLicenceType() {
        this.reportservice.GetLicenceType().subscribe(st => { this.lstLicenceType = st; }, error => this.error = <any>error);
    }

    GetAccountType() {
        this.reportservice.GetAccountType().subscribe(st => { this.lstAccountType = st; }, error => this.error = <any>error);
    }

    GetExpiringSubscriptionReport(this) {
      this._loadingService.ShowLoading("global-loading");
        this.ExpiringSubscription = this.ExpiringSubscriptionReportForm.value;
        var obj = this.ExpiringSubscription;
        this.reportservice.GetExpiringSubscriptionReport(obj).subscribe((ExpiringSubscriptionReports: ExpiringSubscriptionReports[]) => { this.BindFormFields(ExpiringSubscriptionReports); }, error => this.error = <any>error);
            
    }
    BindFormFields(data) {
      this.lstExpiringSubscriptionReport = data
      this.numberOfExpiringSubscriptionReport = this.lstExpiringSubscriptionReport.length; this.limit = this.lstExpiringSubscriptionReport.length;
      if (this.lstExpiringSubscriptionReport.length > 0) {
        this.NoRecord = '';
        this._loadingService.HideLoading("global-loading");
      }
      if (this.lstExpiringSubscriptionReport.length == 0) {
        this.NoRecord = this.global.NoRecords;
        this._loadingService.HideLoading("global-loading");
      }
    }
}