var app=angular.module("supportApp",["ngRoute","LocalStorageModule","smart-table","angularSpinner","ngFileUpload","ui.bootstrap"]),navcontainer;app.config(["$routeProvider",function(n){n.when("/Login",{controller:"loginController",templateUrl:"Front End/Views/LoginView.html"});n.when("/Profile",{controller:"profileController",templateUrl:"Front End/Views/ProfileView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}]}});n.when("/Unauthorised",{controller:"",templateUrl:"Front End/Views/UnauthorisedView.html"});n.when("/Timeout",{controller:"",templateUrl:"Front End/Views/TimeoutView.html"});n.when("/ViewUsers",{controller:"userListController",templateUrl:"Front End/Views/UserListView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(1)}]}});n.when("/EditUser",{controller:"userEditController",templateUrl:"Front End/Views/UserEditView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(1)}]}});n.when("/Home",{controller:"homeController",templateUrl:"Front End/Views/HomeView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}]}});n.when("/SupportTicket",{controller:"observationFormController",templateUrl:"Front End/Views/ObservationFormView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}]}});n.when("/RequestUpgrade",{controller:"upgradeFormController",templateUrl:"Front End/Views/UpgradeFormView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}]}});n.when("/CurrentBinaries",{controller:"binaryDownloadController",templateUrl:"Front End/Views/BinaryDownloadView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(3)}],getLatest:function(){return"false"}}});n.when("/LatestBinaries",{controller:"binaryDownloadController",templateUrl:"Front End/Views/BinaryDownloadView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(3)}],getLatest:function(){return"true"}}});n.when("/CurrentDocuments",{controller:"documentDownloadController",templateUrl:"Front End/Views/DocumentDownloadView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}],getLatest:function(){return"false"}}});n.when("/LatestDocuments",{controller:"documentDownloadController",templateUrl:"Front End/Views/DocumentDownloadView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}],getLatest:function(){return"true"}}});n.when("/Documents",{controller:"genericDocumentDownloadController",templateUrl:"Front End/Views/GenericDocumentDownloadView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}]}});n.when("/Foundations",{controller:"foundationsDownloadController",templateUrl:"Front End/Views/FoundationsDownloadView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}]}});n.when("/ViewLMSUsers",{controller:"LMSUserListController",templateUrl:"Front End/Views/LMSUserListView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}]}});n.when("/CreateLMSUser",{controller:"CreateLMSUserController",templateUrl:"Front End/Views/LMSUserCreateView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}]}});n.when("/EditLMSUser",{controller:"LMSUserEditController",templateUrl:"Front End/Views/LMSUserEditView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}]}});n.when("/CreateLMSUserCSV",{controller:"CreateLMSUserCSVController",templateUrl:"Front End/Views/LMSUserCreateCSVView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}]}});n.when("/ViewLicensedEnvironment",{controller:"LicensedEnvironmentListController",templateUrl:"Front End/Views/LicensedEnvironmentListView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}]}});n.when("/CreateLicensedEnvironment",{controller:"CreateLicensedEnvironmentController",templateUrl:"Front End/Views/LicensedEnvironmentCreateView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}]}});n.when("/CreateUser",{controller:"createUserController",templateUrl:"Front End/Views/UserCreateView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(1)}]}});n.when("/CreateCompany",{controller:"createCompanyController",templateUrl:"Front End/Views/CompanyCreateView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(1)}]}});n.when("/ViewCompanies",{controller:"companyListController",templateUrl:"Front End/Views/CompanyListView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(1)}]}});n.when("/EditCompany",{controller:"companyEditController",templateUrl:"Front End/Views/CompanyEditView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(1)}]}});n.when("/CreateACFile",{controller:"createACFileController",templateUrl:"Front End/Views/ACFileCreateView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(1)}]}});n.when("/ViewACFiles",{controller:"acFileListController",templateUrl:"Front End/Views/ACFileListView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(1)}]}});n.when("/EditACFile",{controller:"acFileEditController",templateUrl:"Front End/Views/ACFileEditView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(1)}]}});n.when("/ViewUploads",{controller:"fileUploadListController",templateUrl:"Front End/Views/FileUploadListView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}]}});n.when("/UploadFile",{controller:"fileUploadController",templateUrl:"Front End/Views/FileUploadView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(7)}]}});n.when("/EditUploadedFile",{controller:"fileUploadEditController",templateUrl:"Front End/Views/FileUploadEditView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(1)}]}});n.when("/CreateVersion",{controller:"createVersionController",templateUrl:"Front End/Views/VersionCreateView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(1)}]}});n.when("/ViewVersions",{controller:"versionListController",templateUrl:"Front End/Views/VersionListView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(1)}]}});n.when("/EditVersion",{controller:"versionEditController",templateUrl:"Front End/Views/VersionEditView.html",resolve:{auth:["authService",function(n){return n.isAuthenticated(1)}]}});n.when("/LoggedOut",{controller:"",templateUrl:"Front End/Views/LoggedOutView.html"});n.otherwise({redirectTo:"/Login"})}]);app.config(["$httpProvider",function(n){n.defaults.headers.get||(n.defaults.headers.get={});n.defaults.headers.get["If-Modified-Since"]="Mon, 26 Jul 1997 05:00:00 GMT";n.defaults.headers.get["Cache-Control"]="no-cache";n.defaults.headers.get.Pragma="no-cache"}]);app.config(["$httpProvider",function(n){n.interceptors.push("authInterceptorService")}]);app.run(["authService","userManagementService",function(n,t){n.fillAuthData();t.refreshLoggedInUser()}]);app.directive("scroll",["$window",function(n){return function(t){angular.element(n).bind("scroll",function(){t.upOrDown=this.pageYOffset!=0;t.$apply()})}}]);navcontainer=jQuery(".nav");app.directive("resize",["$window",function(n){return function(t){angular.element(n).bind("resize",function(){navcontainer.is(":hidden")||(t.preventScrollbar=t.preventScrollbar&&n.innerWidth<960)})}}]);app.factory("globalStorageService",["localStorageService","userManagementService",function(){"use strict";var n={},t,i,r,u,f,e,o;return n.selectedUserForEdit=t,n.selectedCompanyForEdit=i,n.selectedACFileForEdit=r,n.selectedVersionForEdit=u,n.selectedUploadedFileForEdit=f,n.selectedLMSUserForEdit=e,n.licenceList=o,n}]);app.factory("authService",["$rootScope","$http","$q","$location","$timeout","localStorageService",function(n,t,i,r,u,f){"use strict";var s="https://support.autumn.care/SupportSiteAPI/",o={},e={isAuth:!1,userName:"",permissionLevel:0},h=function(n){var u="grant_type=password&username="+n.userName+"&password="+n.password,r=i.defer();return t.post(s+"token",u,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).success(function(t){f.set("authorizationData",{token:t.access_token,userName:n.userName,permissionLevel:t.role});e.isAuth=!0;e.userName=n.userName;e.permissionLevel=t.role;r.resolve(t)}).error(function(n){r.reject(n)}),r.promise},c=function(){f.remove("authorizationData");f.remove("userData");e.isAuth=!1;e.userName="";e.permissionLevel=8;r.path("/LoggedOut");u(function(){r.path("/Login")},2e3)};n.$on("timedOut",function(){f.remove("authorizationData");f.remove("userData");e.isAuth=!1;e.userName="";e.permissionLevel=8;r.url()!=="/Login"&&(r.path("/Timeout"),u(function(){r.path("/Login");r.replace()},5e3))});var l=function(){var n=f.get("authorizationData");n&&(e.permissionLevel=n.permissionLevel,e.isAuth=!0,e.userName=n.userName)},a=function(n){var t=!1;return(n&e.permissionLevel)>0&&(t=!0),t},v=function(n){var t=i.defer();return a(n)===!0?t.resolve(e):(t.reject(),r.path("/Unauthorised"),r.replace()),t.promise},y=function(n){for(var i=!1,t=0;t<n.Length;t++)n[t]==e.permissionLevel&&(i=!0);return i};return o.login=h,o.logOut=c,o.fillAuthData=l,o.authentication=e,o.isAuthenticated=v,o}]);app.factory("userManagementService",["$http","localStorageService","Upload","$q",function(n,t,i,r){"use strict";var f="https://support.autumn.care/SupportSiteAPI/",u={},h=function(n,t){var i,r;for(i in t)if(t.hasOwnProperty(i)&&typeof t[i]=="object"){t[i].isActive=(n.bitmap&i)==i;for(r in t[i].features)t[i].features.hasOwnProperty(r)&&(t[i].features[r].isActive=n.features.hasOwnProperty(i)?(n.features[i]&r)==r:!1)}},c=function(n,t){var i,r;for(i in t)if(t.hasOwnProperty(i)){n.bitmap&=~i;t[i].isActive&&(n.bitmap|=i);for(r in t[i].features)t[i].features.hasOwnProperty(r)&&(n.features[i]&=~r,t[i].features[r].isActive&&(n.features[i]|=r))}return n},l=function(n){var i,t;for(t in n)n.hasOwnProperty(t)&&(i&=~t,n[t].isActive&&(i|=t));return i},a=function(){return t.get("userData")},v=function(n,i){var u=e(),f=o();r.all([u,f]).then(function(i){var r=i[0].data;r.latestVersionNumber=i[1].data.versionNumber;r.latestVersionDate=i[1].data.date;t.set("userData",r);n&&n()},function(){i&&i()})},y=function(t){return n.post(f+"api/account/registerUser",t).then(function(n){return n})},p=function(){return n.get(f+"api/account/getUsers")},e=function(){return n.get(f+"api/account/myUserInfo")},w=function(t){return n.post(f+"api/account/updateUser",t).then(function(n){return n})},b=function(t){return n.post(f+"api/LMSUser/RegisterLMSUser",t).then(function(n){return n})},k=function(t){return n.post(f+"api/LMSUser/RegisterLMSUsersFromCSV",t).then(function(n){return n})},d=function(){return n.get(f+"api/LMSUser/GetLMSUsers")},g=function(t){return n.post(f+"api/LMSUser/UpdateLMSUser",t).then(function(n){return n})},nt=function(t){return n.post(f+"api/LicensedEnvironment/RegisterLicensedEnvironment",t).then(function(n){return n})},tt=function(){return n.get(f+"api/LicensedEnvironment/GetLicensedEnvironments")},it=function(t){return n.post(f+"api/LicensedEnvironment/RemoveLicensedEnvironment",t).then(function(n){return n})},rt=function(t){return n.post(f+"api/Company/RegisterCompany",t).then(function(n){return n})},ut=function(){return n.get(f+"api/Company/getCompanies")},ft=function(){return n.post(f+"api/Company/RefreshMoodleData")},et=function(){return n.get(f+"api/Licences/GetLicenceList")},ot=function(){return n.post(f+"api/Licences/refreshLicenceCache")},st=function(){return n.get(f+"api/Version/getVersions")},o=function(){return n.get(f+"api/Version/getLatest")},ht=function(t){return n.post(f+"api/Version/createVersion",t).then(function(n){return n})},ct=function(t){return n.post(f+"api/Version/updateVersion",t).then(function(n){return n})},lt=function(t){return n.post(f+"api/Company/updateCompany",t).then(function(n){return n})},at=function(t){return n.get(f+"api/Files/CreateInstaller",{params:{getLatest:t}})},vt=function(t,i){return n.get(f+"api/Files/RequestFiles",{params:{requestCategory:t,getLatest:i}})},yt=function(t){return n.post(f+"api/Files/createACFile",t).then(function(n){return n})},pt=function(){return n.get(f+"api/Files/getACFiles")},wt=function(t){return n.post(f+"api/Files/updateACFile",t).then(function(n){return n})},bt=function(t){return n.post(f+"api/Files/deleteACFile",t).then(function(n){return n})},kt=function(n,t,i){var r=f+"/api/Files/DownloadFile"+s(n,t,i);window.open(r,"_blank")},s=function(n,i,r){var u=t.get("authorizationData"),f="";return u&&(f="?fileName="+n+"&folderName="+i+"&getLatest="+r+"&bearer="+u.token),f},dt=function(n){var i=t.get("authorizationData"),r="",u;i&&(r="?getLatest="+n+"&bearer="+i.token);u=f+"api/Files/DownloadInstaller"+r;window.open(u,"_blank")},gt=function(){var n=t.get("authorizationData"),i="",r;n&&(i="?bearer="+n.token);r=f+"api/Licences/DownloadLicenceFile"+i;window.open(r,"_blank")},ni=function(n){var i=t.get("authorizationData"),r="",u;i&&(r="?companyId="+n+"&bearer="+i.token);u=f+"api/Licences/DownloadCompanyLicenceFile"+r;window.open(u,"_blank")},ti=function(){return n.get(f+"api/Files/GetUploadedFiles")},ii=function(n){var i=t.get("authorizationData"),r="",u;i&&(r="?fileGuid="+n.fileGuid+"&bearer="+i.token);u=f+"api/Files/DownloadUploadedFile"+r;window.open(u,"_blank")},ri=function(n){return i.upload({url:f+"api/Files/UploadFile",method:"POST",file:n,fileName:"UTF-8''"+n.name})},ui=function(t){return n.post(f+"api/Files/uploadFileMetaData",t).then(function(n){return n})},fi=function(t){return n.post(f+"api/Files/editFileMetaData",t).then(function(n){return n})},ei=function(t){return n.post(f+"api/Files/GetFullUploadInfo",t).then(function(n){return n})},oi=function(t){return n.post(f+"api/Forms/ObsForm",t,{}).then(function(n){return n})},si=function(t){return n.post(f+"api/Forms/UpgradeForm",t,{}).then(function(n){return n})},hi=function(t){return n.post(f+"api/Forms/DemoForm",t,{}).then(function(n){return n})},ci=function(n){var t;switch(n){case 1:t="Administrator";break;case 2:t="Technical";break;case 4:t="Clinical";break;default:t="Unknown"}return t};return u.getLoggedInUser=a,u.refreshLoggedInUser=v,u.getUsers=p,u.myUserInfo=e,u.createUser=y,u.editUser=w,u.getLMSUsers=d,u.createLMSUser=b,u.createLMSUserCSV=k,u.editLMSUser=g,u.editCompany=lt,u.createCompany=rt,u.getCompanies=ut,u.refreshMoodleData=ft,u.createACFile=yt,u.getACFiles=pt,u.editACFile=wt,u.deleteACFile=bt,u.buildFileDownloadString=s,u.downloadACFile=kt,u.downloadInstaller=dt,u.downloadLicenceFile=gt,u.downloadCompanyLicenceFile=ni,u.uploadFileMetaData=ui,u.getUploadedFiles=ti,u.downloadUploadedFile=ii,u.uploadFile=ri,u.editUploadedFileMetadata=fi,u.getFullUploadInfo=ei,u.getVersions=st,u.getLatestVersion=o,u.createVersion=ht,u.editVersion=ct,u.requestInstaller=at,u.requestFiles=vt,u.getLicenceList=et,u.refreshLicenceCache=ot,u.roleList=[{id:"1",name:"Administrator"},{id:"2",name:"Technical"},{id:"4",name:"Clinical"}],u.mapRoles=ci,u.populateLicenceList=h,u.packLicenceList=c,u.packLicenceListBitmap=l,u.sendObsForm=oi,u.sendUpgradeForm=si,u.sendDemoForm=hi,u.getLicensedEnvironments=tt,u.removeLicensedEnvironment=it,u.createLicensedEnvironment=nt,u}]);app.factory("authInterceptorService",["$rootScope","$q","$location","localStorageService",function(n,t,i,r){"use strict";var u={},f=function(n){n.headers=n.headers||{};var t=r.get("authorizationData");return t&&(n.headers.Authorization="Bearer "+t.token),n},e=function(r){return r.status===401?n.$broadcast("timedOut"):r.status===403&&(i.path("/Unauthorised"),i.replace()),t.reject(r)};return u.request=f,u.responseError=e,u}]);app.controller("navbarController",["$scope","$rootScope","$timeout","$route","authService","userManagementService",function(n,t,i,r,u,f){"use strict";n.initial=!0;n.logout=function(){n.initial=!0;n.isLoggedIn=!1;u.logOut();i(function(){n.initial=!1},0)};n.$on("timedOut",function(){n.isLoggedIn=!1});n.$on("loggedIn",function(){n.initial=!0;n.loggedInUser=f.getLoggedInUser();n.isLoggedIn=!0;i(function(){n.initial=!1},0)});n.preventScrollBar=!1;n.toggleNav=function(){n.preventScrollBar=!n.preventScrollBar;jQuery(".mobile_nav").toggleClass("closed");jQuery(".mobile_nav").toggleClass("open");jQuery("#mobile_menu").slideToggle()};t.$on("$routeChangeSuccess",function(n,t){jQuery('#et-top-navigation li > a[href="#'+t.originalPath+'"]').addClass("current-page");jQuery('#et-top-navigation li > a[href!="#'+t.originalPath+'"]').removeClass("current-page")});n.loggedInUser=f.getLoggedInUser();n.loggedInUser&&(n.isLoggedIn=!0,n.loggedInUser.role==1?(n.administrator=!0,n.technical=!0,n.clinical=!0):n.loggedInUser.role==2?(n.administrator=!1,n.technical=!0,n.clinical=!1):n.loggedInUser.role==4&&(n.administrator=!1,n.technical=!1,n.clinical=!0));i(function(){n.initial=!1},0)}]);app.controller("loginController",["$rootScope","$scope","$location","$q","authService","userManagementService","globalStorageService","localStorageService",function(n,t,i,r,u,f){"use strict";var o,e;t.message="";t.buttonDisabled=!1;o=function(){var n=f.getLoggedInUser();n&&e(!1)};t.loginData={userName:"",password:""};e=function(r){f.refreshLoggedInUser(function(){i.path("/Home");n.$broadcast("loggedIn")},function(){r&&(t.message="Could not get user credentials. Please contact support.");t.buttonDisabled=!1})};o();t.login=function(){t.buttonDisabled=!0;t.message="";u.login(t.loginData).then(function(){e(!0)},function(n){t.message=n.error_description;t.buttonDisabled=!1})}}]);app.controller("observationFormController",["$scope","$location","userManagementService",function(n,t,i){"use strict";var r,u;n.loggedInUser=i.getLoggedInUser();n.selectedVersion=n.loggedInUser.version;r={versionNumber:"",summary:"",detail:""};n.obs=r;n.buttonDisabled=!1;i.getVersions().then(function(t){return n.versionList=t.data,t});n.submitForm=function(){if(r.versionNumber=n.selectedVersion.versionNumber,u()){var f=r;n.buttonDisabled=!0;i.sendObsForm(f).then(function(){toastr.success("Your observation was sent to AutumnCare.");t.url("/Home")},function(){toastr.error("There was a problem sending your observation.  Please try again in a minute, or contact AutumnCare by phone.");n.buttonDisabled=!1})}};u=function(){var n=!0;return r.versionNumber||(n=!1),r.summary||(n=!1),r.detail||(n=!1),n}}]);app.controller("upgradeFormController",["$scope","$location","userManagementService",function(n,t,i){"use strict";var r,u;n.loggedInUser=i.getLoggedInUser();n.selectedVersion=n.loggedInUser.version;n.requestedVersion={versionNumber:n.loggedInUser.latestVersionNumber};r={currentVersionNumber:"",requestedVersionNumber:"",comments:""};n.obs=r;n.buttonDisabled=!1;i.getVersions().then(function(t){return n.versionList=t.data,t});n.submitForm=function(){if(r.currentVersionNumber=n.selectedVersion.versionNumber,r.requestedVersionNumber=n.requestedVersion.versionNumber,u()){var f=r;n.buttonDisabled=!0;i.sendUpgradeForm(f).then(function(){toastr.success("Your request was sent to AutumnCare.");t.url("/Home")},function(){toastr.error("There was a problem sending your request. Please try again in a minute, or contact AutumnCare by phone.");n.buttonDisabled=!1})}};u=function(){var n=!0;return r.currentVersionNumber||(n=!1),r.requestedVersionNumber||(n=!1),n}}]);app.controller("demoFormController",["$scope","$location","userManagementService",function(n,t,i){"use strict";var r,u;n.loggedInUser=i.getLoggedInUser();n.selectedVersion={versionNumber:n.loggedInUser.versionNumber};r={currentVersionNumber:"",comments:""};n.obs=r;n.buttonDisabled=!1;i.getVersions().then(function(t){return n.versionList=t.data,t});n.submitForm=function(){if(r.currentVersionNumber=n.selectedVersion.versionNumber,u()){var f=r;n.buttonDisabled=!0;i.sendDemoForm(f).then(function(){toastr.success("Your request was sent to AutumnCare.");t.url("/Home")},function(){toastr.error("There was a problem sending your request. Please try again in a minute, or contact AutumnCare by phone.");n.buttonDisabled=!1})}};u=function(){var n=!0;return r.currentVersionNumber||(n=!1),n}}]);app.controller("profileController",["$scope","authService","userManagementService",function(n,t,i){"use strict";n.loggedInUser=i.getLoggedInUser();n.role=i.mapRoles(n.loggedInUser.role);n.displayExpiry=new Date(n.loggedInUser.licence.contractEnd).getFullYear()>1800&&new Date(n.loggedInUser.licence.contractEnd).getFullYear()<9999;n.displayFeatures=!0;n.loaded=!0;n.licenceList={};n.licence=n.loggedInUser.licence;n.availableProducts=n.loggedInUser.version.availableProducts}]);app.controller("createUserController",["$scope","$location","userManagementService",function(n,t,i){"use strict";n.roleList=i.roleList;n.restrictedRoleList=n.roleList.slice(1);i.getCompanies().then(function(t){return n.companyList=t.data,t});n.defaultRole={id:"4",name:"Clinical"};n.selectedRole=n.defaultRole;n.selectedCompany={id:"",companyName:""};n.message="";n.checkSelection=function(){n.selectedCompany.companyName!="AutumnCare"&&n.selectedRole.id==1&&(n.selectedRole={id:"4",name:"Clinical"})};n.signupData={userName:"",password:"",confirmPassword:"",email:"",role:"",company:"",name:""};n.buttonDisabled=!1;n.createUser=function(){n.buttonDisabled=!0;n.signupData.role=n.selectedRole.id;n.signupData.company=n.selectedCompany.id;i.createUser(n.signupData).then(function(){toastr.success("User has been successfully registered.");t.path("/Home")},function(t){toastr.error(t.data.message||t.data);n.buttonDisabled=!1})}}]);app.controller("userListController",["$scope","$location","userManagementService","globalStorageService",function(n,t,i,r){"use strict";i.getUsers().then(function(t){return n.userList=t.data,n.displayedUserList=[].concat(n.userList),t});n.editUser=function(n){t.path("/EditUser");r.selectedUserForEdit=n}}]);app.controller("userEditController",["$scope","$location","userManagementService","globalStorageService",function(n,t,i,r){"use strict";var u=function(){$.isEmptyObject(r.selectedUserForEdit)&&(t.path("/ViewUsers"),t.replace())};u();i.getCompanies().then(function(t){return n.companyList=t.data,t});n.roleList=i.roleList;n.restrictedRoleList=i.roleList.slice(1);n.selectedRole={id:r.selectedUserForEdit.role,name:i.mapRoles(r.selectedUserForEdit.role)};n.selectedCompany={id:r.selectedUserForEdit.companyId,companyName:r.selectedUserForEdit.companyName};n.message="";n.checkSelection=function(){n.selectedCompany.companyName!="AutumnCare"&&n.selectedRole.id==1&&(n.selectedRole={id:"4",name:"Clinical"})};n.userData={userName:r.selectedUserForEdit.userName,password:"",confirmPassword:"",email:r.selectedUserForEdit.email,role:n.selectedRole.id,name:r.selectedUserForEdit.name,companyId:n.selectedCompany.id,changePassword:!1};n.buttonDisabled=!1;n.editUser=function(){n.buttonDisabled=!0;var u=$.extend(!0,{},n.userData);u.role=n.selectedRole.id;u.company=n.selectedCompany.id;u.password!=""?u.changePassword=!0:(u.changePassword=!1,u.password="Password",u.confirmPassword="Password");i.editUser(u).then(function(){r.selectedUserForEdit=null;toastr.success("User has been successfully edited.");t.path("/ViewUsers")},function(t){n.buttonDisabled=!1;toastr.error(t.data.message||t.data)})}}]);app.controller("createCompanyController",["$scope","$location","authService","userManagementService",function(n,t,i,r){"use strict";r.getVersions().then(function(t){return n.versionList=t.data,t});n.updateLicence=function(){n.availableProducts=n.selectedVersion.availableProducts};n.signupData={companyName:"",shortCompanyName:"",isEnterprise:!1,versionId:"",canUpload:!1,licence:{bitmap:0,features:{}}};n.displayFeatures=!0;n.loaded=!0;n.licenceList={};n.availableProducts={};n.buttonDisabled=!1;n.createCompany=function(){n.buttonDisabled=!0;r.packLicenceList(n.signupData.licence,n.licenceList);n.signupData.versionId=n.selectedVersion.id;r.createCompany(n.signupData).then(function(){toastr.success("Company has been successfully registered.");t.path("/Home")},function(t){n.buttonDisabled=!1;toastr.error(t.data.message||t.data)})}}]);app.controller("companyListController",["$scope","$location","userManagementService","globalStorageService",function(n,t,i,r){"use strict";i.getCompanies().then(function(t){return n.companyList=t.data,n.displayedCompanyList=[].concat(n.companyList),t});n.predicate=function(n){return function(t){return n||t.isActive}};n.showInActive=!1;n.editCompany=function(n){t.path("/EditCompany");r.selectedCompanyForEdit=n};n.downloadCompanyLicence=function(n){i.downloadCompanyLicenceFile(n.id)}}]);app.controller("companyEditController",["$scope","$filter","$location","userManagementService","globalStorageService",function(n,t,i,r,u){"use strict";var f=function(){return $.isEmptyObject(u.selectedCompanyForEdit)?(i.path("/ViewCompanies"),i.replace(),!1):!0};f()&&(r.getVersions().then(function(t){return n.versionList=t.data,n.selectedVersion=function(){for(var i=n.versionList.length,r=u.selectedCompanyForEdit.versionId,t=0;t<i;t++)if(n.versionList[t].id==r)return n.versionList[t];return{id:u.selectedCompanyForEdit.versionId,versionNumber:u.selectedCompanyForEdit.versionNumber}}(),n.updateLicence(),t}),n.updateLicence=function(){n.availableProducts=n.selectedVersion.availableProducts},n.message="",n.companyData={companyName:u.selectedCompanyForEdit.companyName,shortCompanyName:u.selectedCompanyForEdit.shortCompanyName,id:u.selectedCompanyForEdit.id,isActive:u.selectedCompanyForEdit.isActive,licence:u.selectedCompanyForEdit.licence,versionId:u.selectedCompanyForEdit.versionId,isEnterprise:u.selectedCompanyForEdit.isEnterprise,canUpload:u.selectedCompanyForEdit.canUpload},n.companyData.licence.contractStart=new Date(t("date")(n.companyData.licence.contractStart,"yyyy-MM-dd")),n.companyData.licence.contractEnd=new Date(t("date")(n.companyData.licence.contractEnd,"yyyy-MM-dd")),n.displayFeatures=!0,n.loaded=!0,n.licenceList={},n.licence=n.companyData.licence,n.buttonDisabled=!1,n.editCompany=function(){n.buttonDisabled=!0;r.packLicenceList(n.companyData.licence,n.licenceList);n.companyData.versionId=n.selectedVersion.id;r.editCompany(n.companyData).then(function(){u.selectedCompanyForEdit=null;toastr.success("Company has been successfully edited.");i.path("/ViewCompanies")},function(t){toastr.error(t.data.message||t.data);n.buttonDisabled=!1})})}]);app.controller("createACFileController",["$scope","$location","userManagementService",function(n,t,i){"use strict";n.roleList=i.roleList;n.loaded=!0;n.licenceList={};n.categoryList=[{text:"Server Binary",id:"Server"},{text:"Client Binary",id:"Client"},{text:"Tutorial",id:"RootFolder_Foundations"},{text:"Document",id:"Documents"},{text:"Versionless Document",id:"RootFolder_Documents"}];n.selectedCategory={text:"Server Binary",id:"Server"};n.message="";n.allowTechnical=!1;n.allowClinical=!1;n.fileData={fileName:"",description:"",heading:"",group:"",licence:"",folderName:"",enterpriseOnly:!1,roles:""};n.createACFile=function(){n.buttonDisabled=!0;n.fileData.licence=i.packLicenceListBitmap(n.licenceList);n.fileData.folderName=n.selectedCategory.id;n.fileData.roles=r();i.createACFile(n.fileData).then(function(){toastr.success("Core File has been successfully registered.");t.path("/Home")},function(t){toast.error(t.data.message||t.data);n.buttonDisabled=!1})};var r=function(){var t=1;return n.allowTechnical===!0&&(t=t+2),n.allowClinical===!0&&(t=t+4),t}}]);app.controller("acFileListController",["$scope","$location","$route","$window","userManagementService","globalStorageService",function(n,t,i,r,u,f){"use strict";n.buttonDisabled=!1;u.getACFiles().then(function(t){return n.fileList=t.data,n.displayedFileList=[].concat(n.userList),t});n.editACFile=function(n){t.path("/EditACFile");f.selectedACFileForEdit=n};n.deleteACFile=function(t){n.buttonDisabled=!0;r.confirm("Are you sure you want to delete this file?")&&u.deleteACFile(t).then(function(){toastr.success("Core File has been successfully deleted.");i.reload()},function(t){toastr.error(t.data.message||t.data);n.buttonDisabled=!1});n.buttonDisabled=!1}}]);app.controller("acFileEditController",["$scope","$location","userManagementService","globalStorageService",function(n,t,i,r){"use strict";var u=r.selectedACFileForEdit,o=function(){$.isEmptyObject(u)&&(t.path("/ViewACFiles"),t.replace())},f,e;o();n.roleList=i.roleList;n.licenceList={};n.licence={bitmap:u.licence,features:{}};n.loaded=!0;n.categoryList=[{text:"Server Binary",id:"Server"},{text:"Client Binary",id:"Client"},{text:"Tutorial",id:"RootFolder_Foundations"},{text:"Document",id:"Documents"},{text:"Versionless Document",id:"RootFolder_Documents"}];n.selectedCategory={text:"",id:u.folderName};n.message="";n.allowTechnical=!1;n.allowClinical=!1;f=function(){(u.roles&4)>0&&(n.allowClinical=!0);(u.roles&2)>0&&(n.allowTechnical=!0)};f();n.buttonDisabled=!1;n.fileData={id:u.id,fileName:u.fileName,description:u.description,heading:u.heading,group:u.group,licence:u.licence,folderName:u.folderName,enterpriseOnly:u.enterpriseOnly,roles:u.roles};n.editACFile=function(){n.buttonDisabled=!0;n.fileData.licence=i.packLicenceListBitmap(n.licenceList);n.fileData.folderName=n.selectedCategory.id;n.fileData.roles=e();i.editACFile(n.fileData).then(function(){r.selectedACFileForEdit=null;toastr.success("Core File has been successfully edited.");t.url("/ViewACFiles")},function(t){toastr.error(t.data.message||t.data);n.buttonDisabled=!1})};e=function(){var t=1;return n.allowTechnical===!0&&(t=t+2),n.allowClinical===!0&&(t=t+4),t}}]);app.controller("fileUploadListController",["$scope","$location","userManagementService","globalStorageService",function(n,t,i,r){"use strict";n.isAdministrator=!1;n.filesLoaded=!1;n.loggedInUser=i.getLoggedInUser();n.loggedInUser.role==1&&(n.isAdministrator=!0);i.getUploadedFiles().then(function(t){n.fileList=t.data;n.displayedFileLIst=[].concat(n.fileList);n.filesLoaded=!0});n.downloadFile=function(n){i.downloadUploadedFile(n)};n.editFile=function(n){t.path("/EditUploadedFile");r.selectedUploadedFileForEdit=n}}]);app.controller("fileUploadController",["$scope","$location","$timeout","userManagementService","Upload",function(n,t,i,r){"use strict";var e,o,u,f,s;n.loggedInUser=r.getLoggedInUser();n.buttonDisabled=!1;n.file="";n.isAdmin=!1;n.companyList="";n.versionList="";n.licenceList={};n.selectedItem="";n.isAborted=!1;n.isSuccessful=!1;n.isFailed=!1;n.fileName="";n.loaded=!0;n.isAdmin=n.loggedInUser.role==1?!0:!1;n.isAdmin===!0&&(r.getCompanies().then(function(t){return n.companyList=t.data,n.companyList.unshift({id:-1,companyName:"None"}),t}),r.getVersions().then(function(t){return n.versionList=t.data,n.versionList.unshift({id:-1,versionNumber:"None"}),t}),e={id:-1,companyName:"None"},o={id:-1,versionNumber:"None"},n.selectedItem={company:e,version:o});n.metadata={guid:"",description:"",licenceBitmap:0,companyId:-1,versionId:-1};u=n.metadata;f="";n.uploadFile=function(t){n.isAdmin&&(n.metadata.licenceBitmap=r.packLicenceListBitmap(n.licenceList),n.metadata.companyId=n.selectedItem.company.id,n.metadata.versionId=n.selectedItem.version.id);s(t)&&(n.buttonDisabled=!0,n.isAborted=!1,n.isFailed=!1,n.isSuccessful=!1,f=r.uploadFile(t),f.then(function(t){u.guid=t.data.guid;r.uploadFileMetaData(u).then(function(){n.buttonDisabled=!1;n.uploadSuccessful=!0;toastr.success("Your file was successfully uploaded.");n.isAborted=!1;n.isFailed=!1;n.isSuccessful=!0;n.file.progress=0},function(){n.buttonDisabled=!1;n.isAborted=!1;n.isFailed=!0;n.isSuccessful=!1;n.file=null;toastr.error("File upload failed. Please try again.")})},function(){n.buttonDisabled=!1;n.isSuccessful=!1;n.isAborted||(toastr.error("File upload failed. Please try again."),n.isFailed=!0);n.isAborted=!1;n.file.progress=0},function(t){n.isAborted||(n.file.progress=Math.min(100,parseInt(100*t.loaded/t.total)))}))};n.cancelUpload=function(){f.abort();n.buttonDisabled=!1;n.isAborted=!0;n.isFailed=!1;n.isSuccessful=!1;toastr.warning("File upload was successfully aborted.");n.file.progress=0};n.$on("$locationChangeStart",function(){n.buttonDisabled&&n.cancelUpload()});n.fileChanged=function(){n.isAborted=!0;n.isFailed=!1;n.isSuccessful=!1;n.file.progress=0};s=function(n){var t=!0;return n||(t=!1),u.description||(t=!1),t}}]);app.controller("fileUploadEditController",["$scope","$location","userManagementService","globalStorageService",function(n,t,i,r){"use strict";var u=r.selectedUploadedFileForEdit,o=function(){$.isEmptyObject(u)&&(t.path("/ViewUploads"),t.replace())},f,e;o();n.buttonDisabled=!1;n.file="";n.companyList="";n.versionList="";n.licenceList={};n.licence={bitmap:0,features:{}};n.selectedCompany={id:0,companyName:"None"};n.selectedVersion={id:0,versionNumber:"None"};n.loaded=!1;n.metadata={guid:"",description:"",licenceBitmap:"",companyId:"",versionId:"",isActive:!1};i.getFullUploadInfo({guid:u.fileGuid}).then(function(t){var i=t.data;return n.selectedCompany={id:i.companyPermission},n.selectedVersion={id:i.versionPermission},n.metadata.description=i.description,n.metadata.isActive=i.isActive,n.licence=i.licencePermission,n.metadata.guid=u.fileGuid,n.loaded=!0,t});i.getCompanies().then(function(t){return n.companyList=t.data,n.companyList.unshift({id:0,companyName:"None"}),t});i.getVersions().then(function(t){return n.versionList=t.data,n.versionList.unshift({id:0,versionNumber:"None"}),t});f=n.metadata;n.editFile=function(){n.metadata.licenceBitmap=i.packLicenceListBitmap(n.licenceList);n.metadata.companyId=n.selectedCompany.id;n.metadata.versionId=n.selectedVersion.id;e()&&i.editUploadedFileMetadata(f).then(function(){n.buttonDisabled=!0;toastr.success("Uploaded file was successfully updated.");t.path("/ViewUploads")},function(t){n.buttonDisabled=!1;toastr.error(t.data.message||t.data)})};e=function(){var n=!0;return f.description||(n=!1),n}}]);app.controller("binaryDownloadController",["$scope","localStorageService","authService","userManagementService","getLatest",function(n,t,i,r,u){"use strict";n.gotCurrentInstaller=!1;n.gotServerFiles=!1;n.gotClientFiles=!1;n.errorHasOccurred=!1;n.userInfo=r.getLoggedInUser();u=="true"?(n.versionDate=n.userInfo.latestVersionDate,n.versionNumber=n.userInfo.latestVersionNumber):(n.versionDate=n.userInfo.version.date,n.versionNumber=n.userInfo.version.versionNumber);var f=function(){r.requestInstaller(u).then(function(t){return n.gotCurrentInstaller=!0,t},function(){n.errorHasOccurred=!0;toastr.error("Could not build an installer. An error has occurred.")})},e=function(){r.requestFiles("Client",u).then(function(t){return n.clientFiles=t.data,n.gotClientFiles=!0,t})},o=function(){r.requestFiles("Server",u).then(function(t){return n.serverFiles=t.data,n.gotServerFiles=!0,t})};n.downloadInstaller=function(){r.downloadInstaller(u)};n.downloadFile=function(n,t){r.downloadACFile(n,t,u)};n.downloadLicenceFile=function(){r.downloadLicenceFile(!0)};f();e();n.userInfo.isEnterprise&&o()}]);app.controller("documentDownloadController",["$scope","localStorageService","authService","userManagementService","getLatest",function(n,t,i,r,u){"use strict";n.gotFiles=!1;n.userInfo=r.getLoggedInUser();u=="true"?(n.versionDate=n.userInfo.latestVersionDate,n.versionNumber=n.userInfo.latestVersionNumber):(n.versionDate=n.userInfo.version.date,n.versionNumber=n.userInfo.version.versionNumber);var f=function(){r.requestFiles("Documents",u).then(function(t){return n.documentFiles=t.data,n.gotFiles=!0,t})};f();n.downloadFile=function(n,t){r.downloadACFile(n,t,u)}}]);app.controller("genericDocumentDownloadController",["$scope","localStorageService","authService","userManagementService",function(n,t,i,r){"use strict";n.gotFiles=!1;n.userInfo=r.getLoggedInUser();n.userInfo.role==4?n.pageTitle="Clinical and Nursing Documents":n.userInfo.role==2?n.pageTitle="Technical Documents":n.userInfo.role==1&&(n.pageTitle="Clinical and Technical Documents");var u=function(){r.requestFiles("RootFolder_Documents","false").then(function(t){return n.documentFiles=t.data,n.gotFiles=!0,t})};u();n.downloadFile=function(n,t){r.downloadACFile(n,t,"false")}}]);app.controller("foundationsDownloadController",["$scope","localStorageService","authService","userManagementService",function(n,t,i,r){"use strict";n.filesLoaded=!1;var u=function(){r.requestFiles("RootFolder_Foundations",!1).then(function(t){n.tutorialFiles=t.data.reverse();n.filesLoaded=!0})};n.downloadFile=function(n,t){r.downloadACFile(n,t,"false")};u()}]);app.controller("versionListController",["$scope","$location","userManagementService","globalStorageService",function(n,t,i,r){"use strict";n.filesLoaded=!1;i.getVersions().then(function(t){return n.versionList=t.data,n.displayedVersionList=[].concat(n.versionList),n.filesLoaded=!0,t});n.editVersion=function(n){t.path("/EditVersion");r.selectedVersionForEdit=n}}]);app.controller("createVersionController",["$scope","$location","userManagementService",function(n,t,i){"use strict";n.message="";n.signupData={versionNumber:"",date:"",description:""};n.buttonDisabled=!1;n.createVersion=function(){i.createVersion(n.signupData).then(function(){n.buttonDisabled=!0;toastr.success("Version has been successfully registered.");t.path("/Home")},function(t){toastr.error(t.data.message||t.data);n.buttonDisabled=!1})}}]);app.controller("versionEditController",["$scope","$filter","$location","userManagementService","globalStorageService",function(n,t,i,r,u){"use strict";var o=function(){$.isEmptyObject(u.selectedVersionForEdit)&&(i.path("/ViewVersions"),i.replace())},f,e;o();f=u.selectedVersionForEdit;n.message="";e=new Date(t("date")(f.date,"yyyy-MM-dd"));n.signupData={id:f.id,versionNumber:f.versionNumber,date:e,description:f.description};n.buttonDisabled=!1;n.editVersion=function(){n.buttonDisabled=!0;r.editVersion(n.signupData).then(function(){u.selectedVersionForEdit=null;toastr.success("Version has been successfully edited.");i.path("/ViewVersions")},function(t){toastr.error(t.data.message||t.data);n.buttonDisabled=!1})}}]);app.controller("homeController",["$scope","authService","userManagementService","globalStorageService",function(n,t,i,r){"use strict";n.loggedInUser=i.getLoggedInUser();n.hasFoundations=!1;n.administrator=!1;n.technical=!1;n.clinical=!1;n.versionList;n.roleString="";n.refreshLicenceCache=function(){r.licenceList=null;i.refreshLicenceCache();toastr.success("cache refreshed, you may need to refresh browser to see changes")};n.refreshMoodleData=function(){i.refreshMoodleData();toastr.success("moodle data refreshed")};i.getVersions().then(function(t){return n.versionList=t.data,t});(n.loggedInUser.licence.bitmap&1048576)==1048576&&(n.hasFoundations=!0);t.authentication.permissionLevel==1?(n.administrator=!0,n.technical=!0,n.clinical=!0,n.roleString="administrator"):t.authentication.permissionLevel==2?(n.administrator=!1,n.technical=!0,n.clinical=!1,n.roleString="technician"):t.authentication.permissionLevel==4&&(n.administrator=!1,n.technical=!1,n.clinical=!0,n.roleString="clinician")}]);app.controller("licenceCheckBoxTableController",["$scope","$location","$window","$document","userManagementService","globalStorageService",function(n,t,i,r,u,f){"use strict";n.collapsedHeight=100;n.selectedProductId=-1;n.scrollYOffset=0;n.scrollXOffset=0;n.restoreScrollPos=function(){n.scrollYOffset<=n.collapsedHeight?i.scrollTo(n.scrollXOffset,n.scrollYOffset):i.scrollTo(n.scrollXOffset,n.collapsedHeight)};n.restoreScrollPos();n.toggleProductSelect=function(t){n.scrollYOffset=i.scrollY;n.scrollXOffset=i.scrollX;n.selectedProductId==-1?(n.collapsedHeight=r.innerHeight()-i.innerHeight,n.selectedProductId=t):n.selectedProductId=n.selectedProductId==t?-1:t;n.$evalAsync(n.restoreScrollPos)};n.toggleFeatureCheckBox=function(n,t,i){i.stopPropagation();n.isActive&&(t.isActive=!t.isActive)};n.toggleProductCheckBox=function(n,t){t.stopPropagation();n.isActive=!n.isActive};n.isProductDisabled=function(t){return n.availableProducts&&(n.availableProducts.bitmap&t)==t?!1:!0};n.isFeatureDisabled=function(t,i){return n.availableProducts&&n.availableProducts.features&&n.availableProducts.features.hasOwnProperty(t)&&(n.availableProducts.features[t]&i)==i?!1:!0};n.hasFeatures=function(n){var t;for(t in n.features)if(n.features.hasOwnProperty(t))return!0;return!1};n.hasProfileFeatures=function(t,i){var r;for(r in i.features)if(i.features.hasOwnProperty(r)&&!n.isFeatureDisabled(t,r))return!0;return!1};var e,o=function(){angular.copy(f.licenceList,n.licenceList);n.licence&&(n.loaded===!1?e=n.$watch("loaded",function(t){t&&(u.populateLicenceList(n.licence,n.licenceList),e())},!0):u.populateLicenceList(n.licence,n.licenceList))};f.licenceList?o():u.getLicenceList().then(function(n){return f.licenceList=n.data,o(),n})}]);app.controller("LMSUserListController",["$scope","$location","userManagementService","globalStorageService",function(n,t,i,r){"use strict";i.getLMSUsers().then(function(t){return n.LMSUserList=t.data,n.displayedLMSUserList=[].concat(n.LMSUserList),t});n.editLMSUser=function(n){t.path("/EditLMSUser");r.selectedLMSUserForEdit=n}}]);app.controller("LMSUserEditController",["$scope","$location","userManagementService","globalStorageService",function(n,t,i,r){"use strict";var u=function(){$.isEmptyObject(r.selectedLMSUserForEdit)&&(t.path("/ViewLMSUsers"),t.replace())};u();n.loggedInUser=i.getLoggedInUser();n.isAdmin=!1;n.isAdmin=n.loggedInUser.role==1?!0:!1;n.isAdmin===!0?(i.getCompanies().then(function(t){return n.companyList=t.data,t}),n.selectedCompany={id:r.selectedLMSUserForEdit.companyId,companyName:r.selectedLMSUserForEdit.companyName}):n.selectedCompany={id:n.loggedInUser.companyId,companyName:n.loggedInUser.companyName};n.message="";n.LMSUserData={username:r.selectedLMSUserForEdit.userName,firstname:r.selectedLMSUserForEdit.firstName,lastname:r.selectedLMSUserForEdit.lastName,password:"",confirmPassword:"",email:r.selectedLMSUserForEdit.email,companyId:n.selectedCompany.id,changePassword:!1,isActive:r.selectedLMSUserForEdit.isActive,isActiveChanged:!1,isTrainer:r.selectedLMSUserForEdit.isTrainer,isRoleChanged:!1};n.buttonDisabled=!1;n.editLMSUser=function(){n.buttonDisabled=!0;var u=$.extend(!0,{},n.LMSUserData);u.company=n.selectedCompany.id;u.password!=""?u.changePassword=!0:(u.changePassword=!1,u.password="Password",u.confirmPassword="Password");u.isActive!=r.selectedLMSUserForEdit.isActive&&(u.isActiveChanged=!0);u.isTrainer!=r.selectedLMSUserForEdit.isTrainer&&(u.isRoleChanged=!0);i.editLMSUser(u).then(function(){r.selectedLMSUserForEdit=null;toastr.success("eLearning User has been successfully edited.");t.path("/ViewLMSUsers")},function(t){n.buttonDisabled=!1;toastr.error(t.data.message||t.data)})}}]);app.controller("CreateLMSUserController",["$scope","$location","userManagementService",function(n,t,i){"use strict";n.loggedInUser=i.getLoggedInUser();n.isAdmin=!1;n.isAdmin=n.loggedInUser.role==1?!0:!1;n.isAdmin===!0?(i.getCompanies().then(function(t){return n.companyList=t.data,t}),n.selectedCompany={id:"",companyName:"",shortCompanyName:""}):n.selectedCompany={id:n.loggedInUser.companyId,companyName:n.loggedInUser.companyName,shortCompanyName:n.loggedInUser.shortCompanyName};n.message="";n.LMSUserData={username:"",firstname:"",lastname:"",password:"",confirmPassword:"",email:"",company:"",isTrainer:!1,isActive:!0};n.buttonDisabled=!1;n.updateUserName=function(){var t="";t+=n.selectedCompany.shortCompanyName+"_";n.LMSUserData.firstname.length>0&&(t+=n.LMSUserData.firstname.charAt(0));n.LMSUserData.lastname.length>0&&(t+=n.LMSUserData.lastname);n.LMSUserData.username=t};n.checkSelection=function(){n.updateUserName()};n.createLMSUser=function(){n.buttonDisabled=!0;n.LMSUserData.company=n.selectedCompany.id;i.createLMSUser(n.LMSUserData).then(function(){toastr.success("eLearning User has been successfully registered.");t.path("/Home")},function(t){toastr.error(t.data.message||t.data);n.buttonDisabled=!1})}}]);app.controller("CreateLMSUserCSVController",["$scope","$location","$timeout","userManagementService","Upload",function(n,t,i,r){"use strict";var u,f;n.loggedInUser=r.getLoggedInUser();n.buttonDisabled=!1;n.file="";n.isAdmin=!1;n.isSuccessful=!1;n.isFailed=!1;n.fileName="";n.loaded=!0;n.isAdmin=n.loggedInUser.role==1?!0:!1;u="";n.uploadFile=function(t){f(t)&&(n.buttonDisabled=!0,n.isFailed=!1,n.isSuccessful=!1,u=r.createLMSUserCSV(t),u.then(function(){n.buttonDisabled=!1;n.uploadSuccessful=!0;toastr.success("LMS Users created from CSV successfully.");n.isFailed=!1;n.isSuccessful=!0;n.file.progress=0},function(){n.buttonDisabled=!1;n.isSuccessful=!1;toastr.error("LMS Users failed to create from CSV");n.isFailed=!0;n.file.progress=0},function(t){n.file.progress=Math.min(100,parseInt(100*t.loaded/t.total))}))};n.$on("$locationChangeStart",function(){n.buttonDisabled&&n.cancelUpload()});n.fileChanged=function(){n.isFailed=!1;n.isSuccessful=!1;n.file.progress=0};f=function(n){var t=!0;return n||(t=!1),t}}]);app.controller("CreateLicensedEnvironmentController",["$scope","$location","userManagementService",function(n,t,i){"use strict";n.loggedInUser=i.getLoggedInUser();n.isAdmin=!1;n.isAdmin=n.loggedInUser.role==1?!0:!1;n.isAdmin===!0?(i.getCompanies().then(function(t){return n.companyList=t.data,t}),n.selectedCompany={id:"",companyName:"",shortCompanyName:""}):n.selectedCompany={id:n.loggedInUser.companyId,companyName:n.loggedInUser.companyName,shortCompanyName:n.loggedInUser.shortCompanyName};n.message="";n.LEData={environmentName:"",company:0};n.buttonDisabled=!1;n.createLicensedEnvironment=function(){n.buttonDisabled=!0;n.LEData.company=n.selectedCompany.id;i.createLicensedEnvironment(n.LEData).then(function(){toastr.success("Licensed Environment has been successfully created.");t.path("/Home")},function(t){toastr.error(t.data.message||t.data);n.buttonDisabled=!1})}}]);app.controller("LicensedEnvironmentListController",["$scope","$location","userManagementService","globalStorageService",function(n,t,i){"use strict";i.getLicensedEnvironments().then(function(t){return n.LEList=t.data,n.displayedLEList=[].concat(n.LEList),t});n.LEData={environmentName:"",company:0};n.removeLicensedEnvironment=function(t){n.buttonDisabled=!0;var r=$.extend(!0,{},n.LEData);r.company=t.companyId;r.environmentName=t.environmentName;i.removeLicensedEnvironment(r).then(function(){toastr.success("Licensed Environment has been successfully edited.");location.reload(!0)},function(t){n.buttonDisabled=!1;toastr.error(t.data.message||t.data)})}}])