From e6b869b17d236ce9e6bbe393e73c3c005cc596eb Mon Sep 17 00:00:00 2001 From: gagan.deep Date: Mon, 9 Jul 2018 12:19:34 +0530 Subject: [PATCH] Bug Fixing --- 400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/ReportController.cs | 4 ++-- 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx | 36 ++++++++++++++++++------------------ 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetCancelledLicenses_Result.cs | 2 +- 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetCustomerSummary_Result.cs | 4 ++-- 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetExpiringLicenses_Result.cs | 2 +- 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetNetAdSummaryReport_Result.cs | 2 +- 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetSiteLicenseUsageReports_Result.cs | 2 +- 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetSubscribedLicenses_Result.cs | 4 ++-- 400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetUsageReport_Result.cs | 4 ++-- 400-SOURCECODE/Admin/src/app/app.component.ts | 24 +++++++++++++----------- 400-SOURCECODE/Admin/src/app/app.module.ts | 70 ++++++++++++++++++++++++++++++++++++++-------------------------------- 400-SOURCECODE/Admin/src/app/app.routing.module.ts | 48 ++++++++++++++++++++++++------------------------ 400-SOURCECODE/Admin/src/app/components/LicenseEntity/addlicense.component.ts | 4 ++-- 400-SOURCECODE/Admin/src/app/components/LicenseEntity/editlicensebasicsettings.component.html | 2 +- 400-SOURCECODE/Admin/src/app/components/LicenseEntity/editlicensebasicsettings.component.ts | 409 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 400-SOURCECODE/Admin/src/app/components/LicenseEntity/license.service.ts | 2 +- 400-SOURCECODE/Admin/src/app/components/LicenseEntity/licensemodestysettings.component.html | 57 ++++++++++++++++++++++++++++++--------------------------- 400-SOURCECODE/Admin/src/app/components/LicenseEntity/licensemodestysettings.component.ts | 309 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------- 400-SOURCECODE/Admin/src/app/components/LicenseEntity/licensemodulesettings.component.html | 2 +- 400-SOURCECODE/Admin/src/app/components/LicenseEntity/licensemodulesettings.component.ts | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------- 400-SOURCECODE/Admin/src/app/components/LicenseEntity/searchlicense.component.html | 5 +++++ 400-SOURCECODE/Admin/src/app/components/LicenseEntity/searchlicense.component.ts | 11 ++++++----- 400-SOURCECODE/Admin/src/app/components/LicenseEntity/sitelicenseaccount.component.ts | 8 ++++---- 400-SOURCECODE/Admin/src/app/components/ManageDiscountCode/managediscountcode.component.ts | 8 ++++---- 400-SOURCECODE/Admin/src/app/components/ManageDiscountCode/managediscountcode.service.ts | 2 +- 400-SOURCECODE/Admin/src/app/components/Reports/customersummaryreport.component.ts | 12 +++++++----- 400-SOURCECODE/Admin/src/app/components/Reports/discountcodereport.component.ts | 11 ++++++----- 400-SOURCECODE/Admin/src/app/components/Reports/expiringsubscriptionreport.component.html | 24 ++++++++++++++++-------- 400-SOURCECODE/Admin/src/app/components/Reports/expiringsubscriptionreport.component.ts | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 400-SOURCECODE/Admin/src/app/components/Reports/imageexportreport.component.ts | 15 ++++++++------- 400-SOURCECODE/Admin/src/app/components/Reports/netadsubscriptionreport.component.ts | 15 ++++++++------- 400-SOURCECODE/Admin/src/app/components/Reports/report.service.ts | 8 +++++++- 400-SOURCECODE/Admin/src/app/components/Reports/sitelicenseusagereport.component.ts | 11 ++++++----- 400-SOURCECODE/Admin/src/app/components/Reports/subscriptioncancellationreport.component.ts | 11 ++++++----- 400-SOURCECODE/Admin/src/app/components/Reports/subscriptionreport.component.ts | 11 ++++++----- 400-SOURCECODE/Admin/src/app/components/Reports/usagereport.component.html | 84 ++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------- 400-SOURCECODE/Admin/src/app/components/Reports/usagereport.component.ts | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.component.ts | 8 ++++---- 400-SOURCECODE/Admin/src/app/components/SubscriptionPrice/subscriptionprice.service.ts | 2 +- 400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.html | 2 +- 400-SOURCECODE/Admin/src/app/components/UserEntity/adduser.component.ts | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------ 400-SOURCECODE/Admin/src/app/components/UserEntity/changeuserid.component.ts | 4 ++-- 400-SOURCECODE/Admin/src/app/components/UserEntity/changeuserpassword.component.ts | 4 ++-- 400-SOURCECODE/Admin/src/app/components/UserEntity/unblockuser.component.ts | 6 +++--- 400-SOURCECODE/Admin/src/app/components/UserEntity/updateuserprofile.component.ts | 8 ++++---- 400-SOURCECODE/Admin/src/app/components/UserEntity/user.service.ts | 4 ++-- 400-SOURCECODE/Admin/src/app/components/UserEntity/usergroup.component.html | 19 ++----------------- 400-SOURCECODE/Admin/src/app/components/UserEntity/usergroup.component.ts | 40 ++++------------------------------------ 400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts | 10 +++++----- 400-SOURCECODE/Admin/src/app/shared/global.ts | 4 ++-- 400-SOURCECODE/Admin/src/assets/data/Menu.json | 2 +- 400-SOURCECODE/Admin/src/tsconfig.app.json | 3 ++- 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetCancelledLicenses.sql | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetCustomerSummary.sql | 188 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetDiscountReport.sql | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetExpiringLicenses.sql | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetNetAdSummaryReport.sql | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetSiteLicenseUsageReport.sql | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetSubscribedLicenses.sql | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetUsageReport.sql | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 60 files changed, 2192 insertions(+), 747 deletions(-) create mode 100644 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetCancelledLicenses.sql create mode 100644 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetCustomerSummary.sql create mode 100644 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetDiscountReport.sql create mode 100644 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetExpiringLicenses.sql create mode 100644 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetNetAdSummaryReport.sql create mode 100644 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetSiteLicenseUsageReport.sql create mode 100644 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetSubscribedLicenses.sql create mode 100644 500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetUsageReport.sql diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/ReportController.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/ReportController.cs index e00de28..6c1f3e4 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/ReportController.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Controllers/ReportController.cs @@ -57,7 +57,7 @@ namespace AIAHTML5.ADMIN.API.Controllers public IHttpActionResult GetSubscriptionReport(string sFromDate, string sToDate, decimal icStartPrice, decimal icEndPrice, int iLicenseTypeId, int iAccountTypeId, string sZip, int iStateId, int iCountryId, int pageNo, int pageLength) { var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0); - var lstExpiringSubscriptionReport = dbContext.GetSubscribedLicenses(sFromDate, sToDate, icStartPrice, icEndPrice, (byte)iLicenseTypeId, (byte)iAccountTypeId, sZip, iStateId, iCountryId, pageNo, pageLength, spRecordCount).ToList(); + var lstExpiringSubscriptionReport = dbContext.usp_GetSubscribedLicenses(sFromDate, sToDate, icStartPrice, icEndPrice, (byte)iLicenseTypeId, (byte)iAccountTypeId, sZip, iStateId, iCountryId, pageNo, pageLength, spRecordCount).ToList(); return Ok(new { Subscription = lstExpiringSubscriptionReport, RecordCount = spRecordCount.Value }); } [Route("GetSubscriptionCancellationReport")] @@ -93,7 +93,7 @@ namespace AIAHTML5.ADMIN.API.Controllers try { var spRecordCount = new System.Data.Objects.ObjectParameter("recordCount", 0); - var lstSiteLicenseUsageReport = dbContext.usp_GetSiteLicenseUsageReport(sFromDate, sToDate, sAccountNumber, (byte)iEdition, pageNo, pageLength, spRecordCount).ToList(); + var lstSiteLicenseUsageReport = dbContext.usp_GetSiteLicenseUsageReports(sFromDate, sToDate, sAccountNumber, (byte)iEdition, pageNo, pageLength, spRecordCount).ToList(); return Ok(new { SiteLicenseUsageList = lstSiteLicenseUsageReport, RecordCount = spRecordCount.Value }); } catch (Exception ex) diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx index dd3e2b5..5fb207d 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/AIADBEntity.edmx @@ -8333,7 +8333,6 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] - @@ -8345,9 +8344,9 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + - @@ -8363,7 +8362,8 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] - + + @@ -8375,7 +8375,6 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] - @@ -8388,6 +8387,7 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + @@ -8403,7 +8403,6 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] - @@ -8412,6 +8411,7 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + @@ -8424,12 +8424,11 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] - - - + + @@ -8438,6 +8437,7 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + @@ -8458,7 +8458,6 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] - @@ -8466,13 +8465,13 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + - @@ -8483,7 +8482,8 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] - + + @@ -11170,7 +11170,6 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] - @@ -11182,13 +11181,13 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + - @@ -11205,6 +11204,7 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + @@ -11224,7 +11224,6 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] - @@ -11237,6 +11236,7 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + @@ -11260,7 +11260,6 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] - @@ -11269,6 +11268,7 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + @@ -11289,7 +11289,6 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] - @@ -11303,6 +11302,7 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + @@ -11331,7 +11331,6 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] - @@ -11339,6 +11338,7 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + @@ -11353,7 +11353,6 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] - @@ -11365,6 +11364,7 @@ FROM [dbo].[VocabTermNumberToSystemMap] AS [VocabTermNumberToSystemMap] + diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetCancelledLicenses_Result.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetCancelledLicenses_Result.cs index 144e9c7..2522872 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetCancelledLicenses_Result.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetCancelledLicenses_Result.cs @@ -13,7 +13,6 @@ namespace AIAHTML5.ADMIN.API.Entity public partial class usp_GetCancelledLicenses_Result { - public Nullable RowNum { get; set; } public string AccountNumber { get; set; } public string LicenseeName { get; set; } public string LicenseType { get; set; } @@ -25,5 +24,6 @@ namespace AIAHTML5.ADMIN.API.Entity public string LicenseCreationDate { get; set; } public Nullable SubscriptionPrice { get; set; } public Nullable CardNumber { get; set; } + public Nullable Serial_No { get; set; } } } diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetCustomerSummary_Result.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetCustomerSummary_Result.cs index ba1a770..3a527e4 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetCustomerSummary_Result.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetCustomerSummary_Result.cs @@ -13,7 +13,6 @@ namespace AIAHTML5.ADMIN.API.Entity public partial class usp_GetCustomerSummary_Result { - public Nullable RowNum { get; set; } public string AccountNumber { get; set; } public string LicenseeName { get; set; } public string LicenseType { get; set; } @@ -29,6 +28,7 @@ namespace AIAHTML5.ADMIN.API.Entity public string LicenseCountry { get; set; } public string InstitutionName { get; set; } public string LicenseCreationDate { get; set; } - public Nullable CardNumber { get; set; } + public int CardNumber { get; set; } + public Nullable Serial_No { get; set; } } } diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetExpiringLicenses_Result.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetExpiringLicenses_Result.cs index 7f5d4ef..cf7054a 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetExpiringLicenses_Result.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetExpiringLicenses_Result.cs @@ -13,7 +13,6 @@ namespace AIAHTML5.ADMIN.API.Entity public partial class usp_GetExpiringLicenses_Result { - public Nullable RowNum { get; set; } public string AccountNumber { get; set; } public string LicenseeName { get; set; } public string LicenseType { get; set; } @@ -26,5 +25,6 @@ namespace AIAHTML5.ADMIN.API.Entity public string AccountType { get; set; } public Nullable DaysRemaining { get; set; } public Nullable CardNumber { get; set; } + public Nullable Serial_No { get; set; } } } diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetNetAdSummaryReport_Result.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetNetAdSummaryReport_Result.cs index 4a5bf58..309b006 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetNetAdSummaryReport_Result.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetNetAdSummaryReport_Result.cs @@ -13,7 +13,6 @@ namespace AIAHTML5.ADMIN.API.Entity public partial class usp_GetNetAdSummaryReport_Result { - public Nullable RowNum { get; set; } public string LicenseType { get; set; } public string AccountType { get; set; } public string InstitutionName { get; set; } @@ -22,5 +21,6 @@ namespace AIAHTML5.ADMIN.API.Entity public Nullable RenewSubscription { get; set; } public Nullable InActiveSubscription { get; set; } public Nullable NetAdSubscription { get; set; } + public Nullable Serial_No { get; set; } } } diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetSiteLicenseUsageReports_Result.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetSiteLicenseUsageReports_Result.cs index dba6cba..aeedd41 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetSiteLicenseUsageReports_Result.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetSiteLicenseUsageReports_Result.cs @@ -13,7 +13,6 @@ namespace AIAHTML5.ADMIN.API.Entity public partial class usp_GetSiteLicenseUsageReports_Result { - public Nullable RowNum { get; set; } public string AccountNumber { get; set; } public string EditionTitle { get; set; } public string ReferalUrl { get; set; } @@ -21,5 +20,6 @@ namespace AIAHTML5.ADMIN.API.Entity public string LicenseCreationDate { get; set; } public Nullable TotalLogins { get; set; } public string LastLogin { get; set; } + public Nullable Serial_No { get; set; } } } diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetSubscribedLicenses_Result.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetSubscribedLicenses_Result.cs index d592155..7e66600 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetSubscribedLicenses_Result.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetSubscribedLicenses_Result.cs @@ -13,7 +13,6 @@ namespace AIAHTML5.ADMIN.API.Entity public partial class usp_GetSubscribedLicenses_Result { - public Nullable RowNum { get; set; } public string AccountNumber { get; set; } public string LicenseeName { get; set; } public string LicenseType { get; set; } @@ -24,6 +23,7 @@ namespace AIAHTML5.ADMIN.API.Entity public string EndDate { get; set; } public string LicenseCreationDate { get; set; } public Nullable SubscriptionPrice { get; set; } - public Nullable CardNumber { get; set; } + public int CardNumber { get; set; } + public Nullable Serial_No { get; set; } } } diff --git a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetUsageReport_Result.cs b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetUsageReport_Result.cs index a569219..69ac1ad 100644 --- a/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetUsageReport_Result.cs +++ b/400-SOURCECODE/AIAHTML5.ADMIN.API/Entity/usp_GetUsageReport_Result.cs @@ -13,12 +13,11 @@ namespace AIAHTML5.ADMIN.API.Entity public partial class usp_GetUsageReport_Result { - public Nullable RowNum { get; set; } public string LoginId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string AccountNumber { get; set; } - public Nullable CardNumber { get; set; } + public int CardNumber { get; set; } public string UserType { get; set; } public string LicenseCreationDate { get; set; } public string LicenseZip { get; set; } @@ -27,5 +26,6 @@ namespace AIAHTML5.ADMIN.API.Entity public string InstitutionName { get; set; } public Nullable TotalLogins { get; set; } public string LastLogin { get; set; } + public Nullable Serial_No { get; set; } } } diff --git a/400-SOURCECODE/Admin/src/app/app.component.ts b/400-SOURCECODE/Admin/src/app/app.component.ts index 1bf5c42..e1d4029 100644 --- a/400-SOURCECODE/Admin/src/app/app.component.ts +++ b/400-SOURCECODE/Admin/src/app/app.component.ts @@ -1,11 +1,11 @@ import { Component, OnInit } from '@angular/core'; -import { UserService } from './components/UserEntity/user.service'; -import { ManageDiscountCodeService } from './components/ManageDiscountCode/managediscountcode.service'; -import { SubscriptionPriceService } from './components/SubscriptionPrice/subscriptionprice.service'; -import { LicenseService } from './components/LicenseEntity/license.service'; -import { ReportService } from './components/Reports/report.service'; +import { UserService } from './components/userentity/user.service'; +import { ManageDiscountCodeService } from './components/managediscountcode/managediscountcode.service'; +import { SubscriptionPriceService } from './components/subscriptionprice/subscriptionprice.service'; +import { LicenseService } from './components/licenseentity/license.service'; +import { ReportService } from './components/reports/report.service'; //import { MyAuthService } from './shared/my-auth.service'; -import { GlobalService } from './Shared/global'; +import { GlobalService } from './shared/global'; import { Router, NavigationEnd } from '@angular/router'; //import { HttpClient } from '@angular/common/http'; //import { HttpErrorResponse } from '@angular/common/http'; @@ -22,21 +22,23 @@ export class AppComponent implements OnInit { public objMenu: any; public menustaus: string; public submenustaus: string; - + public UpdateProfileVisible: boolean; constructor(private userservice: UserService, public global: GlobalService, private router: Router ) { } ngOnInit(): void { - this.menustaus = "True"; + this.menustaus = "True"; this.global.getJSON().subscribe(data => { this.obj = data["AdminSections"] for (let i = 0; i < 7; i++) { - if (this.obj[i].Id == this.global.UserType) { - this.objMenu = this.obj[i].HeaderMenu; + if (this.obj[i].Id == this.global.UserType) { + this.objMenu = this.obj[i].HeaderMenu; + this.router.navigate(['/updateuserprofile']); } } }, error => console.log(error)); - this.router.navigate(['/updateuserprofile']); + + } logout() { localStorage.removeItem('loggedInUserDetails'); diff --git a/400-SOURCECODE/Admin/src/app/app.module.ts b/400-SOURCECODE/Admin/src/app/app.module.ts index 71e7a10..ec79704 100644 --- a/400-SOURCECODE/Admin/src/app/app.module.ts +++ b/400-SOURCECODE/Admin/src/app/app.module.ts @@ -5,49 +5,54 @@ import { RouterModule, Routes } from '@angular/router'; import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; import { APP_BASE_HREF } from '@angular/common'; import { HttpModule } from '@angular/http'; +//import { Ng2SmartTableModule } from 'ng2-smart-table'; import { Ng2Bs3ModalModule } from 'ng2-bs3-modal/ng2-bs3-modal'; import { CsvService } from "angular2-json2csv"; +import { BsDatepickerModule, ModalModule } from 'ngx-bootstrap'; +import { BsModalService } from 'ngx-bootstrap/modal'; +import { BsDropdownModule } from 'ngx-bootstrap'; +import { Ng2OrderModule } from 'ng2-order-pipe'; //importing the module + //import { ModalModule } from 'ngx-bootstrap/modal'; -import { UpdateUserProfile } from './components/UserEntity/updateuserprofile.component'; -import { ChangeUserPassword } from './components/UserEntity/changeuserpassword.component'; -import { ChangeUserID } from './components/UserEntity/changeuserid.component'; -import { UsersList } from './components/UserEntity/users.component'; -import { AddUser } from './components/UserEntity/adduser.component'; -import { UnblockUser } from './components/UserEntity/unblockuser.component'; -import { ManageDiscountCode } from './components/ManageDiscountCode/managediscountcode.component'; -import { SubscriptionPrice } from './components/SubscriptionPrice/subscriptionprice.component'; -import { SearchLicense } from './components/LicenseEntity/searchlicense.component'; -import { AddLicense } from './components/LicenseEntity/addlicense.component'; -import { UsageReport } from './components/Reports/usagereport.component'; -import { CustomerSummaryReport } from './components/Reports/customersummaryreport.component'; -import { ExpiringSubscriptionReport } from './components/Reports/expiringsubscriptionreport.component'; -import { SubscriptionReport } from './components/Reports/subscriptionreport.component'; -import { SubscriptionCancellationReport } from './components/Reports/subscriptioncancellationreport.component'; -import { NetAdSubscriptionReport } from './components/Reports/netadsubscriptionreport.component'; -import { SiteLicenseUsageReport } from './components/Reports/sitelicenseusagereport.component'; -import { DiscountCodeReport } from './components/Reports/discountcodereport.component'; -import { ImageExportReport } from './components/Reports/imageexportreport.component'; -import { EditLicenseBasicSettings } from './components/LicenseEntity/editlicensebasicsettings.component'; -import { LicenseModestySettings } from './components/LicenseEntity/licensemodestysettings.component'; -import { LicenseModuleSettings } from './components/LicenseEntity/licensemodulesettings.component'; -import { SiteLicenseAccount } from './components/LicenseEntity/sitelicenseaccount.component'; -import { UserGroup } from './components/UserEntity/usergroup.component'; +import { UpdateUserProfile } from './components/userentity/updateuserprofile.component'; +import { ChangeUserPassword } from './components/userentity/changeuserpassword.component'; +import { ChangeUserID } from './components/userentity/changeuserid.component'; +import { UsersList } from './components/userentity/users.component'; +import { AddUser } from './components/userentity/adduser.component'; +import { UnblockUser } from './components/userentity/unblockuser.component'; +import { ManageDiscountCode } from './components/managediscountcode/managediscountcode.component'; +import { SubscriptionPrice } from './components/subscriptionprice/subscriptionprice.component'; +import { SearchLicense } from './components/licenseentity/searchlicense.component'; +import { AddLicense } from './components/licenseentity/addlicense.component'; +import { UsageReport } from './components/reports/usagereport.component'; +import { CustomerSummaryReport } from './components/reports/customersummaryreport.component'; +import { ExpiringSubscriptionReport } from './components/reports/expiringsubscriptionreport.component'; +import { SubscriptionReport } from './components/reports/subscriptionreport.component'; +import { SubscriptionCancellationReport } from './components/reports/subscriptioncancellationreport.component'; +import { NetAdSubscriptionReport } from './components/reports/netadsubscriptionreport.component'; +import { SiteLicenseUsageReport } from './components/reports/sitelicenseusagereport.component'; +import { DiscountCodeReport } from './components/reports/discountcodereport.component'; +import { ImageExportReport } from './components/reports/imageexportreport.component'; +import { EditLicenseBasicSettings } from './components/licenseentity/editlicensebasicsettings.component'; +import { LicenseModestySettings } from './components/licenseentity/licensemodestysettings.component'; +import { LicenseModuleSettings } from './components/licenseentity/licensemodulesettings.component'; +import { SiteLicenseAccount } from './components/licenseentity/sitelicenseaccount.component'; +import { UserGroup } from './components/userentity/usergroup.component'; import { AppComponent } from './app.component'; import { AppRoutingModule } from './app.routing.module'; //import { AuthGuard } from '../app/authguard.service'; //import { AuthService } from '../app/auth.service'; //import { MyInterceptor } from '../app/token.interceptor'; -import { GlobalService } from './Shared/global'; -import { ConfirmService } from './Shared/Confirm/confirm.service'; -import { ConfirmComponent } from "./Shared/Confirm/confirm.component" -import { BsDatepickerModule, ModalModule } from 'ngx-bootstrap'; -import { BsModalService } from 'ngx-bootstrap/modal'; +import { GlobalService } from './shared/global'; +import { ConfirmService } from './shared/confirm/confirm.service'; +import { ConfirmComponent } from "./shared/confirm/confirm.component" + import { ContenteditableModelDirective } from './shared/contenteditabledirective'; import { LoadingService } from './shared/loading.service'; -import { PagerComponent } from './shared/Pager/pager.component'; +import { PagerComponent } from './shared/pager/pager.component'; import { NumberOnlyDirective } from './shared/numberonlydirective'; import { MyFilterPipe } from './shared/my-filter.pipe'; -import { BsDropdownModule } from 'ngx-bootstrap'; + //import { MyAuthService } from './shared/my-auth.service'; //import { AngularFireAuth } from 'angularfire2/auth'; //import { FirebaseApp, AngularFireModule } from 'angularfire2'; @@ -78,7 +83,8 @@ import { BsDropdownModule } from 'ngx-bootstrap'; ], imports: [ BrowserModule, AppRoutingModule, HttpClientModule, FormsModule, ReactiveFormsModule, HttpModule, Ng2Bs3ModalModule, - BsDatepickerModule.forRoot(), ModalModule.forRoot(), BsDropdownModule.forRoot()//ModalModule.forRoot() + BsDatepickerModule.forRoot(), ModalModule.forRoot(), BsDropdownModule.forRoot(), Ng2OrderModule + //ModalModule.forRoot() // , AngularFireModule.initializeApp(firebaseConfig), ], providers: [GlobalService, ConfirmService, BsModalService, LoadingService, CsvService, diff --git a/400-SOURCECODE/Admin/src/app/app.routing.module.ts b/400-SOURCECODE/Admin/src/app/app.routing.module.ts index 896266d..35be9fd 100644 --- a/400-SOURCECODE/Admin/src/app/app.routing.module.ts +++ b/400-SOURCECODE/Admin/src/app/app.routing.module.ts @@ -1,29 +1,29 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; -import { UpdateUserProfile } from './components/UserEntity/updateuserprofile.component'; -import { ChangeUserPassword } from './components/UserEntity/changeuserpassword.component'; -import { ChangeUserID } from './components/UserEntity/changeuserid.component'; -import { UsersList } from './components/UserEntity/users.component'; -import { UnblockUser } from './components/UserEntity/unblockuser.component'; -import { ManageDiscountCode } from './components/ManageDiscountCode/managediscountcode.component'; -import { SubscriptionPrice } from './components/SubscriptionPrice/subscriptionprice.component'; -import { AddUser } from './components/UserEntity/adduser.component'; -import { SearchLicense } from './components/LicenseEntity/searchlicense.component'; -import { AddLicense } from './components/LicenseEntity/addlicense.component'; -import { UsageReport } from './components/Reports/usagereport.component'; -import { CustomerSummaryReport } from './components/Reports/customersummaryreport.component'; -import { ExpiringSubscriptionReport } from './components/Reports/expiringsubscriptionreport.component'; -import { SubscriptionReport } from './components/Reports/subscriptionreport.component'; -import { SubscriptionCancellationReport } from './components/Reports/subscriptioncancellationreport.component'; -import { NetAdSubscriptionReport } from './components/Reports/netadsubscriptionreport.component'; -import { SiteLicenseUsageReport } from './components/Reports/sitelicenseusagereport.component'; -import { DiscountCodeReport } from './components/Reports/discountcodereport.component'; -import { ImageExportReport } from './components/Reports/imageexportreport.component'; -import { EditLicenseBasicSettings } from './components/LicenseEntity/editlicensebasicsettings.component'; -import { LicenseModestySettings } from './components/LicenseEntity/licensemodestysettings.component'; -import { LicenseModuleSettings } from './components/LicenseEntity/licensemodulesettings.component'; -import { SiteLicenseAccount } from './components/LicenseEntity/sitelicenseaccount.component'; -import { UserGroup } from './components/UserEntity/usergroup.component'; +import { UpdateUserProfile } from './components/userentity/updateuserprofile.component'; +import { ChangeUserPassword } from './components/userentity/changeuserpassword.component'; +import { ChangeUserID } from './components/userentity/changeuserid.component'; +import { UsersList } from './components/userentity/users.component'; +import { UnblockUser } from './components/userentity/unblockuser.component'; +import { ManageDiscountCode } from './components/managediscountcode/managediscountcode.component'; +import { SubscriptionPrice } from './components/subscriptionprice/subscriptionprice.component'; +import { AddUser } from './components/userentity/adduser.component'; +import { SearchLicense } from './components/licenseentity/searchlicense.component'; +import { AddLicense } from './components/licenseentity/addlicense.component'; +import { UsageReport } from './components/reports/usagereport.component'; +import { CustomerSummaryReport } from './components/reports/customersummaryreport.component'; +import { ExpiringSubscriptionReport } from './components/reports/expiringsubscriptionreport.component'; +import { SubscriptionReport } from './components/reports/subscriptionreport.component'; +import { SubscriptionCancellationReport } from './components/reports/subscriptioncancellationreport.component'; +import { NetAdSubscriptionReport } from './components/reports/netadsubscriptionreport.component'; +import { SiteLicenseUsageReport } from './components/reports/sitelicenseusagereport.component'; +import { DiscountCodeReport } from './components/reports/discountcodereport.component'; +import { ImageExportReport } from './components/reports/imageexportreport.component'; +import { EditLicenseBasicSettings } from './components/licenseentity/editlicensebasicsettings.component'; +import { LicenseModestySettings } from './components/licenseentity/licensemodestysettings.component'; +import { LicenseModuleSettings } from './components/licenseentity/licensemodulesettings.component'; +import { SiteLicenseAccount } from './components/licenseentity/sitelicenseaccount.component'; +import { UserGroup } from './components/userentity/usergroup.component'; const appRoutes: Routes = [ //{ path: '', redirectTo:'updateuserprofile',pathMatch } { path: 'updateuserprofile', component: UpdateUserProfile }, diff --git a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/addlicense.component.ts b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/addlicense.component.ts index 8443144..19ec419 100644 --- a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/addlicense.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/addlicense.component.ts @@ -1,9 +1,9 @@ import { Component, OnInit, AfterViewInit, Input, Output, EventEmitter, Pipe, PipeTransform, TemplateRef } from '@angular/core'; import { LicenseService } from './license.service'; -import { GlobalService } from '../../Shared/global'; +import { GlobalService } from '../../shared/global'; import { Router, ActivatedRoute } from '@angular/router'; import { FormControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { License } from '../UserEntity/datamodel'; +import { License } from '../userentity/datamodel'; import { BsDatepickerModule, BsDatepickerConfig } from 'ngx-bootstrap'; import { Http, Response } from '@angular/http'; import { DatePipe } from '@angular/common'; diff --git a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/editlicensebasicsettings.component.html b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/editlicensebasicsettings.component.html index 92901e9..0488105 100644 --- a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/editlicensebasicsettings.component.html +++ b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/editlicensebasicsettings.component.html @@ -43,7 +43,7 @@
-
+
+ +
@@ -22,8 +22,8 @@ @@ -44,21 +44,21 @@
-
- - -
+
+ + +
@@ -68,12 +68,14 @@
+ License Account +
+ Building Level Account +
@@ -101,10 +103,10 @@
@@ -119,10 +121,12 @@
+ On + + Off +
@@ -177,7 +181,6 @@ - diff --git a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/licensemodestysettings.component.ts b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/licensemodestysettings.component.ts index 4932e90..ebb3766 100644 --- a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/licensemodestysettings.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/licensemodestysettings.component.ts @@ -1,179 +1,206 @@ import { Component, OnInit, AfterViewInit, Input, Output, EventEmitter, Pipe, PipeTransform, TemplateRef } from '@angular/core'; import { LicenseService } from './license.service'; -import { GlobalService } from '../../Shared/global'; +import { GlobalService } from '../../shared/global'; import { Router, ActivatedRoute } from '@angular/router'; import { FormControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { License } from '../UserEntity/datamodel'; +import { License } from '../userentity/datamodel'; import { BsDatepickerModule } from 'ngx-bootstrap'; import { Http, Response } from '@angular/http'; import { DatePipe } from '@angular/common'; import { BsModalService } from 'ngx-bootstrap/modal'; import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service'; import { ContenteditableModelDirective } from '../../shared/contenteditabledirective' -import { ConfirmService } from '../../Shared/Confirm/confirm.service'; +import { ConfirmService } from '../../shared/confirm/confirm.service'; @Component({ - templateUrl: './licensemodestysettings.component.html' + templateUrl: './licensemodestysettings.component.html' }) export class LicenseModestySettings implements OnInit { - lstAccountNumbers: any; - tempLstAccountNumbers: any; - lstLicenseSites: any; - lstLicenseEditionModesty: any; - license: License; - updateModestySettingsFrm: FormGroup; - error: any; - alerts: string; - modalAlerts: string; - modalMessage: string; - modalRef: BsModalRef; - selectedSiteId: number = 0; - isBuildingLevel: boolean = false; - accountDropDownText: string; - loopIdx: number; - - constructor(private licenseService: LicenseService, private globalService: GlobalService, private router: Router, private activeRoute: ActivatedRoute, private fb: FormBuilder, - private modalService: BsModalService, private _confirmService: ConfirmService) { } - - ngOnInit(): void - { - this.license = new License(); - this.license.LicenseId = 0; - this.alerts = ''; - this.accountDropDownText = 'Select'; - this.loopIdx = 0; - this.updateModestySettingsFrm = this.fb.group({ - licenseId: [0], - accountNumber: ['', Validators.required], - siteId: [0], - lstModesty: [this.fb.array([])], - }); - this.GetLicenseAccounts(); - } + lstAccountNumbers: any; + tempLstAccountNumbers: any; + lstLicenseSites: any; + lstLicenseEditionModesty: any; + license: License; + updateModestySettingsFrm: FormGroup; + error: any; + alerts: string; + modalAlerts: string; + modalMessage: string; + modalRef: BsModalRef; + selectedSiteId: number = 0; + isBuildingLevel: boolean = false; + accountDropDownText: string; + loopIdx1: number; + loopIdx2: number; + lastScrollPos: number; - openModal(template: TemplateRef) { - this.modalRef = this.modalService.show(template); - } + constructor(private licenseService: LicenseService, private globalService: GlobalService, private router: Router, private activeRoute: ActivatedRoute, private fb: FormBuilder, + private modalService: BsModalService, private _confirmService: ConfirmService) { } - GetLicenseAccounts() { - this.licenseService.GetLicenseAccounts(0) - .subscribe(st => { - this.lstAccountNumbers = st; - this.tempLstAccountNumbers = []; - this.loopIdx = 0; - for (var i = 0; i < 1000; i++) { - if(this.loopIdx < this.lstAccountNumbers.length){ - this.tempLstAccountNumbers.push(this.lstAccountNumbers[this.loopIdx]); - this.loopIdx++; - } - } - }, error => this.error = error); - } + ngOnInit(): void { + this.license = new License(); + this.license.LicenseId = 0; + this.alerts = ''; + this.accountDropDownText = 'Select'; + this.loopIdx1 = 0; + this.loopIdx2 = 0; + this.lastScrollPos = 0; + this.updateModestySettingsFrm = this.fb.group({ + licenseId: [0], + accountNumber: ['', Validators.required], + siteId: [0], + lstModesty: [this.fb.array([])], + }); + this.GetLicenseAccounts(); + } - ShowModestyorSites(template: TemplateRef) { - this.lstLicenseEditionModesty = null; - this.lstLicenseSites = null; - this.selectedSiteId = 0; - if(!this.isBuildingLevel){ - this.GetLicenseEditionModesty(); - } - else{ - this.licenseService.GetLicenseSites(this.license.AccountNumber, 1, 1000) - .subscribe(st => { - this.lstLicenseSites = st.LicenseSiteList; - if(this.lstLicenseSites.length == 0){ - this.modalMessage = 'Account is not a building level account.'; - this.openModal(template); - } - }, error => this.error = error); + openModal(template: TemplateRef) { + this.modalRef = this.modalService.show(template); + } + + GetLicenseAccounts() { + this.licenseService.GetLicenseAccounts(0) + .subscribe(st => { + this.lstAccountNumbers = st; + this.loopIdx1 = 0; + this.loopIdx2 = 0; + this.lastScrollPos = 0; + this.tempLstAccountNumbers = []; + for (var i = 0; i < 50; i++) { + this.tempLstAccountNumbers.push(this.lstAccountNumbers[this.loopIdx2++]); } - } + }, error => this.error = error); + } - GetLicenseEditionModesty() { - this.licenseService.GetLicenseModestySettings(this.license.LicenseId, this.selectedSiteId) - .subscribe(st => { - this.lstLicenseEditionModesty = st; - this.updateModestySettingsFrm.setControl('lstModesty', this.fb.array(this.lstLicenseEditionModesty)); - }, error => this.error = error); + ShowModestyorSites(template: TemplateRef) { + this.lstLicenseEditionModesty = null; + this.lstLicenseSites = null; + this.selectedSiteId = 0; + if (!this.isBuildingLevel) { + this.GetLicenseEditionModesty(); } + else { + this.licenseService.GetLicenseSites(this.license.AccountNumber, 1, 1000) + .subscribe(st => { + this.lstLicenseSites = st.LicenseSiteList; + if (this.lstLicenseSites.length == 0) { + this.modalMessage = 'Account is not a building level account.'; + this.openModal(template); + } + }, error => this.error = error); + } + } - LicenseSiteChanged(siteId: number){ - this.selectedSiteId = siteId; - if(this.selectedSiteId == 0) { - this.lstLicenseEditionModesty = null; - return; - } - this.GetLicenseEditionModesty(); + GetLicenseEditionModesty() { + this.licenseService.GetLicenseModestySettings(this.license.LicenseId, this.selectedSiteId) + .subscribe(st => { + this.lstLicenseEditionModesty = st; + this.updateModestySettingsFrm.setControl('lstModesty', this.fb.array(this.lstLicenseEditionModesty)); + }, error => this.error = error); + } + + LicenseSiteChanged(siteId: number) { + this.selectedSiteId = siteId; + if (this.selectedSiteId == 0) { + this.lstLicenseEditionModesty = null; + return; } + this.GetLicenseEditionModesty(); + } - GetLicenseById() { - if(this.license.LicenseId != 0) - { - this.licenseService.GetLicenseById(this.license.LicenseId) - .subscribe(st => { - this.license = st; - this.updateModestySettingsFrm.controls['licenseId'].setValue(this.license.LicenseId); - this.updateModestySettingsFrm.controls['accountNumber'].setValue(this.license.AccountNumber); - }, - error => this.error = error); - } + GetLicenseById() { + if (this.license.LicenseId != 0) { + this.licenseService.GetLicenseById(this.license.LicenseId) + .subscribe(st => { + this.license = st; + this.updateModestySettingsFrm.controls['licenseId'].setValue(this.license.LicenseId); + this.updateModestySettingsFrm.controls['accountNumber'].setValue(this.license.AccountNumber); + }, + error => this.error = error); } + } - AccountNumberChanged(LicenseId: number, SelectText: string){ - this.accountDropDownText = SelectText; - this.license.LicenseId = LicenseId; - this.lstLicenseEditionModesty = null; - this.lstLicenseSites = null; - this.selectedSiteId = 0; - this.isBuildingLevel = false; - this.GetLicenseById(); + AccountNumberChanged(LicenseId: number, SelectText: string) { + this.accountDropDownText = SelectText; + this.license.LicenseId = LicenseId; + this.lstLicenseEditionModesty = null; + this.lstLicenseSites = null; + this.selectedSiteId = 0; + this.isBuildingLevel = false; + this.GetLicenseById(); + } + + onScroll($event) { + if (this.lastScrollPos > $event.target.scrollTop) { + for (var i = 0; i < 1000; i++) { + if (this.loopIdx1 > 0) + this.tempLstAccountNumbers.unshift(this.lstAccountNumbers[this.loopIdx1--]); + } + } + else { + for (var i = 0; i < 1000; i++) { + if (this.loopIdx2 < this.lstAccountNumbers.length) + this.tempLstAccountNumbers.push(this.lstAccountNumbers[this.loopIdx2++]); + } } + this.lastScrollPos = $event.target.scrollTop; + } - onScroll($event){ - if($event.target.scrollTop >= ($event.target.scrollHeight/2)){ - for (var i = 0; i < 5000; i++) { - if(this.loopIdx < this.lstAccountNumbers.length){ - this.tempLstAccountNumbers.push(this.lstAccountNumbers[this.loopIdx]); - this.loopIdx++; - } - } - } + onOpenChange(data: boolean): void { + if (!data) { + this.loopIdx1 = 0; + this.loopIdx2 = 0; + this.tempLstAccountNumbers = []; + this.lastScrollPos = 0; + for (var i = 0; i < 50; i++) { + this.tempLstAccountNumbers.push(this.lstAccountNumbers[this.loopIdx2++]); + } } + } - onOpenChange(data: boolean): void { - if(!data){ - this.loopIdx = 0; - this.tempLstAccountNumbers = []; - for (var i = 0; i < 1000; i++) { - if(this.loopIdx < this.lstAccountNumbers.length){ - this.tempLstAccountNumbers.push(this.lstAccountNumbers[this.loopIdx]); - this.loopIdx++; - } - } + onKeyPress($event) { + let FindItem = this.lstAccountNumbers.find(C => (C.m_Item2.toLowerCase().indexOf($event.key) == 0)); + let prevIdx = 0; + if (FindItem != null) { + this.tempLstAccountNumbers = []; + for (var i = 0; i < this.lstAccountNumbers.length; i++) { + if (FindItem.m_Item1 == this.lstAccountNumbers[i].m_Item1) { + prevIdx = i; + break; } + } + this.loopIdx1 = prevIdx; + this.loopIdx2 = prevIdx; + for (var i = 0; i < 50; i++) { + if (this.loopIdx2 < this.lstAccountNumbers.length) + this.tempLstAccountNumbers.push(this.lstAccountNumbers[this.loopIdx2++]); + } + this.lastScrollPos = 0; + $event.target.nextElementSibling.scrollTop = 0; } + } - AfterUpdateData(data, template) { - if (data.Status == "false") { - this.alerts = "License modesty settings update unsuccessfull."; - } else { - this._confirmService.activate("License modesty settings updated successfully.", "alertMsg"); - // this.modalAlerts = "

License modesty setings updated successfully.

"; - // this.modalRef = this.modalService.show(template); - } + AfterUpdateData(data, template) { + if (data.Status == "false") { + this.alerts = "License modesty settings update unsuccessfull."; + } else { + this._confirmService.activate("License modesty settings updated successfully.", "alertMsg"); + // this.modalAlerts = "

License modesty setings updated successfully.

"; + // this.modalRef = this.modalService.show(template); } + } - UpdateLicenseModestySettings(template: TemplateRef){ - this.alerts = ''; - if(this.alerts == ''){ - var obj = this.updateModestySettingsFrm.value; - return this.licenseService.UpdateLicenseModestySettings(obj) - .subscribe( - n => (this.AfterUpdateData(n, template)), - error => this.error = error); - } + UpdateLicenseModestySettings(template: TemplateRef) { + this.alerts = ''; + if (this.alerts == '') { + var obj = this.updateModestySettingsFrm.value; + return this.licenseService.UpdateLicenseModestySettings(obj) + .subscribe( + n => (this.AfterUpdateData(n, template)), + error => this.error = error); } - + } + } diff --git a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/licensemodulesettings.component.html b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/licensemodulesettings.component.html index a0fc22d..25577db 100644 --- a/400-SOURCECODE/Admin/src/app/components/LicenseEntity/licensemodulesettings.component.html +++ b/400-SOURCECODE/Admin/src/app/components/LicenseEntity/licensemodulesettings.component.html @@ -32,7 +32,7 @@
-
+
- -
+
diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/usergroup.component.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/usergroup.component.ts index 5f75a85..fd34e4a 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/usergroup.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/usergroup.component.ts @@ -2,16 +2,16 @@ import { Component, OnInit, AfterViewInit, AfterViewChecked, Input, Output, Even import { UserService } from './user.service'; import { Router, ActivatedRoute } from '@angular/router'; import { FormControl, FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { License } from '../UserEntity/datamodel'; +import { License } from '../userentity/datamodel'; import { BsDatepickerModule } from 'ngx-bootstrap'; import { Http, Response } from '@angular/http'; import { DatePipe } from '@angular/common'; import { BsModalService } from 'ngx-bootstrap/modal'; import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service'; -import { ConfirmService } from '../../Shared/Confirm/confirm.service'; -import { PagerComponent } from '../../shared/Pager/pager.component'; +import { ConfirmService } from '../../shared/confirm/confirm.service'; +import { PagerComponent } from '../../shared/pager/pager.component'; import { LoadingService } from '../../shared/loading.service'; -import { GlobalService } from '../../Shared/global'; +import { GlobalService } from '../../shared/global'; declare var $: any; @Component({ @@ -141,14 +141,6 @@ export class UserGroup implements OnInit, AfterViewChecked { this.userService.GetLicenseAccounts(1) .subscribe(st => { this.lstAccountNumbers = st; - this.tempLstAccountNumbers = []; - this.loopIdx = 0; - for (var i = 0; i < 1000; i++) { - if(this.loopIdx < this.lstAccountNumbers.length){ - this.tempLstAccountNumbers.push(this.lstAccountNumbers[this.loopIdx]); - this.loopIdx++; - } - } }, error => this.error = error); } @@ -196,30 +188,6 @@ export class UserGroup implements OnInit, AfterViewChecked { this.SearchRecords(); } - onScroll($event){ - if($event.target.scrollTop >= ($event.target.scrollHeight/2)){ - for (var i = 0; i < 5000; i++) { - if(this.loopIdx < this.lstAccountNumbers.length){ - this.tempLstAccountNumbers.push(this.lstAccountNumbers[this.loopIdx]); - this.loopIdx++; - } - } - } -} - -onOpenChange(data: boolean): void { - if(!data){ - this.loopIdx = 0; - this.tempLstAccountNumbers = []; - for (var i = 0; i < 1000; i++) { - if(this.loopIdx < this.lstAccountNumbers.length){ - this.tempLstAccountNumbers.push(this.lstAccountNumbers[this.loopIdx]); - this.loopIdx++; - } - } - } -} - AfterDeleteData(data, template) { if (data.Status == "false") { this.alerts = "License user group delete unsuccessfull"; diff --git a/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts b/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts index c2d2f5d..378a7d1 100644 --- a/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts +++ b/400-SOURCECODE/Admin/src/app/components/UserEntity/users.component.ts @@ -3,21 +3,21 @@ import { UserService } from './user.service'; import { Router } from '@angular/router'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { User } from '../UserEntity/datamodel'; -import { UserManageRightsModel } from '../UserEntity/datamodel'; +import { User } from '../userentity/datamodel'; +import { UserManageRightsModel } from '../userentity/datamodel'; import { Http, Response } from '@angular/http'; //import { Global } from '../../Shared/global'; //import { DBOperation } from 'S'; import { Observable } from 'rxjs/Observable'; -import { ConfirmService } from '../../Shared/Confirm/confirm.service'; +import { ConfirmService } from '../../shared/confirm/confirm.service'; import 'rxjs/Rx'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/filter'; import { LoadingService } from '../../shared/loading.service'; declare var $: any; import { DatePipe } from '@angular/common'; -import { GlobalService } from '../../Shared/global'; -import { PagerComponent } from '../../shared/Pager/pager.component'; +import { GlobalService } from '../../shared/global'; +import { PagerComponent } from '../../shared/pager/pager.component'; @Component({ templateUrl:'./users.component.html' // '../../../../../wwwroot/html/UpdateProfile/updateuserprofile.component.html' }) diff --git a/400-SOURCECODE/Admin/src/app/shared/global.ts b/400-SOURCECODE/Admin/src/app/shared/global.ts index b2e5d7d..ba42cb6 100644 --- a/400-SOURCECODE/Admin/src/app/shared/global.ts +++ b/400-SOURCECODE/Admin/src/app/shared/global.ts @@ -25,9 +25,9 @@ export class GlobalService { this.LiveAPIURL = "http://beta.interactiveanatomy.com/API/Adminapi/"; this.QAAPIURL = "http://qa.beta.interactiveanatomy.com/API/Adminapi/"; this.LocalURL = "http://localhost:4200"; - //this.resourceBaseUrl = this.hostURL; + this.resourceBaseUrl = this.hostURL; //this.resourceBaseUrl = this.LiveAPIURL; - this.resourceBaseUrl = this.QAAPIURL; + // this.resourceBaseUrl = this.QAAPIURL; if (this.resourceBaseUrl == "http://192.168.84.242:97/") { localStorage.setItem('loggedInUserDetails', JSON.stringify( diff --git a/400-SOURCECODE/Admin/src/assets/data/Menu.json b/400-SOURCECODE/Admin/src/assets/data/Menu.json index 20d1e0c..c1d872d 100644 --- a/400-SOURCECODE/Admin/src/assets/data/Menu.json +++ b/400-SOURCECODE/Admin/src/assets/data/Menu.json @@ -492,7 +492,7 @@ "SubMenuId": "207", "SubMenuName": "List User", "SubMenuUrl": "users", - "SubMenuStatus": "True" + "SubMenuStatus": "False" }, { "SubMenuId": "208", diff --git a/400-SOURCECODE/Admin/src/tsconfig.app.json b/400-SOURCECODE/Admin/src/tsconfig.app.json index 39ba8db..ee99807 100644 --- a/400-SOURCECODE/Admin/src/tsconfig.app.json +++ b/400-SOURCECODE/Admin/src/tsconfig.app.json @@ -4,7 +4,8 @@ "outDir": "../out-tsc/app", "baseUrl": "./", "module": "es2015", - "types": [] + "types": [], + "preserveWhitespaces": true }, "exclude": [ "test.ts", diff --git a/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetCancelledLicenses.sql b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetCancelledLicenses.sql new file mode 100644 index 0000000..de14a59 --- /dev/null +++ b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetCancelledLicenses.sql @@ -0,0 +1,163 @@ +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetCancelledLicenses]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[usp_GetCancelledLicenses] +GO + +CREATE PROCEDURE [dbo].[usp_GetCancelledLicenses] + -- Add the parameters for the stored procedure here + @sFromDate varchar(20), @sToDate varchar(20), @iStartPrice numeric(14,2), @iEndPrice numeric(14,2), @iLicenseTypeId tinyint, + @iAccountTypeId tinyint , @sZip varchar(20) = '', @iStateId int, @iCountryId int,@pageNo int, @pageLength int, @recordCount int out +AS +BEGIN + + IF 1=0 BEGIN + SET FMTONLY OFF + END + -- SET NOCOUNT ON added to prevent extra result sets from + SET NOCOUNT ON; + DECLARE @dtFromDate DATETIME + DECLARE @dtToDate DATETIME + DECLARE @cGetLicenseID CURSOR + DECLARE @iLicenseId INT + DECLARE @iLicenseSubscriptionDetail INT + DECLARE @sAccountNumber VARCHAR(50) + DECLARE @sLicenseeName VARCHAR(100) + DECLARE @sLicenseType VARCHAR(50) + DECLARE @sInstitutionName VARCHAR(100) + DECLARE @dtStartDate DATETIME + DECLARE @dtEndDate DATETIME + DECLARE @dtLicenseCreationDate DATETIME + DECLARE @mSubscriptionPrice MONEY + DECLARE @sAccountType VARCHAR(50) + DECLARE @sEdition VARCHAR(200) + DECLARE @iCardNumber INT + + + -- convert the datatype of fromdate & todate parameter to datetime + SELECT @dtFromDate = CONVERT(DATETIME,@sFromDate) + SELECT @dtToDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sToDate))) + + -- create a temporary table to store the desired results of cancelled licenses on the basis of parameter + CREATE TABLE #CancelledLicenseReport + ( + AccountNumber VARCHAR(50), + LicenseeName VARCHAR(100), + LicenseType VARCHAR(50), + InstitutionName VARCHAR(100), + Edition VARCHAR(200), + ValidFrom DATETIME, + ValidThrough DATETIME, + LicenseCreationDate DATETIME, + Price MONEY, + AccountType VARCHAR(50), + CardNumber INT + ) + + -- define the forward only, read-only cursor + SET @cGetLicenseID = CURSOR FAST_FORWARD + FOR + SELECT LicenseSubscriptionDetail.LicenseId, MAX(LicenseSubscriptionDetail.Id) + FROM LicenseSubscriptionDetail + INNER JOIN License ON License.Id = LicenseSubscriptionDetail.LicenseId + WHERE (License.CancellationDate BETWEEN @dtFromDate AND @dtToDate) AND + (TotalAmount >= (CASE WHEN @iStartPrice > 0 THEN @iStartPrice ELSE 0 END)) + AND (TotalAmount <= (CASE WHEN @iEndPrice = 0 THEN 0 WHEN @iEndPrice > 0 THEN @iEndPrice ELSE 9999999999 END)) + GROUP BY LicenseSubscriptionDetail.LicenseId + --HAVING (MAX(SubscriptionValidThrough) BETWEEN @dtFromDate AND @dtToDate) + + -- open & fetch the cursor variables into the local variables + OPEN @cGetLicenseID + FETCH NEXT FROM @cGetLicenseID INTO @iLicenseId, @iLicenseSubscriptionDetail + -- start of while loop + WHILE @@FETCH_STATUS = 0 + BEGIN + + SET @sEdition = '' + -- fetch the accountnumber, licenseename, licensetype, startdate, enddate, subscriptionprice, accountype of a license + SELECT @sAccountNumber = AccountNumber, @sLicenseeName = LicenseeName, @sLicenseType = LicenseType, + @sInstitutionName = InstitutionName, + @dtStartDate = SubscriptionValidFrom, @dtEndDate = SubscriptionValidThrough, + @dtLicenseCreationDate = CreationDate, + @mSubscriptionPrice = TotalAmount, @sAccountType = AccountType, @iCardNumber = CardNumber + FROM + ( + SELECT AccountNumber, (LicenseeFirstName+' '+LicenseeLastName) as LicenseeName, + LicenseType.Title as LicenseType, License.InstitutionName, + AccountType.Title as AccountType, LicenseSubscriptionDetail.TotalAmount, + LicenseSubscriptionDetail.SubscriptionValidFrom, LicenseSubscriptionDetail.SubscriptionValidThrough, + License.CreationDate, + DATEDIFF(dd,GETDATE(),License.CancellationDate) as DaysRemaining, (CASE WHEN License.CardNumber > 0 THEN License.CardNumber END) as CardNumber + FROM License + INNER JOIN LicenseType ON License.LicenseTypeId = LicenseType.Id + INNER JOIN AccountType ON License.AccountTypeId = AccountType.Id + INNER JOIN State ON License.StateId = State.Id + INNER JOIN Country ON License.CountryId = Country.Id + INNER JOIN LicenseSubscriptionDetail ON License.Id = LicenseSubscriptionDetail.LicenseId + WHERE License.IsActive = 0 + AND License.LicenseTypeId = (CASE WHEN @iLicenseTypeId > 0 THEN @iLicenseTypeId ELSE License.LicenseTypeId END) + AND License.AccountTypeId = (CASE WHEN @iAccountTypeId > 0 THEN @iAccountTypeId ELSE License.AccountTypeId END) + AND State.Id = (CASE WHEN @iStateId > 0 THEN @iStateId ELSE State.Id END) + AND Country.Id = (CASE WHEN @iCountryId > 0 THEN @iCountryId ELSE Country.Id END) + AND License.Zip = (CASE WHEN LEN(@sZip)>0 THEN @sZip ELSE License.Zip END) + AND LicenseSubscriptionDetail.Id = @iLicenseSubscriptionDetail + AND License.LicenseTypeId <> 5 + ) t1 + + -- check whether the above query returns any row + IF @@Rowcount > 0 + BEGIN + -- fetch all the editions mapped as a string with a license + SELECT @sEdition = Edition.Title + '; ' + @sEdition + FROM LicenseToEdition INNER JOIN Edition + ON LicenseToEdition.EditionId = Edition.Id + WHERE LicenseToEdition.LicenseId = @iLicenseId + -- remove the trailing comma-separator from the edition-string + --AMI SET @sEdition = SUBSTRING(@sEdition,1,LEN(@sEdition)-1); + IF LEN(@sEdition)> 1 + -- remove the trailing comma-separator from the edition-string + SET @sEdition = SUBSTRING(@sEdition,1,LEN(@sEdition)-1) + ELSE + SET @sEdition = @sEdition + + -- insert into the temporary table + INSERT INTO #CancelledLicenseReport + (AccountNumber,LicenseeName,LicenseType,InstitutionName,Edition,ValidFrom,ValidThrough,LicenseCreationDate,Price,AccountType,CardNumber) + VALUES(@sAccountNumber,@sLicenseeName,@sLicenseType,@sInstitutionName,@sEdition,@dtStartDate,@dtEndDate,@dtLicenseCreationDate,@mSubscriptionPrice,@sAccountType,@iCardNumber) + END + -- fetch the next record from cursor + FETCH NEXT FROM @cGetLicenseID INTO @iLicenseId,@iLicenseSubscriptionDetail + -- end of while loop + END + -- close the cursor to free up resources + CLOSE @cGetLicenseID + DEALLOCATE @cGetLicenseID + + -- Selecting the desired result from temporary table + --SELECT AccountNumber, LicenseeName, LicenseType,InstitutionName,AccountType, Edition, CONVERT(VARCHAR,ValidFrom,101) as StartDate, + -- CONVERT(VARCHAR,ValidThrough,101) as EndDate,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice, CardNumber + --FROM #CancelledLicenseReport ORDER BY AccountNumber + + + SELECT RowNum as 'Serial_No', AccountNumber, LicenseeName, LicenseType,InstitutionName,AccountType, Edition, StartDate, + EndDate,LicenseCreationDate,SubscriptionPrice, CardNumber + from ( + SELECT ROW_NUMBER() OVER (ORDER BY AccountNumber) AS RowNum, AccountNumber, LicenseeName, LicenseType,InstitutionName,AccountType, Edition, CONVERT(VARCHAR,ValidFrom,101) as StartDate, + CONVERT(VARCHAR,ValidThrough,101) as EndDate,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice, CardNumber + FROM #CancelledLicenseReport) as Tempt + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo + ORDER BY AccountNumber + + --Calculate total number of records + select @recordCount = count(ResultTable.AccountNumber) + from ( + SELECT AccountNumber, LicenseeName, LicenseType,InstitutionName,AccountType, Edition, CONVERT(VARCHAR,ValidFrom,101) as StartDate, + CONVERT(VARCHAR,ValidThrough,101) as EndDate,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice, CardNumber + FROM #CancelledLicenseReport) as ResultTable + + + -- Dropping the temporary table + DROP TABLE #CancelledLicenseReport +END + + + + diff --git a/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetCustomerSummary.sql b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetCustomerSummary.sql new file mode 100644 index 0000000..89e25ee --- /dev/null +++ b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetCustomerSummary.sql @@ -0,0 +1,188 @@ +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetCustomerSummary]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[usp_GetCustomerSummary] +GO + +CREATE PROCEDURE [dbo].[usp_GetCustomerSummary] + -- Add the parameters for the stored procedure here + @sAccoutNumber varchar(50)='', @sLicenseeFullName varchar(100)='', @iStartPrice numeric(14,2), @iEndPrice numeric(14,2), + @iLicenseType tinyint, @iAccountType tinyint, @sZip varchar(20) = '', @iState int, + @iCountry int,@pageNo int, @pageLength int, @recordCount int out +AS +BEGIN + IF 1=0 BEGIN + SET FMTONLY OFF + END + -- SET NOCOUNT ON added to prevent extra result sets from + SET NOCOUNT ON + DECLARE @cGetLicenseDetails CURSOR + DECLARE @iLicenseId INT + DECLARE @sAccountNumber VARCHAR(50) + DECLARE @sLicenseeName VARCHAR(100) + DECLARE @iLicenseTypeId TINYINT + DECLARE @sLicenseType VARCHAR(50) + DECLARE @dtStartDate DATETIME + DECLARE @dtEndDate DATETIME + DECLARE @sAccountType VARCHAR(50) + DECLARE @iAccountTypeId TINYINT + DECLARE @sLicenseStatus VARCHAR(8) + DECLARE @sEdition VARCHAR(200) + DECLARE @bExists bit + DECLARE @sLicenseState VARCHAR(50) + DECLARE @sLicenseZip VARCHAR(20) + DECLARE @sLicenseCountry VARCHAR(50) + DECLARE @sInstitutionName VARCHAR(100) + DECLARE @dtLicenseCreationDate DATETIME + DECLARE @mSubscriptionPrice MONEY + DECLARE @iLicenseSubscriptionId INT + DECLARE @sEmailId VARCHAR(100) + DECLARE @iCardNumber INT + + -- create a temporary table to store the desired results of licenses on the basis of parameter + CREATE TABLE #CustomerReport + ( + AccountNumber VARCHAR(50), + LicenseeName VARCHAR(100), + LicenseType VARCHAR(50), + Edition VARCHAR(200), + Email VARCHAR(100), + ValidFrom DATETIME, + ValidThrough DATETIME, + AccountType VARCHAR(50), + LicenseStatus VARCHAR(8), + Price MONEY, + LicenseState VARCHAR(50), + LicenseZip VARCHAR(20), + LicenseCountry VARCHAR(50), + InstitutionName VARCHAR(100), + LicenseCreationDate DATETIME, + CardNumber INT + ) + + SET @sLicenseeFullName = REPLACE(@sLicenseeFullName,' ',' OR ') + + -- define the forward only, read-only cursor + SET @cGetLicenseDetails = CURSOR FAST_FORWARD + FOR + SELECT License.Id, License.AccountNumber, (License.LicenseeFirstName+' '+License.LicenseeLastName), + License.LicenseTypeId, License.AccountTypeId, License.EmailId, + (CASE License.IsActive WHEN 1 THEN 'Active' ELSE 'Inactive' END) as LicenseStatus, + State.StateName, License.Zip, Country.CountryName, + License.InstitutionName,License.CreationDate, + (CASE WHEN License.CardNumber > 0 THEN License.CardNumber END) as CardNumber + FROM License WITH (NOLOCK) + INNER JOIN State WITH (NOLOCK) ON License.StateId = State.Id + INNER JOIN Country WITH (NOLOCK) ON License.CountryId = Country.Id + WHERE + License.AccountNumber = (CASE WHEN LEN(@sAccoutNumber)>0 THEN @sAccoutNumber ELSE License.AccountNumber END) + AND License.LicenseTypeId = (CASE WHEN @iLicenseType > 0 THEN @iLicenseType ELSE License.LicenseTypeId END) + AND License.AccountTypeId = (CASE WHEN @iAccountType > 0 THEN @iAccountType ELSE License.AccountTypeId END) + AND State.Id = (CASE WHEN @iState > 0 THEN @iState ELSE State.Id END) + AND Country.Id = (CASE WHEN @iCountry > 0 THEN @iCountry ELSE Country.Id END) + AND License.Zip = (CASE WHEN LEN(@sZip)>0 THEN @sZip ELSE License.Zip END) + + -- open & fetch the cursor variables into the local variables + OPEN @cGetLicenseDetails + FETCH NEXT FROM @cGetLicenseDetails INTO @iLicenseId, @sAccountNumber, @sLicenseeName, + @iLicenseTypeId, @iAccountTypeId, @sEmailId, @sLicenseStatus, @sLicenseState, @sLicenseZip, @sLicenseCountry,@sInstitutionName,@dtLicenseCreationDate, @iCardNumber + + -- start of while loop + WHILE @@FETCH_STATUS = 0 + BEGIN + + SET @sEdition = '' + SET @bExists = 1 + -- fetch the latest license start/end date of a license on the basis of Subscription Start & End price if any + SELECT @dtStartDate = MAX(LicenseSubscriptionDetail.SubscriptionValidFrom), + @dtEndDate = MAX(LicenseSubscriptionDetail.SubscriptionValidThrough), + @iLicenseSubscriptionId = MAX(LicenseSubscriptionDetail.Id) + FROM LicenseSubscriptionDetail WITH (NOLOCK) + WHERE LicenseSubscriptionDetail.LicenseId = @iLicenseId + AND (TotalAmount >= (CASE WHEN @iStartPrice > 0 THEN @iStartPrice ELSE 0 END)) + AND (TotalAmount <= (CASE WHEN @iEndPrice = 0 THEN 0 WHEN @iEndPrice > 0 THEN @iEndPrice ELSE 9999999999 END)) + GROUP BY LicenseSubscriptionDetail.LicenseId + + + -- check whether the above query returns any row + IF @@Rowcount > 0 + BEGIN + + -- check whether the name of licensse matches the name entered by user + + IF LEN(@sLicenseeFullName) > 0 + BEGIN + SELECT @bExists = 1 + FROM License WITH (NOLOCK) + WHERE Id = @iLicenseId AND (LicenseeFirstName LIKE '%'+@sLicenseeFullName+'%' OR LicenseeLastName LIKE '%'+@sLicenseeFullName+'%') --CONTAINS((LicenseeFirstName,LicenseeLastName) + IF @@Rowcount = 0 + BEGIN + SET @bExists = 0 + END + END + + -- check whether the above query returns any row + IF @bExists = 1 + BEGIN + -- fetch the licensetype of the license + SELECT @sLicenseType = LicenseType.Title FROM LicenseType WITH (NOLOCK) + WHERE LicenseType.Id = @iLicenseTypeId + -- fetch the accounttype of the license + SELECT @sAccountType = AccountType.Title FROM AccountType WITH (NOLOCK) + WHERE AccountType.Id = @iAccountTypeId + + -- fetch all the editions mapped as a string with a license + SELECT @sEdition = Edition.Title + '; ' + @sEdition + FROM LicenseToEdition WITH (NOLOCK) INNER JOIN Edition WITH (NOLOCK) + ON LicenseToEdition.EditionId = Edition.Id + WHERE LicenseToEdition.LicenseId = @iLicenseId + + IF LEN(@sEdition)> 1 + -- remove the trailing comma-separator from the edition-string + SET @sEdition = SUBSTRING(@sEdition,1,LEN(@sEdition)-1) + ELSE + SET @sEdition = @sEdition + + -- fetch the price of the license + SELECT @mSubscriptionPrice = TotalAmount FROM LicenseSubscriptionDetail WITH (NOLOCK) + WHERE Id = @iLicenseSubscriptionId + + -- insert into the temporary table + INSERT INTO #CustomerReport + (AccountNumber, LicenseeName, LicenseType, Edition, Email, ValidFrom, ValidThrough, AccountType, LicenseStatus, Price, LicenseState, LicenseZip, LicenseCountry, InstitutionName, LicenseCreationDate, CardNumber) + VALUES(@sAccountNumber, @sLicenseeName, @sLicenseType, @sEdition, @sEmailId, @dtStartDate, @dtEndDate, @sAccountType, @sLicenseStatus, @mSubscriptionPrice, @sLicenseState, @sLicenseZip, @sLicenseCountry,@sInstitutionName,@dtLicenseCreationDate, @iCardNumber) + END + END + -- fetch the next record from cursor + FETCH NEXT FROM @cGetLicenseDetails INTO @iLicenseId, @sAccountNumber, @sLicenseeName, + @iLicenseTypeId, @iAccountTypeId, @sEmailId, @sLicenseStatus, @sLicenseState, @sLicenseZip, @sLicenseCountry, @sInstitutionName, @dtLicenseCreationDate, @iCardNumber + -- end of while loop + END + -- close the cursor to free up resources + CLOSE @cGetLicenseDetails + DEALLOCATE @cGetLicenseDetails + + -- Selecting the desired result from temporary table + SELECT RowNum as 'Serial_No', AccountNumber, LicenseeName, LicenseType, AccountType, Edition, Email, StartDate, + EndDate, LicenseStatus, Price, + LicenseZip, LicenseState, LicenseCountry,InstitutionName,LicenseCreationDate , CardNumber + from ( + SELECT ROW_NUMBER() OVER (ORDER BY AccountNumber) AS RowNum, AccountNumber, LicenseeName, LicenseType, AccountType, Edition, Email, CONVERT(VARCHAR,ValidFrom,101) as StartDate, + CONVERT(VARCHAR,ValidThrough,101) as EndDate, LicenseStatus, CONVERT(NUMERIC(14,2),Price) as Price, + LicenseZip, LicenseState, LicenseCountry,InstitutionName, CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate , isnull(CardNumber,'') as CardNumber + FROM #CustomerReport WITH (NOLOCK) ) as usr + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo + ORDER BY AccountNumber + + --Calculate total number of records + select @recordCount = count(ResultTable.AccountNumber) + from ( + SELECT AccountNumber, LicenseeName, LicenseType, AccountType, Edition, Email, CONVERT(VARCHAR,ValidFrom,101) as StartDate, + CONVERT(VARCHAR,ValidThrough,101) as EndDate, LicenseStatus, CONVERT(NUMERIC(14,2),Price) as Price, + LicenseZip, LicenseState, LicenseCountry,InstitutionName, CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate , CardNumber + FROM #CustomerReport WITH (NOLOCK) ) as ResultTable + + -- Dropping the temporary table + DROP TABLE #CustomerReport +END + + + diff --git a/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetDiscountReport.sql b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetDiscountReport.sql new file mode 100644 index 0000000..a565b5d --- /dev/null +++ b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetDiscountReport.sql @@ -0,0 +1,88 @@ +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetDiscountReport]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[usp_GetDiscountReport] +GO + +CREATE PROCEDURE [dbo].[usp_GetDiscountReport] + -- Add the parameters for the stored procedure here + @sStartDate VARCHAR(20) = '', @sEndDate VARCHAR(20) = '', @intDiscountID INT, + @sAccoutNumber VARCHAR(16)='', @pageNo int, @pageLength int, @recordCount int out +AS +BEGIN + + IF 1=0 BEGIN + SET FMTONLY OFF + END + + -- SET NOCOUNT ON added to prevent extra result sets from + -- interfering with SELECT statements. + SET NOCOUNT ON; + DECLARE @dtStartDate DATETIME, @dtEndDate DATETIME + + -- convert the datatype of startdate & enddate parameter to datetime + SELECT @dtStartDate = CONVERT(DATETIME,@sStartDate) + SELECT @dtEndDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sEndDate))) + IF LEN(@sAccoutNumber) > 0 + BEGIN + + Select RowNum, DiscountCode, Percentage, StartDate, EndDate, DiscountStatus, TotalLicenses + from ( + SELECT ROW_NUMBER() OVER (ORDER BY Discount.StartDate) AS RowNum , Discount.DiscountCode, Discount.Percentage, CONVERT(VARCHAR(10),Discount.StartDate,101) as StartDate, + CONVERT(VARCHAR(10),Discount.EndDate,101) as EndDate, + (CASE Discount.IsActive WHEN 1 THEN 'Active' ELSE 'Inactive' END) AS DiscountStatus, + COUNT(DiscountToLicense.LicenseId) AS TotalLicenses + FROM Discount INNER JOIN DiscountToLicense ON Discount.Id = DiscountToLicense.DiscountId + INNER JOIN License ON License.Id = DiscountToLicense.LicenseId + WHERE Discount.StartDate >= (CASE WHEN LEN(@sStartDate) > 0 THEN @dtStartDate ELSE Discount.StartDate END) + AND Discount.EndDate <= (CASE WHEN LEN(@sEndDate) > 0 THEN @dtEndDate ELSE Discount.EndDate END) + AND Discount.Id = (CASE WHEN @intDiscountID > 0 THEN @intDiscountID ELSE Discount.Id END) + AND License.AccountNumber = @sAccoutNumber + GROUP BY Discount.DiscountCode, Discount.Percentage, Discount.StartDate, Discount.EndDate, Discount.IsActive) as usr + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo order by StartDate + + --Calculate total number of records + select @recordCount = count(ResultTable.DiscountCode) from ( + SELECT Discount.DiscountCode, Discount.Percentage, CONVERT(VARCHAR(10),Discount.StartDate,101) as StartDate, + CONVERT(VARCHAR(10),Discount.EndDate,101) as EndDate, + (CASE Discount.IsActive WHEN 1 THEN 'Active' ELSE 'Inactive' END) AS DiscountStatus, + COUNT(DiscountToLicense.LicenseId) AS TotalLicenses + FROM Discount INNER JOIN DiscountToLicense ON Discount.Id = DiscountToLicense.DiscountId + INNER JOIN License ON License.Id = DiscountToLicense.LicenseId + WHERE Discount.StartDate >= (CASE WHEN LEN(@sStartDate) > 0 THEN @dtStartDate ELSE Discount.StartDate END) + AND Discount.EndDate <= (CASE WHEN LEN(@sEndDate) > 0 THEN @dtEndDate ELSE Discount.EndDate END) + AND Discount.Id = (CASE WHEN @intDiscountID > 0 THEN @intDiscountID ELSE Discount.Id END) + AND License.AccountNumber = @sAccoutNumber + GROUP BY Discount.DiscountCode, Discount.Percentage, Discount.StartDate, Discount.EndDate, Discount.IsActive) as ResultTable; + + END + ELSE + BEGIN + + Select RowNum as 'Serial_No', DiscountCode, Percentage, StartDate, EndDate, DiscountStatus, TotalLicenses + from ( + SELECT ROW_NUMBER() OVER (ORDER BY Discount.StartDate) AS RowNum , Discount.DiscountCode, Discount.Percentage, CONVERT(VARCHAR(10),Discount.StartDate,101) as StartDate, + CONVERT(VARCHAR(10),Discount.EndDate,101) as EndDate, + (CASE Discount.IsActive WHEN 1 THEN 'Active' ELSE 'Inactive' END) AS DiscountStatus, + COUNT(DiscountToLicense.LicenseId) AS TotalLicenses + FROM Discount LEFT JOIN DiscountToLicense ON Discount.Id = DiscountToLicense.DiscountId + WHERE Discount.StartDate >= (CASE WHEN LEN(@sStartDate) > 0 THEN @dtStartDate ELSE Discount.StartDate END) + AND Discount.EndDate <= (CASE WHEN LEN(@sEndDate) > 0 THEN @dtEndDate ELSE Discount.EndDate END) + AND Discount.Id = (CASE WHEN @intDiscountID > 0 THEN @intDiscountID ELSE Discount.Id END) + GROUP BY Discount.DiscountCode, Discount.Percentage, Discount.StartDate, Discount.EndDate, Discount.IsActive) as usr + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo order by StartDate + + --Calculate total number of records + select @recordCount = count(ResultTable.DiscountCode) from ( + SELECT Discount.DiscountCode, Discount.Percentage, CONVERT(VARCHAR(10),Discount.StartDate,101) as StartDate, + CONVERT(VARCHAR(10),Discount.EndDate,101) as EndDate, + (CASE Discount.IsActive WHEN 1 THEN 'Active' ELSE 'Inactive' END) AS DiscountStatus, + COUNT(DiscountToLicense.LicenseId) AS TotalLicenses + FROM Discount LEFT JOIN DiscountToLicense ON Discount.Id = DiscountToLicense.DiscountId + WHERE Discount.StartDate >= (CASE WHEN LEN(@sStartDate) > 0 THEN @dtStartDate ELSE Discount.StartDate END) + AND Discount.EndDate <= (CASE WHEN LEN(@sEndDate) > 0 THEN @dtEndDate ELSE Discount.EndDate END) + AND Discount.Id = (CASE WHEN @intDiscountID > 0 THEN @intDiscountID ELSE Discount.Id END) + GROUP BY Discount.DiscountCode, Discount.Percentage, Discount.StartDate, Discount.EndDate, Discount.IsActive) as ResultTable; + + END + +END + diff --git a/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetExpiringLicenses.sql b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetExpiringLicenses.sql new file mode 100644 index 0000000..4fa2764 --- /dev/null +++ b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetExpiringLicenses.sql @@ -0,0 +1,161 @@ +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetExpiringLicenses]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[usp_GetExpiringLicenses] +GO + +CREATE PROCEDURE [dbo].[usp_GetExpiringLicenses] --'2010-01-01','2020-01-01',0,1,0,0,'',0,0,1,10,0 + -- Add the parameters for the stored procedure here + @sFromDate varchar(20), @sToDate varchar(20), @iStartPrice numeric(14,2), @iEndPrice numeric(14,2), + @iLicenseTypeId int, @iAccountTypeId int, @sZip varchar(20)=null, @iStateId int, @iCountryId int + ,@pageNo int, @pageLength int, @recordCount int out +AS +BEGIN + + IF 1=0 BEGIN + SET FMTONLY OFF + END + + -- SET NOCOUNT ON added to prevent extra result sets from + SET NOCOUNT ON; + DECLARE @dtFromDate DATETIME + DECLARE @dtToDate DATETIME + DECLARE @cGetLicenseId CURSOR + DECLARE @iLicenseId INT + DECLARE @iLicenseSubscriptionDetail INT + DECLARE @sAccountNumber VARCHAR(50) + DECLARE @sLicenseeName VARCHAR(100) + DECLARE @sLicenseType VARCHAR(50) + DECLARE @sInstitutionName VARCHAR(100) + DECLARE @dtLicenseCreationDate DATETIME + DECLARE @dtStartDate DATETIME + DECLARE @dtEndDate DATETIME + DECLARE @mSubscriptionPrice MONEY + DECLARE @sAccountType VARCHAR(50) + DECLARE @sEdition VARCHAR(200) + DECLARE @iDaysRemaining INT + DECLARE @iCardNumber INT + + -- convert the datatype of fromdate & todate parameter to datetime + SELECT @dtFromDate = CONVERT(DATETIME,@sFromDate) + SELECT @dtToDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sToDate))) + + -- create a temporary table to store the desired results of license which are going to be expire on the basis of parameter + CREATE TABLE #ExpiringLicenseReport + ( + AccountNumber VARCHAR(50), + LicenseeName VARCHAR(100), + LicenseType VARCHAR(50), + InstitutionName VARCHAR(100), + Edition VARCHAR(200), + ValidFrom DATETIME, + ValidThrough DATETIME, + LicenseCreationDate DATETIME, + Price MONEY, + AccountType VARCHAR(50), + DaysRemaining INT, + CardNumber INT + ) + + -- define the forward only, read-only cursor + SET @cGetLicenseId = CURSOR FAST_FORWARD + FOR + SELECT LicenseSubscriptionDetail.LicenseId, MAX(LicenseSubscriptionDetail.Id) + FROM LicenseSubscriptionDetail WHERE + (TotalAmount >= (CASE WHEN @iStartPrice > 0 THEN @iStartPrice ELSE 0 END)) + AND (TotalAmount <= (CASE WHEN @iEndPrice = 0 THEN 0 WHEN @iEndPrice > 0 THEN @iEndPrice ELSE 9999999999 END)) + GROUP BY LicenseSubscriptionDetail.LicenseId + HAVING (MAX(SubscriptionValidThrough) BETWEEN @dtFromDate AND @dtToDate) + + -- open & fetch the cursor variables into the local variables + OPEN @cGetLicenseId + FETCH NEXT FROM @cGetLicenseId INTO @iLicenseId, @iLicenseSubscriptionDetail + -- start of while loop + WHILE @@FETCH_STATUS = 0 + BEGIN + + SET @sEdition = '' + -- fetch the accountnumber, licenseename, licensetype, startdate, enddate, subscriptionprice, accountype & days remaining to expire for a license + SELECT @sAccountNumber = AccountNumber, @sLicenseeName = LicenseeName, @sLicenseType = LicenseType, + @sInstitutionName = InstitutionName, @dtLicenseCreationDate = CreationDate, + @dtStartDate = SubscriptionValidFrom, @dtEndDate = SubscriptionValidThrough, + @mSubscriptionPrice = TotalAmount, @sAccountType = AccountType, @iDaysRemaining = DaysRemaining, @iCardNumber = CardNumber + FROM + ( + SELECT AccountNumber, (LicenseeFirstName+' '+LicenseeLastName) as LicenseeName, + LicenseType.Title as LicenseType, AccountType.Title as AccountType, + License.InstitutionName,License.CreationDate, + LicenseSubscriptionDetail.TotalAmount, + LicenseSubscriptionDetail.SubscriptionValidFrom, LicenseSubscriptionDetail.SubscriptionValidThrough, + DATEDIFF(dd,GETDATE(),LicenseSubscriptionDetail.SubscriptionValidThrough) as DaysRemaining, (CASE WHEN License.CardNumber > 0 THEN License.CardNumber END) as CardNumber + FROM License + INNER JOIN LicenseType ON License.LicenseTypeId = LicenseType.Id + INNER JOIN AccountType ON License.AccountTypeId = AccountType.Id + INNER JOIN LicenseSubscriptionDetail ON License.Id = LicenseSubscriptionDetail.LicenseId + INNER JOIN State ON License.StateId = State.Id + INNER JOIN Country ON License.CountryId = Country.Id + WHERE License.IsActive = 1 + AND License.LicenseTypeId = (CASE WHEN @iLicenseTypeId > 0 THEN @iLicenseTypeId ELSE License.LicenseTypeId END) + AND License.AccountTypeId = (CASE WHEN @iAccountTypeId > 0 THEN @iAccountTypeId ELSE License.AccountTypeId END) + AND State.Id = (CASE WHEN @iStateId > 0 THEN @iStateId ELSE State.Id END) + AND Country.Id = (CASE WHEN @iCountryId > 0 THEN @iCountryId ELSE Country.Id END) + AND (@sZip is NULL or License.Zip = (CASE WHEN LEN(@sZip)>0 THEN @sZip ELSE License.Zip END)) + AND LicenseSubscriptionDetail.Id = @iLicenseSubscriptionDetail + AND License.LicenseTypeId <> 5 + ) t1 + WHERE DaysRemaining>=0 + -- check whether the above query returns any row + IF @@Rowcount > 0 + BEGIN + -- fetch all the editions mapped as a string with a license + SELECT @sEdition = Edition.Title + '; ' + @sEdition + FROM LicenseToEdition INNER JOIN Edition + ON LicenseToEdition.EditionId = Edition.Id + WHERE LicenseToEdition.LicenseId = @iLicenseId + -- remove the trailing comma-separator from the edition-string + SET @sEdition = SUBSTRING(@sEdition,1,LEN(@sEdition)-1); + + -- insert into the temporary table + INSERT INTO #ExpiringLicenseReport + (AccountNumber, LicenseeName, LicenseType,InstitutionName, Edition, ValidFrom, ValidThrough,LicenseCreationDate, Price, AccountType, DaysRemaining,CardNumber) + VALUES(@sAccountNumber,@sLicenseeName,@sLicenseType,@sInstitutionName,@sEdition,@dtStartDate,@dtEndDate,@dtLicenseCreationDate, @mSubscriptionPrice,@sAccountType,@iDaysRemaining,@iCardNumber) + END + -- fetch the next record from cursor + FETCH NEXT FROM @cGetLicenseId INTO @iLicenseId,@iLicenseSubscriptionDetail + -- end of while loop + END + -- close the cursor to free up resources + CLOSE @cGetLicenseId + DEALLOCATE @cGetLicenseId + + -- Selecting the desired result from temporary table + --SELECT AccountNumber,LicenseeName,LicenseType,InstitutionName,Edition, + --CONVERT(VARCHAR,ValidFrom,101) as StartDate,CONVERT(VARCHAR,ValidThrough,101) as EndDate, + --CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, + --CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice,AccountType,DaysRemaining, CardNumber + --FROM #ExpiringLicenseReport ORDER BY AccountNumber + + + SELECT RowNum as 'Serial_No', AccountNumber,LicenseeName,LicenseType,InstitutionName,Edition, + StartDate,EndDate,LicenseCreationDate,SubscriptionPrice,AccountType,DaysRemaining, CardNumber + from ( + SELECT ROW_NUMBER() OVER (ORDER BY AccountNumber) AS RowNum, AccountNumber,LicenseeName,LicenseType,InstitutionName,Edition, + CONVERT(VARCHAR,ValidFrom,101) as StartDate,CONVERT(VARCHAR,ValidThrough,101) as EndDate, + CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, + CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice,AccountType,DaysRemaining, isnull(CardNumber,'') as CardNumber + FROM #ExpiringLicenseReport) as Tempt + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo + ORDER BY AccountNumber + + --Calculate total number of records + select @recordCount = count(ResultTable.AccountNumber) + from ( + SELECT AccountNumber,LicenseeName,LicenseType,InstitutionName,Edition, + CONVERT(VARCHAR,ValidFrom,101) as StartDate,CONVERT(VARCHAR,ValidThrough,101) as EndDate, + CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, + CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice,AccountType,DaysRemaining, CardNumber + FROM #ExpiringLicenseReport ) as ResultTable + + -- Dropping the temporary table + DROP TABLE #ExpiringLicenseReport +END + + diff --git a/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetNetAdSummaryReport.sql b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetNetAdSummaryReport.sql new file mode 100644 index 0000000..f30e5c9 --- /dev/null +++ b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetNetAdSummaryReport.sql @@ -0,0 +1,183 @@ +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetNetAdSummaryReport]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[usp_GetNetAdSummaryReport] +GO + +CREATE PROCEDURE [dbo].[usp_GetNetAdSummaryReport] --'2015-05-01','2018-05-01',0,0,0,1,100,1000 + -- Add the parameters for the stored procedure here + -- FromDate & ToDate are mandatory + @sFromDate varchar(20), @sToDate varchar(20), @iStartPrice numeric(14,2), @iEndPrice numeric(14,2), @iLicenseTypeId tinyint, + @pageNo int, @pageLength int, @recordCount int out +AS +BEGIN + + IF 1=0 BEGIN + SET FMTONLY OFF + END + + -- SET NOCOUNT ON added to prevent extra result sets from + SET NOCOUNT ON; + DECLARE @dtFromDate DATETIME + DECLARE @dtToDate DATETIME + DECLARE @cGetSummary CURSOR + DECLARE @iLicenseId INT + DECLARE @iLicenseSubscriptioId INT + DECLARE @iActiveSubscription INT + DECLARE @iRenewSubscription INT + DECLARE @iCancelSubscription INT + DECLARE @iNetAdSubscription INT + DECLARE @sLicenseType VARCHAR(50) + DECLARE @sInstitutionname VARCHAR(100) + DECLARE @dtLicenseCreationDate DATETIME + DECLARE @sAccountType VARCHAR(50) + DECLARE @IsActive BIT + DECLARE @sRenew BIT + + -- set the default parameters to 0 + SET @iActiveSubscription = 0 + SET @iRenewSubscription = 0 + SET @iCancelSubscription = 0 + + -- convert the datatype of fromdate & todate parameter to datetime + SELECT @dtFromDate = CONVERT(DATETIME,@sFromDate) + SELECT @dtToDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sToDate))) + + -- create a temporary table to store the first-level of result shown in the netad subscription report on the basis of parameter + CREATE TABLE #NetAdSummaryReport + ( + LicenseType VARCHAR(50), + AccountType VARCHAR(50), + InstitutionName VARCHAR(100), + LicenseCreationDate DATETIME, + IsActive BIT, + IsRenew BIT + ) + CREATE CLUSTERED INDEX IK_NetAdSummaryReport_1 ON #NetAdSummaryReport (LicenseType, AccountType) + CREATE NONCLUSTERED INDEX IK_NetAdSummaryReport_2 ON #NetAdSummaryReport (IsActive) + + -- create a temporary table + CREATE TABLE #NetAdResult + ( + LicenseType VARCHAR(50), + AccountType VARCHAR(50), + InstitutionName VARCHAR(100), + LicenseCreationDate DATETIME, + ActiveSubscription INT, + RenewSubscription INT, + InActiveSubscription INT, + NetAdSubscription INT + ) + + -- define the forward only, read-only cursor + SET @cGetSummary = CURSOR FAST_FORWARD + FOR + SELECT License.Id, LicenseSubscriptionDetail.Id + FROM LicenseSubscriptionDetail + INNER JOIN License ON LicenseSubscriptionDetail.LicenseId = License.Id WHERE + ((License.CancellationDate BETWEEN @dtFromDate AND @dtToDate AND License.IsActive = 0 ) + OR (License.CreationDate BETWEEN @dtFromDate AND @dtToDate ) + OR (RenewalDate BETWEEN @dtFromDate AND @dtToDate)) + AND License.LicenseTypeId = (CASE WHEN @iLicenseTypeId > 0 THEN @iLicenseTypeId ELSE License.LicenseTypeId END) + AND (TotalAmount >= (CASE WHEN @iStartPrice > 0 THEN @iStartPrice ELSE 0 END)) + AND (TotalAmount <= (CASE WHEN @iEndPrice = 0 THEN 0 WHEN @iEndPrice > 0 THEN @iEndPrice ELSE 9999999999 END)) + AND License.LicenseTypeId <> 5 + GROUP BY License.Id, LicenseSubscriptionDetail.Id + + + -- open & fetch the cursor variables into the local variables + OPEN @cGetSummary + FETCH NEXT FROM @cGetSummary INTO @iLicenseId, @iLicenseSubscriptioId + -- start of while loop + WHILE @@FETCH_STATUS = 0 + BEGIN + + -- fetch the licensetype, accountype & the status of a license + SELECT @sLicenseType = LicenseType.Title, @sAccountType = AccountType.Title, + @sInstitutionname = License.InstitutionName, @dtLicenseCreationDate = License.CreationDate, + @IsActive = License.IsActive, + @sRenew = (CASE WHEN LicenseSubscriptionDetail.RenewalDate IS NULL THEN 0 ELSE 1 END) + FROM License + INNER JOIN LicenseType ON License.LicenseTypeId = LicenseType.Id + INNER JOIN AccountType ON License.AccountTypeId = AccountType.Id + INNER JOIN LicenseSubscriptionDetail ON LicenseSubscriptionDetail.LicenseId = License.Id + WHERE License.Id = @iLicenseId + AND LicenseSubscriptionDetail.Id = @iLicenseSubscriptioId + + + -- check whether the above query returns any row + IF @@Rowcount > 0 + BEGIN + + IF @IsActive = 1 + BEGIN + IF @sRenew = 1 + BEGIN + SET @iRenewSubscription = @iRenewSubscription + 1 + END + ELSE + BEGIN + SET @iActiveSubscription = @iActiveSubscription + 1 + END + END + ELSE + BEGIN + IF @sRenew = 1 + BEGIN + SET @iRenewSubscription = @iRenewSubscription + 1 + END + ELSE + BEGIN + SET @iCancelSubscription = @iCancelSubscription + 1 + END + END + + -- insert into the temporary table + INSERT INTO #NetAdSummaryReport + (LicenseType,AccountType,InstitutionName,LicenseCreationDate,IsActive,IsRenew) + VALUES(@sLicenseType,@sAccountType,@sInstitutionname,@dtLicenseCreationDate,@IsActive,@sRenew) + END + -- fetch the next record from cursor + FETCH NEXT FROM @cGetSummary INTO @iLicenseId, @iLicenseSubscriptioId + -- end of while loop + END + -- close the cursor to free up resources + CLOSE @cGetSummary + DEALLOCATE @cGetSummary + + -- Selecting the desired result from temporary table + INSERT INTO #NetAdResult (LicenseType, AccountType,InstitutionName,LicenseCreationDate,ActiveSubscription, RenewSubscription, InActiveSubscription, + NetAdSubscription) + SELECT LicenseType,AccountType,MAX(InstitutionName) as InstitutionName, MAX(LicenseCreationDate) as LicenseCreationDate,(SELECT COUNT(1) FROM #NetAdSummaryReport + WHERE LicenseType = N1.LicenseType AND AccountType = N1.AccountType AND IsActive = 1 AND IsRenew = 0) as ActiveSubscription, + (SELECT COUNT(1) FROM #NetAdSummaryReport + WHERE LicenseType = N1.LicenseType AND AccountType = N1.AccountType AND IsRenew = 1) as RenewSubscription, + (SELECT COUNT(1) FROM #NetAdSummaryReport + WHERE LicenseType = N1.LicenseType AND AccountType = N1.AccountType AND IsActive = 0 AND IsRenew = 0) as InActiveSubscription, + ((SELECT COUNT(1) FROM #NetAdSummaryReport + WHERE LicenseType = N1.LicenseType AND AccountType = N1.AccountType AND IsActive = 1 AND IsRenew = 0) + (SELECT COUNT(1) FROM #NetAdSummaryReport + WHERE LicenseType = N1.LicenseType AND AccountType = N1.AccountType AND IsRenew = 1) - (SELECT COUNT(1) FROM #NetAdSummaryReport + WHERE LicenseType = N1.LicenseType AND AccountType = N1.AccountType AND IsActive = 0)) as NetAdSubscription + FROM #NetAdSummaryReport N1 GROUP BY LicenseType,AccountType + + -- to show the sum of active, renew, cancel & netad subscriptions + if((Select COUNT(*) from #NetAdResult)>0) + begin + INSERT INTO #NetAdResult (LicenseType,LicenseCreationDate, ActiveSubscription, RenewSubscription, InActiveSubscription, + NetAdSubscription) SELECT 'Total','9999-01-01', @iActiveSubscription, @iRenewSubscription, @iCancelSubscription, + (@iActiveSubscription+@iRenewSubscription-@iCancelSubscription) + End + + Select RowNum as 'Serial_No', LicenseType, AccountType,InstitutionName,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, ActiveSubscription, RenewSubscription, InActiveSubscription, + NetAdSubscription + from ( + SELECT ROW_NUMBER() OVER (ORDER BY LicenseCreationDate Asc) AS RowNum ,LicenseType, AccountType,InstitutionName,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, ActiveSubscription, RenewSubscription, InActiveSubscription, + NetAdSubscription FROM #NetAdResult) as usr + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo order by LicenseCreationDate desc + + --Calculate total number of records + select @recordCount = count(ResultTable.NetAdSubscription) from (SELECT LicenseType, AccountType,InstitutionName,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, ActiveSubscription, RenewSubscription, InActiveSubscription, + NetAdSubscription FROM #NetAdResult) as ResultTable; + + -- Dropping the temporary tables + DROP TABLE #NetAdSummaryReport + DROP TABLE #NetAdResult +END diff --git a/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetSiteLicenseUsageReport.sql b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetSiteLicenseUsageReport.sql new file mode 100644 index 0000000..2a9420f --- /dev/null +++ b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetSiteLicenseUsageReport.sql @@ -0,0 +1,56 @@ +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetSiteLicenseUsageReports]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[usp_GetSiteLicenseUsageReports] +GO + +CREATE PROCEDURE [dbo].[usp_GetSiteLicenseUsageReports] + -- Add the parameters for the stored procedure here + @sFromDate varchar(20), @sToDate varchar(20), @sAccoutNumber varchar(50)='', @iEditionId tinyint = 0, + @pageNo int, @pageLength int, @recordCount int out +AS +BEGIN + IF 1=0 BEGIN + SET FMTONLY OFF + END + -- SET NOCOUNT ON added to prevent extra result sets from + SET NOCOUNT ON + DECLARE @dtFromDate DATETIME + DECLARE @dtToDate DATETIME + + -- convert the datatype of fromdate & todate parameter to datetime + SELECT @dtFromDate = CONVERT(DATETIME,@sFromDate) + SELECT @dtToDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sToDate))) + + Select RowNum as 'Serial_No',AccountNumber, EditionTitle, ReferalUrl, InstitutionName, LicenseCreationDate,TotalLogins,LastLogin + from ( + SELECT ROW_NUMBER() OVER (ORDER BY UserLoginLog.AccountNumber) AS RowNum , UserLoginLog.AccountNumber, Edition.Title AS EditionTitle, UserLoginLog.ReferalUrl, + (SELECT License.InstitutionName FROM License WHERE License.AccountNumber = UserLoginLog.AccountNumber) as InstitutionName, + (SELECT CONVERT(VARCHAR,License.CreationDate,101) FROM License WHERE License.AccountNumber = UserLoginLog.AccountNumber) as LicenseCreationDate, + COUNT(DISTINCT UserLoginLog.LogDate) AS TotalLogins, + CONVERT(VARCHAR,MAX(UserLoginLog.LogDate),101) AS LastLogin FROM + UserLoginLog INNER JOIN Edition ON UserLoginLog.Edition = CAST(Edition.Id AS NVARCHAR) + WHERE UserLoginLog.FailureId IS NULL + AND UserLoginLog.LogDate BETWEEN @dtFromDate AND @dtToDate + AND UserLoginLog.AccountNumber = (CASE WHEN LEN(@sAccoutNumber) > 0 THEN @sAccoutNumber ELSE UserLoginLog.AccountNumber END) + AND Edition.IsActive = 1 + AND Edition.Id = (CASE WHEN @iEditionId > 0 THEN @iEditionId ELSE Edition.Id END) + GROUP BY UserLoginLog.AccountNumber, Edition.Title, UserLoginLog.ReferalUrl) as usr + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo order by AccountNumber + + + --Calculate total number of records + select @recordCount = count(ResultTable.AccountNumber) from ( + SELECT UserLoginLog.AccountNumber, Edition.Title AS EditionTitle, UserLoginLog.ReferalUrl, + (SELECT License.InstitutionName FROM License WHERE License.AccountNumber = UserLoginLog.AccountNumber) as InstitutionName, + (SELECT CONVERT(VARCHAR,License.CreationDate,101) FROM License WHERE License.AccountNumber = UserLoginLog.AccountNumber) as LicenseCreationDate, + COUNT(DISTINCT UserLoginLog.LogDate) AS TotalLogins, + CONVERT(VARCHAR,MAX(UserLoginLog.LogDate),101) AS LastLogin FROM + UserLoginLog INNER JOIN Edition ON UserLoginLog.Edition = CAST(Edition.Id AS NVARCHAR) + WHERE UserLoginLog.FailureId IS NULL + AND UserLoginLog.LogDate BETWEEN @dtFromDate AND @dtToDate + AND UserLoginLog.AccountNumber = (CASE WHEN LEN(@sAccoutNumber) > 0 THEN @sAccoutNumber ELSE UserLoginLog.AccountNumber END) + AND Edition.IsActive = 1 + AND Edition.Id = (CASE WHEN @iEditionId > 0 THEN @iEditionId ELSE Edition.Id END) + GROUP BY UserLoginLog.AccountNumber, Edition.Title, UserLoginLog.ReferalUrl) as ResultTable; + +END + diff --git a/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetSubscribedLicenses.sql b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetSubscribedLicenses.sql new file mode 100644 index 0000000..528b037 --- /dev/null +++ b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetSubscribedLicenses.sql @@ -0,0 +1,160 @@ +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetSubscribedLicenses]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[usp_GetSubscribedLicenses] +GO + +CREATE PROCEDURE [dbo].[usp_GetSubscribedLicenses] + -- Add the parameters for the stored procedure here + @sFromDate varchar(20), @sToDate varchar(20), @iStartPrice numeric(14,2), @iEndPrice numeric(14,2), @iLicenseTypeId tinyint, + @iAccountTypeId tinyint, @sZip varchar(20) = '', @iStateId int, @iCountryId int,@pageNo int, @pageLength int, @recordCount int out +AS +BEGIN + IF 1=0 BEGIN + SET FMTONLY OFF + END + -- SET NOCOUNT ON added to prevent extra result sets from + SET NOCOUNT ON; + DECLARE @dtFromDate DATETIME + DECLARE @dtToDate DATETIME + DECLARE @cGetLicenseID CURSOR + DECLARE @iLicenseId INT + DECLARE @iLicenseSubscriptionDetail INT + DECLARE @sAccountNumber VARCHAR(50) + DECLARE @sLicenseeName VARCHAR(100) + DECLARE @sLicenseType VARCHAR(50) + DECLARE @sInstitutionName VARCHAR(100) + DECLARE @dtStartDate DATETIME + DECLARE @dtEndDate DATETIME + DECLARE @dtLicenseCreationDate DATETIME + DECLARE @mSubscriptionPrice MONEY + DECLARE @sAccountType VARCHAR(50) + DECLARE @sEdition VARCHAR(200) + DECLARE @iCardNumber INT + + + -- convert the datatype of fromdate & todate parameter to datetime + SELECT @dtFromDate = CONVERT(DATETIME,@sFromDate) + SELECT @dtToDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sToDate))) + + -- create a temporary table to store the desired results of subscribed licenses on the basis of parameter + CREATE TABLE #SubscribedLicenseReport + ( + AccountNumber VARCHAR(50), + LicenseeName VARCHAR(100), + LicenseType VARCHAR(50), + InstitutionName VARCHAR(100), + Edition VARCHAR(200), + ValidFrom DATETIME, + ValidThrough DATETIME, + LicenseCreationDate DATETIME, + Price MONEY, + AccountType varchar(50), + CardNumber INT + ) + + -- define the forward only, read-only cursor + SET @cGetLicenseID = CURSOR FAST_FORWARD + FOR + SELECT LicenseSubscriptionDetail.LicenseId, MAX(LicenseSubscriptionDetail.Id) + FROM LicenseSubscriptionDetail WHERE + (TotalAmount >= (CASE WHEN @iStartPrice > 0 THEN @iStartPrice ELSE 0 END)) + AND (TotalAmount <= (CASE WHEN @iEndPrice = 0 THEN 0 WHEN @iEndPrice > 0 THEN @iEndPrice ELSE 9999999999 END)) + GROUP BY LicenseSubscriptionDetail.LicenseId + HAVING (MAX(SubscriptionValidFrom) BETWEEN @dtFromDate AND @dtToDate) + + -- open & fetch the cursor variables into the local variables + OPEN @cGetLicenseID + FETCH NEXT FROM @cGetLicenseID INTO @iLicenseId, @iLicenseSubscriptionDetail + -- start of while loop + WHILE @@FETCH_STATUS = 0 + BEGIN + + SET @sEdition = '' + + -- fetch the accountnumber, licenseename, licensetype, accountype of a license + SELECT @sAccountNumber = AccountNumber, @sLicenseeName = (LicenseeFirstName+' '+LicenseeLastName), + @sLicenseType = LicenseType.Title, @sAccountType = AccountType.Title, + @iCardNumber = (CASE WHEN License.CardNumber > 0 THEN License.CardNumber END), + @sInstitutionName = License.InstitutionName,@dtLicenseCreationDate = License.CreationDate + FROM License + INNER JOIN LicenseType ON License.LicenseTypeId = LicenseType.Id + INNER JOIN AccountType ON License.AccountTypeId = AccountType.Id + INNER JOIN State ON License.StateId = State.Id + INNER JOIN Country ON License.CountryId = Country.Id + WHERE License.Id = @iLicenseId AND License.IsActive = 1 + AND License.LicenseTypeId = (CASE WHEN @iLicenseTypeId > 0 THEN @iLicenseTypeId ELSE License.LicenseTypeId END) + AND License.AccountTypeId = (CASE WHEN @iAccountTypeId > 0 THEN @iAccountTypeId ELSE License.AccountTypeId END) + AND State.Id = (CASE WHEN @iStateId > 0 THEN @iStateId ELSE State.Id END) + AND Country.Id = (CASE WHEN @iCountryId > 0 THEN @iCountryId ELSE Country.Id END) + AND License.Zip = (CASE WHEN LEN(@sZip)>0 THEN @sZip ELSE License.Zip END) + AND License.LicenseTypeId <> 5 + + -- check whether the above query returns any row + IF @@Rowcount > 0 + BEGIN + -- fetch startdate, enddate, subscriptionprice of a license + SELECT @mSubscriptionPrice = LicenseSubscriptionDetail.TotalAmount, + @dtStartDate = LicenseSubscriptionDetail.SubscriptionValidFrom, + @dtEndDate = LicenseSubscriptionDetail.SubscriptionValidThrough + FROM LicenseSubscriptionDetail + WHERE LicenseSubscriptionDetail.Id = @iLicenseSubscriptionDetail + + -- fetch all the editions mapped as a string with a license + SELECT @sEdition = Edition.Title + '; ' + @sEdition + FROM LicenseToEdition INNER JOIN Edition + ON LicenseToEdition.EditionId = Edition.Id + WHERE LicenseToEdition.LicenseId = @iLicenseId + -- remove the trailing comma-separator from the edition-string + -- AMI SET @sEdition = SUBSTRING(@sEdition,1,LEN(@sEdition)-1); + IF LEN(@sEdition)> 1 + -- remove the trailing comma-separator from the edition-string + SET @sEdition = SUBSTRING(@sEdition,1,LEN(@sEdition)-1) + ELSE + SET @sEdition = @sEdition + + -- insert into the temporary table + INSERT INTO #SubscribedLicenseReport + (AccountNumber, LicenseeName, LicenseType, InstitutionName, Edition, ValidFrom, ValidThrough,LicenseCreationDate, Price, AccountType,CardNumber) + VALUES(@sAccountNumber,@sLicenseeName,@sLicenseType,@sInstitutionName,@sEdition,@dtStartDate,@dtEndDate,@dtLicenseCreationDate,@mSubscriptionPrice,@sAccountType,@iCardNumber) + END + -- fetch the next record from cursor + FETCH NEXT FROM @cGetLicenseID INTO @iLicenseId,@iLicenseSubscriptionDetail + -- end of while loop + END + -- close the cursor to free up resources + CLOSE @cGetLicenseID + DEALLOCATE @cGetLicenseID + + -- Selecting the desired result from temporary table + --SELECT AccountNumber, LicenseeName, LicenseType,InstitutionName, AccountType, Edition, + --CONVERT(VARCHAR,ValidFrom,101) as StartDate, CONVERT(VARCHAR,ValidThrough,101) as EndDate, + --CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, + --CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice,CardNumber + --FROM #SubscribedLicenseReport ORDER BY AccountNumber + + + SELECT RowNum as 'Serial_No', AccountNumber, LicenseeName, LicenseType,InstitutionName, AccountType, Edition, + StartDate, EndDate, + LicenseCreationDate, + SubscriptionPrice,CardNumber + from ( + SELECT ROW_NUMBER() OVER (ORDER BY AccountNumber) AS RowNum, AccountNumber, LicenseeName, LicenseType,InstitutionName, AccountType, Edition, + CONVERT(VARCHAR,ValidFrom,101) as StartDate, CONVERT(VARCHAR,ValidThrough,101) as EndDate, + CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, + CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice,isnull(CardNumber,'') as CardNumber + FROM #SubscribedLicenseReport) as Tempt + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo + ORDER BY AccountNumber + + select @recordCount = count(ResultTable.AccountNumber) + from ( + SELECT AccountNumber, LicenseeName, LicenseType,InstitutionName, AccountType, Edition, + CONVERT(VARCHAR,ValidFrom,101) as StartDate, CONVERT(VARCHAR,ValidThrough,101) as EndDate, + CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, + CONVERT(NUMERIC(14,2),Price) as SubscriptionPrice,CardNumber + FROM #SubscribedLicenseReport) as ResultTable + + -- Dropping the temporary table + DROP TABLE #SubscribedLicenseReport +END + + diff --git a/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetUsageReport.sql b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetUsageReport.sql new file mode 100644 index 0000000..488d10a --- /dev/null +++ b/500-DBDump/AIA-StoredProcedures/ADMIN-ANGULAR-VERSION-PROCS/dbo.usp_GetUsageReport.sql @@ -0,0 +1,147 @@ +if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[usp_GetUsageReport]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) +drop procedure [dbo].[usp_GetUsageReport] +GO +Create PROCEDURE [dbo].[usp_GetUsageReport]--'2011-01-01','2018-01-01','','',0,0,1,10,0 + -- Add the parameters for the stored procedure here + -- FromDate & ToDate are mandatory parameters + @sFromDate varchar(20), @sToDate varchar(20), @sAccoutNumber varchar(50)='', + @sZip varchar(20) = '', @iState int, @iCountry int, + @pageNo int, @pageLength int, @recordCount int out +AS +BEGIN + IF 1=0 BEGIN + SET FMTONLY OFF + END + -- SET NOCOUNT ON added to prevent extra result sets from + SET NOCOUNT ON + DECLARE @cGetUserDetails CURSOR + DECLARE @iUserId INT + DECLARE @sAccountNumber VARCHAR(50) + DECLARE @iCardNumber INT + DECLARE @sLoginId VARCHAR(50) + DECLARE @sFirstName VARCHAR(100) + DECLARE @sLastName VARCHAR(100) + DECLARE @sUserType VARCHAR(50) + DECLARE @dtFromDate DATETIME + DECLARE @dtToDate DATETIME + DECLARE @dtLicenseCreationDate DATETIME + DECLARE @sLicenseState VARCHAR(50) + DECLARE @sLicenseZip VARCHAR(20) + DECLARE @sLicenseCountry VARCHAR(50) + DECLARE @sInstitutionName VARCHAR(100) + DECLARE @iTotalLogins INT + DECLARE @dtLastLogin DATETIME + + -- convert the datatype of fromdate & todate parameter to datetime + SELECT @dtFromDate = CONVERT(DATETIME,@sFromDate) + SELECT @dtToDate = DATEADD(ms,-3,DATEADD(DAY,1,CONVERT(DATETIME,@sToDate))) + + -- create a temporary table to store the results of users logged into the system within a particular time period + CREATE TABLE #UsageReport + ( + LoginId VARCHAR(50), + FirstName VARCHAR(100), + LastName VARCHAR(100), + AccountNumber VARCHAR(50), + CardNumber INT, + UserType VARCHAR(50), + LicenseCreationDate DATETIME, + LicenseState VARCHAR(50), + LicenseZip VARCHAR(20), + LicenseCountry VARCHAR(50), + InstitutionName VARCHAR(100), + TotalLogins INT, + LastLoginDate DATETIME + ) + + -- define the forward only, read-only cursor + SET @cGetUserDetails = CURSOR FAST_FORWARD + FOR + SELECT LoginDetail.UserId, COUNT(1) as TotalLogins, MAX(LoginDetail.LoginTime) + FROM LoginDetail WHERE + (LoginTime) BETWEEN @dtFromDate AND @dtToDate + GROUP BY LoginDetail.UserId + + -- open & fetch the cursor variables into the local variables + OPEN @cGetUserDetails + FETCH NEXT FROM @cGetUserDetails INTO @iUserId, @iTotalLogins, @dtLastLogin + -- start of while loop + WHILE @@FETCH_STATUS = 0 + BEGIN + -- fetch account number, state, zip, country of the license to which the user is belonged + SELECT @sAccountNumber = License.AccountNumber, + @dtLicenseCreationDate = License.CreationDate, + @sInstitutionName = License.InstitutionName, + @sLicenseState = State.StateName, + @sLicenseZip = License.Zip, + @sLicenseCountry = Country.CountryName, + @iCardNumber = (CASE WHEN License.CardNumber > 0 THEN License.CardNumber END) + FROM AIAUserToLicenseEdition + INNER JOIN LicenseToEdition ON AIAUserToLicenseEdition.LicenseEditionId = LicenseToEdition.Id + INNER JOIN License ON LicenseToEdition.LicenseId = License.Id + INNER JOIN State ON License.StateId = State.Id + INNER JOIN Country ON License.CountryId = Country.Id + WHERE AIAUserToLicenseEdition.UserId = @iUserId + AND License.IsActive = 1 + AND License.AccountNumber = (CASE WHEN LEN(@sAccoutNumber)>0 THEN @sAccoutNumber ELSE License.AccountNumber END) + AND State.Id = (CASE WHEN @iState > 0 THEN @iState ELSE State.Id END) + AND Country.Id = (CASE WHEN @iCountry > 0 THEN @iCountry ELSE Country.Id END) + AND License.Zip = (CASE WHEN LEN(@sZip)>0 THEN @sZip ELSE License.Zip END) + --AND License.LicenseTypeId <> 5 + --AND License.Country = (CASE WHEN LEN(@sCountry)>0 THEN @sCountry ELSE License.Country END) + + -- check whether the above query returns any row + IF @@Rowcount > 0 + BEGIN + -- fetch loginid, firstname, lastname, usertype of the user + SELECT @sLoginId = AIAUser.LoginId, @sFirstName = AIAUser.Firstname, + @sLastName = AIAUser.LastName, @sUserType = UserType.Title + FROM AIAUser + INNER JOIN UserType ON AIAUser.UserTypeId = UserType.Id + WHERE AIAUser.Id = @iUserId + AND AIAUser.IsActive = 1 + + IF @@Rowcount > 0 + BEGIN + -- insert into the temporary table + INSERT INTO #UsageReport + (LoginId, FirstName, LastName, AccountNumber,CardNumber ,UserType,LicenseCreationDate, LicenseState, LicenseZip, + LicenseCountry,InstitutionName, TotalLogins, LastLoginDate) + VALUES(@sLoginId, @sFirstName, @sLastName, @sAccountNumber, @iCardNumber, @sUserType,@dtLicenseCreationDate, + @sLicenseState, @sLicenseZip, @sLicenseCountry,@sInstitutionName, @iTotalLogins, @dtLastLogin) + END + END + -- fetch the next record from cursor + FETCH NEXT FROM @cGetUserDetails INTO @iUserId, @iTotalLogins, @dtLastLogin + -- end of while loop + END + -- close the cursor to free up resources + CLOSE @cGetUserDetails + DEALLOCATE @cGetUserDetails + + -- Selecting the desired result from temporary table + --SELECT LoginId, FirstName, LastName, AccountNumber, CardNumber,UserType,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, LicenseZip, LicenseState, + --LicenseCountry,InstitutionName, TotalLogins, CONVERT(VARCHAR,LastLoginDate,101) as LastLogin FROM #UsageReport ORDER BY AccountNumber + + + Select RowNum as 'Serial_No', + LoginId, FirstName, LastName, AccountNumber, CardNumber,UserType,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, LicenseZip, LicenseState, + LicenseCountry,InstitutionName, TotalLogins, LastLogin + from ( + SELECT ROW_NUMBER() OVER (ORDER BY AccountNumber) AS RowNum , + LoginId, FirstName, LastName, isnull(AccountNumber,'') as AccountNumber, isnull(CardNumber,'') as CardNumber,UserType,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, + LicenseZip, LicenseState, + LicenseCountry,InstitutionName, TotalLogins, CONVERT(VARCHAR,LastLoginDate,101) as LastLogin FROM #UsageReport) as usr + WHERE RowNum > @pageLength * (@pageNo - 1) AND RowNum <= @pageLength * @pageNo + order by AccountNumber + + + --Calculate total number of records + select @recordCount = count(ResultTable.LoginId) from (SELECT LoginId, FirstName, LastName, AccountNumber, CardNumber,UserType,CONVERT(VARCHAR,LicenseCreationDate,101) as LicenseCreationDate, LicenseZip, LicenseState, + LicenseCountry,InstitutionName, TotalLogins, CONVERT(VARCHAR,LastLoginDate,101) as LastLogin FROM #UsageReport) as ResultTable; + -- Dropping the temporary table + DROP TABLE #UsageReport +END + + + -- libgit2 0.21.4