app.controller('allineamentoSEDACtrl', function ($scope,$http,$cookies,$window, $location,$timeout, $mdDialog, $q, $routeParams, $mdMedia, utilsSvc, userService, incassoSDDSvc, UserManager, ComboManager, DisposizioniAea, DistinteBanca) { var vm=this; vm.filteredView = (typeof $routeParams.filter!="undefined"); $location.search('filter', null).replace(); if ($cookies.get("filter")) { userService.setFiltroIncassiSDD($scope.$eval($cookies.get("filter"))); $cookies.remove("filter"); userService.hideMenu(); } vm.maxItems = 0; vm.itemsPerPage = 500; vm.records=[]; vm.esitiAea=[]; vm.filter = userService.getFiltroIncassiSDD(); vm.selectedIndex=-1; vm.topIndex = 0; vm.allSelected=false; vm.abilitaFirma = false; vm.initFilter = function() { return; if (vm.filter.tipoChiamata!="DistinteBanca") { vm.filter.idDistintaBanca = 0; vm.filter.idDistintaFlusso = 0; vm.filter.codiceClienteDebitore=''; userService.setFiltroIncassiSDD(vm.filter); } } vm.toggleSelectAll=function(){ vm.allSelected=!vm.allSelected; vm.records.forEach(function(item) { item.selected = vm.allSelected }); } vm.getSelectedIds = function(){ var res = []; if (vm.allSelected) res.push(-1); else vm.records.forEach(function(item){ if (item.selected) res.push(item.id)} ); return res; } vm.largeScreen = function(){ return utilsSvc.largeScreen(); console.log(utilsSvc.largeScreen()); } vm.cancellaDisposizioni = function(ev){ utilsSvc.showConfirm('Attenzione','Confermi la cancellazione delle disposizioni selezionate?',ev).then(function(){ utilsSvc.showForever('Cancellazione in corso...'); ids=vm.getSelectedIds(); let filter = new Object(); filter = vm.filter; filter.selectedIds=ids; DisposizioniAea.MassDelete({},filter).$promise.then(function(data){ utilsSvc.cancelMessage(); if (data.value) utilsSvc.showMessage('Cancellazione effettuata'); else utilsSvc.showMessage('Cancellazione effettuata. Alcune distinte non erano in uno stato da permetterne la cancellazione'); vm.getDisposizioni(); }).catch(function(err){ utilsSvc.cancelMessage(); utilsSvc.showMessage('Si è verificato un errore durante la cancellazione'); }) }); } vm.initFilter(); if (localStorage.getItem("filter")) { vm.filter = $scope.$eval(localStorage.getItem("filter")); localStorage.removeItem("filter"); userService.hideMenu(); } if (utilsSvc.largeScreen()) vm.columnWidths=[ 70, //0 90, //1 180, //2 120, //3 90, //4 120, //5 114, //6 114, //7 60, //8 220, //9 90, //10 70, //11 140, //12 290, //13 220 //14 ]; else vm.columnWidths=[ 80, //0 90, //1 220, //2 120, //3 90, //4 80, //5 114, //6 114, //7 60, //8 220, //9 90, //10 70, //11 140, //12 290, //13 220 //14 ]; vm.getListHeight = function() { containerHeight = ($window.innerHeight - $('#container').position().top - $('#view').position().top); return {'height': containerHeight + 'px'}; }; vm.getGridItemHeight = function() { return utilsSvc.getGridHeight(); } $window.addEventListener('resize', onResize); function onResize() { $scope.$digest(); } $scope.$on('$destroy', function() { $window.removeEventListener('resize', onResize); }); $timeout(function() { var evt = $window.document.createEvent('UIEvents'); evt.initUIEvent('resize', true, false, $window, 0); $window.dispatchEvent(evt); }); $scope.largeScreen =function(){ return utilsSvc.largeScreen(); } vm.getColumnWidth = // } // this.lastStartIdx = index; function(idx) { return { 'width': vm.columnWidths[idx] + 'px', 'min-width':vm.columnWidths[idx] + 'px', //'padding-left':'6px', //'padding-right':'6px', 'margin-left':'8px', 'margin-right':'8px' }; } vm.getMaxListWidth = function() { var res=0; for (var i=0;ivm.maxItems) return null; if (!vm.infiniteItems.loading_) if (index > vm.records.length) { this.fetchMoreItems_(index); return null; } return vm.records [index]; }, // Required. // For infinite scroll behavior, we always return a slightly // higher // number than the previously loaded items. getLength: function() { return vm.maxItems; }, fetchMoreItems_: function(index) { if (vm.infiniteItems.toLoad_ < index) { vm.infiniteItems.toLoad_ += vm.itemsPerPage; utilsSvc.showWaitMessage('Ricerca in corso...'); vm.infiniteItems.loading_ = true; if ((vm.records.length+vm.itemsPerPage)= vm.appVariables.importoLimiteFirma && (userService.getFiltroIncassiSDD().userIdFirmatario1 == '' || userService .getFiltroIncassiSDD().userIdFirmatario1 == null)) { utilsSvc .showConfirm( "Conferma", "Confermi la firma della distinta e l'emissione del flusso di pagamento?
Per l'emissione del flusso di pagamento sarà richiesto il secondo firmatario") .then( function(res) { vm .eseguiFirma( 1, 0, userService .getFiltroIncassiSDD().idDistintaBanca); }); } else if (userService.getFiltroIncassiSDD().userIdFirmatario1 != '') { utilsSvc .showConfirm("Conferma", "Confermi la firma della distinta e l'emissione del flusso di pagamento?") .then( function(res) { vm .eseguiFirma( 2, 1, userService .getFiltroIncassiSDD().idDistintaBanca); }); } } vm.eseguiFirma = function(tipoFirma, generaFlusso, idDistintaBanca) { DistinteBanca.FirmaDistinta({ tipoFirma : tipoFirma, generaFlusso : generaFlusso, idDistintaBanca : idDistintaBanca }).$promise .then(function(res) { if (res[0] == "0") utilsSvc.show("Firma distinta effettuata"); else if (res[0] == "4") utilsSvc.show("Firma distinta non effettuata: Errore : ErrorConflict"); else if (res[0] == "5") utilsSvc.show("Firma distinta non effettuata: Errore : ErrorConflictRecordDeleted"); else if (res[0] == "6") utilsSvc.show("Firma distinta non effettuata, tutte le disposizioni sono state eliminate"); else utilsSvc.show("Firma distinta non effettuata: Errore : " + res); $location.path('/distinteBanca'); }) } vm.init(); } ); console.log()