Commit 7e529b71937f8dbfbc3bba451f0c7f7c30a2f822

Authored by Eric Fernandez
Exists in master and in 2 other branches develop, lab

Merge branch 'develop' into 'master'

Develop

See merge request !10
src/js/controller.js
1 angular.module('focaActivarHojaRuta') 1 angular.module('focaActivarHojaRuta')
2 .controller('focaActivarHojaRutaController', [ 2 .controller('focaActivarHojaRutaController', [
3 '$scope', 'focaActivarHojaRutaService', 'focaModalService', 'focaBotoneraLateralService', 3 '$scope', 'focaActivarHojaRutaService', 'focaModalService', 'focaBotoneraLateralService',
4 '$filter','$uibModal', 4 '$filter','$uibModal',
5 function($scope, focaActivarHojaRutaService, focaModalService, focaBotoneraLateralService, 5 function($scope, focaActivarHojaRutaService, focaModalService, focaBotoneraLateralService,
6 $filter, $uibModal) { 6 $filter, $uibModal) {
7 config(); 7 config();
8 8
9 //METODOS 9 //METODOS
10 function config() { 10 function config() {
11 $scope.botonera = [{ 11 $scope.botonera = [{
12 label: 'Chofer', 12 label: 'Chofer',
13 image: 'cliente.png' 13 image: 'cliente.png'
14 }]; 14 }];
15 //SETEO BOTONERA LATERAL 15 //SETEO BOTONERA LATERAL
16 focaBotoneraLateralService.showSalir(true); 16 focaBotoneraLateralService.showSalir(true);
17 focaBotoneraLateralService.showPausar(false); 17 focaBotoneraLateralService.showPausar(false);
18 focaBotoneraLateralService.showCancelar(false); 18 focaBotoneraLateralService.showCancelar(false);
19 focaBotoneraLateralService.showGuardar(false); 19 focaBotoneraLateralService.showGuardar(false);
20 20
21 init(); 21 init();
22 } 22 }
23 23
24 function init() { 24 function init() {
25 $scope.now = new Date(); 25 $scope.now = new Date();
26 $scope.hojasRuta = []; 26 $scope.hojasRuta = [];
27 $scope.$broadcast('removeCabecera', 'Chofer:'); 27 $scope.$broadcast('removeCabecera', 'Chofer:');
28 } 28 }
29 29
30 $scope.seleccionarChofer = function() { 30 $scope.seleccionarChofer = function() {
31 var parametrosModal = { 31 var parametrosModal = {
32 titulo: 'Búsqueda de Chofer', 32 titulo: 'Búsqueda de Chofer',
33 query: '/chofer', 33 query: '/chofer',
34 columnas: [ 34 columnas: [
35 { 35 {
36 propiedad: 'id', 36 propiedad: 'id',
37 nombre: 'Código', 37 nombre: 'Código',
38 filtro: { 38 filtro: {
39 nombre: 'rellenarDigitos', 39 nombre: 'rellenarDigitos',
40 parametro: 3 40 parametro: 3
41 } 41 }
42 }, 42 },
43 { 43 {
44 propiedad: 'nombre', 44 propiedad: 'nombre',
45 nombre: 'Nombre' 45 nombre: 'Nombre'
46 }, 46 },
47 { 47 {
48 propiedad: 'dni', 48 propiedad: 'dni',
49 nombre: 'DNI' 49 nombre: 'DNI'
50 }, 50 },
51 { 51 {
52 propiedad: 'telefono', 52 propiedad: 'telefono',
53 nombre: 'Teléfono' 53 nombre: 'Teléfono'
54 } 54 }
55 ] 55 ]
56 }; 56 };
57 focaModalService.modal(parametrosModal).then( 57 focaModalService.modal(parametrosModal).then(
58 function(chofer) { 58 function(chofer) {
59 $scope.chofer = chofer.id; 59 $scope.chofer = chofer.id;
60 focaActivarHojaRutaService.getHojasRutas($scope.chofer) 60 focaActivarHojaRutaService.getHojasRutas($scope.chofer)
61 .then(function(hojasRutas) { 61 .then(function(hojasRutas) {
62 $scope.$broadcast('addCabecera', { 62 $scope.$broadcast('addCabecera', {
63 label: 'Chofer:', 63 label: 'Chofer:',
64 valor: $scope.chofer + ' - ' + chofer.nombre 64 valor: $scope.chofer + ' - ' + chofer.nombre
65 }); 65 });
66 66
67 $scope.hojasRuta = hojasRutas.data; 67 $scope.hojasRuta = hojasRutas.data;
68 }); 68 });
69 }, function() {} 69 }, function() {}
70 ); 70 );
71 }; 71 };
72 72
73 $scope.mostrarRemitos = function (hojasRutas) { 73 $scope.mostrarRemitos = function (hojasRutas) {
74 $uibModal.open( 74 $uibModal.open(
75 { 75 {
76 ariaLabelledBy: '', 76 ariaLabelledBy: '',
77 templateUrl: 'modal-remitos.html', 77 templateUrl: 'modal-remitos.html',
78 controller: 'focaModalDetalleController', 78 controller: 'focaModalRemitosHojaRutaController',
79 resolve: { 79 resolve: {
80 hojasRutas: function () { return hojasRutas; }, 80 hojasRutas: function () { return hojasRutas; },
81 }, 81 },
82 size: 'lg', 82 size: 'lg',
83 } 83 }
84 ); 84 );
85 }; 85 };
86 86
87 $scope.setearEstado = function (estado) { 87 $scope.setearEstado = function (estado) {
88 var texto = ''; 88 var texto = '';
89 switch (estado) { 89 switch (estado) {
90 case 0: 90 case 0:
91 texto = 'Disponible'; 91 texto = 'Disponible';
92 break; 92 break;
93 case 1: 93 case 1:
94 texto = 'Asignada'; 94 texto = 'Asignada';
95 break; 95 break;
96 case 2: 96 case 2:
97 texto = 'Terminada'; 97 texto = 'Terminada';
98 break; 98 break;
99 default: 99 default:
100 break; 100 break;
101 } 101 }
102 return texto; 102 return texto;
103 }; 103 };
104 104
105 $scope.activarHojaRuta = function(hojaRuta) { 105 $scope.activarHojaRuta = function(hojaRuta) {
106 validarChoferDisponible().then(function(hojaRutaAsignada) { 106 validarChoferDisponible().then(function(hojaRutaAsignada) {
107 if (hojaRutaAsignada) { 107 if (hojaRutaAsignada) {
108 var texto = 'El chofer tiene asignada la Hoja de Ruta Nº ' + 108 var texto = 'El chofer tiene asignada la Hoja de Ruta Nº ' +
109 $filter('comprobante')([hojaRutaAsignada.sucursal, 109 $filter('comprobante')([hojaRutaAsignada.sucursal,
110 hojaRutaAsignada.numeroHojaRuta]) + 110 hojaRutaAsignada.numeroHojaRuta]) +
111 ', ¿desea reemplazarla por esta?'; 111 ', ¿desea reemplazarla por esta?';
112 112
113 focaModalService 113 focaModalService
114 .confirm(texto) 114 .confirm(texto)
115 .then(function(res) { 115 .then(function(res) {
116 if (res) activar(); 116 if (res) activar();
117 }); 117 });
118 } else { 118 } else {
119 activar(); 119 activar();
120 } 120 }
121 121
122 function activar() { 122 function activar() {
123 focaActivarHojaRutaService 123 focaActivarHojaRutaService
124 .activarHojaRuta(hojaRuta.id, $scope.chofer) 124 .activarHojaRuta(hojaRuta.id, $scope.chofer)
125 .then(function() { 125 .then(function() {
126 hojaRuta.estado = 1; 126 hojaRuta.estado = 1;
127 init(); 127 init();
128 focaModalService.alert('Hoja de ruta activada'); 128 focaModalService.alert('Hoja de ruta activada');
129 }); 129 });
130 } 130 }
131 }); 131 });
132 }; 132 };
133 133
134 function validarChoferDisponible() { 134 function validarChoferDisponible() {
135 return new Promise(function(resolve, reject) { 135 return new Promise(function(resolve, reject) {
136 focaActivarHojaRutaService 136 focaActivarHojaRutaService
137 .getHojaRutaByIdChofer($scope.chofer) 137 .getHojaRutaByIdChofer($scope.chofer)
138 .then(function(res) { 138 .then(function(res) {
139 resolve(res.data); 139 resolve(res.data);
140 }) 140 })
141 .catch(reject); 141 .catch(reject);
142 }); 142 });
143 } 143 }
144 144
145 145
146 /* 146 /*
147 147
148 if(focaActivarHojaRutaService.transportistaSeleccionado.COD) { 148 if(focaActivarHojaRutaService.transportistaSeleccionado.COD) {
149 elegirTransportista(focaActivarHojaRutaService.transportistaSeleccionado); 149 elegirTransportista(focaActivarHojaRutaService.transportistaSeleccionado);
150 } 150 }
151 focaActivarHojaRutaService.cleanCisternasLocal(); 151 focaActivarHojaRutaService.cleanCisternasLocal();
152 $scope.editar = function(id) { 152 $scope.editar = function(id) {
153 $location.path('/vehiculo/' + id + '/' + $scope.idTransportista); 153 $location.path('/vehiculo/' + id + '/' + $scope.idTransportista);
154 }; 154 };
155 $scope.solicitarConfirmacion = function(vehiculo) { 155 $scope.solicitarConfirmacion = function(vehiculo) {
156 focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' + 156 focaModalService.confirm('¿Está seguro que desea borrar el vehiculo ' +
157 vehiculo.id + ' ' + vehiculo.tractor + ' ?').then( 157 vehiculo.id + ' ' + vehiculo.tractor + ' ?').then(
158 function(data) { 158 function(data) {
159 if(data) { 159 if(data) {
160 focaActivarHojaRutaService.deleteVehiculo(vehiculo.id); 160 focaActivarHojaRutaService.deleteVehiculo(vehiculo.id);
161 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); 161 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1);
162 } 162 }
163 } 163 }
164 ); 164 );
165 }; 165 };
166 166
167 function elegirTransportista(transportista) { 167 function elegirTransportista(transportista) {
168 var codigo = ('00000' + transportista.COD).slice(-5); 168 var codigo = ('00000' + transportista.COD).slice(-5);
169 $scope.idTransportista = transportista.COD; 169 $scope.idTransportista = transportista.COD;
170 $scope.filtros = transportista.NOM.trim(); 170 $scope.filtros = transportista.NOM.trim();
171 $timeout(function() { 171 $timeout(function() {
172 $scope.$broadcast('addCabecera', { 172 $scope.$broadcast('addCabecera', {
173 label: 'Transportista:', 173 label: 'Transportista:',
174 valor: codigo + ' - ' + transportista.NOM 174 valor: codigo + ' - ' + transportista.NOM
175 }); 175 });
176 }); 176 });
177 buscar(transportista.COD); 177 buscar(transportista.COD);
178 } 178 }
179 179
180 function buscar(idTransportista) { 180 function buscar(idTransportista) {
181 focaActivarHojaRutaService 181 focaActivarHojaRutaService
182 .getVehiculosPorTransportista(idTransportista) 182 .getVehiculosPorTransportista(idTransportista)
183 .then(function(datos) { 183 .then(function(datos) {
184 $scope.vehiculos = datos.data; 184 $scope.vehiculos = datos.data;
185 }); 185 });
186 }*/ 186 }*/
187 } 187 }
188 ]); 188 ]);
189 189
src/js/controllerDetalle.js
1 angular.module('focaActivarHojaRuta') 1 angular.module('focaActivarHojaRuta')
2 .controller('focaModalDetalleController', [ 2 .controller('focaModalRemitosHojaRutaController', [
3 '$scope', '$timeout', '$uibModalInstance', 'focaModalService', 3 '$scope', '$timeout', '$uibModalInstance', 'focaModalService',
4 'focaActivarHojaRutaService','hojasRutas', 4 'focaActivarHojaRutaService','hojasRutas',
5 function ($scope, $timeout, $uibModalInstance, focaModalService, 5 function ($scope, $timeout, $uibModalInstance, focaModalService,
6 focaActivarHojaRutaService, hojasRutas) { 6 focaActivarHojaRutaService, hojasRutas) {
7 7
8 $scope.mostrar = false; 8 $scope.mostrar = false;
9 $scope.hojasRutas = hojasRutas; 9 $scope.hojasRutas = hojasRutas;
10 10
11 $scope.cancel = function () { 11 $scope.cancel = function () {
12 $uibModalInstance.close(hojasRutas); 12 $uibModalInstance.close(hojasRutas);
13 }; 13 };
14 } 14 }
15 ]); 15 ]);
16 16