Commit c1834cab6d94c249fb618717dc531a3e5ef19c94
1 parent
df5fab47a8
Exists in
master
guardado hoja de ruta, muchos refactors
Showing
3 changed files
with
195 additions
and
259 deletions
Show diff stats
src/js/controller.js
... | ... | @@ -5,35 +5,33 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
5 | 5 | '$location', |
6 | 6 | '$filter', |
7 | 7 | '$timeout', |
8 | - 'crearHojaRutaService', | |
8 | + 'focaCrearHojaRutaService', | |
9 | 9 | 'focaModalService', |
10 | 10 | 'focaBotoneraLateralService', |
11 | 11 | function($scope, $uibModal, $location, $filter, $timeout, |
12 | - crearHojaRutaService, focaModalService, focaBotoneraLateralService) { | |
12 | + focaCrearHojaRutaService, focaModalService, focaBotoneraLateralService) { | |
13 | 13 | |
14 | - $scope.botonera = crearHojaRutaService.getBotonera(); | |
14 | + $scope.botonera = focaCrearHojaRutaService.getBotonera(); | |
15 | 15 | $scope.datepickerAbierto = false; |
16 | 16 | |
17 | 17 | $scope.show = false; |
18 | 18 | $scope.cargando = true; |
19 | - $scope.dateOptions = { | |
20 | - maxDate: new Date(), | |
21 | - minDate: new Date(2010, 0, 1) | |
22 | - }; | |
23 | - | |
24 | - $scope.hojaRuta = { | |
25 | - fecha: new Date(), | |
26 | - litros: 0, | |
27 | - chofer: {}, | |
28 | - vehiculo: { | |
29 | - capacidad: 0 | |
30 | - }, | |
31 | - transportista: {}, | |
32 | - tarifario: { | |
33 | - costo: null | |
34 | - } | |
35 | - }; | |
36 | 19 | |
20 | + function nuevaHojaRuta() { | |
21 | + $scope.hojaRuta = { | |
22 | + fecha: new Date(), | |
23 | + litros: 0, | |
24 | + chofer: {}, | |
25 | + vehiculo: { | |
26 | + capacidad: 0 | |
27 | + }, | |
28 | + transportista: {}, | |
29 | + tarifario: { | |
30 | + costo: null | |
31 | + } | |
32 | + }; | |
33 | + } | |
34 | + nuevaHojaRuta(); | |
37 | 35 | $scope.showCabecera = true; |
38 | 36 | |
39 | 37 | $scope.now = new Date(); |
... | ... | @@ -41,8 +39,6 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
41 | 39 | $scope.comprobante = '00000000'; |
42 | 40 | $scope.remitosTabla = []; |
43 | 41 | $scope.idLista = undefined; |
44 | - //La pantalla solo se usa para cargar pedidos | |
45 | - //var hojaRutaTemp = crearHojaRutaService.getHojaRuta(); | |
46 | 42 | |
47 | 43 | //SETEO BOTONERA LATERAL |
48 | 44 | $timeout(function() { |
... | ... | @@ -51,7 +47,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
51 | 47 | focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta); |
52 | 48 | }); |
53 | 49 | |
54 | - crearHojaRutaService.getNumeroHojaRuta().then( | |
50 | + focaCrearHojaRutaService.getNumeroHojaRuta().then( | |
55 | 51 | function(res) { |
56 | 52 | $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4); |
57 | 53 | $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8); |
... | ... | @@ -61,95 +57,44 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
61 | 57 | console.info(err); |
62 | 58 | } |
63 | 59 | ); |
64 | - //La pantalla solo se usa para cargar pedidos | |
65 | - // if (hojaRutaTemp !== undefined) { | |
66 | - // hojaRutaTemp.fechaCarga = new Date(hojaRutaTemp.fechaCarga); | |
67 | - // $scope.hojaRuta = hojaRutaTemp; | |
68 | - // $scope.hojaRuta.flete = ($scope.hojaRuta.flete).toString(); | |
69 | - // $scope.hojaRuta.bomba = ($scope.hojaRuta.bomba).toString(); | |
70 | - // $scope.idLista = $scope.hojaRuta.precioCondicion; | |
71 | - // crearHojaRutaService | |
72 | - // .getArticulosByIdHojaRuta($scope.hojaRuta.id).then( | |
73 | - // function(res) { | |
74 | - // $scope.remitosTabla = res.data; | |
75 | - // } | |
76 | - // ); | |
77 | - //TODO DOMICILIOS QUE SE CARGAN AL EDITAR NOTA DE PEDIDO | |
78 | - //(NO REQUERIDO EN ESTA VERSION) | |
79 | - // crearHojaRutaService.getDomiciliosByIdHojaRuta($scope.hojaRuta.id).then( | |
80 | - // function(res) { | |
81 | - // $scope.hojaRuta.domicilio = res.data; | |
82 | - // } | |
83 | - // ); | |
84 | - // } else { | |
85 | - // $scope.hojaRuta.fechaCarga = new Date(); | |
86 | - // $scope.hojaRuta.bomba = '0'; | |
87 | - // $scope.hojaRuta.flete = '0'; | |
88 | - // $scope.idLista = undefined; | |
89 | - // } | |
90 | - //TO DO - FUNCIONES PARA MULTIPLES DOMICILIOS NO IMPLEMENTADAS EN ESTA DEMO | |
91 | - // $scope.addNewDom = function() { | |
92 | - // $scope.hojaRuta.domicilio.push({ 'id': 0 }); | |
93 | - // }; | |
94 | - // $scope.removeNewChoice = function(choice) { | |
95 | - // if ($scope.hojaRuta.domicilio.length > 1) { | |
96 | - // $scope.hojaRuta.domicilio.splice($scope.hojaRuta.domicilio.findIndex( | |
97 | - // function(c) { | |
98 | - // return c.$$hashKey === choice.$$hashKey; | |
99 | - // } | |
100 | - // ), 1); | |
101 | - // } | |
102 | - // }; | |
103 | - | |
104 | 60 | $scope.crearHojaRuta = function() { |
105 | - if($scope.hojaRuta.litros <= 0) { | |
61 | + if(!$scope.remitosTabla.length) { | |
106 | 62 | focaModalService.alert('Ingrese Remitos'); |
107 | 63 | return; |
108 | - } | |
109 | - | |
64 | + } | |
110 | 65 | if(!$scope.hojaRuta.chofer.id) { |
111 | 66 | focaModalService.alert('Ingrese Chofer'); |
112 | 67 | return; |
113 | 68 | } |
114 | - | |
115 | 69 | if(!$scope.hojaRuta.vehiculo.id) { |
116 | 70 | focaModalService.alert('Ingrese Vehiculo'); |
117 | 71 | return; |
118 | - } | |
119 | - | |
120 | - if(!$scope.hojaRuta.transportista.codigo) { | |
72 | + } | |
73 | + if(!$scope.hojaRuta.transportista.COD) { | |
121 | 74 | focaModalService.alert('Ingrese Transportista'); |
122 | 75 | return; |
123 | - } | |
124 | - | |
125 | - if($scope.hojaRuta.vehiculo.capacidad < $scope.hojaRuta.litros) { | |
126 | - focaModalService.alert( | |
127 | - 'La capacidad del Vehiculo es menor a lo ingresado en Remitos' | |
128 | - ); | |
129 | - return; | |
130 | - } | |
131 | - | |
76 | + } | |
132 | 77 | if(!$scope.hojaRuta.tarifario.costo) { |
133 | 78 | focaModalService.alert('Ingrese Tarifario'); |
134 | 79 | return; |
135 | 80 | } |
136 | - | |
137 | 81 | var date = new Date(); |
138 | 82 | var save = { |
139 | 83 | hojaRuta: { |
140 | 84 | id: 0, |
141 | - fechaCreacion: | |
142 | - new Date(date.getTime() - (date.getTimezoneOffset() * 60000)) | |
143 | - .toISOString().slice(0, 19) .replace('T', ' '), | |
144 | - idTransportista: $scope.hojaRuta.transportista.codigo, | |
85 | + fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) | |
86 | + .replace('T', ' '), | |
87 | + idTransportista: $scope.hojaRuta.transportista.COD, | |
145 | 88 | idChofer: $scope.hojaRuta.chofer.id, |
146 | 89 | idVehiculo: $scope.hojaRuta.vehiculo.id, |
147 | - tarifaFlete: $scope.hojaRuta.tarifario.costo | |
90 | + tarifaFlete: $scope.hojaRuta.tarifario.costo, | |
91 | + fechaReparto: $scope.fechaReparto.toISOString().substring(0, 10), | |
92 | + estado: 0 | |
148 | 93 | }, |
149 | 94 | remitos: $scope.remitosTabla |
150 | 95 | }; |
151 | 96 | |
152 | - crearHojaRutaService.crearHojaRuta(save).then( | |
97 | + focaCrearHojaRutaService.crearHojaRuta(save).then( | |
153 | 98 | function(data) { |
154 | 99 | focaModalService.alert( |
155 | 100 | 'Hoja ruta creada Nº: ' + |
... | ... | @@ -157,34 +102,23 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
157 | 102 | '-' + |
158 | 103 | $scope.rellenar(data.data.numeroHojaRuta, 8) |
159 | 104 | ); |
160 | - $scope.hojaRuta = { | |
161 | - fecha: new Date(), | |
162 | - litros: 0, | |
163 | - chofer: {}, | |
164 | - vehiculo: { | |
165 | - capacidad: 0 | |
166 | - }, | |
167 | - transportista: {}, | |
168 | - tarifario: { | |
169 | - costo: null | |
170 | - } | |
171 | - }; | |
172 | - | |
105 | + nuevaHojaRuta(); | |
173 | 106 | $scope.remitosTabla = []; |
174 | 107 | $scope.$broadcast('cleanCabecera'); |
175 | 108 | |
176 | - crearHojaRutaService.getNumeroHojaRuta().then(function(res) { | |
109 | + focaCrearHojaRutaService.getNumeroHojaRuta().then(function(res) { | |
177 | 110 | $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8); |
178 | 111 | }); |
179 | 112 | }, |
180 | 113 | function(error) { |
181 | - focaModalService.alert('Hubo un error al crear la nota de pedido'); | |
114 | + focaModalService.alert('Hubo un error al crear la hoja de ruta'); | |
182 | 115 | console.info(error); |
183 | 116 | } |
184 | 117 | ); |
185 | 118 | }; |
186 | 119 | |
187 | 120 | $scope.seleccionarTransportista = function() { |
121 | + if(eligioPreConfirmado()) return; | |
188 | 122 | var modalInstance = $uibModal.open( |
189 | 123 | { |
190 | 124 | ariaLabelledBy: 'Busqueda de Transportista', |
... | ... | @@ -200,8 +134,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
200 | 134 | ); |
201 | 135 | modalInstance.result.then( |
202 | 136 | function(proveedor) { |
203 | - console.info($scope.hojaRuta); | |
204 | - $scope.hojaRuta.transportista.codigo = proveedor.COD; | |
137 | + $scope.hojaRuta.transportista = proveedor; | |
205 | 138 | $scope.$broadcast('addCabecera', { |
206 | 139 | label: 'Transportista:', |
207 | 140 | valor: proveedor.NOM |
... | ... | @@ -236,37 +169,8 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
236 | 169 | }; |
237 | 170 | |
238 | 171 | $scope.seleccionarVehiculo = function() { |
239 | - var modalInstance = $uibModal.open( | |
240 | - { | |
241 | - ariaLabelledBy: 'Busqueda de Vehiculo', | |
242 | - templateUrl: 'modal-vehiculo.html', | |
243 | - controller: 'focaModalVehiculoController', | |
244 | - size: 'lg', | |
245 | - resolve: { | |
246 | - idTransportista: $scope.hojaRuta.transportista.codigo | |
247 | - } | |
248 | - } | |
249 | - ); | |
250 | - | |
251 | - modalInstance.result.then( | |
252 | - function(vehiculo) { | |
253 | - $scope.hojaRuta.vehiculo = vehiculo; | |
254 | - $scope.$broadcast('addCabecera', { | |
255 | - label: 'Tractor:', | |
256 | - valor: vehiculo.tractor | |
257 | - }); | |
258 | - $scope.$broadcast('addCabecera', { | |
259 | - label: 'Semi:', | |
260 | - valor: vehiculo.semi | |
261 | - }); | |
262 | - $scope.$broadcast('addCabecera', { | |
263 | - label: 'Capacidad:', | |
264 | - valor: vehiculo.capacidad | |
265 | - }); | |
266 | - }, function() { | |
267 | - // funcion ejecutada cuando se cancela el modal | |
268 | - } | |
269 | - ); | |
172 | + if(eligioPreConfirmado()) return; | |
173 | + modalVehiculos(); | |
270 | 174 | }; |
271 | 175 | |
272 | 176 | $scope.seleccionarTarifario = function() { |
... | ... | @@ -298,6 +202,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
298 | 202 | }; |
299 | 203 | |
300 | 204 | $scope.seleccionarRemitos = function() { |
205 | + if(eligioPreConfirmado() || !eligioFecha() || !eligioVehiculo()) return; | |
301 | 206 | var modalInstance = $uibModal.open( |
302 | 207 | { |
303 | 208 | ariaLabelledBy: 'Busqueda de Remito', |
... | ... | @@ -309,152 +214,173 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
309 | 214 | ); |
310 | 215 | modalInstance.result.then( |
311 | 216 | function(remito) { |
312 | - for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { | |
313 | - if ($scope.remitosTabla[i].id === remito.id) { | |
314 | - focaModalService.alert('Remito ya incluido'); | |
315 | - return; | |
316 | - } | |
317 | - } | |
217 | + // TODO: borrar cuando no se use definitivamente | |
218 | + // for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { | |
219 | + // if ($scope.remitosTabla[i].id === remito.id) { | |
220 | + // focaModalService.alert('Remito ya incluido'); | |
221 | + // return; | |
222 | + // } | |
223 | + // } | |
318 | 224 | |
319 | - var litros = 0; | |
320 | - for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { | |
321 | - litros = litros + parseFloat(remito.articulosRemito[j].cantidad); | |
322 | - } | |
225 | + // var litros = 0; | |
226 | + // for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { | |
227 | + // litros = litros + parseFloat(remito.articulosRemito[j].cantidad); | |
228 | + // } | |
323 | 229 | |
324 | - if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { | |
325 | - focaModalService.alert( | |
326 | - 'Debe ingresar toda la información para el transporte' | |
327 | - ); | |
328 | - return; | |
329 | - } | |
230 | + // if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { | |
231 | + // focaModalService.alert( | |
232 | + // 'Debe ingresar toda la información para el transporte' | |
233 | + // ); | |
234 | + // return; | |
235 | + // } | |
330 | 236 | |
331 | - if ($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) | |
332 | - { | |
333 | - var litrostotales = litros; | |
334 | - litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; | |
335 | - focaModalService.alert( | |
336 | - 'La carga excede la capacidad disponible del vehiculo. ' + | |
337 | - 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' | |
338 | - ); | |
339 | - } | |
237 | + //if($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) | |
238 | + // { | |
239 | + // var litrostotales = litros; | |
240 | + // litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; | |
241 | + // focaModalService.alert( | |
242 | + // 'La carga excede la capacidad disponible del vehiculo. ' + | |
243 | + // 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' | |
244 | + // ); | |
245 | + // } | |
340 | 246 | |
341 | - remito.litros = litros; | |
342 | - $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; | |
343 | - $scope.remitosTabla.push(remito); | |
247 | + // remito.litros = litros; | |
248 | + // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; | |
249 | + $scope.cargarCisterna(remito.id).then(function() { | |
250 | + $scope.remitosTabla.push(remito); | |
251 | + }, function() { | |
252 | + // funcion ejecutada cuando se cancela el modal | |
253 | + }); | |
344 | 254 | }, function() { |
345 | 255 | // funcion ejecutada cuando se cancela el modal |
346 | 256 | } |
347 | 257 | ); |
348 | 258 | }; |
349 | 259 | |
350 | - $scope.getTotal = function() { | |
351 | - var total = 0; | |
352 | - var arrayTempArticulos = $scope.remitosTabla; | |
353 | - for (var i = 0; i < arrayTempArticulos.length; i++) { | |
354 | - total += arrayTempArticulos[i].precio * arrayTempArticulos[i].cantidad; | |
355 | - } | |
356 | - return parseFloat(total.toFixed(2)); | |
260 | + $scope.seleccionarVehiculosPrecargados = function() { | |
261 | + if(!eligioFecha()) return; | |
262 | + modalVehiculos(true); | |
357 | 263 | }; |
358 | 264 | |
359 | - $scope.getSubTotal = function() { | |
360 | - if($scope.articuloACargar) { | |
361 | - return $scope.articuloACargar.precio * $scope.articuloACargar.cantidad; | |
362 | - } | |
363 | - }; | |
364 | - | |
365 | - $scope.limpiarPantalla = function() { | |
366 | - $scope.limpiarFlete(); | |
367 | - $scope.hojaRuta.flete = '0'; | |
368 | - $scope.hojaRuta.bomba = '0'; | |
369 | - $scope.hojaRuta.precioCondicion = ''; | |
370 | - $scope.remitosTabla = []; | |
371 | - $scope.hojaRuta.vendedor.nombre = ''; | |
372 | - $scope.hojaRuta.cliente = {nombre: ''}; | |
373 | - $scope.hojaRuta.domicilio = {dom: ''}; | |
374 | - $scope.hojaRuta.litros = 0; | |
375 | - $scope.domiciliosCliente = []; | |
376 | - }; | |
377 | - //Recibe aviso si el teclado está en uso | |
378 | - // $rootScope.$on('usarTeclado', function(event, data) { | |
379 | - // if(data) { | |
380 | - // $scope.mostrarTeclado = true; | |
381 | - // return; | |
382 | - // } | |
383 | - // $scope.mostrarTeclado = false; | |
384 | - // }) | |
385 | - $scope.selectFocus = function($event) { | |
386 | - //Si el teclado esta en uso no selecciona el valor | |
387 | - // if($scope.mostrarTeclado) { | |
388 | - // return; | |
389 | - // } | |
390 | - $event.target.select(); | |
265 | + $scope.cargarCisterna = function(idRemito) { | |
266 | + if(!eligioFecha() || !$scope.hojaRuta.vehiculo.id) return; | |
267 | + var modalInstance = $uibModal.open( | |
268 | + { | |
269 | + ariaLabelledBy: 'Busqueda de Vehiculo', | |
270 | + templateUrl: 'foca-detalle-vehiculo.html', | |
271 | + controller: 'focaDetalleVehiculo', | |
272 | + size: 'lg', | |
273 | + resolve: { | |
274 | + idVehiculo: function() {return $scope.hojaRuta.vehiculo.id;}, | |
275 | + idRemito: function() {return idRemito;}, | |
276 | + fechaReparto: function() {return $scope.fechaReparto;} | |
277 | + } | |
278 | + } | |
279 | + ); | |
280 | + return modalInstance.result; | |
391 | 281 | }; |
392 | 282 | |
393 | - $scope.salir = function() { | |
394 | - $location.path('/'); | |
283 | + $scope.seleccionarFechaEntrega = function() { | |
284 | + if(!$scope.fechaReparto) { | |
285 | + elegirFecha(); | |
286 | + return; | |
287 | + } | |
288 | + focaModalService | |
289 | + .confirm('Si cambia la fecha se perderán los datos actuales') | |
290 | + .then(function() { | |
291 | + elegirFecha(); | |
292 | + }, function() { | |
293 | + return ; | |
294 | + }); | |
395 | 295 | }; |
396 | 296 | |
397 | - $scope.parsearATexto = function(articulo) { | |
398 | - articulo.cantidad = parseFloat(articulo.cantidad); | |
399 | - articulo.precio = parseFloat(articulo.precio); | |
400 | - }; | |
297 | + function elegirFecha() { | |
298 | + focaModalService.modalFecha('Fecha de entrega').then(function(fecha) { | |
299 | + $scope.$broadcast('addCabecera', { | |
300 | + label: 'Fecha de entrega:', | |
301 | + valor: fecha.toLocaleDateString() | |
302 | + }); | |
303 | + $scope.fechaReparto = fecha; | |
304 | + nuevaHojaRuta(); | |
305 | + }); | |
306 | + } | |
401 | 307 | |
402 | 308 | $scope.rellenar = function(relleno, longitud) { |
403 | 309 | relleno = '' + relleno; |
404 | 310 | while (relleno.length < longitud) { |
405 | 311 | relleno = '0' + relleno; |
406 | 312 | } |
407 | - | |
408 | 313 | return relleno; |
409 | 314 | }; |
410 | 315 | |
411 | - $scope.quitarArticulo = function(key) { | |
412 | - $scope.remitosTabla.splice(key, 1); | |
413 | - var litros = 0; | |
414 | - | |
415 | - for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { | |
416 | - litros += parseFloat($scope.remitosTabla[i].litros); | |
316 | + function eligioPreConfirmado() { | |
317 | + if($scope.eligioPreConfirmado) { | |
318 | + focaModalService.alert('No puede elegir si eligió un vehiculo pre cargado'); | |
319 | + return true; | |
417 | 320 | } |
321 | + return false; | |
322 | + } | |
418 | 323 | |
419 | - $scope.hojaRuta.litros = litros; | |
324 | + function eligioFecha() { | |
325 | + if(!$scope.fechaReparto) { | |
326 | + focaModalService.alert('Primero seleccione fecha de reparto'); | |
327 | + return false; | |
328 | + } | |
329 | + return true; | |
330 | + } | |
420 | 331 | |
421 | - }; | |
332 | + function eligioVehiculo() { | |
333 | + if(!$scope.hojaRuta.vehiculo.id) { | |
334 | + focaModalService.alert('Primero seleccione vehiculo'); | |
335 | + return false; | |
336 | + } | |
337 | + return true; | |
338 | + } | |
339 | + | |
340 | + function modalVehiculos(preCargados) { | |
341 | + var query = ''; | |
342 | + var titulo = ''; | |
343 | + if(preCargados) { | |
344 | + query = '/vehiculo/obtener/pre-confirmados/' + $scope.fechaReparto | |
345 | + .toISOString().substring(0, 10); | |
346 | + titulo = 'Búsqueda de vehiculos pre confirmados'; | |
347 | + }else { | |
348 | + query = '/vehiculo'; | |
349 | + titulo = 'Búsqueda de vehículos'; | |
350 | + } | |
351 | + var columnas = { | |
352 | + nombre: ['Código', 'tractor', 'Semi'], | |
353 | + propiedad: ['codigo', 'tractor', 'semi'] | |
354 | + }; | |
355 | + focaModalService.modal(columnas, query, titulo).then(function(vehiculo) { | |
356 | + $scope.hojaRuta.vehiculo = vehiculo; | |
357 | + $scope.hojaRuta.transportista = vehiculo.transportista; | |
358 | + if(preCargados) { | |
359 | + $scope.eligioPreConfirmado = true; | |
360 | + $scope.hojaRuta.vehiculo = vehiculo; | |
361 | + $scope.$broadcast('addCabecera', { | |
362 | + label: 'Transportista:', | |
363 | + valor: vehiculo.transportista.NOM | |
364 | + }); | |
365 | + focaCrearHojaRutaService | |
366 | + .getRemitosByIdVehiculo(vehiculo.id, $scope.fechaReparto) | |
367 | + .then(function(res) { | |
368 | + $scope.remitosTabla = res.data; | |
369 | + }); | |
370 | + } | |
371 | + $scope.$broadcast('addCabecera', { | |
372 | + label: 'Tractor:', | |
373 | + valor: vehiculo.tractor | |
374 | + }); | |
375 | + $scope.$broadcast('addCabecera', { | |
376 | + label: 'Semi:', | |
377 | + valor: vehiculo.semi | |
378 | + }); | |
379 | + $scope.$broadcast('addCabecera', { | |
380 | + label: 'Capacidad:', | |
381 | + valor: vehiculo.capacidad | |
382 | + }); | |
383 | + }); | |
384 | + } | |
422 | 385 | } |
423 | - ] | |
424 | -) | |
425 | -.controller('hojaRutaListaCtrl', [ | |
426 | - '$scope', | |
427 | - 'crearHojaRutaService', | |
428 | - '$location', | |
429 | - function($scope, crearHojaRutaService, $location) { | |
430 | - crearHojaRutaService.obtenerHojaRuta().then(function(datos) { | |
431 | - $scope.hojaRutas = datos.data; | |
432 | - }); | |
433 | - $scope.editar = function(hojaRuta) { | |
434 | - crearHojaRutaService.setHojaRuta(hojaRuta); | |
435 | - $location.path('/venta-nota-pedido/abm/'); | |
436 | - }; | |
437 | - $scope.crearPedido = function() { | |
438 | - crearHojaRutaService.clearHojaRuta(); | |
439 | - $location.path('/venta-nota-pedido/abm/'); | |
440 | - }; | |
441 | - } | |
442 | -]) | |
443 | -.controller('focaCrearHojaRutaFichaClienteController', [ | |
444 | - '$scope', | |
445 | - 'crearHojaRutaService', | |
446 | - '$location', | |
447 | - function($scope, crearHojaRutaService, $location) { | |
448 | - crearHojaRutaService.obtenerHojaRuta().then(function(datos) { | |
449 | - $scope.hojaRutas = datos.data; | |
450 | - }); | |
451 | - $scope.editar = function(hojaRuta) { | |
452 | - crearHojaRutaService.setHojaRuta(hojaRuta); | |
453 | - $location.path('/venta-nota-pedido/abm/'); | |
454 | - }; | |
455 | - $scope.crearPedido = function() { | |
456 | - crearHojaRutaService.clearHojaRuta(); | |
457 | - $location.path('/venta-nota-pedido/abm/'); | |
458 | - }; | |
459 | - } | |
460 | -]); | |
386 | + ]); |
src/js/service.js
1 | 1 | angular.module('focaCrearHojaRuta') |
2 | - .service('crearHojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | |
2 | + .service('focaCrearHojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { | |
3 | 3 | var route = API_ENDPOINT.URL; |
4 | 4 | return { |
5 | 5 | crearHojaRuta: function(hojaRuta) { |
... | ... | @@ -55,9 +55,17 @@ angular.module('focaCrearHojaRuta') |
55 | 55 | getNumeroHojaRuta: function() { |
56 | 56 | return $http.get(route + '/hoja-ruta/numero-siguiente'); |
57 | 57 | }, |
58 | + getRemitosByIdVehiculo: function(idVehiculo, fechaReparto) { | |
59 | + return $http.get(route + '/vehiculo/obtener/remitos/' + | |
60 | + idVehiculo + '/' + fechaReparto.toISOString().substring(0, 10)); | |
61 | + }, | |
58 | 62 | getBotonera: function() { |
59 | 63 | return [ |
60 | 64 | { |
65 | + label: 'Fecha Entrega', | |
66 | + image: 'fechaDeReparto.png' | |
67 | + }, | |
68 | + { | |
61 | 69 | label: 'Transportista', |
62 | 70 | image: 'transportista.png' |
63 | 71 | }, |
... | ... | @@ -76,6 +84,10 @@ angular.module('focaCrearHojaRuta') |
76 | 84 | { |
77 | 85 | label: 'Remitos', |
78 | 86 | image: 'remito.png' |
87 | + }, | |
88 | + { | |
89 | + label: 'Vehiculos precargados', | |
90 | + image: 'vehiculos.png' | |
79 | 91 | } |
80 | 92 | ]; |
81 | 93 | } |
src/views/hoja-ruta.html
... | ... | @@ -10,7 +10,7 @@ |
10 | 10 | <div class="col-12 col-md-10 border border-light rounded"> |
11 | 11 | <div class="row px-5 py-2 botonera-secundaria"> |
12 | 12 | <div class="col-12"> |
13 | - <foca-botonera-facturador botones="botonera" extra="7" class="row"></foca-botonera-facturador> | |
13 | + <foca-botonera-facturador botones="botonera" extra="5" class="row"></foca-botonera-facturador> | |
14 | 14 | </div> |
15 | 15 | </div> |
16 | 16 | <!-- PC --> |
... | ... | @@ -22,7 +22,6 @@ |
22 | 22 | <th class="col-2">Remito</th> |
23 | 23 | <th class="col">Cliente</th> |
24 | 24 | <th class="col">Dirección</th> |
25 | - <th class="text-right" style="width: 80px">Cantidad</th> | |
26 | 25 | <th class="col-auto"> |
27 | 26 | <button |
28 | 27 | class="btn btn-outline-light selectable" |
... | ... | @@ -55,9 +54,8 @@ |
55 | 54 | class="col-2" |
56 | 55 | ng-bind="rellenar(remito.sucursal, 4) + '-' + rellenar(remito.numeroRemito, 8)" |
57 | 56 | ></td> |
58 | - <th class="col" ng-bind="remito.cliente[0].NOM"></th> | |
57 | + <th class="col" ng-bind="remito.nombreCliente"></th> | |
59 | 58 | <th class="col" ng-bind="remito.domicilioStamp"></th> |
60 | - <th class="text-right" ng-bind="remito.litros" style="width: 80px"></th> | |
61 | 59 | <td class="text-center col-auto"> |
62 | 60 | <button |
63 | 61 | class="btn btn-outline-light" |