Commit 1c526cc217946a0818eef8b845e151c565553e38
Exists in
master
and in
2 other branches
Merge branch 'develop' into 'master'
Develop See merge request !44
Showing
2 changed files
Show diff stats
src/js/controller.js
... | ... | @@ -33,8 +33,22 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
33 | 33 | focaBotoneraLateralService.addCustomButton('Salir', salir); |
34 | 34 | }); |
35 | 35 | |
36 | + focaCrearHojaRutaService.getParametros().then(function(res) { | |
37 | + | |
38 | + var parametros = JSON.parse(res.data[0].jsonText); | |
39 | + | |
40 | + if ($localStorage.hojaRuta) { | |
41 | + $timeout(function() {getLSHojaRuta();}); | |
42 | + } else { | |
43 | + | |
44 | + for(var property in parametros) { | |
45 | + $scope.hojaRuta[property] = parametros[property]; | |
46 | + } | |
47 | + | |
48 | + setearHojaRuta($scope.hojaRuta); | |
49 | + } | |
50 | + }); | |
36 | 51 | init(); |
37 | - $timeout(function() {getLSHojaRuta();}); | |
38 | 52 | } |
39 | 53 | |
40 | 54 | function init() { |
... | ... | @@ -48,9 +62,6 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
48 | 62 | capacidad: 0 |
49 | 63 | }, |
50 | 64 | transportista: {}, |
51 | - tarifario: { | |
52 | - costo: null | |
53 | - }, | |
54 | 65 | remitosTabla: [] |
55 | 66 | }; |
56 | 67 | $scope.idLista = undefined; |
... | ... | @@ -70,6 +81,19 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
70 | 81 | } |
71 | 82 | |
72 | 83 | $scope.$watch('hojaRuta', function(newValue) { |
84 | + | |
85 | + // Seteo checked en remitos | |
86 | + if ($scope.hojaRuta.remitosTabla.length) { | |
87 | + | |
88 | + $filter('filter')($scope.botonera, { | |
89 | + label: 'Remitos', | |
90 | + })[0].checked = true; | |
91 | + } else { | |
92 | + $filter('filter')($scope.botonera, { | |
93 | + label: 'Remitos', | |
94 | + })[0].checked = false; | |
95 | + } | |
96 | + | |
73 | 97 | focaBotoneraLateralService.setPausarData({ |
74 | 98 | label: 'hojaRuta', |
75 | 99 | val: newValue |
... | ... | @@ -93,7 +117,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
93 | 117 | focaModalService.alert('Ingrese Transportista'); |
94 | 118 | return; |
95 | 119 | } |
96 | - if (!$scope.hojaRuta.tarifario.costo) { | |
120 | + if (!$scope.hojaRuta.tarifario) { | |
97 | 121 | focaModalService.alert('Ingrese Tarifario'); |
98 | 122 | return; |
99 | 123 | } |
... | ... | @@ -110,7 +134,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
110 | 134 | idTransportista: $scope.hojaRuta.transportista.COD, |
111 | 135 | idChofer: $scope.hojaRuta.chofer.id, |
112 | 136 | idVehiculo: $scope.hojaRuta.vehiculo.id, |
113 | - tarifaFlete: $scope.hojaRuta.tarifario.costo, | |
137 | + tarifaFlete: $scope.hojaRuta.tarifario, | |
114 | 138 | fechaReparto: |
115 | 139 | new Date($scope.hojaRuta.fechaReparto).toISOString().substring(0, 10), |
116 | 140 | estado: 0 |
... | ... | @@ -126,7 +150,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
126 | 150 | $filter('rellenarDigitos')(data.data.numeroHojaRuta, 8) |
127 | 151 | ); |
128 | 152 | |
129 | - init(); | |
153 | + config(); | |
130 | 154 | }, |
131 | 155 | function(error) { |
132 | 156 | focaModalService.alert('Hubo un error al crear la hoja de ruta'); |
... | ... | @@ -163,6 +187,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
163 | 187 | valor: $filter('rellenarDigitos')(proveedor.COD, 5) + ' - ' + |
164 | 188 | proveedor.NOM |
165 | 189 | }); |
190 | + | |
191 | + $filter('filter')($scope.botonera, { | |
192 | + label: 'Transportista', | |
193 | + })[0].checked = true; | |
166 | 194 | }, function() { |
167 | 195 | |
168 | 196 | } |
... | ... | @@ -203,6 +231,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
203 | 231 | label: 'Chofer:', |
204 | 232 | valor: $filter('rellenarDigitos')(chofer.id, 3) + ' - ' +chofer.nombre |
205 | 233 | }); |
234 | + | |
235 | + $filter('filter')($scope.botonera, { | |
236 | + label: 'Chofer', | |
237 | + })[0].checked = true; | |
206 | 238 | }, function() { |
207 | 239 | // funcion ejecutada cuando se cancela el modal |
208 | 240 | } |
... | ... | @@ -218,7 +250,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
218 | 250 | focaModalService |
219 | 251 | .prompt({ |
220 | 252 | titulo: 'Tarifa flete', |
221 | - value: $scope.hojaRuta.tarifario.costo | |
253 | + value: $scope.hojaRuta.tarifario | |
222 | 254 | }) |
223 | 255 | .then(function(costo) { |
224 | 256 | if (isNaN(costo)) { |
... | ... | @@ -231,11 +263,15 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
231 | 263 | return; |
232 | 264 | } |
233 | 265 | |
234 | - $scope.hojaRuta.tarifario.costo = costo; | |
266 | + $scope.hojaRuta.tarifario = costo; | |
235 | 267 | $scope.$broadcast('addCabecera', { |
236 | 268 | label: 'Tarifario:', |
237 | 269 | valor: costo |
238 | 270 | }); |
271 | + | |
272 | + $filter('filter')($scope.botonera, { | |
273 | + label: 'Tarifario', | |
274 | + })[0].checked = true; | |
239 | 275 | }); |
240 | 276 | }; |
241 | 277 | |
... | ... | @@ -390,6 +426,11 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
390 | 426 | } |
391 | 427 | ); |
392 | 428 | return modalInstance.result.then(function(datosExtra) { |
429 | + | |
430 | + $filter('filter')($scope.botonera, { | |
431 | + label: 'Datos extra', | |
432 | + })[0].checked = true; | |
433 | + | |
393 | 434 | $scope.hojaRuta.datosExtra = datosExtra; |
394 | 435 | }, function() { |
395 | 436 | //se ejecuta cuando se cancela el modal |
... | ... | @@ -438,10 +479,16 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
438 | 479 | minDate: new Date() |
439 | 480 | }; |
440 | 481 | focaModalService.modalFecha(fechaEntrega).then(function(fecha) { |
482 | + | |
441 | 483 | $scope.$broadcast('addCabecera', { |
442 | 484 | label: 'Fecha de entrega: ', |
443 | 485 | valor: fecha.toLocaleDateString() |
444 | 486 | }); |
487 | + | |
488 | + $filter('filter')($scope.botonera, { | |
489 | + label: 'Fecha Entrega', | |
490 | + })[0].checked = true; | |
491 | + | |
445 | 492 | $scope.hojaRuta.fechaReparto = fecha; |
446 | 493 | }); |
447 | 494 | } |
... | ... | @@ -509,12 +556,22 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
509 | 556 | focaCrearHojaRutaService |
510 | 557 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto) |
511 | 558 | .then(function(res) { |
559 | + | |
560 | + $filter('filter')($scope.botonera, { | |
561 | + label: 'Vehiculos precargados', | |
562 | + })[0].checked = true; | |
563 | + | |
512 | 564 | $scope.hojaRuta.remitosTabla = res.data; |
513 | 565 | }); |
514 | 566 | } else { |
515 | 567 | focaCrearHojaRutaService |
516 | 568 | .getRemitosByIdVehiculo(vehiculo.id, $scope.hojaRuta.fechaReparto, true) |
517 | 569 | .then(function(res) { |
570 | + | |
571 | + $filter('filter')($scope.botonera, { | |
572 | + label: 'Vehiculo', | |
573 | + })[0].checked = true; | |
574 | + | |
518 | 575 | $scope.hojaRuta.remitosTabla = res.data; |
519 | 576 | }); |
520 | 577 | } |
... | ... | @@ -530,6 +587,7 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
530 | 587 | label: 'Capacidad:', |
531 | 588 | valor: vehiculo.capacidad |
532 | 589 | }); |
590 | + | |
533 | 591 | }); |
534 | 592 | } |
535 | 593 | |
... | ... | @@ -581,6 +639,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
581 | 639 | label: 'Fecha de entrega:', |
582 | 640 | valor: $filter('date')(hojaRuta.fechaReparto, 'dd/MM/yyyy') |
583 | 641 | }); |
642 | + | |
643 | + $filter('filter')( $scope.botonera, { | |
644 | + label: 'Fecha Entrega' | |
645 | + })[0].checked = true; | |
584 | 646 | } |
585 | 647 | if (hojaRuta.transportista.COD) { |
586 | 648 | cabeceras.push({ |
... | ... | @@ -588,6 +650,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
588 | 650 | valor: $filter('rellenarDigitos')(hojaRuta.transportista.COD, 5) + ' - ' + |
589 | 651 | hojaRuta.transportista.NOM |
590 | 652 | }); |
653 | + | |
654 | + $filter('filter')( $scope.botonera, { | |
655 | + label: 'Transportista' | |
656 | + })[0].checked = true; | |
591 | 657 | } |
592 | 658 | if (hojaRuta.chofer.id) { |
593 | 659 | cabeceras.push({ |
... | ... | @@ -595,6 +661,10 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
595 | 661 | valor: $filter('rellenarDigitos')(hojaRuta.chofer.id, 3) + |
596 | 662 | ' - ' + hojaRuta.chofer.nombre |
597 | 663 | }); |
664 | + | |
665 | + $filter('filter')( $scope.botonera, { | |
666 | + label: 'Chofer' | |
667 | + })[0].checked = true; | |
598 | 668 | } |
599 | 669 | if (hojaRuta.vehiculo.id) { |
600 | 670 | cabeceras.push({ |
... | ... | @@ -609,12 +679,20 @@ angular.module('focaCrearHojaRuta') .controller('hojaRutaCtrl', |
609 | 679 | label: 'Capacidad:', |
610 | 680 | valor: hojaRuta.vehiculo.capacidad |
611 | 681 | }); |
682 | + | |
683 | + $filter('filter')( $scope.botonera, { | |
684 | + label: 'Vehiculo' | |
685 | + })[0].checked = true; | |
612 | 686 | } |
613 | - if (hojaRuta.tarifario.costo) { | |
687 | + if (hojaRuta.tarifario) { | |
614 | 688 | cabeceras.push({ |
615 | 689 | label: 'Tarifario:', |
616 | - valor: hojaRuta.tarifario.costo | |
690 | + valor: hojaRuta.tarifario | |
617 | 691 | }); |
692 | + | |
693 | + $filter('filter')( $scope.botonera, { | |
694 | + label: 'Tarifario' | |
695 | + })[0].checked = true; | |
618 | 696 | } |
619 | 697 | |
620 | 698 | addArrayCabecera(cabeceras); |
src/js/service.js