| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
- app.controller('delegheSedaCtrl',
- function ($scope,$mdDialog, $window, $q,$location, $cookies, $mdBottomSheet, uiGridGroupingConstants, utilsSvc, DelegheSepa, Deleghe, Banche,
- DisposizioniRid, DisposizioniAea, DisposizioniBonifici, userService, locals) {
-
- $scope.disposizione = locals.disposizione;
- $scope.tipo = locals.tipo;
- $scope.maxItems = 0;
- $scope.itemsPerPage = 1000;
- $scope.selectedIndex=-1;
- $scope.records=[];
- $scope.vistaAggregatoAbi = false;
- $scope.lastAbi = '';
- $scope.ricercaInCorso = false;
- $scope.fromDisposizioni = false;
- $scope.topPosition = 0;
- $scope.lastIndexToRetrieve = 0;
-
- $scope.getListHeight = function() {
- containerHeight = ($window.innerHeight - $('#container').position().top - $('#view').position().top-85);
- return {'height': containerHeight + 'px'};
- };
- $scope.getGridItemHeight = function() {
- return utilsSvc.getGridHeight();
- }
- $window.addEventListener('resize', onResize);
- function onResize() {
- $scope.$digest();
- }
- $scope.$on('$destroy', function() {
- $window.removeEventListener('resize', onResize);
- });
-
- $scope.filterChiamante = userService.getFiltroIncassiSDD();
-
- $scope.disabilitaFiltri = function() {
- return $scope.filterChiamante.tipoChiamata != "Destinatari";
- }
-
- $scope.filteredView = false;
- $scope.delegheSepa = [];
- $scope.filter = {
- tipo:'0',
- statoDelega: '-1',
- cbDaDataApertura: false,
- daDataApertura: null,
- cbADataApertura: false,
- aDataApertura: null,
- cbDaDataChiusura: false,
- daDataChiusura: null,
- cbDaDataChiusura: false,
- aDataChiusura: null,
- codiceDelega: '',
- aggregazioneABI: false,
- codiceAbi: '',
- codiceClienteDebitore: '',
- idOrdinante: -1
- }
- $scope.defaultFilter = {
- tipo:'0',
- statoDelega: '-1',
- cbDaDataApertura: false,
- daDataApertura: null,
- cbADataApertura: false,
- aDataApertura: null,
- cbDaDataChiusura: false,
- daDataChiusura: null,
- cbDaDataChiusura: false,
- aDataChiusura: null,
- codiceDelega: '',
- aggregazioneABI: false,
- codiceAbi: '',
- codiceClienteDebitore: '',
- idOrdinante: -1
- }
-
- if ($scope.tipo!='')
- $scope.filter.tipo='0';
-
- if ($scope.tipo=="RID") {
- $scope.filter.codiceClienteDebitore = $scope.disposizione.codiceClienteDebitore;
- $scope.fromDisposizioni = true;
- $scope.filteredView = true;
- } else if ($scope.tipo=='SCT') {
- $scope.filter.codiceDestinatario = $scope.disposizione.codiceClienteDebitore;
- $scope.fromDisposizioni = true;
- $scope.filteredView = true;
- } else if ($scope.tipo=='SEDA') {
- $scope.filter.codiceClienteDebitore = $scope.disposizione.codiceClienteDebitore;
- $scope.fromDisposizioni = true;
- $scope.filteredView = true;
- }
-
- $scope.gridOptions = {
- enableSorting: true,
- columnDefs: [
- { name:'Abi', field: 'abi', grouping: { groupPriority: 0 } },
- { name:'Banca', field: 'banca'},
- { name:'Numero mandati', field: 'numeroMandati'},
- { name:'Stato', field: 'statoAllineamento'}
- ],
- data : $scope.records,
- enableFiltering: true,
- treeRowHeaderAlwaysVisible: false,
- onRegisterApi: function( gridApi ) {
- $scope.gridApi = gridApi;
- }
- };
-
- $scope.reportTotali = function(ev) {
- utilsSvc.showForever('Generazione in corso...');
- DelegheSepa.Print({},$scope.filter).$promise.then(function(data){
- utilsSvc.downloadFile('application/pdf',data.response,'AggregazioneDelegheSeda.pdf');
- utilsSvc.cancelMessage();
- }, function(err){
- utilsSvc.cancelMessage();
- if (error.status == 404)
- utilsSvc.showForever('Messuna delega estratta');
- else
- utilsSvc.handleHttpError(err);
- }).catch(function(err){
- if (err.status==404) {
- utilsSvc.cancelMessage();
- utilsSvc.showMessage('Nessuna delega estratta');
- } else
- utilsSvc.handleHttpError(err);
- });
- }
-
- $scope.exportXLS= function(ev) {
- utilsSvc.showForever('Generazione in corso...');
- DelegheSepa.Export({},$scope.filter).$promise.then(function(data){
- utilsSvc.downloadFile('attachment/csv',data.response,'ReportTotali.csv');
- utilsSvc.cancelMessage();
- }, function(err){
- utilsSvc.cancelMessage();
- if (error.status == 404)
- utilsSvc.showForever('Messuna delega estratta');
- else
- utilsSvc.handleHttpError(err);
- });
- }
-
- $scope.showCommands = function(index,$event) {
- $scope.selectedIndex = index;
- $mdBottomSheet.show({
- templateUrl: 'templates/bottom-sheet-template.html',
- controller: 'comandiDelegheSepaCtrl',
- idx: index,
- appVariables: $scope.appVariables,
- fromDisposizioni: $scope.fromDisposizioni,
- targetEvent: $event,
- parent:document.getElementById('dialogSeda')
- }).then(function(selectedCommand) {
- $scope.executeCommand(selectedCommand.cmdIndex, selectedCommand.recordIdx, $event);
- },
- function(){}
- );
- }
- $scope.executeCommand = function(cmdIndex, ndx, event) {
- if (cmdIndex==0)
- $scope.delegheSdd(ndx, event);
- else if (cmdIndex==1)
- $scope.delegheSeda(ndx, event);
- else if (cmdIndex==2)
- $scope.denominazioneBanca(ndx, event);
- }
-
-
- $scope.eseguiRicerca = function() {
- $scope.topPosition = 0;
- $scope.lastAbi = '';
- $scope.records = [];
- // $scope.filteredView = !$scope.filteredView;
- if (!$scope.filteredView) {
- $scope.filter.aggregazioneABI=false;
- $scope.filter=$scope.defaultFilter;
- }
-
- $scope.getDeleghe();
- }
-
- $scope.denominazioneBanca = function(ndx,ev) {
- Banche.GetByAbi({abi:$scope.records[ndx].abi.trim()}).$promise.then(function(data){
- var descrizioneBanca = data.descri;
-
- $mdDialog.show({
- targetEvent: ev,
- templateUrl: 'templates/ricercaFiliali.html',
- controller: 'ricercaFilialiCtrl',
- locals: {abi: data.abi, istituto: descrizioneBanca},
- multiple: true
- }).then(function(filiale){
- // non cambiare le info
- })
- });
- }
-
- $scope.getDeleghe = function() {
- if ($scope.ricercaInCorso)
- return;
- $scope.ricercaInCorso = true;
- utilsSvc.showForever('Ricerca in corso...');
- DelegheSepa.Count({}, ($scope.filteredView? $scope.filter: $scope.defaultFilter))
- .$promise.then(function(data){
- $scope.vistaAggregatoAbi = $scope.filter.aggregazioneABI;
- $scope.records=[];
- $scope.maxItems = data.value;
- $scope.infiniteItems.numLoaded_ = 0;
- $scope.infiniteItems.toLoad_ = 0;
- $scope.lastIndexToRetrieve = 0;
-
- if ($scope.filter.aggregazioneABI) {
- var listPromise = DelegheSepa.List({start: $scope.records.length,size:999999},
- ($scope.filteredView? $scope.filter: $scope.defaultFilter)).$promise;
- listPromise.then(
- function(data){
- $scope.ricercaInCorso = false;
- utilsSvc.cancelMessage();
- $scope.vistaAggregatoAbi = $scope.filter.aggregazioneABI;
- $scope.records = $scope.records.concat(data);
- $scope.gridOptions.data = data;
- // $scope.gridApi.grouping.clearGrouping();
- // $scope.gridApi.grouping.groupColumn('Abi');
- // $scope.gridApi.grouping.aggregateColumn('Banca', uiGridGroupingConstants.aggregation.COUNT);
- // $scope.gridApi.treeBase.expandAllRows();
- },
- function(error) {
- $scope.ricercaInCorso = false;
- utilsSvc.cancelMessage();
- utilsSvc.handleHttpError(error);
- }
- )
-
- } else {
- $scope.ricercaInCorso = false;
- if (data.value==0) {
- utilsSvc.cancelMessage();
- utilsSvc.show('Nessuna disposizione collegata alla delega');
- // if ($scope.filteredView)
- // window.close();
- }
- }
-
- });
- }
-
- $scope.getDeleghe();
-
- $scope.cancelDialog = function() {
- $mdDialog.cancel();
- }
-
- $scope.isEndAbiBlock=function(abi) {
- if ($scope.lastAbi!=abi) {
- $scope.lastAbi = abi;
- return true;
- }
- return false;
-
- }
-
- $scope.delegheSdd = function(ndx, ev){
- var filtro = userService.newFilter();
- filtro.codiceClienteDebitore = $scope.records[ndx].codiceDestinatario;
- filtro.tipoChiamata = 'FiltroDisposizioniReadOnly';
- DisposizioniRid.Count(filtro,
- function(data){
- if (data.value>0) {
- localStorage.setItem("filter", JSON.stringify(filtro));
- $window.open('#/incassiSDD','_blank');
- }
- else
- utilsSvc.showMessage('Nessuna disposizione collegata alla delega');
- }
- );
-
- }
-
- $scope.delegheSeda = function(ndx, ev){
- var filtro = userService.newFilter();
- filtro.codiceClienteDebitore = $scope.records[ndx].codiceDestinatario;
- filtro.tipoChiamata = 'FiltroDisposizioniReadOnly';
- DisposizioniAea.Count(filtro,
- function(data){
- if (data.value>0) {
- localStorage.setItem("filter", JSON.stringify(filtro));
- $window.open('#/allineamentoSEDA','_blank');
- }
- else
- utilsSvc.showMessage('Nessuna disposizione collegata alla delega');
- }
- );
- }
-
- $scope.decodeTipoDestinatario = function(tipoDestinatario){
- var res ="";
- switch (tipoDestinatario) {
- case "1":
- return "Utenza";
- case "2":
- return "Matricola";
- case "3":
- return "Codice fiscale";
- case "4":
- return "Codice cliente";
- case "5":
- return "Codice fornitore";
- case "6":
- return "Portafoglio commerciale"
- case "9":
- return "Altri";
-
- default:
- return "Altri";
-
- }
- }
-
- $scope.decodeStato = function(stato) {
- switch (stato) {
- case "0":
- return "In attesa di esito";
- case "1":
- return "Attiva";
- case "2":
- return "Non attiva";
- case "6":
- return "Attivata SDD";
-
- }
- }
-
- $scope.infiniteItems = {
- numLoaded_: 0,
- toLoad_: 0,
- loading_:false,
- listPromise:null,
- canceler: $q.defer(),
- // Required.
- getItemAtIndex: function(index) {
- if ($scope.maxItems==0 || index>$scope.maxItems)
- return null;
- if (!$scope.infiniteItems.loading_)
- if (index > $scope.records.length) {
- this.fetchMoreItems_(index);
- return null;
- }
- return $scope.records [index];
- },
- // Required.
- // For infinite scroll behavior, we always return a slightly
- // higher
- // number than the previously loaded items.
- getLength: function() {
- return $scope.maxItems;
-
- },
- fetchMoreItems_: function(index) {
- if (this.toLoad_ < index) {
- this.toLoad_ += $scope.itemsPerPage;
- $scope.infiniteItems.loading_ = true;
- //this.listPromise = DelegheSepa.List({start: index,size:$scope.itemsPerPage},
- this.listPromise = DelegheSepa.List({start: $scope.records.length,size:$scope.itemsPerPage}, //Math.max($scope.records.length+index,$scope.itemsPerPage)},
- ($scope.filteredView? $scope.filter: $scope.defaultFilter)).$promise;
- var mod=this;
- this.listPromise.then(
- function(data){
- $scope.infiniteItems.loading_ = false;
- utilsSvc.cancelMessage();
- $scope.vistaAggregatoAbi = $scope.filter.aggregazioneABI;
- $scope.records = $scope.records.concat(data);
- mod.numLoaded_ = $scope.records.length;
- },
- function(error) {
- $scope.infiniteItems.loading_ = false;
- utilsSvc.cancelMessage();
- utilsSvc.handleHttpError(error);
- }
- )
- }
- }
- }
-
- })
- .controller('comandiDelegheSepaCtrl', function($scope, $mdBottomSheet, idx, appVariables, fromDisposizioni) {
- $scope.title = 'Comandi';
-
- $scope.items = [
- { id:0, name: "SDD", icon: 'fa-folder-open', visible: true },
- { id:1, name: "Seda", icon: 'fa-folder-open',visible: true },
- { id:2, name: "Denom. Banca", icon: 'fa-bank',visible: true }
- ];
- if (fromDisposizioni) {
- $scope.items[0].visible = false;
- $scope.items[1].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();
- }
- })
|