Commit 5c227b8581a0a2575b0ab33b4d56f850d26e36e0

Authored by Jose Pinto
Exists in master and in 1 other branch develop

Merge branch 'master' into 'master'

Master(efernandez)

See merge request !14
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 function($scope, $uibModal, $location, $filter, $timeout, 11 function($scope, $uibModal, $location, $filter, $timeout,
12 focaCrearHojaRutaService, focaModalService, focaBotoneraLateralService) { 12 focaCrearHojaRutaService, focaModalService, focaBotoneraLateralService) {
13 13
14 $scope.botonera = focaCrearHojaRutaService.getBotonera(); 14 $scope.botonera = focaCrearHojaRutaService.getBotonera();
15 $scope.datepickerAbierto = false; 15 $scope.datepickerAbierto = false;
16 16
17 $scope.show = false; 17 $scope.show = false;
18 $scope.cargando = true; 18 $scope.cargando = true;
19 19
20 function nuevaHojaRuta() { 20 function nuevaHojaRuta() {
21 $scope.hojaRuta = { 21 $scope.hojaRuta = {
22 fecha: new Date(), 22 fecha: new Date(),
23 litros: 0, 23 litros: 0,
24 chofer: {}, 24 chofer: {},
25 vehiculo: { 25 vehiculo: {
26 capacidad: 0 26 capacidad: 0
27 }, 27 },
28 transportista: {}, 28 transportista: {},
29 tarifario: { 29 tarifario: {
30 costo: null 30 costo: null
31 } 31 }
32 }; 32 };
33 } 33 }
34 nuevaHojaRuta(); 34 nuevaHojaRuta();
35 $scope.showCabecera = true; 35 $scope.showCabecera = true;
36 36
37 $scope.now = new Date(); 37 $scope.now = new Date();
38 $scope.puntoVenta = '0000'; 38 $scope.puntoVenta = '0000';
39 $scope.comprobante = '00000000'; 39 $scope.comprobante = '00000000';
40 $scope.remitosTabla = []; 40 $scope.remitosTabla = [];
41 $scope.idLista = undefined; 41 $scope.idLista = undefined;
42 42
43 //SETEO BOTONERA LATERAL 43 //SETEO BOTONERA LATERAL
44 $timeout(function() { 44 $timeout(function() {
45 focaBotoneraLateralService.showSalir(true); 45 focaBotoneraLateralService.showSalir(true);
46 focaBotoneraLateralService.showPausar(true); 46 focaBotoneraLateralService.showPausar(true);
47 focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta); 47 focaBotoneraLateralService.showGuardar(true, $scope.crearHojaRuta);
48 }); 48 });
49 49
50 focaCrearHojaRutaService.getNumeroHojaRuta().then( 50 focaCrearHojaRutaService.getNumeroHojaRuta().then(
51 function(res) { 51 function(res) {
52 $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4); 52 $scope.puntoVenta = $scope.rellenar(res.data.sucursal, 4);
53 $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8); 53 $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8);
54 }, 54 },
55 function(err) { 55 function(err) {
56 focaModalService.alert('La terminal no esta configurada correctamente'); 56 focaModalService.alert('La terminal no esta configurada correctamente');
57 console.info(err); 57 console.info(err);
58 } 58 }
59 ); 59 );
60 $scope.crearHojaRuta = function() { 60 $scope.crearHojaRuta = function() {
61 if(!$scope.remitosTabla.length) { 61 if(!$scope.remitosTabla.length) {
62 focaModalService.alert('Ingrese Remitos'); 62 focaModalService.alert('Ingrese Remitos');
63 return; 63 return;
64 } 64 }
65 if(!$scope.hojaRuta.chofer.id) { 65 if(!$scope.hojaRuta.chofer.id) {
66 focaModalService.alert('Ingrese Chofer'); 66 focaModalService.alert('Ingrese Chofer');
67 return; 67 return;
68 } 68 }
69 if(!$scope.hojaRuta.vehiculo.id) { 69 if(!$scope.hojaRuta.vehiculo.id) {
70 focaModalService.alert('Ingrese Vehiculo'); 70 focaModalService.alert('Ingrese Vehiculo');
71 return; 71 return;
72 } 72 }
73 if(!$scope.hojaRuta.transportista.COD) { 73 if(!$scope.hojaRuta.transportista.COD) {
74 focaModalService.alert('Ingrese Transportista'); 74 focaModalService.alert('Ingrese Transportista');
75 return; 75 return;
76 } 76 }
77 if(!$scope.hojaRuta.tarifario.costo) { 77 if(!$scope.hojaRuta.tarifario.costo) {
78 focaModalService.alert('Ingrese Tarifario'); 78 focaModalService.alert('Ingrese Tarifario');
79 return; 79 return;
80 } 80 }
81 if(!$scope.hojaRuta.datosExtra) { 81 if(!$scope.hojaRuta.datosExtra) {
82 focaModalService.alert('Ingrese Datos extra'); 82 focaModalService.alert('Ingrese Datos extra');
83 return; 83 return;
84 } 84 }
85 var date = new Date(); 85 var date = new Date();
86 var save = { 86 var save = {
87 hojaRuta: { 87 hojaRuta: {
88 id: 0, 88 id: 0,
89 fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19) 89 fechaCreacion: new Date(date.getTime()).toISOString().slice(0, 19)
90 .replace('T', ' '), 90 .replace('T', ' '),
91 idTransportista: $scope.hojaRuta.transportista.COD, 91 idTransportista: $scope.hojaRuta.transportista.COD,
92 idChofer: $scope.hojaRuta.chofer.id, 92 idChofer: $scope.hojaRuta.chofer.id,
93 idVehiculo: $scope.hojaRuta.vehiculo.id, 93 idVehiculo: $scope.hojaRuta.vehiculo.id,
94 tarifaFlete: $scope.hojaRuta.tarifario.costo, 94 tarifaFlete: $scope.hojaRuta.tarifario.costo,
95 fechaReparto: $scope.fechaReparto.toISOString().substring(0, 10), 95 fechaReparto: $scope.fechaReparto.toISOString().substring(0, 10),
96 estado: 0 96 estado: 0
97 }, 97 },
98 remitos: $scope.remitosTabla 98 remitos: $scope.remitosTabla
99 }; 99 };
100 save.hojaRuta = angular.extend({}, save.hojaRuta, $scope.hojaRuta.datosExtra); 100 save.hojaRuta = angular.extend({}, save.hojaRuta, $scope.hojaRuta.datosExtra);
101 focaCrearHojaRutaService.crearHojaRuta(save).then( 101 focaCrearHojaRutaService.crearHojaRuta(save).then(
102 function(data) { 102 function(data) {
103 focaModalService.alert( 103 focaModalService.alert(
104 'Hoja ruta creada Nº: ' + 104 'Hoja ruta creada Nº: ' +
105 $scope.rellenar(data.data.sucursal, 4) + 105 $scope.rellenar(data.data.sucursal, 4) +
106 '-' + 106 '-' +
107 $scope.rellenar(data.data.numeroHojaRuta, 8) 107 $scope.rellenar(data.data.numeroHojaRuta, 8)
108 ); 108 );
109 nuevaHojaRuta(); 109 nuevaHojaRuta();
110 $scope.remitosTabla = []; 110 $scope.remitosTabla = [];
111 $scope.$broadcast('cleanCabecera'); 111 $scope.$broadcast('cleanCabecera');
112 112
113 focaCrearHojaRutaService.getNumeroHojaRuta().then(function(res) { 113 focaCrearHojaRutaService.getNumeroHojaRuta().then(function(res) {
114 $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8); 114 $scope.comprobante = $scope.rellenar(res.data.numeroHojaRuta, 8);
115 }); 115 });
116 }, 116 },
117 function(error) { 117 function(error) {
118 focaModalService.alert('Hubo un error al crear la hoja de ruta'); 118 focaModalService.alert('Hubo un error al crear la hoja de ruta');
119 console.info(error); 119 console.info(error);
120 } 120 }
121 ); 121 );
122 }; 122 };
123 123
124 $scope.seleccionarTransportista = function() { 124 $scope.seleccionarTransportista = function() {
125 if(eligioPreConfirmado()) return; 125 if(eligioPreConfirmado()) return;
126 var modalInstance = $uibModal.open( 126 var modalInstance = $uibModal.open(
127 { 127 {
128 ariaLabelledBy: 'Busqueda de Transportista', 128 ariaLabelledBy: 'Busqueda de Transportista',
129 templateUrl: 'modal-proveedor.html', 129 templateUrl: 'modal-proveedor.html',
130 controller: 'focaModalProveedorCtrl', 130 controller: 'focaModalProveedorCtrl',
131 size: 'lg', 131 size: 'lg',
132 resolve: { 132 resolve: {
133 transportista: function() { 133 transportista: function() {
134 return true; 134 return true;
135 } 135 }
136 } 136 }
137 } 137 }
138 ); 138 );
139 modalInstance.result.then( 139 modalInstance.result.then(
140 function(proveedor) { 140 function(proveedor) {
141 $scope.hojaRuta.transportista = proveedor; 141 $scope.hojaRuta.transportista = proveedor;
142 $scope.$broadcast('addCabecera', { 142 $scope.$broadcast('addCabecera', {
143 label: 'Transportista:', 143 label: 'Transportista:',
144 valor: proveedor.NOM 144 valor: proveedor.NOM
145 }); 145 });
146 }, function() { 146 }, function() {
147 147
148 } 148 }
149 ); 149 );
150 }; 150 };
151 151
152 $scope.seleccionarChofer = function() { 152 $scope.seleccionarChofer = function() {
153 var modalInstance = $uibModal.open( 153 var modalInstance = $uibModal.open(
154 { 154 {
155 ariaLabelledBy: 'Busqueda de Chofer', 155 ariaLabelledBy: 'Busqueda de Chofer',
156 templateUrl: 'modal-chofer.html', 156 templateUrl: 'modal-chofer.html',
157 controller: 'focaModalChoferController', 157 controller: 'focaModalChoferController',
158 size: 'lg' 158 size: 'lg'
159 } 159 }
160 ); 160 );
161 161
162 modalInstance.result.then( 162 modalInstance.result.then(
163 function(chofer) { 163 function(chofer) {
164 $scope.hojaRuta.chofer = chofer; 164 $scope.hojaRuta.chofer = chofer;
165 $scope.$broadcast('addCabecera', { 165 $scope.$broadcast('addCabecera', {
166 label: 'Chofer:', 166 label: 'Chofer:',
167 valor: chofer.nombre 167 valor: chofer.nombre
168 }); 168 });
169 }, function() { 169 }, function() {
170 // funcion ejecutada cuando se cancela el modal 170 // funcion ejecutada cuando se cancela el modal
171 } 171 }
172 ); 172 );
173 }; 173 };
174 174
175 $scope.seleccionarVehiculo = function() { 175 $scope.seleccionarVehiculo = function() {
176 if(eligioPreConfirmado()) return; 176 if(eligioPreConfirmado()) return;
177 modalVehiculos(); 177 modalVehiculos();
178 }; 178 };
179 179
180 $scope.seleccionarTarifario = function() { 180 $scope.seleccionarTarifario = function() {
181 var modalInstance = $uibModal.open( 181 var modalInstance = $uibModal.open(
182 { 182 {
183 ariaLabelledBy: 'Busqueda de Tarifario', 183 ariaLabelledBy: 'Busqueda de Tarifario',
184 templateUrl: 'modal-tarifa-flete.html', 184 templateUrl: 'modal-tarifa-flete.html',
185 controller: 'focaModalTarifaFleteController', 185 controller: 'focaModalTarifaFleteController',
186 size: 'lg', 186 size: 'lg',
187 resolve: { 187 resolve: {
188 parametrosTarifaFlete: function() { 188 parametrosTarifaFlete: function() {
189 return $scope.hojaRuta.tarifario.costo; 189 return $scope.hojaRuta.tarifario.costo;
190 } 190 }
191 } 191 }
192 } 192 }
193 ); 193 );
194 194
195 modalInstance.result.then( 195 modalInstance.result.then(
196 function(tarifario) { 196 function(tarifario) {
197 $scope.hojaRuta.tarifario = tarifario; 197 $scope.hojaRuta.tarifario = tarifario;
198 $scope.$broadcast('addCabecera', { 198 $scope.$broadcast('addCabecera', {
199 label: 'Tarifario:', 199 label: 'Tarifario:',
200 valor: tarifario.costo 200 valor: tarifario.costo
201 }); 201 });
202 }, function() { 202 }, function() {
203 // funcion ejecutada cuando se cancela el modal 203 // funcion ejecutada cuando se cancela el modal
204 } 204 }
205 ); 205 );
206 }; 206 };
207 207
208 $scope.seleccionarRemitos = function() { 208 $scope.seleccionarRemitos = function() {
209 if(eligioPreConfirmado() || !eligioFecha() || !eligioVehiculo()) return; 209 if(eligioPreConfirmado() || !eligioFecha() || !eligioVehiculo()) return;
210 var modalInstance = $uibModal.open( 210 var modalInstance = $uibModal.open(
211 { 211 {
212 ariaLabelledBy: 'Busqueda de Remito', 212 ariaLabelledBy: 'Busqueda de Remito',
213 templateUrl: 'foca-modal-remito.html', 213 templateUrl: 'foca-modal-remito.html',
214 controller: 'focaModalRemitoController', 214 controller: 'focaModalRemitoController',
215 size: 'lg', 215 size: 'lg',
216 resolve: {usadoPor: function() {return 'hojaRuta';}} 216 resolve: {usadoPor: function() {return 'hojaRuta';}}
217 } 217 }
218 ); 218 );
219 modalInstance.result.then( 219 modalInstance.result.then(
220 function(remito) { 220 function(remito) {
221 // TODO: borrar cuando no se use definitivamente 221 // TODO: borrar cuando no se use definitivamente
222 // for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) { 222 // for (var i = $scope.remitosTabla.length - 1; i >= 0; i--) {
223 // if ($scope.remitosTabla[i].id === remito.id) { 223 // if ($scope.remitosTabla[i].id === remito.id) {
224 // focaModalService.alert('Remito ya incluido'); 224 // focaModalService.alert('Remito ya incluido');
225 // return; 225 // return;
226 // } 226 // }
227 // } 227 // }
228 228
229 // var litros = 0; 229 // var litros = 0;
230 // for (var j = remito.articulosRemito.length - 1; j >= 0; j--) { 230 // for (var j = remito.articulosRemito.length - 1; j >= 0; j--) {
231 // litros = litros + parseFloat(remito.articulosRemito[j].cantidad); 231 // litros = litros + parseFloat(remito.articulosRemito[j].cantidad);
232 // } 232 // }
233 233
234 // if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) { 234 // if ($scope.hojaRuta.litros >= $scope.hojaRuta.vehiculo.capacidad) {
235 // focaModalService.alert( 235 // focaModalService.alert(
236 // 'Debe ingresar toda la información para el transporte' 236 // 'Debe ingresar toda la información para el transporte'
237 // ); 237 // );
238 // return; 238 // return;
239 // } 239 // }
240 240
241 //if($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad) 241 //if($scope.hojaRuta.litros + litros >= $scope.hojaRuta.vehiculo.capacidad)
242 // { 242 // {
243 // var litrostotales = litros; 243 // var litrostotales = litros;
244 // litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros; 244 // litros = $scope.hojaRuta.vehiculo.capacidad - $scope.hojaRuta.litros;
245 // focaModalService.alert( 245 // focaModalService.alert(
246 // 'La carga excede la capacidad disponible del vehiculo. ' + 246 // 'La carga excede la capacidad disponible del vehiculo. ' +
247 // 'Excedente no cargado: ' + (litrostotales - litros) + ' litros' 247 // 'Excedente no cargado: ' + (litrostotales - litros) + ' litros'
248 // ); 248 // );
249 // } 249 // }
250 250
251 // remito.litros = litros; 251 // remito.litros = litros;
252 // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros; 252 // $scope.hojaRuta.litros = $scope.hojaRuta.litros + litros;
253 $scope.cargarCisterna(remito.id).then(function() { 253 $scope.cargarCisterna(remito.id).then(function() {
254 $scope.remitosTabla.push(remito); 254 $scope.remitosTabla.push(remito);
255 $scope.seleccionarRemitos(); 255 $scope.seleccionarRemitos();
256 }, function() { 256 }, function() {
257 $scope.seleccionarRemitos(); 257 $scope.seleccionarRemitos();
258 }); 258 });
259 }, function() { 259 }, function() {
260 // funcion ejecutada cuando se cancela el modal 260 // funcion ejecutada cuando se cancela el modal
261 } 261 }
262 ); 262 );
263 }; 263 };
264 264
265 $scope.seleccionarVehiculosPrecargados = function() { 265 $scope.seleccionarVehiculosPrecargados = function() {
266 if(!eligioFecha()) return; 266 if(!eligioFecha()) return;
267 modalVehiculos(true); 267 modalVehiculos(true);
268 }; 268 };
269 269
270 $scope.cargarCisterna = function(idRemito) { 270 $scope.cargarCisterna = function(idRemito) {
271 if(!eligioFecha() || !$scope.hojaRuta.vehiculo.id) return; 271 if(!eligioFecha() || !$scope.hojaRuta.vehiculo.id) return;
272 var modalInstance = $uibModal.open( 272 var modalInstance = $uibModal.open(
273 { 273 {
274 ariaLabelledBy: 'Busqueda de Vehiculo', 274 ariaLabelledBy: 'Busqueda de Vehiculo',
275 templateUrl: 'foca-detalle-vehiculo.html', 275 templateUrl: 'foca-detalle-vehiculo.html',
276 controller: 'focaDetalleVehiculo', 276 controller: 'focaDetalleVehiculo',
277 size: 'lg', 277 size: 'lg',
278 resolve: { 278 resolve: {
279 idVehiculo: function() {return $scope.hojaRuta.vehiculo.id;}, 279 idVehiculo: function() {return $scope.hojaRuta.vehiculo.id;},
280 idRemito: function() {return idRemito;}, 280 idRemito: function() {return idRemito;},
281 fechaReparto: function() {return $scope.fechaReparto;} 281 fechaReparto: function() {return $scope.fechaReparto;}
282 } 282 }
283 } 283 }
284 ); 284 );
285 return modalInstance.result; 285 return modalInstance.result;
286 }; 286 };
287 287
288 $scope.seleccionarFechaEntrega = function() { 288 $scope.seleccionarFechaEntrega = function() {
289 if(!$scope.fechaReparto) { 289 if(!$scope.fechaReparto) {
290 elegirFecha(); 290 elegirFecha();
291 return; 291 return;
292 } 292 }
293 focaModalService 293 focaModalService
294 .confirm('Si cambia la fecha se perderán los datos actuales') 294 .confirm('Si cambia la fecha se perderán los datos actuales')
295 .then(function() { 295 .then(function() {
296 elegirFecha(); 296 elegirFecha();
297 }, function() { 297 }, function() {
298 return ; 298 return ;
299 }); 299 });
300 }; 300 };
301 301
302 $scope.seleccionarDatosExtra = function() { 302 $scope.seleccionarDatosExtra = function() {
303 var datosHojaRuta = $scope.hojaRuta.datosExtra; 303 var datosHojaRuta = $scope.hojaRuta.datosExtra;
304 var modalInstance = $uibModal.open( 304 var modalInstance = $uibModal.open(
305 { 305 {
306 templateUrl: 'foca-modal-datos-hoja-ruta.html', 306 templateUrl: 'foca-modal-datos-hoja-ruta.html',
307 controller: 'focaModalDatosHojaRutaCtrl', 307 controller: 'focaModalDatosHojaRutaCtrl',
308 size: 'lg', 308 size: 'lg',
309 resolve: { 309 resolve: {
310 parametrosDatos: function() { 310 parametrosDatos: function() {
311 return { 311 return {
312 datosHojaRuta: datosHojaRuta 312 datosHojaRuta: datosHojaRuta
313 }; 313 };
314 } 314 }
315 } 315 }
316 } 316 }
317 ); 317 );
318 return modalInstance.result.then(function(datosExtra) { 318 return modalInstance.result.then(function(datosExtra) {
319 $scope.hojaRuta.datosExtra = datosExtra; 319 $scope.hojaRuta.datosExtra = datosExtra;
320 }, function() { 320 }, function() {
321 //se ejecuta cuando se cancela el modal 321 //se ejecuta cuando se cancela el modal
322 }); 322 });
323 }; 323 };
324 324
325 $scope.desasociarRemito = function(key, idRemito) {
326 var idsRemito = [idRemito];
327 focaModalService.confirm('¿Está seguro que desea desasociar este remito del' +
328 ' vehículo?').then(function() {
329 focaCrearHojaRutaService.desasociarRemitos(idsRemito,
330 $scope.hojaRuta.vehiculo.id, $scope.remitosTabla.length <= 1).then(
331 function() {
332 $scope.remitosTabla.splice(key, 1);
333 focaModalService.alert('Remito desasociado con éxito');
334 }
335 );
336 });
337 };
338
325 function elegirFecha() { 339 function elegirFecha() {
326 focaModalService.modalFecha('Fecha de entrega').then(function(fecha) { 340 focaModalService.modalFecha('Fecha de entrega').then(function(fecha) {
327 $scope.$broadcast('addCabecera', { 341 $scope.$broadcast('addCabecera', {
328 label: 'Fecha de entrega:', 342 label: 'Fecha de entrega:',
329 valor: fecha.toLocaleDateString() 343 valor: fecha.toLocaleDateString()
330 }); 344 });
331 $scope.fechaReparto = fecha; 345 $scope.fechaReparto = fecha;
332 nuevaHojaRuta(); 346 nuevaHojaRuta();
333 }); 347 });
334 } 348 }
335 349
336 $scope.rellenar = function(relleno, longitud) { 350 $scope.rellenar = function(relleno, longitud) {
337 relleno = '' + relleno; 351 relleno = '' + relleno;
338 while (relleno.length < longitud) { 352 while (relleno.length < longitud) {
339 relleno = '0' + relleno; 353 relleno = '0' + relleno;
340 } 354 }
341 return relleno; 355 return relleno;
342 }; 356 };
343 357
344 function eligioPreConfirmado() { 358 function eligioPreConfirmado() {
345 if($scope.eligioPreConfirmado) { 359 if($scope.eligioPreConfirmado) {
346 focaModalService.alert('No puede elegir si eligió un vehiculo pre cargado'); 360 focaModalService.alert('No puede elegir si eligió un vehiculo pre cargado');
347 return true; 361 return true;
348 } 362 }
349 return false; 363 return false;
350 } 364 }
351 365
352 function eligioFecha() { 366 function eligioFecha() {
353 if(!$scope.fechaReparto) { 367 if(!$scope.fechaReparto) {
354 focaModalService.alert('Primero seleccione fecha de reparto'); 368 focaModalService.alert('Primero seleccione fecha de reparto');
355 return false; 369 return false;
356 } 370 }
357 return true; 371 return true;
358 } 372 }
359 373
360 function eligioVehiculo() { 374 function eligioVehiculo() {
361 if(!$scope.hojaRuta.vehiculo.id) { 375 if(!$scope.hojaRuta.vehiculo.id) {
362 focaModalService.alert('Primero seleccione vehiculo'); 376 focaModalService.alert('Primero seleccione vehiculo');
363 return false; 377 return false;
364 } 378 }
365 return true; 379 return true;
366 } 380 }
367 381
368 function modalVehiculos(preCargados) { 382 function modalVehiculos(preCargados) {
369 var query = ''; 383 var query = '';
370 var titulo = ''; 384 var titulo = '';
371 if(preCargados) { 385 if(preCargados) {
372 query = '/vehiculo/obtener/pre-confirmados/' + $scope.fechaReparto 386 query = '/vehiculo/obtener/pre-confirmados/' + $scope.fechaReparto
373 .toISOString().substring(0, 10); 387 .toISOString().substring(0, 10);
374 titulo = 'Búsqueda de vehiculos pre confirmados'; 388 titulo = 'Búsqueda de vehiculos pre confirmados';
375 }else { 389 }else {
376 query = '/vehiculo'; 390 query = '/vehiculo';
377 titulo = 'Búsqueda de vehículos'; 391 titulo = 'Búsqueda de vehículos';
378 } 392 }
379 var columnas = { 393 var columnas = {
380 nombre: ['Código', 'tractor', 'Semi'], 394 nombre: ['Código', 'tractor', 'Semi'],
381 propiedad: ['codigo', 'tractor', 'semi'] 395 propiedad: ['codigo', 'tractor', 'semi']
382 }; 396 };
383 focaModalService.modal(columnas, query, titulo).then(function(vehiculo) { 397 focaModalService.modal(columnas, query, titulo).then(function(vehiculo) {
384 $scope.hojaRuta.vehiculo = vehiculo; 398 $scope.hojaRuta.vehiculo = vehiculo;
385 $scope.hojaRuta.transportista = vehiculo.transportista; 399 $scope.hojaRuta.transportista = vehiculo.transportista;
386 if(preCargados) { 400 if(preCargados) {
387 $scope.eligioPreConfirmado = true; 401 $scope.eligioPreConfirmado = true;
388 $scope.hojaRuta.vehiculo = vehiculo; 402 $scope.hojaRuta.vehiculo = vehiculo;
389 $scope.$broadcast('addCabecera', { 403 $scope.$broadcast('addCabecera', {
390 label: 'Transportista:', 404 label: 'Transportista:',
391 valor: vehiculo.transportista.NOM 405 valor: vehiculo.transportista.NOM
392 }); 406 });
393 focaCrearHojaRutaService 407 focaCrearHojaRutaService
394 .getRemitosByIdVehiculo(vehiculo.id, $scope.fechaReparto) 408 .getRemitosByIdVehiculo(vehiculo.id, $scope.fechaReparto)
395 .then(function(res) { 409 .then(function(res) {
396 $scope.remitosTabla = res.data; 410 $scope.remitosTabla = res.data;
397 }); 411 });
398 } 412 }
399 $scope.$broadcast('addCabecera', { 413 $scope.$broadcast('addCabecera', {
400 label: 'Tractor:', 414 label: 'Tractor:',
401 valor: vehiculo.tractor 415 valor: vehiculo.tractor
402 }); 416 });
403 $scope.$broadcast('addCabecera', { 417 $scope.$broadcast('addCabecera', {
404 label: 'Semi:', 418 label: 'Semi:',
405 valor: vehiculo.semi 419 valor: vehiculo.semi
406 }); 420 });
407 $scope.$broadcast('addCabecera', { 421 $scope.$broadcast('addCabecera', {
408 label: 'Capacidad:', 422 label: 'Capacidad:',
409 valor: vehiculo.capacidad 423 valor: vehiculo.capacidad
410 }); 424 });
411 }); 425 });
412 } 426 }
413 } 427 }
414 ]); 428 ]);
415 429
1 angular.module('focaCrearHojaRuta') 1 angular.module('focaCrearHojaRuta')
2 .service('focaCrearHojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) { 2 .service('focaCrearHojaRutaService', ['$http', 'API_ENDPOINT', function($http, API_ENDPOINT) {
3 var route = API_ENDPOINT.URL; 3 var route = API_ENDPOINT.URL;
4 return { 4 return {
5 crearHojaRuta: function(hojaRuta) { 5 crearHojaRuta: function(hojaRuta) {
6 return $http.post(route + '/hoja-ruta', hojaRuta); 6 return $http.post(route + '/hoja-ruta', hojaRuta);
7 }, 7 },
8 obtenerHojaRuta: function() { 8 obtenerHojaRuta: function() {
9 return $http.get(route +'/hoja-ruta'); 9 return $http.get(route +'/hoja-ruta');
10 }, 10 },
11 setHojaRuta: function(hojaRuta) { 11 setHojaRuta: function(hojaRuta) {
12 this.hojaRuta = hojaRuta; 12 this.hojaRuta = hojaRuta;
13 }, 13 },
14 clearHojaRuta: function() { 14 clearHojaRuta: function() {
15 this.hojaRuta = undefined; 15 this.hojaRuta = undefined;
16 }, 16 },
17 getHojaRuta: function() { 17 getHojaRuta: function() {
18 return this.hojaRuta; 18 return this.hojaRuta;
19 }, 19 },
20 getArticulosByIdHojaRuta: function(id) { 20 getArticulosByIdHojaRuta: function(id) {
21 return $http.get(route+'/articulos/hoja-ruta/'+id); 21 return $http.get(route+'/articulos/hoja-ruta/'+id);
22 }, 22 },
23 crearArticulosParaHojaRuta: function(articuloHojaRuta) { 23 crearArticulosParaHojaRuta: function(articuloHojaRuta) {
24 return $http.post(route + '/articulos/hoja-ruta', 24 return $http.post(route + '/articulos/hoja-ruta',
25 {articuloHojaRuta: articuloHojaRuta}); 25 {articuloHojaRuta: articuloHojaRuta});
26 }, 26 },
27 getDomiciliosByIdHojaRuta: function(id) { 27 getDomiciliosByIdHojaRuta: function(id) {
28 return $http.get(route +'/hoja-ruta/' + id + '/domicilios'); 28 return $http.get(route +'/hoja-ruta/' + id + '/domicilios');
29 }, 29 },
30 getDomiciliosByIdCliente: function(id) { 30 getDomiciliosByIdCliente: function(id) {
31 var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega) 31 var idTipoEntrega = 2;//Solo traigo los domicilios que tienen tipo 2 (tipo entrega)
32 return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id ); 32 return $http.get(route + '/domicilio/tipo/' + idTipoEntrega + '/cliente/' + id );
33 }, 33 },
34 getPrecioCondicion: function() { 34 getPrecioCondicion: function() {
35 return $http.get(route + '/precio-condicion'); 35 return $http.get(route + '/precio-condicion');
36 }, 36 },
37 getPrecioCondicionById: function(id) { 37 getPrecioCondicionById: function(id) {
38 return $http.get(route + '/precio-condicion/' + id); 38 return $http.get(route + '/precio-condicion/' + id);
39 }, 39 },
40 getPlazoPagoByPrecioCondicion: function(id) { 40 getPlazoPagoByPrecioCondicion: function(id) {
41 return $http.get(route + '/plazo-pago/precio-condicion/' + id); 41 return $http.get(route + '/plazo-pago/precio-condicion/' + id);
42 }, 42 },
43 crearFlete: function(flete) { 43 crearFlete: function(flete) {
44 return $http.post(route + '/flete', {flete : flete}); 44 return $http.post(route + '/flete', {flete : flete});
45 }, 45 },
46 crearPlazosParaHojaRuta: function(plazos) { 46 crearPlazosParaHojaRuta: function(plazos) {
47 return $http.post(route + '/plazo-pago/hoja-ruta', plazos); 47 return $http.post(route + '/plazo-pago/hoja-ruta', plazos);
48 }, 48 },
49 getCotizacionByIdMoneda: function(id) { 49 getCotizacionByIdMoneda: function(id) {
50 return $http.get(route + '/moneda/' + id); 50 return $http.get(route + '/moneda/' + id);
51 }, 51 },
52 crearEstadoParaHojaRuta: function(estado) { 52 crearEstadoParaHojaRuta: function(estado) {
53 return $http.post(route + '/estado', {estado: estado}); 53 return $http.post(route + '/estado', {estado: estado});
54 }, 54 },
55 getNumeroHojaRuta: function() { 55 getNumeroHojaRuta: function() {
56 return $http.get(route + '/hoja-ruta/numero-siguiente'); 56 return $http.get(route + '/hoja-ruta/numero-siguiente');
57 }, 57 },
58 getRemitosByIdVehiculo: function(idVehiculo, fechaReparto) { 58 getRemitosByIdVehiculo: function(idVehiculo, fechaReparto) {
59 return $http.get(route + '/vehiculo/obtener/remitos/' + 59 return $http.get(route + '/vehiculo/obtener/remitos/' +
60 idVehiculo + '/' + fechaReparto.toISOString().substring(0, 10)); 60 idVehiculo + '/' + fechaReparto.toISOString().substring(0, 10));
61 }, 61 },
62 desasociarRemitos: function(idsRemitos, idVehiculo, sinRemitos) {
63 return $http.post(route + '/vehiculo/desasociar-remitos',
64 {
65 idsRemitos: idsRemitos,
66 idVehiculo: idVehiculo,
67 vehiculoSinRemitos: sinRemitos
68 });
69 },
62 getBotonera: function() { 70 getBotonera: function() {
63 return [ 71 return [
64 { 72 {
65 label: 'Fecha Entrega', 73 label: 'Fecha Entrega',
66 image: 'fechaDeReparto.png' 74 image: 'fechaDeReparto.png'
67 }, 75 },
68 { 76 {
69 label: 'Transportista', 77 label: 'Transportista',
70 image: 'transportista.png' 78 image: 'transportista.png'
71 }, 79 },
72 { 80 {
73 label: 'Chofer', 81 label: 'Chofer',
74 image: 'chofer.png' 82 image: 'chofer.png'
75 }, 83 },
76 { 84 {
77 label: 'Vehiculo', 85 label: 'Vehiculo',
78 image: 'vehiculos.png' 86 image: 'vehiculos.png'
79 }, 87 },
80 { 88 {
81 label: 'Tarifario', 89 label: 'Tarifario',
82 image: 'tarifario.png' 90 image: 'tarifario.png'
83 }, 91 },
84 { 92 {
85 label: 'Remitos', 93 label: 'Remitos',
86 image: 'remito.png' 94 image: 'remito.png'
87 }, 95 },
88 { 96 {
89 label: 'Vehiculos precargados', 97 label: 'Vehiculos precargados',
90 image: 'vehiculos.png' 98 image: 'vehiculos.png'
91 }, 99 },
92 { 100 {
93 label: 'Datos extra', 101 label: 'Datos extra',
94 image: 'tarifario.png' 102 image: 'tarifario.png'
95 } 103 }
96 ]; 104 ];
97 } 105 }
98 }; 106 };
99 }]); 107 }]);
100 108
src/views/hoja-ruta.html
1 <div class="crear-hoja-ruta foca-crear row"> 1 <div class="crear-hoja-ruta foca-crear row">
2 <foca-cabecera-facturador 2 <foca-cabecera-facturador
3 titulo="'Hoja de ruta'" 3 titulo="'Hoja de ruta'"
4 numero="puntoVenta + '-' + comprobante" 4 numero="puntoVenta + '-' + comprobante"
5 fecha="now" 5 fecha="now"
6 class="mb-0 col-lg-12" 6 class="mb-0 col-lg-12"
7 ></foca-cabecera-facturador> 7 ></foca-cabecera-facturador>
8 <div class="col-lg-12"> 8 <div class="col-lg-12">
9 <div class="row mt-4"> 9 <div class="row mt-4">
10 <div class="col-12 col-md-10 border border-light rounded"> 10 <div class="col-12 col-md-10 border border-light rounded">
11 <div class="row px-5 py-2 botonera-secundaria"> 11 <div class="row px-5 py-2 botonera-secundaria">
12 <div class="col-12"> 12 <div class="col-12">
13 <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador> 13 <foca-botonera-facturador botones="botonera" extra="4" class="row"></foca-botonera-facturador>
14 </div> 14 </div>
15 </div> 15 </div>
16 <!-- PC --> 16 <!-- PC -->
17 <div class="row grilla-articulo align-items-end d-none d-sm-flex"> 17 <div class="row grilla-articulo align-items-end d-none d-sm-flex">
18 <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom"> 18 <table class="table tabla-articulo table-striped table-sm mb-0 rounded-bottom">
19 <thead> 19 <thead>
20 <tr class="d-flex"> 20 <tr class="d-flex">
21 <th class="col-auto">#</th> 21 <th class="col-auto">#</th>
22 <th class="col-2">Remito</th> 22 <th class="col-2">Remito</th>
23 <th class="col">Cliente</th> 23 <th class="col">Cliente</th>
24 <th class="col">Dirección</th> 24 <th class="col">Dirección</th>
25 <th class="col-auto"> 25 <th class="col-auto">
26 <button 26 <button
27 class="btn btn-outline-light selectable" 27 class="btn btn-outline-light selectable"
28 ng-click="show = !show; masMenos()" 28 ng-click="show = !show; masMenos()"
29 > 29 >
30 <i 30 <i
31 class="fa fa-chevron-down" 31 class="fa fa-chevron-down"
32 ng-show="show" 32 ng-show="show"
33 aria-hidden="true" 33 aria-hidden="true"
34 > 34 >
35 </i> 35 </i>
36 <i 36 <i
37 class="fa fa-chevron-up" 37 class="fa fa-chevron-up"
38 ng-hide="show" 38 ng-hide="show"
39 aria-hidden="true"> 39 aria-hidden="true">
40 </i> 40 </i>
41 </button> 41 </button>
42 </th> 42 </th>
43 </th> 43 </th>
44 </tr> 44 </tr>
45 </thead> 45 </thead>
46 <tbody class="tabla-articulo-body"> 46 <tbody class="tabla-articulo-body">
47 <tr 47 <tr
48 ng-repeat="(key, remito) in remitosTabla" 48 ng-repeat="(key, remito) in remitosTabla"
49 class="d-flex" 49 class="d-flex"
50 ng-show="show || key == remitosTabla.length - 1" 50 ng-show="show || key == remitosTabla.length - 1"
51 > 51 >
52 <td ng-bind="key + 1" class="col-auto"></td> 52 <td ng-bind="key + 1" class="col-auto"></td>
53 <td 53 <td
54 class="col-2" 54 class="col-2"
55 ng-bind="rellenar(remito.sucursal, 4) + '-' + rellenar(remito.numeroRemito, 8)" 55 ng-bind="rellenar(remito.sucursal, 4) + '-' + rellenar(remito.numeroRemito, 8)"
56 ></td> 56 ></td>
57 <th class="col" ng-bind="remito.nombreCliente"></th> 57 <th class="col" ng-bind="remito.nombreCliente"></th>
58 <th class="col" ng-bind="remito.domicilioStamp"></th> 58 <th class="col" ng-bind="remito.domicilioStamp"></th>
59 <td class="text-center col-auto"> 59 <td class="text-center col-auto">
60 <button 60 <button
61 class="btn btn-outline-light" 61 class="btn btn-outline-light"
62 ng-click="quitarArticulo(key)" 62 ng-click="desasociarRemito(key, remito.id)"
63 > 63 >
64 <i class="fa fa-trash"></i> 64 <i class="fa fa-trash"></i>
65 </button> 65 </button>
66 </td> 66 </td>
67 </tr> 67 </tr>
68 </tbody> 68 </tbody>
69 <tfoot> 69 <tfoot>
70 <tr class="d-flex"> 70 <tr class="d-flex">
71 <td class="col-auto px-1"> 71 <td class="col-auto px-1">
72 <strong>Remitos:</strong> 72 <strong>Remitos:</strong>
73 <a ng-bind="remitosTabla.length"></a> 73 <a ng-bind="remitosTabla.length"></a>
74 </td> 74 </td>
75 <td class="col"></td> 75 <td class="col"></td>
76 <td class="col-auto px-1"> 76 <td class="col-auto px-1">
77 <strong>Cantidad:</strong> 77 <strong>Cantidad:</strong>
78 <a ng-bind="hojaRuta.litros"></a> 78 <a ng-bind="hojaRuta.litros"></a>
79 </td> 79 </td>
80 </tr> 80 </tr>
81 </tfoot> 81 </tfoot>
82 </table> 82 </table>
83 </div> 83 </div>
84 </div> 84 </div>
85 </div> 85 </div>
86 </div> 86 </div>
87 </div> 87 </div>
88 88