app.controller('distinteBancaCtrl', function ($scope,$http,$cookies,$window, $location,$timeout, $mdDialog, $q, $routeParams, $mdBottomSheet, $mdMenu, utilsSvc, userService, DistinteBanca, ProvenienzaDisposizioni, UserManager) { var vm=this; vm.filteredView = (typeof $routeParams.filter!="undefined"); $location.search('filter', null); vm.provenienza=['Findomest']; vm.maxItems = 0; vm.itemsPerPage = 100; vm.selectedIndex=-1; vm.records=[]; vm.esitiRid=[]; vm.appVariables={}; vm.ricercaInCorso = false; vm.filteredView=false; vm.topIndex = 0; vm.selectedIndex = -1; vm.filter={ provenienza: '', vistaGenerale: false, sdd: false, sdd_esteri: false, seda: false, sct: false, dom: false, sct_int: false, sct_inps:false, sct_esteri:false, assegni: false, orderField:null, flagAbilitaDaDataCreazione: false, flagAbilitaADataCreazione: false, daDataCreazione:null, aDataCreazione: null, flagAbilitaDaDataValuta: false, flagAbilitaADataValuta: false, daDataValuta:null, aDataValuta: null, daImporto:null, aImporto:null, daDistinta:null, aDistinta:null, nomeSupportoCBI:'', contoOrdinante:'' }; vm.tipologieSelezionate=[]; vm.filtriTipologie=[ {id:'sdd', label:"SDD"}, {id:'sdd_esteri', label:"SDD_ESTERI"}, {id:'seda', label:"SEDA"}, {id:'sct', label:"SCT"}, {id:'dom', label:"DOM"}, {id:'sct_int', label:"SCT INT"}, {id:'sct_inps', label:"SCT INPS"}, {id:'sct_esteri', label:"SCT Esteri"}, {id:'intesa', label:"Assegni Intesa"} ] if (localStorage.getItem("filterDistinte")) { vm.filter = $scope.$eval(localStorage.getItem("filterDistinte")); vm.filteredView = $scope.$eval(localStorage.getItem("filterDistinteAttivo")); vm.selectedIndex = $scope.$eval(localStorage.getItem("filterDistinteSelectedIndex")); } vm.defaultFilter=angular.copy(vm.filter); vm.aggiornaFiltro=function(){ vm.filter.sdd=vm.tipologieSelezionate.indexOf('sdd')>=0; vm.filter.sdd_esteri=vm.tipologieSelezionate.indexOf('sdd_esteri')>=0; vm.filter.seda=vm.tipologieSelezionate.indexOf('seda')>=0; vm.filter.sct=vm.tipologieSelezionate.indexOf('sct')>=0; vm.filter.dom=vm.tipologieSelezionate.indexOf('dom')>=0; vm.filter.sct_int=vm.tipologieSelezionate.indexOf('sct_int')>=0; vm.filter.sct_inps=vm.tipologieSelezionate.indexOf('sct_inps')>=0; vm.filter.sct_esteri=vm.tipologieSelezionate.indexOf('sct_esteri')>=0; vm.filter.assegni=vm.tipologieSelezionate.indexOf('intesa')>=0; } vm.setSelected=function(idx) { vm.selectedIndex = idx; } $timeout(function() { var evt = $window.document.createEvent('UIEvents'); evt.initUIEvent('resize', true, false, $window, 0); $window.dispatchEvent(evt); }); UserManager.AppVariables().$promise.then(function(data) { vm.appVariables = data; }); if (utilsSvc.largeScreen()) vm.columnWidths=[ 70, // 0 100, // 1 90, // 2 90, // 3 150, // 4 140, // 5 150, // 6 90, // 7 70, // 8 120, // 9 140, // 10 120, // 11 120, // 12 200, // 13 320 // 14 ]; else vm.columnWidths=[ 100, // 0 100, // 1 90, // 2 90, // 3 150, // 4 140, // 5 100, // 6 100, // 7 100, // 8 90, // 9 140, // 10 120, // 11 120, // 12 200, // 13 320 // 14 ]; vm.largeScreen =function(){ return utilsSvc.largeScreen(); } vm.veryLargeScreen =function(){ return utilsSvc.veryLargeScreen(); } 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); }); vm.largeScreen =function(){ return utilsSvc.largeScreen(); } vm.openMenu = function($mdMenu, ev) { originatorEv = ev; $mdMenu.open(ev); }; 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;i TASC effettuata"); else utilsSvc.showMessage("Si è verificato un errore; codice: " + data); vm.getDistinte(); }); }); } vm.showCommands = function(distinta,index,$event) { vm.selectedIndex = index; $mdBottomSheet.show({ templateUrl: 'templates/bottom-sheet-template.html', controller: 'comandiDistintaCtrl', distinta: distinta, idx: index, appVariables: vm.appVariables, targetEvent: $event }).then(function(selectedCommand) { vm.executeCommand(selectedCommand.cmdIndex, selectedCommand.recordIdx, $event); }, function(){} ); } vm.executeCommand = function(id,idx, $event) { vm.selectedIndex = idx; switch(id) { case 0: vm.espandiDistinta(vm.records[idx],$event);break; case 1: vm.apriDistinta(vm.records[idx],$event);break; case 2: vm.stampaDistinta(vm.records[idx],$event);break; case 3: vm.annullaDistinta(vm.records[idx],$event);break; case 4: vm.logStatiDistinta(vm.records[idx],$event);break; case 5: vm.modificaContoOrdinante(vm.records[idx],$event);break; case 6: vm.modificaValutaBeneficiario(vm.records[idx],$event);break; case 7: vm.modificaDataEsecuzione(vm.records[idx],$event);break; case 8: vm.validaEGeneraFlusso(vm.records[idx],$event);break; case 9: vm.generaFlusso(vm.records[idx],$event);break; case 10: vm.exportDistinte(vm.records[idx],$event);break; case 11: vm.abilitaExport(vm.records[idx],$event);break; case 12: vm.forzaturaInviata(vm.records[idx],$event);break; } } vm.infiniteItems = { numLoaded_: 0, toLoad_: 0, loading_:false, lastStartIdx:-1, listPromise:null, canceler: $q.defer(), // Required. getItemAtIndex: function(index) { if (vm.maxItems==0 || index>vm.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 (this.toLoad_ < index) { this.toLoad_ += vm.itemsPerPage; utilsSvc.showWaitMessage('Ricerca in corso...'); vm.infiniteItems.loading_ = true; if ((vm.records.length+vm.itemsPerPage) TASC è possibile solo se la // distinte non risulta già esportata $scope.items[11].visible = distinta.flagChiusuraPartitaSep; $scope.items[12].visible = distinta.statoDistinta=='Disposta'; if (appVariables.profiloLocale == 'VI') { $scope.items[0].visible = false; $scope.items[3].visible = false; $scope.items[5].visible = false; $scope.items[6].visible = false; $scope.items[7].visible = false; $scope.items[8].visible = false; $scope.items[9].visible = false; } $scope.listItemClick = function($index, $event) { var clickedItem = $scope.items[$index]; var result = {cmdIndex: $index, recordIdx: idx, event:$event} $mdBottomSheet.hide(result); }; $scope.dismissBottomSheet = function() { $mdBottomSheet.cancel(); } }) ;