| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- app.controller('estrattoreCtrl',
-
- function ($scope,$http,$cookies,$window, $location,$timeout, $mdDialog, $q, utilsSvc, PianiEstrazioneDistinte, FunzioniOrdinanti) {
-
- var vm=this;
- vm.records = [];
-
- vm.decodeStatus = function(status){
- switch (status) {
- case 1: return 'Tutte le disposizioni estratte';
- case 2: return 'Alcune disposizioni non estratte per errori di convalida';
- case 3: return 'Alcune disposizioni non estratte';
- case 4: return 'Estrazione non effettuata';
- }
- }
-
- vm.init = function() {
- PianiEstrazioneDistinte.List().$promise.then(function (data){
- vm.records = data;
- },
- function(error){
- utilsSvc.handleHttpError(error);
- })
-
- }
-
- vm.delegatiFirma = function(ev) {
- $mdDialog.show({
- targetEvent:ev,
- templateUrl: 'templates/delegatiFirma.html',
- controller: 'delegatiFirmaCtrl',
- multiple: true
- }).then(function(){
- });
- }
-
- vm.nuovoPiano = function($event) {
- PianiEstrazioneDistinte.New().$promise.then(function(res){
- vm.records.push(res);
- vm.modificaPiano(vm.records.length-1, $event);
- })
- }
-
- vm.modificaPiano = function(idx, ev) {
- if (typeof vm.records=="undefined" || typeof vm.records[idx]=="undefined")
- return
- var piano = angular.copy(vm.records[idx]);
- $mdDialog.show({
- templateUrl: 'templates/dettaglioEstrattore.html',
- controller: 'dettaglioEstrattoreCtrl',
- targetEvent: ev,
- locals: {piano:piano}
- })
- .then(function(args){
- vm.init();
- },
- function(){
-
- }
- );
-
- }
-
- vm.eliminaPiano = function(idx, ev) {
- utilsSvc.showConfirm("Confermi l'eliminazione dell'elemento?",'Conferma')
- .then(function(res){
- PianiEstrazioneDistinte.Delete({id: vm.records[idx].id})
- .$promise.then(function(res){
- if (res.value==0)
- utilsSvc.showMessage('Eliminazione effettuata');
- else
- utilsSvc.show("Si è verificato un errore durante l'eliminazione del piano: " +res.value);
- vm.init();
- },
- function(err){
- utilsSvc.handleHttpError(err);
- vm.init();
- }
- )
- })
-
- }
-
- vm.init();
-
- });
|