Commit 1bc980de8202733261384d5fcfc58ebc4ba9e149
1 parent
c8ad496f18
Exists in
master
boton con imagen
Showing
1 changed file
with
4 additions
and
1 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaAbmChofer') | 1 | angular.module('focaAbmChofer') |
2 | .controller('focaAbmChoferesController', [ | 2 | .controller('focaAbmChoferesController', [ |
3 | '$scope', 'focaAbmChoferService', '$location', '$uibModal', | 3 | '$scope', 'focaAbmChoferService', '$location', '$uibModal', |
4 | 'focaModalService', 'focaBotoneraLateralService', '$timeout', | 4 | 'focaModalService', 'focaBotoneraLateralService', '$timeout', |
5 | function($scope, focaAbmChoferService, $location, $uibModal, focaModalService, | 5 | function($scope, focaAbmChoferService, $location, $uibModal, focaModalService, |
6 | focaBotoneraLateralService, $timeout) { | 6 | focaBotoneraLateralService, $timeout) { |
7 | 7 | ||
8 | $scope.now = new Date(); | 8 | $scope.now = new Date(); |
9 | $scope.filters = ''; | 9 | $scope.filters = ''; |
10 | $scope.choferes = []; | 10 | $scope.choferes = []; |
11 | $scope.botonera = ['Transportista']; | 11 | $scope.botonera = [{ |
12 | label: 'Transportista', | ||
13 | image: 'cliente.png' | ||
14 | }]; | ||
12 | $scope.focused = 1; | 15 | $scope.focused = 1; |
13 | 16 | ||
14 | //SETEO BOTONERA LATERAL | 17 | //SETEO BOTONERA LATERAL |
15 | $timeout(function() { | 18 | $timeout(function() { |
16 | focaBotoneraLateralService.showSalir(true); | 19 | focaBotoneraLateralService.showSalir(true); |
17 | focaBotoneraLateralService.showPausar(false); | 20 | focaBotoneraLateralService.showPausar(false); |
18 | focaBotoneraLateralService.showCancelar(false); | 21 | focaBotoneraLateralService.showCancelar(false); |
19 | focaBotoneraLateralService.showGuardar(false); | 22 | focaBotoneraLateralService.showGuardar(false); |
20 | }); | 23 | }); |
21 | 24 | ||
22 | if(focaAbmChoferService.transportistaSeleccionado.COD) { | 25 | if(focaAbmChoferService.transportistaSeleccionado.COD) { |
23 | elegirTransportista(focaAbmChoferService.transportistaSeleccionado); | 26 | elegirTransportista(focaAbmChoferService.transportistaSeleccionado); |
24 | } | 27 | } |
25 | 28 | ||
26 | $scope.editar = function(id) { | 29 | $scope.editar = function(id) { |
27 | $location.path('/chofer/' + id + '/' + $scope.idTransportista); | 30 | $location.path('/chofer/' + id + '/' + $scope.idTransportista); |
28 | }; | 31 | }; |
29 | 32 | ||
30 | $scope.solicitarConfirmacion = function(chofer) { | 33 | $scope.solicitarConfirmacion = function(chofer) { |
31 | focaModalService.confirm('¿Está seguro que desea borrar el chofer ' + | 34 | focaModalService.confirm('¿Está seguro que desea borrar el chofer ' + |
32 | chofer.nombre + ' ?').then(function(confirmed) { | 35 | chofer.nombre + ' ?').then(function(confirmed) { |
33 | if(confirmed) { | 36 | if(confirmed) { |
34 | focaAbmChoferService.deleteChofer(chofer.id); | 37 | focaAbmChoferService.deleteChofer(chofer.id); |
35 | $scope.choferes.splice($scope.choferes.indexOf(chofer), 1); | 38 | $scope.choferes.splice($scope.choferes.indexOf(chofer), 1); |
36 | } | 39 | } |
37 | }); | 40 | }); |
38 | }; | 41 | }; |
39 | 42 | ||
40 | $scope.seleccionarTransportista = function() { | 43 | $scope.seleccionarTransportista = function() { |
41 | var modalInstance = $uibModal.open( | 44 | var modalInstance = $uibModal.open( |
42 | { | 45 | { |
43 | ariaLabelledBy: 'Busqueda de Transportista', | 46 | ariaLabelledBy: 'Busqueda de Transportista', |
44 | templateUrl: 'modal-proveedor.html', | 47 | templateUrl: 'modal-proveedor.html', |
45 | controller: 'focaModalProveedorCtrl', | 48 | controller: 'focaModalProveedorCtrl', |
46 | size: 'lg', | 49 | size: 'lg', |
47 | resolve: { | 50 | resolve: { |
48 | transportista: function() { | 51 | transportista: function() { |
49 | return true; | 52 | return true; |
50 | } | 53 | } |
51 | } | 54 | } |
52 | } | 55 | } |
53 | ); | 56 | ); |
54 | modalInstance.result.then( | 57 | modalInstance.result.then( |
55 | function(transportista) { | 58 | function(transportista) { |
56 | elegirTransportista(transportista); | 59 | elegirTransportista(transportista); |
57 | focaAbmChoferService.transportistaSeleccionado = transportista; | 60 | focaAbmChoferService.transportistaSeleccionado = transportista; |
58 | }, function() {} | 61 | }, function() {} |
59 | ); | 62 | ); |
60 | }; | 63 | }; |
61 | 64 | ||
62 | function elegirTransportista(transportista) { | 65 | function elegirTransportista(transportista) { |
63 | buscar(transportista.COD); | 66 | buscar(transportista.COD); |
64 | var codigo = ('00000' + transportista.COD).slice(-5); | 67 | var codigo = ('00000' + transportista.COD).slice(-5); |
65 | $scope.idTransportista = transportista.COD; | 68 | $scope.idTransportista = transportista.COD; |
66 | $timeout(function() { | 69 | $timeout(function() { |
67 | $scope.$broadcast('addCabecera', { | 70 | $scope.$broadcast('addCabecera', { |
68 | label: 'Transportista:', | 71 | label: 'Transportista:', |
69 | valor: codigo + ' - ' + transportista.NOM | 72 | valor: codigo + ' - ' + transportista.NOM |
70 | }); | 73 | }); |
71 | }); | 74 | }); |
72 | } | 75 | } |
73 | 76 | ||
74 | function buscar(id) { | 77 | function buscar(id) { |
75 | focaAbmChoferService.getChoferPorTransportista(id).then(function(res) { | 78 | focaAbmChoferService.getChoferPorTransportista(id).then(function(res) { |
76 | $scope.choferes = res.data; | 79 | $scope.choferes = res.data; |
77 | }); | 80 | }); |
78 | } | 81 | } |
79 | } | 82 | } |
80 | ]) | 83 | ]) |
81 | .controller('focaAbmChoferController', [ | 84 | .controller('focaAbmChoferController', [ |
82 | '$scope', 'focaAbmChoferService', '$routeParams', | 85 | '$scope', 'focaAbmChoferService', '$routeParams', |
83 | '$location', 'focaBotoneraLateralService', '$timeout', | 86 | '$location', 'focaBotoneraLateralService', '$timeout', |
84 | function($scope, focaAbmChoferService, $routeParams, | 87 | function($scope, focaAbmChoferService, $routeParams, |
85 | $location, focaBotoneraLateralService, $timeout) { | 88 | $location, focaBotoneraLateralService, $timeout) { |
86 | $scope.nuevo = $routeParams.id === '0'; | 89 | $scope.nuevo = $routeParams.id === '0'; |
87 | $scope.chofer = {}; | 90 | $scope.chofer = {}; |
88 | $scope.transportistas = []; | 91 | $scope.transportistas = []; |
89 | $scope.now = new Date(); | 92 | $scope.now = new Date(); |
90 | $scope.next = function(key) { | 93 | $scope.next = function(key) { |
91 | if (key === 13) $scope.focused++; | 94 | if (key === 13) $scope.focused++; |
92 | }; | 95 | }; |
93 | 96 | ||
94 | //SETEO BOTONERA LATERAL | 97 | //SETEO BOTONERA LATERAL |
95 | $timeout(function() { | 98 | $timeout(function() { |
96 | focaBotoneraLateralService.showSalir(false); | 99 | focaBotoneraLateralService.showSalir(false); |
97 | focaBotoneraLateralService.showPausar(true); | 100 | focaBotoneraLateralService.showPausar(true); |
98 | focaBotoneraLateralService.showCancelar(true); | 101 | focaBotoneraLateralService.showCancelar(true); |
99 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); | 102 | focaBotoneraLateralService.showGuardar(true, $scope.guardar); |
100 | }); | 103 | }); |
101 | 104 | ||
102 | if($scope.nuevo) { | 105 | if($scope.nuevo) { |
103 | focaAbmChoferService | 106 | focaAbmChoferService |
104 | .getTransportistaPorId($routeParams.idTransportista) | 107 | .getTransportistaPorId($routeParams.idTransportista) |
105 | .then(function(res) { | 108 | .then(function(res) { |
106 | var codigo = ('00000' + res.data.COD).slice(-5); | 109 | var codigo = ('00000' + res.data.COD).slice(-5); |
107 | $scope.chofer.idTransportista = res.data.COD; | 110 | $scope.chofer.idTransportista = res.data.COD; |
108 | $scope.chofer.transportista = res.data; | 111 | $scope.chofer.transportista = res.data; |
109 | $scope.$broadcast('addCabecera', { | 112 | $scope.$broadcast('addCabecera', { |
110 | label: 'Transportista:', | 113 | label: 'Transportista:', |
111 | valor: codigo + ' - ' + res.data.NOM | 114 | valor: codigo + ' - ' + res.data.NOM |
112 | }); | 115 | }); |
113 | }); | 116 | }); |
114 | } | 117 | } |
115 | 118 | ||
116 | focaAbmChoferService.getChofer($routeParams.id).then(function(res) { | 119 | focaAbmChoferService.getChofer($routeParams.id).then(function(res) { |
117 | if(res.data) { | 120 | if(res.data) { |
118 | var codigo = ('00000' + res.data.transportista.COD).slice(-5); | 121 | var codigo = ('00000' + res.data.transportista.COD).slice(-5); |
119 | $scope.chofer = res.data; | 122 | $scope.chofer = res.data; |
120 | $scope.$broadcast('addCabecera', { | 123 | $scope.$broadcast('addCabecera', { |
121 | label: 'Transportista:', | 124 | label: 'Transportista:', |
122 | valor: codigo + ' - ' + res.data.transportista.NOM | 125 | valor: codigo + ' - ' + res.data.transportista.NOM |
123 | }); | 126 | }); |
124 | } | 127 | } |
125 | }); | 128 | }); |
126 | 129 | ||
127 | focaAbmChoferService.getTransportistas().then(function(res) { | 130 | focaAbmChoferService.getTransportistas().then(function(res) { |
128 | $scope.transportistas = res.data; | 131 | $scope.transportistas = res.data; |
129 | }); | 132 | }); |
130 | 133 | ||
131 | $scope.cancelar = function() { | 134 | $scope.cancelar = function() { |
132 | $location.path('/chofer'); | 135 | $location.path('/chofer'); |
133 | }; | 136 | }; |
134 | 137 | ||
135 | $scope.guardar = function() { | 138 | $scope.guardar = function() { |
136 | $scope.chofer.idTransportista = $routeParams.idTransportista; | 139 | $scope.chofer.idTransportista = $routeParams.idTransportista; |
137 | delete $scope.chofer.transportista; | 140 | delete $scope.chofer.transportista; |
138 | focaAbmChoferService.guardarChofer($scope.chofer).then(function() { | 141 | focaAbmChoferService.guardarChofer($scope.chofer).then(function() { |
139 | $location.path('/chofer'); | 142 | $location.path('/chofer'); |
140 | }); | 143 | }); |
141 | }; | 144 | }; |
142 | } | 145 | } |
143 | ]); | 146 | ]); |
144 | 147 |