1app.controller('manageReportsCntrl', [ 2 '$scope', 3 '$rootScope', 4 '$http', 5 '$timeout', 6 '$state', 7 '$interval', 8 '$anchorScroll', 9 '$location', 10 '$stateParams', 11 'ReportService', 12 '$filter', 13 'AccountSummaryService', 14 'PayeeNewEditService', 15 'CommonService', 16 'UserNewEditService', 17 function($scope, $rootScope, $http, $timeout, $state, $interval, 18 $anchorScroll, $location, $stateParams, ReportService, $filter, 19 AccountSummaryService,PayeeNewEditService,CommonService,UserNewEditService) { 20 $scope.reportCriteria={}; 21 22 $scope.loading=true; 23 /** This method will be used for both add criteria and view criteria pages**/ 24 $scope.getReportTypes=function(){ 25 $scope.loadingTable1=true; 26 ReportService.getReportTypes().then(function(response){ 27 if(response.success){ 28 $scope.reportTypes=response.responseObj.reportTypes; 29 $scope.accessTypes=response.responseObj.accessTypes; 30 $scope.enumList={"Payment Status":response.responseObj.paymentStatusList}; 31 } 32 $scope.loadReportList(); 33 }); 34 }; 35 $scope.loadReportList=function(){ 36 ReportService.loadReportList(0).then(function(response){ 37 if(response.success){ 38 let reportlist=[] 39 var _user = angular.copy($rootScope.currentUser); 40 angular.forEach(response.responseObj, function(item) { 41 if(item.accessType=="Company"){ 42 if(item.companyId==_user.entityId){ 43 reportlist.push(item); 44 } 45 }else if(item.accessType=="User"){ 46 if (item.reportUser && item.reportUser.some(user => user.toLowerCase() === _user.userId.toLowerCase())) { 47 reportlist.push(item); 48 } 49 }else{ 50 reportlist.push(item); 51 } 52 }); 53 $scope.loadingTable1=false; 54 $scope.reports=angular.copy(reportlist); 55 $scope.tableViewby = "10"; 56 $scope.tableTotalItems = reportlist.length; 57 $scope.tableCurrentPage = 1; 58 $scope.tableItemsPerPage = $scope.tableViewby; 59 $scope.setTableItemsPerPage = function(num) { 60 $scope.tableItemsPerPage = num; 61 $scope.tableCurrentPage = 1; //reset to first page 62 } 63 $scope.accessTypes=response.responseObj.accessTypes; 64 $scope.enumList={"Payment Status":response.responseObj.paymentStatusList}; 65 } 66 $scope.loadAccounts(); 67 }); 68 }; 69 $scope.getReportTypes(); 70 $scope.loadAccounts=function(){ 71 PayeeNewEditService.active_payee_list().then(function(response) { 72 $scope.filterUserActivePayees(response); 73 AccountSummaryService.bankAccount_list().then(function(response) { 74 $scope.filterUserActiveAccounts(response); 75 loadUserList(); 76 }); 77 }); 78 } 79 /** 80 * Load User List for this particular Entity. 81 */ 82 function loadUserList(){ 83 UserNewEditService.getUserList().then(function(data){ 84 $scope.loading=false; 85 var responseObj = data.responseObj; 86 var _userList = []; 87 for(var i in responseObj){ 88 responseObj[i]["isActive"] = (responseObj[i].status=="Active")?true:false 89 _userList.push(responseObj[i]); 90 } 91 $scope.userList = _userList; 92 }); 93 } 94 95 /****** 96 ** Filter active payee list by user 97 */ 98 $scope.filterUserActivePayees =function(response) 99 { 100 101 var accountsMap={}; 102 var userPayeeList=[]; 103 var _user = angular.copy($rootScope.currentUser); 104 angular.forEach(response.responseObj, function(account) { 105 accountsMap[account.id]=account; 106 }); 107 if(_user.allowedFundingAccounts && _user.allowedBeneAccounts.indexOf("ALL")==-1){ 108 angular.forEach(_user.allowedBeneAccounts, function(accountId) { 109 userPayeeList.push(accountsMap[accountId]); 110 }); 111 }else{ 112 userPayeeList=angular.copy(response.responseObj); 113 } 114 115 if($scope.editPaymentMode){ 116 userPayeeList=angular.copy(response.responseObj); 117 } 118 $scope.payeeList = CommonService.maskAccountNumber(userPayeeList); 119 } 120 121 /****** 122 ** Filter active from accountlist by user 123 */ 124 $scope.filterUserActiveAccounts =function(response) 125 { 126 var accountsMap={}; 127 var userAccountList=[]; 128 var _user = angular.copy($rootScope.currentUser); 129 angular.forEach(response.responseObj, function(account) { 130 accountsMap[account.id]=account; 131 }); 132 if(_user.allowedFundingAccounts && _user.allowedFundingAccounts.indexOf("ALL")==-1){ 133 angular.forEach(_user.allowedFundingAccounts, function(accountId) { 134 if(accountsMap[accountId]) 135 userAccountList.push(accountsMap[accountId]); 136 }); 137 }else{ 138 userAccountList=angular.copy(response.responseObj); 139 } 140 if($scope.editPaymentMode){ 141 userAccountList=angular.copy(response.responseObj); 142 } 143 $scope.stageAccountList = angular.copy(userAccountList); 144 $scope.accountList = CommonService.maskAccountNumber($scope.stageAccountList); 145 } 146 147 $scope.deleteReport=function(reportId){ 148 ReportService.deleteReport(reportId).then(function(response){ 149 $state.go($state.current, $stateParams, { 150 reload: true, 151 inherit: false, 152 notify: true 153 }); 154 }); 155 } 156 157 $scope.$watch('searchText', function () { 158 if (Array.isArray($scope.reports)) { 159 const filteredReports = $scope.reports.filter($scope.customFilter); 160 if (filteredReports) { 161 $scope.tableTotalItems = filteredReports.length;
162 $scope.totalTablePagesNumber = Math.ceil($scope.tableTotalItems / $scope.tableItemsPerPage); 163 if ($scope.tableTotalItems === 0) { 164 $scope.tableCurrentPage = 1; 165 } 166 } 167 } 168 }); 169 170 $scope.customFilter = function (report) { 171 if (!$scope.searchText) { 172 return true; 173 } 174 175 const searchTextLower = $scope.searchText.toLowerCase(); 176 return ( 177 (report.reportTypeView.reportType && report.reportTypeView.reportType.toLowerCase().includes(searchTextLower)) || 178 (report.reportName && report.reportName.toLowerCase().includes(searchTextLower)) || 179 (report.accessType && report.accessType.toLowerCase().includes(searchTextLower)) 180 ); 181 }; 182} ]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.