| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684 |
- app.controller('sedaRemunerationCtrl',
-
- function ($scope,$http,$cookies,$window, $location,$timeout, $mdDialog, $q, $mdBottomSheet, utilsSvc, userService, Remuneration) {
- var vm=this;
-
- vm.maxItems = 0;
- vm.maxDetailItems = 0;
- vm.itemsPerPage = 500;
- vm.records=[];
- vm.detailrecords=[];
- vm.currentDetailId = 0;
- vm.codiciSia=[];
- vm.codiceSiaSelezionato='';
- vm.selectedIndex = -1;
- vm.selectedDetailIndex = 0;
-
- vm.columnWidths=[
- 70, //0
- 50, //1
- 80, //2
- 220, //3
- 180, //4
- 90, //5
- 100, //6
- 100, //7
- 100, //8
- 80, //9
- 100, //10
- 100, //11
- 100, //12
- 120, //13
- 100, //14
- 90, //15
- 90, //16
- 90, //17.
- 90, //18
- 150, //19
- 150, //20
- 90, //21
- 120, //22
- 120, //23
- 90,
- 320
- ];
- vm.getListHeight = function() {
- containerHeight = $('#details').position().top - $('#container').position().top-8;
- return {'height': containerHeight + 'px'};
- };
-
- vm.getGridItemHeight = function() {
- return utilsSvc.getGridHeight();
- }
-
- vm.getGridWithButtonItemHeight = function() {
- return utilsSvc.getGridWithButtonHeight();
- }
- vm.getDetailListHeight = function() {
-
- detailsContainerHeight = window.innerHeight - document.getElementById('vertical-container-details').getBoundingClientRect().top-50;
- return {'height': detailsContainerHeight + 'px'};
- };
-
- $window.addEventListener('resize', onResize);
- function onResize() {
- $scope.$digest();
- }
-
- $scope.$on('$destroy', function() {
- $window.removeEventListener('resize', onResize);
- });
-
- vm.largeScreen =function(){
- return utilsSvc.largeScreen();
- }
-
- vm.getColumnWidth = 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;
-
- return {'width': res + 'px'}
- }
-
- vm.getStatusColor = function(statusCode) {
- var color;
- if (statusCode==0)
- color = 'red';
- else if (statusCode==1)
- color = 'green';
- else
- color = 'yellow';
- return {'color': color};
- }
-
- vm.decodeTipoDettaglio = function(tipo){
- if (tipo=='CMF')
- return 'Solo mandati rilasciati presso il beneficiario';
- if (tipo=='DMF')
- return 'Solo mandati rilasciati presso PSP (Banca) del pagatore';
- if (tipo=='ALL')
- return 'Tutti i mandati';
- }
-
- vm.decodeTipoRichiesta = function(tipo){
- if (tipo=='ALL')
- return 'Tutti i Mandati attivi nel periodo di riferimento';
- if (tipo=='CHG')
- return 'Mandati attivati nel periodo di riferimento e mandati revocati o disattivati nel periodo di riferimento precedente';
- }
-
- vm.getCodiciSia = function() {
- Remuneration.CodiciSia().$promise.then(function(data){
- vm.codiciSia = data;
- })
- }
-
- vm.setOrderField = function(field) {
- if (vm.filter.orderField!=field)
- vm.filter.orderField = field;
- else
- vm.filter.orderField = "-" +field;
-
- vm.getData();
- }
-
- 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;
-
- this.listPromise = Remuneration.Header({codiceSia: vm.codiceSiaSelezionato, start: vm.records.length,size:Math.max(vm.records.length+index,vm.itemsPerPage)}).$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;
- if (vm.records.length>0 && vm.selectedIndex==-1) {
- vm.selectedIndex=0;
- vm.getProvisioning(0, vm.records[0].idremuneration);
- }
- },
- function(error) {
- vm.infiniteItems.loading_ = false;
- vm.infiniteItems.toLoad_=0;
- utilsSvc.handleHttpError(error);
- }
- )
-
- }
- }
- }
- vm.infiniteDetailItems = {
- numLoaded_: 0,
- toLoad_: 0,
- loading_:false,
- lastStartIdx:-1,
- listPromise:null,
- canceler: $q.defer(),
- // Required.
- getItemAtIndex: function(index) {
- if (vm.maxDetailItems==0 || index>vm.maxDetailItems)
- return null;
- if (!vm.infiniteDetailItems.loading_)
- if (index > vm.detailrecords.length) {
- this.fetchMoreItems_(index);
- return null;
- }
- return vm.detailrecords [index];
- },
- // Required.
- // For infinite scroll behavior, we always return a slightly
- // higher
- // number than the previously loaded items.
- getLength: function() {
- return vm.maxDetailItems;
- },
- fetchMoreItems_: function(index) {
- if (this.toLoad_ < index) {
- this.toLoad_ += vm.itemsPerPage;
- utilsSvc.showWaitMessage('Ricerca in corso...');
- vm.infiniteDetailItems.loading_ = true;
-
- this.listPromise = Remuneration.Provisioning({id: vm.currentDetailId,start: vm.detailrecords.length,size:Math.max(vm.detailrecords.length+index,vm.itemsPerPage)}).$promise;
- var moddetail=this;
- this.listPromise.then(
- function(data){
- vm.infiniteDetailItems.loading_ = false;
- vm.infiniteDetailItems.toLoad_=0;
- utilsSvc.cancelWaitMessage();
- vm.detailrecords = vm.detailrecords.concat(data);
- moddetail.numLoaded_ = vm.detailrecords.length;
- moddetail.lastStartIdx = vm.detailrecords.length;
- },
- function(error) {
- vm.infiniteDetailItems.loading_ = false;
- vm.infiniteDetailItems.toLoad_=0;
- utilsSvc.handleHttpError(error);
- }
- )
-
- }
- }
- }
-
-
- vm.getData = function(){
- Remuneration.HeaderCount({codiceSia: vm.codiceSiaSelezionato}).$promise.then(
- function(data){
- vm.records=[];
- vm.maxItems = data.value;
- vm.infiniteItems.numLoaded_ = 0;
- vm.infiniteItems.toLoad_ = 0;
- }
- );
-
- }
-
-
-
-
- vm.getProvisioning = function(idx, idremuneration) {
- vm.selectedIndex = idx;
- vm.currentDetailId = idremuneration;
- Remuneration.ProvisioningCount({id: idremuneration}).$promise.then(
- function(data){
- vm.detailrecords=[];
- vm.maxDetailItems = data.value;
- vm.infiniteDetailItems.numLoaded_ = 0;
- vm.infiniteDetailItems.toLoad_ = 0;
- }
- );
- }
-
- vm.richiestaDettaglioTuttiTrimestri = function(idx, event) {
- $mdDialog.show({
- targetEvent:event,
- templateUrl: 'templates/richiestaDettaglioMandatiSeda.html',
- controller: 'opzioniDettaglioCtrl',
- locals: {
- dialogTitle:'Richiesta dettaglio mandati SEDA'
- },
- multiple: true
- }).then(function(opzioni){
- Remuneration.GeneraRichiestaDettagli({id:vm.records[idx].idremuneration, all: true, tipoDettaglio:opzioni.tipologiaDettaglio,tipoRichiesta: opzioni.tipologiaRichiesta})
- .$promise.then(function(data){
- if (data.value=="")
- utilsSvc.showMessage("Richiesta dettaglio mandati effettuata");
- else
- utilsSvc.showMessage("Si è verificato un errore durante l'esecuzione del comando: " + data.value);
- })
- });
- }
-
- vm.exportMessaggi = function(idx, event) {
- if (vm.records[idx].flagUtil) {
- utilsSvc.showConfirm('Conferma', 'I messaggi SEDA Remuneration per il rendiconto corrente sono già stati creati, vuoi eseguire una nuova esportazione?')
- .then(function(){
- vm.doExportMessaggi(idx, event);
- })
- } else
- vm.doExportMessaggi(idx,event);
- }
- vm.doExportMessaggi = function(idx, event) {
- utilsSvc.showConfirm('Conferma',"Confermi l'esportazione dei messaggi SEDA Remuneration per il rendiconto corrente?")
- .then(function(res){
- Remuneration.ExportMessaggi({idremuneration:vm.records[idx].idremuneration})
- .$promise.then(function(data){
- vm.records[idx].flagUtil=true;
- var dt = new Date();
- utilsSvc.downloadFile('attachment/csv',data.response,'ExportRemunerationSeda_' + dt.getFullYear()+dt.getMonth().padZero(2)+dt.getDay().padZero(2)+'_'
- +dt.getHours().padZero(2)+ dt.getMinutes().padZero(2)
- +'.csv');
- }
- ).catch(function(err){
- if (err.status == 404)
- utilsSvc.showForever('Messuna delega estratta');
- else
- utilsSvc.handleHttpError(err);
- });
- })
- }
-
-
-
- vm.ricalcolaQuadratura = function(event) {
- if (vm.records.length>0 && vm.detailrecords.length>0) {
- utilsSvc.showConfirm('Conferma',"Confermi il ricalcolo della quadratura mandati attivi per tutti i trimestri presenti?")
- .then(function(res){
- utilsSvc.showForever('Richiesta in corso...');
- Remuneration.QuadraRemuneration({id:vm.records[vm.selectedIndex].idremuneration})
- .$promise.then(function(data){
- if (data.value=="0")
- utilsSvc.showMessage("Ricalcolo quadratura effettuato.");
- else
- utilsSvc.showMessage("Si è verificato un errore durante il ricalcolo: " +data.value);
- vm.getData();
- });
- })
- }
- }
-
- vm.ricalcolaQuadraturaDettaglio = function(event) {
- if (vm.records.length>0 && vm.detailrecords.length>0) {
- utilsSvc.showConfirm('Conferma',"Confermi il ricalcolo della quadratura mandati attivi per il rendiconto corrente?")
- .then(function(res){
- utilsSvc.showForever('Richiesta in corso...');
- Remuneration.QuadraDetail({id:vm.records[vm.selectedIndex].idremuneration, idDettaglio:vm.detailrecords[vm.selectedDetailIndex].idprevisioning})
- .$promise.then(function(data){
- if (data.value=="0")
- utilsSvc.showMessage("Ricalcolo quadratura effettuato.");
- else
- utilsSvc.showMessage("Si è verificato un errore durante il ricalcolo: " +data.value);
- vm.getData();
- });
- })
- }
- }
-
- vm.richiestaDettaglioMandati = function(idx, event) {
- Remuneration.DetailCount({id: vm.detailrecords[idx].idprevisioning})
- .$promise.then(function(data){
- if (data.value==0)
- utilsSvc.showMessage('Non è presente il dettaglio dei mandati ');
- else {
- $mdDialog.show({
- targetEvent:event,
- templateUrl: 'templates/dettaglioMandati.html',
- controller: 'dettaglioMandatiCtrl',
- locals: {
- dialogTitle:'Dettaglio mandati',
- maxItems: data.value,
- id: vm.detailrecords[idx].idprevisioning
- },
- multiple: true
- }).then(function(opzioni){
- });
-
- }
- })
- }
-
- vm.stampaRendiconto = function(idx, event) {
- utilsSvc.showForever('Generazione report in corso...');
- Remuneration.PrintPrevisioning({id: vm.detailrecords[idx].idremuneration})
- .$promise.then(function(data){
- utilsSvc.downloadFile('application/pdf',data.response,'sedaRemuneration.pdf');
- utilsSvc.cancelMessage();
- }).catch(function(err){
- if (err.status==404) {
- utilsSvc.cancelMessage();
- utilsSvc.showMessage('Nessun rendiconto estratto');
- } else
- utilsSvc.handleHttpError(err);
- }); ;
- }
-
-
-
- vm.richiestaDettaglioTrimestre = function(idx, event) {
- $mdDialog.show({
- targetEvent:event,
- templateUrl: 'templates/richiestaDettaglioMandatiSeda.html',
- controller: 'opzioniDettaglioCtrl',
- locals: {
- dialogTitle:'Richiesta dettaglio mandati SEDA'
- },
- multiple: true
- }).then(function(opzioni){
- Remuneration.GeneraRichiestaDettagliTrimestre({id:vm.records[vm.selectedIndex].idremuneration, idDettaglio: vm.detailrecords[idx].idprevisioning, all: true, tipoDettaglio:opzioni.tipologiaDettaglio,tipoRichiesta: opzioni.tipologiaRichiesta})
- .$promise.then(function(data){
- if (data.value=="")
- utilsSvc.showMessage("Richiesta dettaglio mandati effettuata");
- else
- utilsSvc.showMessage("Si è verificato un errore durante l'esecuzione del comando: " + data.value);
- })
- });
- }
-
-
- vm.mostraComandi = function(index, event){
- vm.getProvisioning(index, vm.records[index].idremuneration);
- vm.selectedIndex = index;
- $mdBottomSheet.show({
- templateUrl: 'templates/bottom-sheet-template.html',
- controller: 'comandiRemunerationCtrl',
- idx: index,
- targetEvent: event
- }).then(function(selectedCommand) {
- vm.executeCommand(selectedCommand.cmdIndex, selectedCommand.recordIdx, event);
- },
- function(){}
- );
- }
-
- vm.mostraComandiDettaglio = function(index, event){
- vm.selectedDetailIndex = index;
- $mdBottomSheet.show({
- templateUrl: 'templates/bottom-sheet-template.html',
- controller: 'comandiDettaglioCtrl',
- idx: index,
- targetEvent: event
- }).then(function(selectedCommand) {
- vm.executeDetailCommand(selectedCommand.cmdIndex, selectedCommand.recordIdx, event);
- },
- function(){}
- );
- }
-
- vm.init = function() {
- vm.getCodiciSia();
- vm.getData();
- }
-
-
- vm.executeDetailCommand = function(cmdIndex, idx, event) {
- switch(cmdIndex){
- case 0: vm.richiestaDettaglioTrimestre(idx, event); break;
- case 1: vm.richiestaDettaglioMandati(idx, event); break;
- case 2: vm.stampaRendiconto(idx, event); break;
- case 3: vm.ricalcolaQuadraturaDettaglio(event); break;
-
- }
- }
-
- vm.executeCommand = function(cmdIndex, idx, event) {
- switch(cmdIndex){
- case 0: vm.richiestaDettaglioTuttiTrimestri(idx, event); break;
- case 1: vm.exportMessaggi(idx, event); break;
- case 2: vm.ricalcolaQuadratura(event); break;
- }
- }
-
- vm.init();
- }
- )
- .controller('opzioniDettaglioCtrl',
- function ($scope,$mdDialog,$timeout,utilsSvc, locals) {
-
- $scope.dialogTitle = locals.dialogTitle;
- $scope.opzioni= {
- tipologiaDettaglio: 'ALL',
- tipologiaRichiesta: 'ALL'
- }
-
- $scope.confirmDialog = function() {
- $mdDialog.hide($scope.opzioni);
- }
-
- $scope.cancelDialog = function() {
- $mdDialog.cancel();
- }
-
- })
- .controller('comandiRemunerationCtrl', function($scope, $mdBottomSheet, idx) {
- $scope.title = 'Comandi remuneration';
-
- $scope.items = [
- { id:0, name: "Dettaglio trimestri", icon: 'fa-search', visible: true },
- { id:1, name: "Export messaggi", icon: 'fa-file-excel-o',visible: true },
- { id:2, name: "Ricalc. quadratura", icon: 'fa-cogs', visible: true }
- ];
- $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();
- }
- })
- .controller('comandiDettaglioCtrl', function($scope, $mdBottomSheet, idx) {
- $scope.title = 'Comandi';
-
- $scope.items = [
- { id:0, name: "Dettaglio trimestre", icon: 'fa-arrows-alt', visible: true },
- { id:1, name: "Dettaglio mandati", icon: 'fa-file-o',visible: true },
- { id:2, name: "Stampa rendiconto", icon: 'fa-print', visible: true },
- { id:3, name: "Ricalc. quadratura", icon: 'fa-cogs', visible: true }
- ];
-
- $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();
- }
- })
- .controller('dettaglioMandatiCtrl', function($scope, $window, $mdDialog, $q, utilsSvc, Remuneration, locals) {
- $scope.dialogTitle = locals.dialogTitle;
- $scope.maxItems = locals.maxItems;
- $scope.maxDetailItems = 0;
- $scope.itemsPerPage = 500;
- $scope.id = locals.id;
- $scope.records=[];
- $scope.orderField = "idprevisioning";
- $scope.confirmDialog = function() {
- $mdDialog.hide();
- }
-
- $scope.columnWidths=[
- 90, //0
- 90, //1
- 90, //2
- 120, //3
- 120, //4
- 110, //5this.listPromise
- 90, //6
- 90, //7
- 80
- ];
-
- $scope.setOrderField = function(field) {
- if ($scope.orderField!=field)
- $scope.orderField = field;
- else
- $scope.orderField = "-" +field;
-
- $scope.records=[];
- $scope.infiniteItems.numLoaded_ = 0;
- $scope.infiniteItems.toLoad_ = 0;
- }
- $scope.getListHeight = function() {
- return {'height': '260px'};
- // containerHeight = ($window.innerHeight - $('#container').position().top - $('#view').position().top);
- // return {'height': containerHeight + 'px'};
- };
- $window.addEventListener('resize', onResize);
- function onResize() {
- $scope.$digest();
- }
- $scope.$on('$destroy', function() {
- $window.removeEventListener('resize', onResize);
- });
- $scope.getColumnWidth = // }
- function(idx) {
- return {
- 'width': $scope.columnWidths[idx] + 'px',
- 'min-width':$scope.columnWidths[idx] + 'px',
- 'margin-left':'8px',
- 'margin-right':'8px'
- };
- }
-
- $scope.getMaxListWidth = function() {
- var res=0;
- for (var i=0;i<$scope.columnWidths.length;i++)
- res += $scope.columnWidths[i]+6+8+10;
-
- $('#container').css('width',($('#header').width()+10)+'px');
- return {'width': res+ 'px!important;'}
- }
- $scope.print = function() {
- utilsSvc.showForever('Generazione in corso...');
- Remuneration.PrintDetails({id:$scope.id}).$promise.then(function(data){
- utilsSvc.downloadFile('application/pdf',data.response,'RemunerazioneSedaDettagli.pdf');
- utilsSvc.cancelMessage();
- },function(err){
- utilsSvc.cancelMessage();
- if(err.status==404)
- utilsSvc.showMessage('Nessun rendiconto estratto');
- else
- utilsSvc.handleHttpError(err);
- })
- }
-
- $scope.infiniteItems = {
- numLoaded_: 0,
- toLoad_: 0,
- loading_:false,
- lastStartIdx:-1,
- listPromise:null,
- canceler: $q.defer(),
- // Required.
- getItemAtIndex: function(index) {
- if ($scope.maxItems==0 || index>$scope.maxItems)
- return null;
- 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;
- utilsSvc.showWaitMessage('Ricerca in corso...');
-
- this.listPromise = Remuneration.Detail({id:$scope.id, start: $scope.records.length,size:Math.max($scope.records.length+index,$scope.itemsPerPage),orderBy:$scope.orderField}).$promise;
- var mod=this;
- this.listPromise.then(
- function(data){
- utilsSvc.cancelWaitMessage();
- $scope.records = $scope.records.concat(data);
- mod.numLoaded_ = $scope.records.length;
- mod.lastStartIdx = $scope.records.length;
- },
- function(error) {
- utilsSvc.handleHttpError(error);
- }
- )
-
- }
- }
- }
-
- })
- ;
|