| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555 |
- app.controller('assegniIntesaCtrl',
- function($scope, $http, $cookies, $window, $location, $timeout,
- $mdDialog, $q, $routeParams, $mdMedia, utilsSvc,
- userService, ComboManager, DisposizioniBonifici,
- DistinteBanca, UserManager) {
- var vm = this;
- vm.nomeFunzione = 'Assegni Intesa';
-
- vm.filteredView = (typeof $routeParams.filter != "undefined");
- $location.search('filter', null).replace();
- vm.maxItems = 0;
- vm.itemsPerPage = 100;
- vm.records = [];
- vm.esitiRid = [];
- vm.selectedIndex = -1;
- vm.topIndex = 0;
- vm.filter = userService.getFiltroIncassiSDD();
- vm.abilitaFirma = false;
- vm.appVariables = {};
- vm.allSelected=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.initFilter();
- if (utilsSvc.largeScreen())
- vm.columnWidths = [
- 70, // 0
- 90, // 1
- 80, // 2
- 100, // 3
- 90, // 4
- 90, // 5
- 130, // 6
- 250, // 7
- 90, // 8
- 90, // 9
- 120, // 10
- 180, // 11
- 180, // 12
- 120, // 13
- 240, // 14
- 200
- ];
- else
- vm.columnWidths = [
- 70, // 0
- 90, // 1
- 70, // 2
- 70, // 3
- 90, // 4
- 80, // 5
- 130, // 6
- 250, // 7
- 90, // 8
- 90, // 9
- 120, // 10
- 180, // 11
- 180, // 12
- 120, // 13
- 240, // 14
- 200
- ];
-
- 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);
- },100);
- 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 < vm.columnWidths.length; i++)
- res += vm.columnWidths[i] + 6 + 8 + 10;
- $('#container').css('width',
- ($('#header').width() + 10) + 'px');
- return {
- 'width' : res + 'px!important;'
- }
- }
- vm.getEsitoColor = function(esito) {
- var color;
- if (esito == 2)
- color = 'red';
- else if (esito == 1)
- color = 'green';
- return {
- 'color' : color
- };
- }
- vm.setOrderField = function(field) {
- if (vm.filter.orderField != field)
- vm.filter.orderField = field;
- else
- vm.filter.orderField = "-" + field;
- vm.getDisposizioni();
- }
- vm.cercaErrori = function(event) {
- vm.getDisposizioni();
- }
- vm.stampaDisposizioni = function() {
- utilsSvc.showForever('Generazione in corso...');
-
- ids=vm.getSelectedIds();
- let filter = new Object();
- if (vm.filteredView)
- filter = userService.getFilter();
- else
- filter = vm.filter;
-
- filter.selectedIds=ids;
-
- if (vm.filteredView)
- DisposizioniBonifici.PrintFiltered({}, filter).$promise.then(function(data) {
- utilsSvc.downloadFile('application/pdf',
- data.response,
- 'DisposizioniBonifici.pdf');
- utilsSvc.cancelMessage();
- }).catch(function(err){
- if (err.status==404) {
- utilsSvc.cancelMessage();
- utilsSvc.showMessage('Nessuna disposizione estratta');
- } else
- utilsSvc.handleHttpError(err);
- });
- else
- DisposizioniBonifici.Print({}, filter).$promise
- .then(function(data) {
- utilsSvc.downloadFile(
- 'application/pdf',
- data.response,
- 'DisposizioniBonifici.pdf');
- utilsSvc.cancelMessage();
- }).catch(function(err){
- if (err.status==404) {
- utilsSvc.cancelMessage();
- utilsSvc.showMessage('Nessuna disposizione estratta');
- } else
- utilsSvc.handleHttpError(err);
- });
- }
- vm.firmaDistinta = function() {
- if (userService.getFiltroIncassiSDD().importoDistinta < 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?")
- .then(
- function(res) {
- vm
- .eseguiFirma(
- 1,
- 1,
- userService
- .getFiltroIncassiSDD().idDistintaBanca);
- });
- } else if (userService.getFiltroIncassiSDD().importoDistinta >= 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?<br>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.exportExcel = function() {
- ids=vm.getSelectedIds();
- let filter = new Object();
- if (vm.filteredView)
- filter = userService.getFilter();
- else
- filter = vm.filter;
-
- filter.selectedIds=ids;
-
- if (vm.filteredView) {
- utilsSvc.showForever('Generazione in corso...');
- DisposizioniBonifici.ExportFiltered({}, filter).$promise.then(function(data) {
- utilsSvc.downloadFile('attachment/csv',
- data.response, 'export.csv');
- utilsSvc.cancelMessage();
- }).catch(function(err){
- if (err.status==404) {
- utilsSvc.cancelMessage();
- utilsSvc.showMessage('Nessuna distinta estratta');
- }
- })
- } else {
- utilsSvc.showForever('Generazione in corso...');
- DisposizioniBonifici.Export({}, filter).$promise
- .then(function(data) {
- utilsSvc.downloadFile('attachment/csv',
- data.response, 'export.csv');
- utilsSvc.cancelMessage();
- }).catch(function(err){
- if (err.status==404) {
- utilsSvc.cancelMessage();
- utilsSvc.showMessage('Nessuna distinta estratta');
- }
- })
- }
- }
- 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) {
- vm.infiniteItems.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) < vm.selectedIndex)
- vm.itemsPerPage = vm.selectedIndex - vm.records.length;
- if (vm.filteredView) {
- var args = {filtroRicerca : userService.getFilter(),filtro : vm.filter};
- this.listPromise = DisposizioniBonifici.Filter({start : vm.records.length,size : Math.max(vm.records.length + index,vm.itemsPerPage),orderField : vm.filter.orderField}, args).$promise;
- } else
- this.listPromise = DisposizioniBonifici.List({start : vm.records.length,size : Math.max(vm.records.length+ index,vm.itemsPerPage)}, vm.filter).$promise;
- var mod = this;
- this.listPromise.then(function(data) {
- vm.infiniteItems.loading_ = false;
- vm.infiniteItems.toLoad_=0;
- utilsSvc.cancelWaitMessage();
- vm.records = vm.records.concat(data);
- mod.numLoaded_ = vm.records.length;
- mod.lastStartIdx = vm.records.length;
- vm.topIndex = vm.selectedIndex;
- }, function(error) {
- vm.infiniteItems.loading_ = false;
- vm.infiniteItems.toLoad_=0;
- utilsSvc.handleHttpError(error);
- })
- }
- }
- }
-
- 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;
-
- DisposizioniBonifici.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.getDisposizioni = function() {
- utilsSvc.showWaitMessage('Ricerca in corso...');
- vm.filter.selectedIds=[];
- if (vm.filteredView) {
- var args = {
- filtroRicerca : userService.getFilter(),
- filtro : vm.filter
- };
- DisposizioniBonifici.CountFiltered({}, args,
- function(data) {
- vm.records = [];
- vm.maxItems = data.value;
- vm.infiniteItems.numLoaded_ = 0;
- vm.infiniteItems.toLoad_ = 0;
- utilsSvc.cancelWaitMessage();
- if (data.value==0 && vm.filteredView) {
- utilsSvc.showMessage('Nessuna disposizione estratta');
- $window.history.back();
- }
- }, function(error) {
- utilsSvc.cancelWaitMessage();
- utilsSvc.handleHttpError(error);
- });
- } else
- DisposizioniBonifici.Count(vm.filter,
- function(data) {
- vm.records = [];
- vm.maxItems = data.value;
- vm.infiniteItems.numLoaded_ = 0;
- vm.infiniteItems.toLoad_ = 0;
- utilsSvc.cancelWaitMessage();
-
- }, function(error) {
- utilsSvc.cancelWaitMessage();
- utilsSvc.handleHttpError(error);
- });
- }
- vm.getEsitoIcon = function(esito) {
- if (esito === '1')
- return "fa-clear";
- else if (esito === '2')
- return 'fa-times';
- }
- vm.ricercaDisposizioni = function(ev) {
- $mdDialog.show({
- templateUrl : 'templates/filtroDisposizioni.html',
- controller : 'filtroDisposizioniCtrl',
- targetEvent : ev,
- locals : {
- filter : vm.filter
- }
- }).then(function(args) {
- vm.filteredView = false;
- // dialog confirmed
- vm.filter = args;
- vm.getDisposizioni();
- }, function() {
- });
- }
- vm.mostraDisposizione = function(idx, ev) {
- if (typeof vm.records == "undefined"
- || typeof vm.records[idx] == "undefined")
- return
- vm.selectedIndex = idx;
- // disposizione.importo =
- // parseFloat(disposizione.importo.replace(",","."));
- DisposizioniBonifici.Get({
- id : vm.records[idx].id
- }).$promise
- .then(
- function(res) {
- var disposizione = res;
- $mdDialog
- .show(
- {
- templateUrl : 'templates/dettaglioDisposizioneSCT.html',
- controller : 'dettaglioDisposizioneSctCtrl',
- targetEvent : ev,
- locals : {
- label: (utilsSvc.largeScreen()?'Dettaglio disposizione Assegni Intesa': 'ASSEGNI_INTESA'),
- disposizione : angular
- .copy(disposizione),
- appVariables : vm.appVariables
- }
- })
- .then(function(args) {
- vm.initFilter();
- vm.getDisposizioni();
- }, function() {
- });
- }, function(err) {
- utilsSvc.handleHttpError(err);
- });
- }
- vm.key = function($event) {
- console.log($event.keyCode);
- if ($event.keyCode == 38)
- if (vm.selectedIndex > 0)
- vm.selectedIndex--;
- else if ($event.keyCode == 40)
- if (vm.selectedIndex < vm.maxItems)
- vm.selectedIndex++;
- }
- vm.init = function() {
- UserManager.AppVariables().$promise
- .then(function(data) {
- vm.appVariables = data;
- if (vm.filter.tipoChiamata == 'FiltroDisposizioni'
- || vm.filter.tipoChiamata == 'FiltroDisposizioniReadOnly'
- || vm.filter.tipoChiamata == 'DistinteBanca') {
- vm.abilitaFirma = vm.appVariables.profiloLocale == "DF";
- }
- });
- vm.getDisposizioni();
- }
- vm.init();
- });
|