Commit ee52a0425069369d6963828c611343ad55f4184c
Exists in
master
Merge branch 'develop' of http://git.focasoftware.com/npm/foca-crear-hoja-ruta
Showing
1 changed file
Show diff stats
src/js/controller.js
1 | angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', | 1 | angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
2 | [ | 2 | [ |
3 | '$scope', | 3 | '$scope', |
4 | '$uibModal', | 4 | '$uibModal', |
5 | '$location', | 5 | '$location', |
6 | '$filter', | 6 | '$filter', |
7 | '$timeout', | 7 | '$timeout', |
8 | 'focaCrearHojaRutaService', | 8 | 'focaCrearHojaRutaService', |
9 | 'focaModalService', | 9 | 'focaModalService', |
10 | 'focaBotoneraLateralService', | 10 | 'focaBotoneraLateralService', |
11 | 'focaLoginService', | 11 | 'focaLoginService', |
12 | '$localStorage', | 12 | '$localStorage', |
13 | function($scope, $uibModal, $location, $filter, $timeout, | 13 | function($scope, $uibModal, $location, $filter, $timeout, |
14 | focaCrearHojaRutaService, focaModalService, focaBotoneraLateralService, | 14 | focaCrearHojaRutaService, focaModalService, focaBotoneraLateralService, |
15 | focaLoginSrv, $localStorage) | 15 | focaLoginSrv, $localStorage) |
16 | { | 16 | { |
17 | config(); | 17 | config(); |
18 | 18 | ||
19 | function config() { | 19 | function config() { |
20 | $scope.botonera = focaCrearHojaRutaService.getBotonera(); | 20 | $scope.botonera = focaCrearHojaRutaService.getBotonera(); |
21 | $scope.datepickerAbierto = false; | 21 | $scope.datepickerAbierto = false; |
22 | $scope.show = false; | 22 | $scope.show = false; |
23 | $scope.cargando = true; | 23 | $scope.cargando = true; |
24 | $scope.now = new Date(); | 24 | $scope.now = new Date(); |
25 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); | 25 | $scope.puntoVenta = $filter('rellenarDigitos')(0, 4); |
26 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); | 26 | $scope.comprobante = $filter('rellenarDigitos')(0, 8); |
27 | 27 | ||
28 | //SETEO BOTONERA LATERAL | 28 | //SETEO BOTONERA LATERAL |
29 | $timeout(function() { | 29 | $timeout(function() { |
30 | focaBotoneraLateralService.showSalir(false); | 30 | focaBotoneraLateralService.showSalir(false); |
31 | focaBotoneraLateralService.showPausar(true); | 31 | focaBotoneraLateralService.showPausar(true); |
32 | focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta); | 32 | focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta); |
33 | focaBotoneraLateralService.addCustomButton('Salir', salir); | 33 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
34 | }); | 34 | }); |
35 | 35 | ||
36 | focaCrearHojaRutaService.getParametros().then(function(res) { | 36 | focaCrearHojaRutaService.getParametros().then(function(res) { |
37 | 37 | ||
38 | var parametros = JSON.parse(res.data[0].jsonText); | 38 | var parametros = JSON.parse(res.data[0].jsonText); |
39 | 39 | ||
40 | if ($localStorage.hojaRuta) { | 40 | if ($localStorage.hojaRuta) { |
41 | $timeout(function() {getLSHojaRuta();}); | 41 | $timeout(function() {getLSHojaRuta();}); |
42 | } else { | 42 | } else { |
43 | 43 | ||
44 | for(var property in parametros) { | 44 | for(var property in parametros) { |
45 | $scope.hojaRuta[property] = parametros[property]; | 45 | $scope.hojaRuta[property] = parametros[property]; |
46 | } | 46 | } |
47 | 47 | ||
48 | setearHojaRuta($scope.hojaRuta); | 48 | setearHojaRuta($scope.hojaRuta); |
49 | } | 49 | } |
50 | }); | 50 | }); |
51 | init(); | 51 | init(); |
52 | } | 52 | } |
53 | 53 | ||
54 | function init() { | 54 | function init() { |
55 | $scope.$broadcast('cleanCabecera'); | 55 | $scope.$broadcast('cleanCabecera'); |
56 | 56 | ||
57 | $scope.hojaRuta = { | 57 | $scope.hojaRuta = { |
58 | fecha: new Date(), | 58 | fecha: new Date(), |
59 | litros: 0, | 59 | litros: 0, |
60 | chofer: {}, | 60 | chofer: {}, |
61 | vehiculo: { | 61 | vehiculo: { |
62 | capacidad: 0 | 62 | capacidad: 0 |
63 | }, | 63 | }, |
64 | transportista: {}, | 64 | transportista: {}, |
65 | remitosTabla: [] | 65 | remitosTabla: [] |
66 | }; | 66 | }; |
67 | $scope.idLista = undefined; | 67 | $scope.idLista = undefined; |
68 | 68 | ||
69 | focaCrearHojaRutaService.getNumeroHojaRuta().then( | 69 | focaCrearHojaRutaService.getNumeroHojaRuta().then( |
70 | function(res) { | 70 | function(res) { |
71 | $scope.puntoVenta = $filter('rellenarDigitos')(res.data.sucursal, 4); | 71 | $scope.puntoVenta = $filter('rellenarDigitos')(res.data.sucursal, 4); |
72 | $scope.comprobante = $filter('rellenarDigitos')(res.data.numeroHojaRuta, 8); | 72 | $scope.comprobante = $filter('rellenarDigitos')(res.data.numeroHojaRuta, 8); |
73 | }, | 73 | }, |
74 | function(err) { | 74 | function(err) { |
75 | focaModalService.alert('La terminal no esta configurada correctamente'); | 75 | focaModalService.alert('La terminal no esta configurada correctamente'); |
76 | console.info(err); | 76 | console.info(err); |
77 | } | 77 | } |
78 | ); | 78 | ); |
79 | setearFecha(new Date()); | 79 | setearFecha(new Date()); |
80 | $scope.inicial = angular.copy($scope.hojaRuta); | 80 | $scope.inicial = angular.copy($scope.hojaRuta); |
81 | } | 81 | } |
82 | 82 | ||
83 | $scope.$watch('hojaRuta', function(newValue) { | 83 | $scope.$watch('hojaRuta', function(newValue) { |
84 | 84 | ||
85 | // Seteo checked en remitos | 85 | // Seteo checked en remitos |
86 | if ($scope.hojaRuta.remitosTabla.length) { | 86 | if ($scope.hojaRuta.remitosTabla.length) { |
87 | 87 | ||
88 | $filter('filter')($scope.botonera, { | 88 | $filter('filter')($scope.botonera, { |
89 | label: 'Remitos', | 89 | label: 'Remitos', |
90 | })[0].checked = true; | 90 | })[0].checked = true; |
91 | } else { | 91 | } else { |
92 | $filter('filter')($scope.botonera, { | 92 | $filter('filter')($scope.botonera, { |
93 | label: 'Remitos', | 93 | label: 'Remitos', |
94 | })[0].checked = false; | 94 | })[0].checked = false; |
95 | } | 95 | } |
96 | 96 | ||
97 | focaBotoneraLateralService.setPausarData({ | 97 | focaBotoneraLateralService.setPausarData({ |
98 | label: 'hojaRuta', | 98 | label: 'hojaRuta', |
99 | val: newValue | 99 | val: newValue |
100 | }); | 100 | }); |
101 | }, true); | 101 | }, true); |
102 | 102 | ||
103 | $scope.crearHojaRuta = function() { | 103 | $scope.crearHojaRuta = function() { |
104 | if (!$scope.hojaRuta.remitosTabla.length) { | 104 | if (!$scope.hojaRuta.remitosTabla.length) { |
105 | focaModalService.alert('Ingrese Remitos'); | 105 | focaModalService.alert('Ingrese Remitos'); |
106 | return; | 106 | return; |
107 | } | 107 | } |
108 | if (!$scope.hojaRuta.chofer.id) { | 108 | if (!$scope.hojaRuta.chofer.id) { |
109 | focaModalService.alert('Ingrese Chofer'); | 109 | focaModalService.alert('Ingrese Chofer'); |
110 | return; | 110 | return; |
111 | } | 111 | } |
112 | if (!$scope.hojaRuta.vehiculo.id) { | 112 | if (!$scope.hojaRuta.vehiculo.id) { |
113 | focaModalService.alert('Ingrese Vehiculo'); | 113 | focaModalService.alert('Ingrese Vehiculo'); |
114 | return; | 114 | return; |
115 | } | 115 | } |
116 | if (!$scope.hojaRuta.transportista.COD) { | 116 | if (!$scope.hojaRuta.transportista.COD) { |
117 | focaModalService.alert('Ingrese Transportista'); | 117 | focaModalService.alert('Ingrese Transportista'); |
118 | return; | 118 | return; |
119 | } | 119 | } |
120 | if (!$scope.hojaRuta.tarifario) { | 120 | if (!$scope.hojaRuta.tarifario) { |
121 | focaModalService.alert('Ingrese Tarifario'); | 121 | focaModalService.alert('Ingrese Tarifario'); |
122 | return; | 122 | return; |
123 | } | 123 | } |
124 | if (!$scope.hojaRuta.datosExtra) { | 124 | if (!$scope.hojaRuta.datosExtra) { |
125 | focaModalService.alert('Ingrese Datos extra'); | 125 | focaModalService.alert('Ingrese Datos extra'); |
126 | return; | 126 | return; |
127 | } | 127 | } |
128 | var date = new Date(); | 128 | var date = new Date(); |
129 | var save = { | 129 | var save = { |
130 | hojaRuta: { | 130 | hojaRuta: { |
131 | id: 0, | 131 | id: 0, |
132 | fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) | 132 | fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) |
133 | .replace('T', ' '), | 133 | .replace('T', ' '), |
134 | idTransportista: $scope.hojaRuta.transportista.COD, | 134 | idTransportista: $scope.hojaRuta.transportista.COD, |
135 | idChofer: $scope.hojaRuta.chofer.id, | 135 | idChofer: $scope.hojaRuta.chofer.id, |
136 | idVehiculo: $scope.hojaRuta.vehiculo.id, | 136 | idVehiculo: $scope.hojaRuta.vehiculo.id, |
137 | tarifaFlete: $scope.hojaRuta.tarifario, | 137 | tarifaFlete: $scope.hojaRuta.tarifario, |
138 | fechaReparto: | 138 | fechaReparto: |
139 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), | 139 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), |
140 | estado: 0 | 140 | estado: 0 |
141 | }, | 141 | }, |
142 | remitos: $scope.hojaRuta.remitosTabla | 142 | remitos: $scope.hojaRuta.remitosTabla |
143 | }; | 143 | }; |
144 | save.hojaRuta = angular.extend({}, save.hojaRuta, $scope.hojaRuta.datosExtra); | 144 | save.hojaRuta = angular.extend({}, save.hojaRuta, $scope.hojaRuta.datosExtra); |
145 | focaCrearHojaRutaService.crearHojaRuta(save).then( | 145 | focaCrearHojaRutaService.crearHojaRuta(save).then( |
146 | function(data) { | 146 | function(data) { |
147 | focaModalService.alert( | 147 | focaModalService.alert( |
148 | 'Hoja ruta creada Nº: ' + | 148 | 'Hoja ruta creada Nº: ' + |
149 | $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + | 149 | $filter('rellenarDigitos')(data.data.sucursal, 4) + '-' + |
150 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) | 150 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) |
151 | ); | 151 | ); |
152 | 152 | ||
153 | config(); | 153 | config(); |
154 | }, | 154 | }, |
155 | function(error) { | 155 | function(error) { |
156 | focaModalService.alert('Hubo un error al crear la hoja de ruta'); | 156 | focaModalService.alert('Hubo un error al crear la hoja de ruta'); |
157 | console.info(error); | 157 | console.info(error); |
158 | } | 158 | } |
159 | ); | 159 | ); |
160 | }; | 160 | }; |
161 | 161 | ||
162 | $scope.seleccionarTransportista = function() { | 162 | $scope.seleccionarTransportista = function() { |
163 | if (eligioPreConfirmado()) return; | 163 | if (eligioPreConfirmado()) return; |
164 | var parametrosModal = { | 164 | var parametrosModal = { |
165 | titulo: 'Búsqueda de transportista', | 165 | titulo: 'Búsqueda de transportista', |
166 | query: '/transportista', | 166 | query: '/transportista', |
167 | columnas: [ | 167 | columnas: [ |
168 | { | 168 | { |
169 | nombre: 'Código', | 169 | nombre: 'Código', |
170 | propiedad: 'COD' | 170 | propiedad: 'COD' |
171 | }, | 171 | }, |
172 | { | 172 | { |
173 | nombre: 'Nombre', | 173 | nombre: 'Nombre', |
174 | propiedad: 'NOM' | 174 | propiedad: 'NOM' |
175 | }, | 175 | }, |
176 | { | 176 | { |
177 | nombre: 'CUIT', | 177 | nombre: 'CUIT', |
178 | propiedad: 'CUIT' | 178 | propiedad: 'CUIT' |
179 | } | 179 | } |
180 | ] | 180 | ] |
181 | }; | 181 | }; |
182 | focaModalService.modal(parametrosModal).then( | 182 | focaModalService.modal(parametrosModal).then( |
183 | function(proveedor) { | 183 | function(proveedor) { |
184 | $scope.hojaRuta.transportista = proveedor; | 184 | $scope.hojaRuta.transportista = proveedor; |
185 | $scope.$broadcast('addCabecera', { | 185 | $scope.$broadcast('addCabecera', { |
186 | label: 'Transportista:', | 186 | label: 'Transportista:', |
187 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + | 187 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
188 | proveedor.NOM | 188 | proveedor.NOM |
189 | }); | 189 | }); |
190 | 190 | ||
191 | $filter('filter')($scope.botonera, { | 191 | $filter('filter')($scope.botonera, { |
192 | label: 'Transportista', | 192 | label: 'Transportista', |
193 | })[0].checked = true; | 193 | })[0].checked = true; |
194 | }, function() { | 194 | }, function() { |
195 | 195 | ||
196 | } | 196 | } |
197 | ); | 197 | ); |
198 | }; | 198 | }; |
199 | 199 | ||
200 | $scope.seleccionarChofer = function() { | 200 | $scope.seleccionarChofer = function() { |
201 | var parametrosModal = { | 201 | var parametrosModal = { |
202 | titulo: 'Búsqueda de Chofer', | 202 | titulo: 'Búsqueda de Chofer', |
203 | query: '/chofer', | 203 | query: '/chofer', |
204 | columnas: [ | 204 | columnas: [ |
205 | { | 205 | { |
206 | propiedad: 'id', | 206 | propiedad: 'id', |
207 | nombre: 'Código', | 207 | nombre: 'Código', |
208 | filtro: { | 208 | filtro: { |
209 | nombre: 'rellenarDigitos', | 209 | nombre: 'rellenarDigitos', |
210 | parametro: 3 | 210 | parametro: 3 |
211 | } | 211 | } |
212 | }, | 212 | }, |
213 | { | 213 | { |
214 | propiedad: 'nombre', | 214 | propiedad: 'nombre', |
215 | nombre: 'Nombre' | 215 | nombre: 'Nombre' |
216 | }, | 216 | }, |
217 | { | 217 | { |
218 | propiedad: 'dni', | 218 | propiedad: 'dni', |
219 | nombre: 'DNI' | 219 | nombre: 'DNI' |
220 | }, | 220 | }, |
221 | { | 221 | { |
222 | propiedad: 'telefono', | 222 | propiedad: 'telefono', |
223 | nombre: 'Teléfono' | 223 | nombre: 'Teléfono' |
224 | } | 224 | } |
225 | ] | 225 | ] |
226 | }; | 226 | }; |
227 | focaModalService.modal(parametrosModal).then( | 227 | focaModalService.modal(parametrosModal).then( |
228 | function(chofer) { | 228 | function(chofer) { |
229 | $scope.hojaRuta.chofer = chofer; | 229 | $scope.hojaRuta.chofer = chofer; |
230 | $scope.$broadcast('addCabecera', { | 230 | $scope.$broadcast('addCabecera', { |
231 | label: 'Chofer:', | 231 | label: 'Chofer:', |
232 | valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' +chofer.nombre | 232 | valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' +chofer.nombre |
233 | }); | 233 | }); |
234 | 234 | ||
235 | $filter('filter')($scope.botonera, { | 235 | $filter('filter')($scope.botonera, { |
236 | label: 'Chofer', | 236 | label: 'Chofer', |
237 | })[0].checked = true; | 237 | })[0].checked = true; |
238 | }, function() { | 238 | }, function() { |
239 | // funcion ejecutada cuando se cancela el modal | 239 | // funcion ejecutada cuando se cancela el modal |
240 | } | 240 | } |
241 | ); | 241 | ); |
242 | }; | 242 | }; |
243 | 243 | ||
244 | $scope.seleccionarVehiculo = function() { | 244 | $scope.seleccionarVehiculo = function() { |
245 | if (!eligioFecha() || eligioPreConfirmado()) return; | 245 | if (!eligioFecha() || eligioPreConfirmado()) return; |
246 | modalVehiculos(); | 246 | modalVehiculos(); |
247 | }; | 247 | }; |
248 | 248 | ||
249 | $scope.seleccionarTarifario = function() { | 249 | $scope.seleccionarTarifario = function() { |
250 | focaModalService | 250 | focaModalService |
251 | .prompt({ | 251 | .prompt({ |
252 | titulo: 'Tarifa flete', | 252 | titulo: 'Tarifa flete', |
253 | value: $scope.hojaRuta.tarifario | 253 | value: $scope.hojaRuta.tarifario |
254 | }) | 254 | }) |
255 | .then(function(costo) { | 255 | .then(function(costo) { |
256 | if (isNaN(costo)) { | 256 | if (isNaN(costo)) { |
257 | focaModalService | 257 | focaModalService |
258 | .alert('Ingrese un valor válido') | 258 | .alert('Ingrese un valor válido') |
259 | .then(function() { | 259 | .then(function() { |
260 | $scope.seleccionarTarifario(); | 260 | $scope.seleccionarTarifario(); |
261 | }); | 261 | }); |
262 | 262 | ||
263 | return; | 263 | return; |
264 | } | 264 | } |
265 | 265 | ||
266 | $scope.hojaRuta.tarifario = costo; | 266 | $scope.hojaRuta.tarifario = costo; |
267 | $scope.$broadcast('addCabecera', { | 267 | $scope.$broadcast('addCabecera', { |
268 | label: 'Tarifario:', | 268 | label: 'Tarifario:', |
269 | valor: costo | 269 | valor: costo |
270 | }); | 270 | }); |
271 | 271 | ||
272 | $filter('filter')($scope.botonera, { | 272 | $filter('filter')($scope.botonera, { |
273 | label: 'Tarifario', | 273 | label: 'Tarifario', |
274 | })[0].checked = true; | 274 | })[0].checked = true; |
275 | }); | 275 | }); |
276 | }; | 276 | }; |
277 | 277 | ||
278 | $scope.seleccionarRemitos = function() { | 278 | $scope.seleccionarRemitos = function() { |
279 | if (eligioPreConfirmado() || !eligioFecha() || !eligioVehiculo()) return; | 279 | if (eligioPreConfirmado() || !eligioFecha() || !eligioVehiculo()) return; |
280 | var modalInstance = $uibModal.open( | 280 | var modalInstance = $uibModal.open( |
281 | { | 281 | { |
282 | ariaLabelledBy: 'Busqueda de Remito', | 282 | ariaLabelledBy: 'Busqueda de Remito', |
283 | templateUrl: 'foca-modal-remito.html', | 283 | templateUrl: 'foca-modal-remito.html', |
284 | controller: 'focaModalRemitoController', | 284 | controller: 'focaModalRemitoController', |
285 | size: 'lg', | 285 | size: 'lg', |
286 | resolve: {usadoPor: function() {return 'hojaRuta';}} | 286 | resolve: {usadoPor: function() {return 'hojaRuta';}} |
287 | } | 287 | } |
288 | ); | 288 | ); |
289 | modalInstance.result.then( | 289 | modalInstance.result.then( |
290 | function(remito) { | 290 | function(remito) { |
291 | // TODO: borrar cuando no se use definitivamente | 291 | // TODO: borrar cuando no se use definitivamente |
292 | // for (var i = $scope.hojaRuta.remitosTabla.length - 1; i >= 0; i--) { | 292 | // for (var i = $scope.hojaRuta.remitosTabla.length - 1; i >= 0; i--) { |
293 | // if ($scope.hojaRuta.remitosTabla[i].id === remito.id) { | 293 | // if ($scope.hojaRuta.remitosTabla[i].id === remito.id) { |
294 | // focaModalService.alert('Remito ya incluido'); | 294 | // focaModalService.alert('Remito ya incluido'); |
295 | // return; | 295 | // return; |
296 | // } | 296 | // } |
297 | // } | 297 | // } |
298 | 298 | ||
299 | // var litros = 0; | 299 | // var litros = 0; |
300 | // for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { | 300 | // for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { |
301 | // litros = litros + parseFloat(remito.articulosRemito[j].cantidad); | 301 | // litros = litros + parseFloat(remito.articulosRemito[j].cantidad); |
302 | // } | 302 | // } |
303 | 303 | ||
304 | // if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { | 304 | // if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { |
305 | // focaModalService.alert( | 305 | // focaModalService.alert( |
306 | // 'Debe ingresar toda la información para el transporte' | 306 | // 'Debe ingresar toda la información para el transporte' |
307 | // ); | 307 | // ); |
308 | // return; | 308 | // return; |
309 | // } | 309 | // } |
310 | 310 | ||
311 | //if($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) | 311 | //if($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) |
312 | // { | 312 | // { |
313 | // var litrostotales = litros; | 313 | // var litrostotales = litros; |
314 | // litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; | 314 | // litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; |
315 | // focaModalService.alert( | 315 | // focaModalService.alert( |
316 | // 'La carga excede la capacidad disponible del vehiculo. ' + | 316 | // 'La carga excede la capacidad disponible del vehiculo. ' + |
317 | // 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' | 317 | // 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' |
318 | // ); | 318 | // ); |
319 | // } | 319 | // } |
320 | 320 | ||
321 | // remito.litros = litros; | 321 | // remito.litros = litros; |
322 | // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; | 322 | // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; |
323 | $scope.cargarCisterna(remito.id).then(function() { | 323 | $scope.cargarCisterna(remito.id).then(function() { |
324 | $scope.hojaRuta.remitosTabla.push(remito); | 324 | $scope.hojaRuta.remitosTabla.push(remito); |
325 | }, function(error) { | 325 | }, function(error) { |
326 | 326 | ||
327 | if (error && error !== 'backdrop click') { | 327 | if (error && error !== 'backdrop click') { |
328 | 328 | ||
329 | focaModalService | 329 | focaModalService |
330 | .alert(error || 'Ha ocurrido un error') | 330 | .alert(error || 'Ha ocurrido un error') |
331 | .then(function() { | 331 | .then(function() { |
332 | $scope.seleccionarRemitos(); | 332 | $scope.seleccionarRemitos(); |
333 | }); | 333 | }); |
334 | 334 | ||
335 | } else { | 335 | } else { |
336 | |||
337 | $scope.seleccionarRemitos(); | ||
338 | |||
339 | } | ||
340 | }); | ||
341 | }, function() { | ||
342 | // funcion ejecutada cuando se cancela el modal | ||
343 | } | ||
344 | ); | ||
345 | }; | ||
346 | |||
347 | $scope.seleccionarVehiculosPrecargados = function() { | ||
348 | if (!eligioFecha()) return; | ||
349 | modalVehiculos(true); | ||
350 | }; | ||
351 | |||
352 | $scope.cargarCisterna = function(idRemito) { | ||
353 | if (!eligioFecha() || !$scope.hojaRuta.vehiculo.id) return; | ||
354 | var modalInstance = $uibModal.open( | ||
355 | { | ||
356 | ariaLabelledBy: 'Busqueda de Vehiculo', | ||
357 | templateUrl: 'foca-detalle-vehiculo.html', | ||
358 | controller: 'focaDetalleVehiculo', | ||
359 | size: 'lg', | ||
360 | resolve: { | ||
361 | idVehiculo: function() {return $scope.hojaRuta.vehiculo.id;}, | ||
336 | 362 | idRemito: function() {return idRemito;}, | |
337 | $scope.seleccionarRemitos(); | ||
338 | 363 | fechaReparto: function() {return $scope.hojaRuta.fechaReparto;} | |
339 | } | 364 | } |
340 | }); | ||
341 | }, function() { | ||
342 | // funcion ejecutada cuando se cancela el modal | ||
343 | } | ||
344 | ); | ||
345 | }; | ||
346 | |||
347 | $scope.seleccionarVehiculosPrecargados = function() { | 365 | } |
348 | if (!eligioFecha()) return; | 366 | ); |
349 | modalVehiculos(true); | 367 | return modalInstance.result; |
350 | }; | 368 | }; |
351 | 369 | ||
352 | $scope.cargarCisterna = function(idRemito) { | 370 | $scope.seleccionarFechaEntrega = function() { |
353 | if (!eligioFecha() || !$scope.hojaRuta.vehiculo.id) return; | 371 | var confirmacion = false; |
354 | var modalInstance = $uibModal.open( | 372 | var hasVehiculoId = $scope.hojaRuta.vehiculo.id !== undefined; |
355 | { | 373 | var hasTarifario = $scope.hojaRuta.tarifario.costo !== null; |
356 | ariaLabelledBy: 'Busqueda de Vehiculo', | 374 | var hasTransportista = Object.keys($scope.hojaRuta.transportista).length > 0; |
357 | templateUrl: 'foca-detalle-vehiculo.html', | 375 | var hasChofer = Object.keys($scope.hojaRuta.chofer).length > 0; |
358 | controller: 'focaDetalleVehiculo', | 376 | var hasDatosExtra = $scope.hojaRuta.datosExtra !== undefined; |
359 | size: 'lg', | 377 | |
360 | resolve: { | 378 | if (hasVehiculoId || hasTarifario || hasTransportista || |
361 | idVehiculo: function() {return $scope.hojaRuta.vehiculo.id;}, | 379 | hasChofer || hasDatosExtra) { |
362 | idRemito: function() {return idRemito;}, | 380 | confirmacion = true; |
363 | fechaReparto: function() {return $scope.hojaRuta.fechaReparto;} | 381 | if (confirmacion) { |
364 | } | 382 | focaModalService |
365 | } | 383 | .confirm('Si cambia la fecha se perderán los datos actuales') |
366 | ); | 384 | .then(function(data) { |
367 | return modalInstance.result; | 385 | if(data) { |
368 | }; | 386 | $scope.hojaRuta.vehiculo.id = undefined; |
369 | 387 | $scope.hojaRuta.tarifario.costo = null; | |
370 | $scope.seleccionarFechaEntrega = function() { | 388 | $scope.hojaRuta.transportista = {}; |
371 | if (!$scope.hojaRuta.fechaReparto) { | 389 | $scope.hojaRuta.chofer = {}; |
372 | elegirFecha(); | 390 | $scope.hojaRuta.datosExtra = undefined; |
373 | return; | 391 | elegirFecha(); |
374 | } | 392 | } |
375 | focaModalService | 393 | }, function() { |
376 | .confirm('Si cambia la fecha se perderán los datos actuales') | 394 | return ; |
377 | .then(function() { | 395 | }); |
378 | elegirFecha(); | 396 | } |
379 | }, function() { | 397 | } else { |
380 | return ; | 398 | elegirFecha(); |
381 | }); | 399 | } |
382 | }; | 400 | } |
383 | 401 | ||
384 | function setearFecha(fecha) { | 402 | function setearFecha(fecha) { |
385 | $timeout(function() { | 403 | $timeout(function() { |
386 | $scope.$broadcast('addCabecera', { | 404 | $scope.$broadcast('addCabecera', { |
387 | label: 'Fecha de entrega: ', | 405 | label: 'Fecha de entrega: ', |
388 | valor: fecha.toLocaleDateString() | 406 | valor: fecha.toLocaleDateString() |
389 | }); | 407 | }); |
390 | $scope.hojaRuta.fechaReparto = fecha; | 408 | $scope.hojaRuta.fechaReparto = fecha; |
391 | }); | 409 | }); |
392 | } | 410 | } |
393 | 411 | ||
394 | $scope.seleccionarDatosExtra = function() { | 412 | $scope.seleccionarDatosExtra = function() { |
395 | var datosHojaRuta = $scope.hojaRuta.datosExtra; | 413 | var datosHojaRuta = $scope.hojaRuta.datosExtra; |
396 | var modalInstance = $uibModal.open( | 414 | var modalInstance = $uibModal.open( |
397 | { | 415 | { |
398 | templateUrl: 'foca-modal-datos-hoja-ruta.html', | 416 | templateUrl: 'foca-modal-datos-hoja-ruta.html', |
399 | controller: 'focaModalDatosHojaRutaCtrl', | 417 | controller: 'focaModalDatosHojaRutaCtrl', |
400 | size: 'lg', | 418 | size: 'lg', |
401 | resolve: { | 419 | resolve: { |
402 | parametrosDatos: function() { | 420 | parametrosDatos: function() { |
403 | return { | 421 | return { |
404 | datosHojaRuta: datosHojaRuta | 422 | datosHojaRuta: datosHojaRuta |
405 | }; | 423 | }; |
406 | } | 424 | } |
407 | } | 425 | } |
408 | } | 426 | } |
409 | ); | 427 | ); |
410 | return modalInstance.result.then(function(datosExtra) { | 428 | return modalInstance.result.then(function(datosExtra) { |
411 | 429 | ||
412 | $filter('filter')($scope.botonera, { | 430 | $filter('filter')($scope.botonera, { |
413 | label: 'Datos extra', | 431 | label: 'Datos extra', |
414 | })[0].checked = true; | 432 | })[0].checked = true; |
415 | 433 | ||
416 | $scope.hojaRuta.datosExtra = datosExtra; | 434 | $scope.hojaRuta.datosExtra = datosExtra; |
417 | }, function() { | 435 | }, function() { |
418 | //se ejecuta cuando se cancela el modal | 436 | //se ejecuta cuando se cancela el modal |
419 | }); | 437 | }); |
420 | }; | 438 | }; |
421 | 439 | ||
422 | $scope.desasociarRemito = function(key, idRemito) { | 440 | $scope.desasociarRemito = function(key, idRemito) { |
423 | var idsRemito = [idRemito]; | 441 | var idsRemito = [idRemito]; |
424 | focaModalService.confirm('¿Está seguro que desea desasociar este remito del' + | 442 | focaModalService.confirm('¿Está seguro que desea desasociar este remito del' + |
425 | ' vehículo?').then(function() { | 443 | ' vehículo?').then(function() { |
426 | focaCrearHojaRutaService.desasociarRemitos(idsRemito, | 444 | focaCrearHojaRutaService.desasociarRemitos(idsRemito, |
427 | $scope.hojaRuta.vehiculo.id, $scope.hojaRuta.remitosTabla.length <= 1) | 445 | $scope.hojaRuta.vehiculo.id, $scope.hojaRuta.remitosTabla.length <= 1) |
428 | .then(function() { | 446 | .then(function() { |
429 | $scope.hojaRuta.remitosTabla.splice(key, 1); | 447 | $scope.hojaRuta.remitosTabla.splice(key, 1); |
430 | focaModalService.alert('Remito desasociado con éxito'); | 448 | focaModalService.alert('Remito desasociado con éxito'); |
431 | }); | 449 | }); |
432 | }); | 450 | }); |
433 | }; | 451 | }; |
434 | 452 | ||
435 | $scope.verProductosRemito = function(idRemito) { | 453 | $scope.verProductosRemito = function(idRemito) { |
436 | var parametrosModal = { | 454 | var parametrosModal = { |
437 | titulo: 'Articulos remito', | 455 | titulo: 'Articulos remito', |
438 | query: '/articulos/remito/' + idRemito, | 456 | query: '/articulos/remito/' + idRemito, |
439 | soloMostrar: true, | 457 | soloMostrar: true, |
440 | columnas: [ | 458 | columnas: [ |
441 | { | 459 | { |
442 | nombre: 'Código', | 460 | nombre: 'Código', |
443 | propiedad: 'codigo' | 461 | propiedad: 'codigo' |
444 | }, | 462 | }, |
445 | { | 463 | { |
446 | nombre: 'Descripción', | 464 | nombre: 'Descripción', |
447 | propiedad: 'descripcion' | 465 | propiedad: 'descripcion' |
448 | }, | 466 | }, |
449 | { | 467 | { |
450 | nombre: 'Cantidad', | 468 | nombre: 'Cantidad', |
451 | propiedad: 'cantidad' | 469 | propiedad: 'cantidad' |
452 | } | 470 | } |
453 | ] | 471 | ] |
454 | }; | 472 | }; |
455 | focaModalService.modal(parametrosModal).then(); | 473 | focaModalService.modal(parametrosModal).then(); |
456 | }; | 474 | }; |
457 | 475 | ||
458 | function elegirFecha() { | 476 | function elegirFecha() { |
459 | var fechaEntrega = { | 477 | var fechaEntrega = { |
460 | titulo: 'Fecha de entrega', | 478 | titulo: 'Fecha de entrega', |
461 | minDate: new Date() | 479 | minDate: new Date() |
462 | }; | 480 | }; |
463 | focaModalService.modalFecha(fechaEntrega).then(function(fecha) { | 481 | focaModalService.modalFecha(fechaEntrega).then(function(fecha) { |
464 | 482 | ||
465 | $scope.$broadcast('addCabecera', { | 483 | $scope.$broadcast('addCabecera', { |
466 | label: 'Fecha de entrega: ', | 484 | label: 'Fecha de entrega: ', |
467 | valor: fecha.toLocaleDateString() | 485 | valor: fecha.toLocaleDateString() |
468 | }); | 486 | }); |
469 | 487 | ||
470 | $filter('filter')($scope.botonera, { | 488 | $filter('filter')($scope.botonera, { |
471 | label: 'Fecha Entrega', | 489 | label: 'Fecha Entrega', |
472 | })[0].checked = true; | 490 | })[0].checked = true; |
473 | 491 | ||
474 | $scope.hojaRuta.fechaReparto = fecha; | 492 | $scope.hojaRuta.fechaReparto = fecha; |
475 | }); | 493 | }); |
476 | } | 494 | } |
477 | 495 | ||
478 | function eligioPreConfirmado() { | 496 | function eligioPreConfirmado() { |
479 | if ($scope.eligioPreConfirmado) { | 497 | if ($scope.eligioPreConfirmado) { |
480 | focaModalService.alert('No puede elegir si eligió un vehiculo pre cargado'); | 498 | focaModalService.alert('No puede elegir si eligió un vehiculo pre cargado'); |
481 | return true; | 499 | return true; |
482 | } | 500 | } |
483 | return false; | 501 | return false; |
484 | } | 502 | } |
485 | 503 | ||
486 | function eligioFecha() { | 504 | function eligioFecha() { |
487 | if (!$scope.hojaRuta.fechaReparto) { | 505 | if (!$scope.hojaRuta.fechaReparto) { |
488 | focaModalService.alert('Primero seleccione fecha de reparto'); | 506 | focaModalService.alert('Primero seleccione fecha de reparto'); |
489 | return false; | 507 | return false; |
490 | } | 508 | } |
491 | return true; | 509 | return true; |
492 | } | 510 | } |
493 | 511 | ||
494 | function eligioVehiculo() { | 512 | function eligioVehiculo() { |
495 | if (!$scope.hojaRuta.vehiculo.id) { | 513 | if (!$scope.hojaRuta.vehiculo.id) { |
496 | focaModalService.alert('Primero seleccione vehiculo'); | 514 | focaModalService.alert('Primero seleccione vehiculo'); |
497 | return false; | 515 | return false; |
498 | } | 516 | } |
499 | return true; | 517 | return true; |
500 | } | 518 | } |
501 | 519 | ||
502 | function modalVehiculos(preCargados) { | 520 | function modalVehiculos(preCargados) { |
503 | var parametrosModal = {}; | 521 | var parametrosModal = {}; |
504 | if (preCargados) { | 522 | if (preCargados) { |
505 | parametrosModal.query = '/vehiculo/obtener/pre-confirmados/' + | 523 | parametrosModal.query = '/vehiculo/obtener/pre-confirmados/' + |
506 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10); | 524 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10); |
507 | parametrosModal.titulo = 'Búsqueda de vehiculos pre confirmados'; | 525 | parametrosModal.titulo = 'Búsqueda de vehiculos pre confirmados'; |
508 | } else { | 526 | } else { |
509 | parametrosModal.query = '/vehiculo'; | 527 | parametrosModal.query = '/vehiculo'; |
510 | parametrosModal.titulo = 'Búsqueda de vehículos'; | 528 | parametrosModal.titulo = 'Búsqueda de vehículos'; |
511 | } | 529 | } |
512 | parametrosModal.columnas = [ | 530 | parametrosModal.columnas = [ |
513 | { | 531 | { |
514 | propiedad: 'codigo', | 532 | propiedad: 'codigo', |
515 | nombre: 'Código' | 533 | nombre: 'Código' |
516 | }, | 534 | }, |
517 | { | 535 | { |
518 | propiedad: 'tractor', | 536 | propiedad: 'tractor', |
519 | nombre: 'tractor' | 537 | nombre: 'tractor' |
520 | }, | 538 | }, |
521 | { | 539 | { |
522 | propiedad: 'semi', | 540 | propiedad: 'semi', |
523 | nombre: 'Semi' | 541 | nombre: 'Semi' |
524 | } | 542 | } |
525 | ]; | 543 | ]; |
526 | focaModalService.modal(parametrosModal).then(function(vehiculo) { | 544 | focaModalService.modal(parametrosModal).then(function(vehiculo) { |
527 | if (!preCargados && vehiculoEnUso(vehiculo)) return; | 545 | if (!preCargados && vehiculoEnUso(vehiculo)) return; |
528 | $scope.hojaRuta.vehiculo = vehiculo; | 546 | $scope.hojaRuta.vehiculo = vehiculo; |
529 | $scope.hojaRuta.transportista = vehiculo.transportista; | 547 | $scope.hojaRuta.transportista = vehiculo.transportista; |
530 | if (preCargados) { | 548 | if (preCargados) { |
531 | $scope.eligioPreConfirmado = true; | 549 | $scope.eligioPreConfirmado = true; |
532 | $scope.hojaRuta.vehiculo = vehiculo; | 550 | $scope.hojaRuta.vehiculo = vehiculo; |
533 | $scope.$broadcast('addCabecera', { | 551 | $scope.$broadcast('addCabecera', { |
534 | label: 'Transportista:', | 552 | label: 'Transportista:', |
535 | valor: $filter('rellenarDigitos')(vehiculo.transportista.COD, 5) + | 553 | valor: $filter('rellenarDigitos')(vehiculo.transportista.COD, 5) + |
536 | ' - ' + vehiculo.transportista.NOM | 554 | ' - ' + vehiculo.transportista.NOM |
537 | }); | 555 | }); |
538 | focaCrearHojaRutaService | 556 | focaCrearHojaRutaService |
539 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto) | 557 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto) |
540 | .then(function(res) { | 558 | .then(function(res) { |
541 | 559 | ||
542 | $filter('filter')($scope.botonera, { | 560 | $filter('filter')($scope.botonera, { |
543 | label: 'Vehiculos precargados', | 561 | label: 'Vehiculos precargados', |
544 | })[0].checked = true; | 562 | })[0].checked = true; |
545 | 563 | ||
546 | $scope.hojaRuta.remitosTabla = res.data; | 564 | $scope.hojaRuta.remitosTabla = res.data; |
547 | }); | 565 | }); |
548 | } else { | 566 | } else { |
549 | focaCrearHojaRutaService | 567 | focaCrearHojaRutaService |
550 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto, true) | 568 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto, true) |
551 | .then(function(res) { | 569 | .then(function(res) { |
552 | 570 | ||
553 | $filter('filter')($scope.botonera, { | 571 | $filter('filter')($scope.botonera, { |
554 | label: 'Vehiculo', | 572 | label: 'Vehiculo', |
555 | })[0].checked = true; | 573 | })[0].checked = true; |
556 | 574 | ||
557 | $scope.hojaRuta.remitosTabla = res.data; | 575 | $scope.hojaRuta.remitosTabla = res.data; |
558 | }); | 576 | }); |
559 | } | 577 | } |
560 | $scope.$broadcast('addCabecera', { | 578 | $scope.$broadcast('addCabecera', { |
561 | label: 'Tractor:', | 579 | label: 'Tractor:', |
562 | valor: vehiculo.tractor | 580 | valor: vehiculo.tractor |
563 | }); | 581 | }); |
564 | $scope.$broadcast('addCabecera', { | 582 | $scope.$broadcast('addCabecera', { |
565 | label: 'Semi:', | 583 | label: 'Semi:', |
566 | valor: vehiculo.semi | 584 | valor: vehiculo.semi |
567 | }); | 585 | }); |
568 | $scope.$broadcast('addCabecera', { | 586 | $scope.$broadcast('addCabecera', { |
569 | label: 'Capacidad:', | 587 | label: 'Capacidad:', |
570 | valor: vehiculo.capacidad | 588 | valor: vehiculo.capacidad |
571 | }); | 589 | }); |
572 | 590 | ||
573 | }); | 591 | }); |
574 | } | 592 | } |
575 | 593 | ||
576 | function vehiculoEnUso(vehiculo) { | 594 | function vehiculoEnUso(vehiculo) { |
577 | var idUsuario = focaLoginSrv.getLoginData().vendedorCobrador; | 595 | var idUsuario = focaLoginSrv.getLoginData().vendedorCobrador; |
578 | for (var i = 0; i < vehiculo.cisternas.length; i++) { | 596 | for (var i = 0; i < vehiculo.cisternas.length; i++) { |
579 | for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | 597 | for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { |
580 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; | 598 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; |
581 | if (cisternaCarga.fechaReparto.substring(0, 10) === | 599 | if (cisternaCarga.fechaReparto.substring(0, 10) === |
582 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10) && | 600 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10) && |
583 | cisternaCarga.idUsuarioProceso && | 601 | cisternaCarga.idUsuarioProceso && |
584 | cisternaCarga.idUsuarioProceso !== idUsuario) | 602 | cisternaCarga.idUsuarioProceso !== idUsuario) |
585 | { | 603 | { |
586 | focaModalService.alert('El vehículo está siendo usado por otro' + | 604 | focaModalService.alert('El vehículo está siendo usado por otro' + |
587 | ' usuario'); | 605 | ' usuario'); |
588 | return true; | 606 | return true; |
589 | } | 607 | } |
590 | } | 608 | } |
591 | } | 609 | } |
592 | return false; | 610 | return false; |
593 | } | 611 | } |
594 | 612 | ||
595 | function salir() { | 613 | function salir() { |
596 | var confirmacion = false; | 614 | var confirmacion = false; |
597 | 615 | ||
598 | if (!angular.equals($scope.hojaRuta, $scope.inicial)) { | 616 | if (!angular.equals($scope.hojaRuta, $scope.inicial)) { |
599 | confirmacion = true; | 617 | confirmacion = true; |
600 | } | 618 | } |
601 | 619 | ||
602 | if (confirmacion) { | 620 | if (confirmacion) { |
603 | focaModalService.confirm( | 621 | focaModalService.confirm( |
604 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' | 622 | '¿Está seguro de que desea salir? Se perderán todos los datos cargados.' |
605 | ).then(function(data) { | 623 | ).then(function(data) { |
606 | if (data) { | 624 | if (data) { |
607 | $location.path('/'); | 625 | $location.path('/'); |
608 | } | 626 | } |
609 | }); | 627 | }); |
610 | } else { | 628 | } else { |
611 | $location.path('/'); | 629 | $location.path('/'); |
612 | } | 630 | } |
613 | } | 631 | } |
614 | 632 | ||
615 | function setearHojaRuta(hojaRuta) { | 633 | function setearHojaRuta(hojaRuta) { |
616 | $scope.$broadcast('cleanCabecera'); | 634 | $scope.$broadcast('cleanCabecera'); |
617 | 635 | ||
618 | var cabeceras = []; | 636 | var cabeceras = []; |
619 | if (hojaRuta.fechaReparto) { | 637 | if (hojaRuta.fechaReparto) { |
620 | cabeceras.push({ | 638 | cabeceras.push({ |
621 | label: 'Fecha de entrega:', | 639 | label: 'Fecha de entrega:', |
622 | valor: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy') | 640 | valor: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy') |
623 | }); | 641 | }); |
624 | 642 | ||
625 | $filter('filter')( $scope.botonera, { | 643 | $filter('filter')( $scope.botonera, { |
626 | label: 'Fecha Entrega' | 644 | label: 'Fecha Entrega' |
627 | })[0].checked = true; | 645 | })[0].checked = true; |
628 | } | 646 | } |
629 | if (hojaRuta.transportista.COD) { | 647 | if (hojaRuta.transportista.COD) { |
630 | cabeceras.push({ | 648 | cabeceras.push({ |
631 | label: 'Transportista:', | 649 | label: 'Transportista:', |
632 | valor: $filter('rellenarDigitos')(hojaRuta.transportista.COD, 5) + ' - ' + | 650 | valor: $filter('rellenarDigitos')(hojaRuta.transportista.COD, 5) + ' - ' + |
633 | hojaRuta.transportista.NOM | 651 | hojaRuta.transportista.NOM |
634 | }); | 652 | }); |
635 | 653 | ||
636 | $filter('filter')( $scope.botonera, { | 654 | $filter('filter')( $scope.botonera, { |
637 | label: 'Transportista' | 655 | label: 'Transportista' |
638 | })[0].checked = true; | 656 | })[0].checked = true; |
639 | } | 657 | } |
640 | if (hojaRuta.chofer.id) { | 658 | if (hojaRuta.chofer.id) { |
641 | cabeceras.push({ | 659 | cabeceras.push({ |
642 | label: 'Chofer:', | 660 | label: 'Chofer:', |
643 | valor: $filter('rellenarDigitos')(hojaRuta.chofer.id, 3) + | 661 | valor: $filter('rellenarDigitos')(hojaRuta.chofer.id, 3) + |
644 | ' - ' + hojaRuta.chofer.nombre | 662 | ' - ' + hojaRuta.chofer.nombre |
645 | }); | 663 | }); |
646 | 664 | ||
647 | $filter('filter')( $scope.botonera, { | 665 | $filter('filter')( $scope.botonera, { |
648 | label: 'Chofer' | 666 | label: 'Chofer' |
649 | })[0].checked = true; | 667 | })[0].checked = true; |
650 | } | 668 | } |
651 | if (hojaRuta.vehiculo.id) { | 669 | if (hojaRuta.vehiculo.id) { |
652 | cabeceras.push({ | 670 | cabeceras.push({ |
653 | label: 'Tractor:', | 671 | label: 'Tractor:', |
654 | valor: hojaRuta.vehiculo.tractor | 672 | valor: hojaRuta.vehiculo.tractor |
655 | }); | 673 | }); |
656 | cabeceras.push({ | 674 | cabeceras.push({ |
657 | label: 'Semi:', | 675 | label: 'Semi:', |
658 | valor: hojaRuta.vehiculo.semi | 676 | valor: hojaRuta.vehiculo.semi |
659 | }); | 677 | }); |
660 | cabeceras.push({ | 678 | cabeceras.push({ |
661 | label: 'Capacidad:', | 679 | label: 'Capacidad:', |
662 | valor: hojaRuta.vehiculo.capacidad | 680 | valor: hojaRuta.vehiculo.capacidad |
663 | }); | 681 | }); |
664 | 682 | ||
665 | $filter('filter')( $scope.botonera, { | 683 | $filter('filter')( $scope.botonera, { |
666 | label: 'Vehiculo' | 684 | label: 'Vehiculo' |
667 | })[0].checked = true; | 685 | })[0].checked = true; |
668 | } | 686 | } |
669 | if (hojaRuta.tarifario) { | 687 | if (hojaRuta.tarifario) { |
670 | cabeceras.push({ | 688 | cabeceras.push({ |
671 | label: 'Tarifario:', | 689 | label: 'Tarifario:', |
672 | valor: hojaRuta.tarifario | 690 | valor: hojaRuta.tarifario |
673 | }); | 691 | }); |
674 | 692 | ||
675 | $filter('filter')( $scope.botonera, { | 693 | $filter('filter')( $scope.botonera, { |
676 | label: 'Tarifario' | 694 | label: 'Tarifario' |
677 | })[0].checked = true; | 695 | })[0].checked = true; |
678 | } | 696 | } |
679 | 697 | ||
680 | addArrayCabecera(cabeceras); | 698 | addArrayCabecera(cabeceras); |
681 | $scope.hojaRuta = hojaRuta; | 699 | $scope.hojaRuta = hojaRuta; |
682 | } | 700 | } |
683 | 701 | ||
684 | function getLSHojaRuta() { | 702 | function getLSHojaRuta() { |
685 | var hojaRuta = JSON.parse($localStorage.hojaRuta || null); | 703 | var hojaRuta = JSON.parse($localStorage.hojaRuta || null); |
686 | if (hojaRuta) { | 704 | if (hojaRuta) { |
687 | setearHojaRuta(hojaRuta); | 705 | setearHojaRuta(hojaRuta); |
688 | delete $localStorage.hojaRuta; | 706 | delete $localStorage.hojaRuta; |
689 | } | 707 | } |
690 | } | 708 | } |
691 | function addArrayCabecera(array) { | 709 | function addArrayCabecera(array) { |
692 | for(var i = 0; i < array.length; i++) { | 710 | for(var i = 0; i < array.length; i++) { |
693 | $scope.$broadcast('addCabecera', { | 711 | $scope.$broadcast('addCabecera', { |