Commit 658aafc9a0683eca98f3c7aae451485f7937ac1d
Exists in
master
Merge branch 'master' into 'master'
Master(efernandez) See merge request !7
Showing
4 changed files
Show diff stats
src/js/controllerDetalleVehiculo.js
1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
2 | .controller('focaDetalleVehiculo', | 2 | .controller('focaDetalleVehiculo', |
3 | ['$scope', | 3 | ['$scope', |
4 | '$uibModalInstance', | 4 | '$uibModalInstance', |
5 | 'idVehiculo', | 5 | 'idVehiculo', |
6 | 'idRemito', | 6 | 'idRemito', |
7 | 'focaModalService', | 7 | 'focaModalService', |
8 | '$filter', | 8 | '$filter', |
9 | 'focaLogisticaPedidoRutaService', | 9 | 'focaLogisticaPedidoRutaService', |
10 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, | 10 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, |
11 | focaLogisticaPedidoRutaService | 11 | focaLogisticaPedidoRutaService |
12 | ) { | 12 | ) { |
13 | //seteo variables | 13 | //seteo variables |
14 | $scope.articulos = []; | 14 | $scope.articulos = []; |
15 | $scope.vehiculo = {}; | 15 | $scope.vehiculo = {}; |
16 | $scope.remito = {}; | 16 | $scope.remito = {}; |
17 | $scope.aCargar = []; | 17 | $scope.aCargar = []; |
18 | var cisternaMovimientos = []; | 18 | var cisternaMovimientos = []; |
19 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then( | 19 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then( |
20 | function(res) { | 20 | function(res) { |
21 | $scope.vehiculo = res.data; | 21 | $scope.vehiculo = res.data; |
22 | } | 22 | } |
23 | ); | 23 | ); |
24 | focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito).then( | 24 | focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito).then( |
25 | function(res) { | 25 | function(res) { |
26 | $scope.remito = res.data; | 26 | $scope.remito = res.data; |
27 | if($scope.remito.idUsuarioProceso && $scope.remito.idUsuarioProceso !== | 27 | if($scope.remito.idUsuarioProceso) { |
28 | focaLogisticaPedidoRutaService.idUsuario) | ||
29 | { | ||
30 | focaModalService.alert('El remito esta siendo cargado por otro usario'); | 28 | focaModalService.alert('El remito esta siendo cargado por otro usario'); |
31 | $uibModalInstance.close(); | 29 | $uibModalInstance.close(); |
32 | } | 30 | } |
33 | $scope.articulos = res.data.articulosRemito; | 31 | $scope.articulos = res.data.articulosRemito; |
34 | } | 32 | } |
35 | ); | 33 | ); |
36 | $scope.aceptar = function() { | 34 | $scope.aceptar = function() { |
37 | $scope.cargando = true; | 35 | $scope.cargando = true; |
38 | var cisternaCargas = []; | 36 | var cisternaCargas = []; |
39 | for (var i = 0; i < $scope.vehiculo.cisternas.length; i++) { | 37 | for (var i = 0; i < $scope.vehiculo.cisternas.length; i++) { |
40 | delete $scope.vehiculo.cisternas[i].cisternaCarga.articulo; | 38 | delete $scope.vehiculo.cisternas[i].cisternaCarga.articulo; |
41 | cisternaCargas.push($scope.vehiculo.cisternas[i].cisternaCarga); | 39 | cisternaCargas.push($scope.vehiculo.cisternas[i].cisternaCarga); |
42 | } | 40 | } |
43 | var cisterna = { | 41 | var cisterna = { |
44 | cisternaMovimientos: cisternaMovimientos, | 42 | cisternaMovimientos: cisternaMovimientos, |
45 | cisternaCargas: cisternaCargas, | 43 | cisternaCargas: cisternaCargas, |
46 | idVehiculo: $scope.vehiculo.id | 44 | idVehiculo: $scope.vehiculo.id |
47 | }; | 45 | }; |
48 | focaLogisticaPedidoRutaService.guardarCisternas(cisterna, $scope.remito.id) | 46 | focaLogisticaPedidoRutaService.guardarCisternas(cisterna, $scope.remito.id) |
49 | .then(function() { | 47 | .then(function() { |
50 | focaModalService.alert('Cisternas cargadas con éxito').then(function() { | 48 | focaModalService.alert('Cisternas cargadas con éxito').then(function() { |
51 | $scope.cargando = false; | 49 | $scope.cargando = false; |
52 | $uibModalInstance.close(); | 50 | $uibModalInstance.close(); |
53 | }); | 51 | }); |
54 | }).catch(function(error) { | 52 | }).catch(function(error) { |
55 | $scope.cargando = false; | 53 | $scope.cargando = false; |
56 | $uibModalInstance.close(); | 54 | $uibModalInstance.close(); |
57 | if (error.status === 403.1) { | 55 | if (error.status === 403.1) { |
58 | focaModalService.alert('ERROR: El vehículo esta en uso'); | 56 | focaModalService.alert('ERROR: El vehículo esta en uso'); |
59 | } | 57 | } |
60 | if(error.status === 403.2) { | 58 | if(error.status === 403.2) { |
61 | focaModalService.alert('ERROR: Otro usario ya cargó este remito'); | 59 | focaModalService.alert('ERROR: Otro usario ya cargó este remito'); |
62 | return; | 60 | return; |
63 | } | 61 | } |
64 | focaModalService.alert('Hubo un error al cargar las cisternas'); | 62 | focaModalService.alert('Hubo un error al cargar las cisternas'); |
65 | }); | 63 | }); |
66 | }; | 64 | }; |
67 | 65 | ||
68 | $scope.cancelar = function() { | 66 | $scope.cancelar = function() { |
69 | $uibModalInstance.close(); | 67 | $uibModalInstance.close(); |
70 | }; | 68 | }; |
71 | 69 | ||
72 | $scope.cargarACisternas = function(vehiculo) { | 70 | $scope.cargarACisternas = function(vehiculo) { |
73 | for(var i = 0; i < vehiculo.cisternas.length; i++) { | 71 | for(var i = 0; i < vehiculo.cisternas.length; i++) { |
74 | var cisterna = vehiculo.cisternas[i]; | 72 | var cisterna = vehiculo.cisternas[i]; |
75 | var aCargar = parseFloat($scope.aCargar[i]); | 73 | var aCargar = parseFloat($scope.aCargar[i]); |
76 | //validaciones | 74 | //validaciones |
77 | if(!aCargar) { | 75 | if(!aCargar) { |
78 | continue; | 76 | continue; |
79 | } | 77 | } |
80 | if(aCargar > cisterna.disponible) { | 78 | if(aCargar > cisterna.disponible) { |
81 | focaModalService.alert('La cantidad cargada supera la capacidad de la' + | 79 | focaModalService.alert('La cantidad cargada supera la capacidad de la' + |
82 | 'cisterna ' + cisterna.codigo); | 80 | 'cisterna ' + cisterna.codigo); |
83 | return; | 81 | return; |
84 | } | 82 | } |
85 | //cargar | 83 | //cargar |
86 | if(cisterna.cisternaCarga.cantidad) { | 84 | if(cisterna.cisternaCarga.cantidad) { |
87 | cisterna.cisternaCarga.cantidad += aCargar; | 85 | cisterna.cisternaCarga.cantidad += aCargar; |
88 | }else { | 86 | }else { |
89 | cisterna.cisternaCarga.cantidad = aCargar; | 87 | cisterna.cisternaCarga.cantidad = aCargar; |
90 | cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.idArticulo; | 88 | cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.idArticulo; |
91 | } | 89 | } |
92 | cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad; | 90 | cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad; |
93 | 91 | ||
94 | cisterna.cisternaCarga.articulo = { | 92 | cisterna.cisternaCarga.articulo = { |
95 | DetArt: $scope.articuloSeleccionado.descripcion | 93 | DetArt: $scope.articuloSeleccionado.descripcion |
96 | }; | 94 | }; |
97 | $filter('filter')($scope.articulos, {id: $scope.articuloSeleccionado.id})[0] | 95 | $filter('filter')($scope.articulos, {id: $scope.articuloSeleccionado.id})[0] |
98 | .cargado = true; | 96 | .cargado = true; |
99 | 97 | ||
100 | $scope.calcularPorcentaje(cisterna); | 98 | $scope.calcularPorcentaje(cisterna); |
101 | //Guardar | 99 | //Guardar |
102 | var now = new Date(); | 100 | var now = new Date(); |
103 | var cisternaMovimiento = { | 101 | var cisternaMovimiento = { |
104 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), | 102 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), |
105 | cantidad: aCargar, | 103 | cantidad: aCargar, |
106 | metodo: 'carga', | 104 | metodo: 'carga', |
107 | idCisternaCarga: cisterna.cisternaCarga.id, | 105 | idCisternaCarga: cisterna.cisternaCarga.id, |
108 | idRemito: $scope.remito.id | 106 | idRemito: $scope.remito.id |
109 | }; | 107 | }; |
110 | cisternaMovimientos.push(cisternaMovimiento); | 108 | cisternaMovimientos.push(cisternaMovimiento); |
111 | } | 109 | } |
112 | var articuloSiguiente = $scope.articulos.filter( | 110 | var articuloSiguiente = $scope.articulos.filter( |
113 | function(filter) { | 111 | function(filter) { |
114 | return filter.cargado !== true; | 112 | return filter.cargado !== true; |
115 | } | 113 | } |
116 | ); | 114 | ); |
117 | if(articuloSiguiente.length > 0) { | 115 | if(articuloSiguiente.length > 0) { |
118 | $scope.cambioArticulo(articuloSiguiente[0]); | 116 | $scope.cambioArticulo(articuloSiguiente[0]); |
119 | } | 117 | } |
120 | $scope.aCargar = []; | 118 | $scope.aCargar = []; |
121 | }; | 119 | }; |
122 | $scope.calcularPorcentaje = function(cisterna) { | 120 | $scope.calcularPorcentaje = function(cisterna) { |
123 | if(!cisterna.cisternaCarga.cantidad) { | 121 | if(!cisterna.cisternaCarga.cantidad) { |
124 | cisterna.cisternaCarga.cantidad = 0; | 122 | cisterna.cisternaCarga.cantidad = 0; |
125 | } | 123 | } |
126 | var porcentaje = (cisterna.cisternaCarga.cantidad * 100 / | 124 | var porcentaje = (cisterna.cisternaCarga.cantidad * 100 / |
127 | cisterna.capacidad) + '%'; | 125 | cisterna.capacidad) + '%'; |
128 | var elementHtml = document.getElementById(cisterna.id); | 126 | var elementHtml = document.getElementById(cisterna.id); |
129 | if(elementHtml) { | 127 | if(elementHtml) { |
130 | elementHtml.style.width = porcentaje; | 128 | elementHtml.style.width = porcentaje; |
131 | } | 129 | } |
132 | }; | 130 | }; |
133 | $scope.cambioArticulo = function(articulo) { | 131 | $scope.cambioArticulo = function(articulo) { |
134 | articulo.checked = true; | 132 | articulo.checked = true; |
135 | $scope.articuloSeleccionado = articulo; | 133 | $scope.articuloSeleccionado = articulo; |
136 | }; | 134 | }; |
137 | $scope.actualizarArticulo = function () { | 135 | $scope.actualizarArticulo = function () { |
138 | $scope.articuloSeleccionado.cantidadCargada = 0; | 136 | $scope.articuloSeleccionado.cantidadCargada = 0; |
139 | for (var i = 0; i < $scope.aCargar.length; i++) { | 137 | for (var i = 0; i < $scope.aCargar.length; i++) { |
140 | $scope.articuloSeleccionado.cantidadCargada += | 138 | $scope.articuloSeleccionado.cantidadCargada += |
141 | parseFloat($scope.aCargar[i]) || 0; | 139 | parseFloat($scope.aCargar[i]) || 0; |
142 | } | 140 | } |
143 | }; | 141 | }; |
144 | $scope.tieneArticulosPendientes = function() { | 142 | $scope.tieneArticulosPendientes = function() { |
145 | var articulosDescargados = $scope.articulos.filter(function(filter) { | 143 | var articulosDescargados = $scope.articulos.filter(function(filter) { |
146 | return filter.cargado === true; | 144 | return filter.cargado === true; |
147 | }); | 145 | }); |
148 | if(articulosDescargados.length === $scope.articulos.length) { | 146 | if(articulosDescargados.length === $scope.articulos.length) { |
149 | return false; | 147 | return false; |
150 | } | 148 | } |
151 | return true; | 149 | return true; |
152 | }; | 150 | }; |
153 | }]); | 151 | }]); |
154 | 152 |
src/js/controllerHojaRuta.js
1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
2 | .controller('focaModalCrearHojaRuta', [ | 2 | .controller('focaModalCrearHojaRuta', [ |
3 | '$scope', | 3 | '$scope', |
4 | '$uibModalInstance', | 4 | '$uibModalInstance', |
5 | '$uibModal', | 5 | '$uibModal', |
6 | 'focaLogisticaPedidoRutaService', | 6 | 'focaLogisticaPedidoRutaService', |
7 | 'idVehiculo', | 7 | 'idVehiculo', |
8 | 'focaModalService', | 8 | 'focaModalService', |
9 | '$filter', | 9 | '$filter', |
10 | function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService, | 10 | function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService, |
11 | idVehiculo, focaModalService, $filter) { | 11 | idVehiculo, focaModalService, $filter) { |
12 | $scope.vehiculo = {}; | 12 | $scope.vehiculo = {}; |
13 | $scope.remitos = []; | 13 | $scope.remitos = []; |
14 | $scope.now = new Date(); | 14 | $scope.now = new Date(); |
15 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) { | 15 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) { |
16 | $scope.vehiculo = res.data; | 16 | $scope.vehiculo = res.data; |
17 | }); | 17 | }); |
18 | //TODO: refactor código esta rre feo | 18 | //TODO: refactor código esta rre feo |
19 | focaLogisticaPedidoRutaService.getRemitos(idVehiculo).then(function(res) { | 19 | focaLogisticaPedidoRutaService.getRemitos(idVehiculo).then(function(res) { |
20 | $scope.remitos = focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data); | 20 | $scope.remitos = focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data); |
21 | }); | 21 | }); |
22 | 22 | ||
23 | focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { | 23 | focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { |
24 | $scope.sucursal = res.data.sucursal; | 24 | $scope.sucursal = res.data.sucursal; |
25 | $scope.numero = res.data.numeroHojaRuta; | 25 | $scope.numero = res.data.numeroHojaRuta; |
26 | }); | 26 | }); |
27 | $scope.cancelar = function() { | 27 | $scope.cancelar = function() { |
28 | $uibModalInstance.close(); | 28 | $uibModalInstance.close(); |
29 | }; | 29 | }; |
30 | $scope.aceptar = function() { | 30 | $scope.aceptar = function() { |
31 | var save = { | 31 | var save = { |
32 | hojaRuta: { | 32 | hojaRuta: { |
33 | id: 0, | 33 | id: 0, |
34 | fechaCreacion: $scope.now.toISOString().slice(0, 19).replace('T', ' '), | 34 | fechaCreacion: $scope.now.toISOString().slice(0, 19).replace('T', ' '), |
35 | idTransportista: $scope.vehiculo.idTransportista, | 35 | idTransportista: $scope.vehiculo.idTransportista, |
36 | idChofer: $scope.chofer.id, | 36 | idChofer: $scope.chofer.id, |
37 | idVehiculo: $scope.vehiculo.id, | 37 | idVehiculo: $scope.vehiculo.id, |
38 | tarifaFlete: $scope.tarifaFlete | 38 | tarifaFlete: $scope.tarifaFlete |
39 | }, | 39 | }, |
40 | remitos: $scope.remitos, | 40 | remitos: $scope.remitos, |
41 | idVehiculo: $scope.vehiculo.id | 41 | idVehiculo: $scope.vehiculo.id |
42 | }; | 42 | }; |
43 | focaLogisticaPedidoRutaService.crearHojaRuta(save).then(function() { | 43 | focaLogisticaPedidoRutaService.crearHojaRuta(save).then(function() { |
44 | $uibModalInstance.close(); | 44 | $uibModalInstance.close(); |
45 | focaModalService.alert('Hoja de ruta guardada con éxito'); | 45 | focaModalService.alert('Hoja de ruta guardada con éxito'); |
46 | }); | 46 | }); |
47 | }; | 47 | }; |
48 | $scope.seleccionarChofer = function() { | 48 | $scope.seleccionarChofer = function() { |
49 | var modalInstance = $uibModal.open( | 49 | var modalInstance = $uibModal.open( |
50 | { | 50 | { |
51 | ariaLabelledBy: 'Busqueda de Chofer', | 51 | ariaLabelledBy: 'Busqueda de Chofer', |
52 | templateUrl: 'modal-chofer.html', | 52 | templateUrl: 'modal-chofer.html', |
53 | controller: 'focaModalChoferController', | 53 | controller: 'focaModalChoferController', |
54 | size: 'lg' | 54 | size: 'lg' |
55 | } | 55 | } |
56 | ); | 56 | ); |
57 | 57 | ||
58 | modalInstance.result.then( | 58 | modalInstance.result.then( |
59 | function(chofer) { | 59 | function(chofer) { |
60 | $scope.chofer = chofer; | 60 | $scope.chofer = chofer; |
61 | }, function() { | 61 | }, function() { |
62 | // funcion ejecutada cuando se cancela el modal | 62 | // funcion ejecutada cuando se cancela el modal |
63 | } | 63 | } |
64 | ); | 64 | ); |
65 | }; | 65 | }; |
66 | $scope.eliminarRemitos = function() { | ||
67 | var remitosDel = $filter('filter')($scope.remitos, {checked: true}); | ||
68 | focaModalService.alert('¿Seguro que desea desasociar estos remitos del vehículo?') | ||
69 | .then(function() { | ||
70 | eliminarRemitos(remitosDel); | ||
71 | } | ||
72 | ); | ||
73 | }; | ||
74 | $scope.minimoUnoChecked = function() { | ||
75 | var remitosChequeados = $filter('filter')($scope.remitos, {checked: true}); | ||
76 | return !remitosChequeados.length; | ||
77 | }; | ||
78 | function eliminarRemitos(remitosDel) { | ||
79 | var nuevosRemitos = $filter('filter')($scope.remitos, {checked: !true}); | ||
80 | focaLogisticaPedidoRutaService.desasociarRemitos(remitosDel, $scope.vehiculo.id, | ||
81 | nuevosRemitos ? true : false).then(function() { | ||
82 | focaModalService.alert('Remitos desasociados con éxito'); | ||
83 | $scope.remitos = nuevosRemitos; | ||
84 | }); | ||
85 | } | ||
66 | }]); | 86 | }]); |
67 | 87 |
src/js/service.js
1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
2 | .service( | 2 | .service( |
3 | 'focaLogisticaPedidoRutaService', [ | 3 | 'focaLogisticaPedidoRutaService', [ |
4 | '$http', | 4 | '$http', |
5 | '$cookies', | 5 | '$cookies', |
6 | 'API_ENDPOINT', | 6 | 'API_ENDPOINT', |
7 | '$filter', | 7 | '$filter', |
8 | function($http, $cookies, API_ENDPOINT, $filter) { | 8 | function($http, $cookies, API_ENDPOINT, $filter) { |
9 | return { | 9 | return { |
10 | idUsuario: $cookies.get('idUsuario'), | 10 | idUsuario: $cookies.get('idUsuario'), |
11 | obtenerActividad: function(parametros) { | 11 | obtenerActividad: function(parametros) { |
12 | return $http.post(API_ENDPOINT.URL + '/seguimiento/filtros', parametros); | 12 | return $http.post(API_ENDPOINT.URL + '/seguimiento/filtros', parametros); |
13 | }, | 13 | }, |
14 | obtenerVehiculoById: function(idVehiculo) { | 14 | obtenerVehiculoById: function(idVehiculo) { |
15 | return $http.get(API_ENDPOINT.URL + '/vehiculo/' + idVehiculo); | 15 | return $http.get(API_ENDPOINT.URL + '/vehiculo/' + idVehiculo); |
16 | }, | 16 | }, |
17 | obtenerRemitoById: function(idRemito) { | 17 | obtenerRemitoById: function(idRemito) { |
18 | return $http.get(API_ENDPOINT.URL + '/remito/obtener/' + idRemito); | 18 | return $http.get(API_ENDPOINT.URL + '/remito/obtener/' + idRemito); |
19 | }, | 19 | }, |
20 | guardarCisternas: function(cisterna, idRemito) { | 20 | guardarCisternas: function(cisterna, idRemito) { |
21 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' + | 21 | return $http.post(API_ENDPOINT.URL + '/cisterna/guardar/cargar/' + |
22 | this.idUsuario + '/' + idRemito,cisterna); | 22 | this.idUsuario + '/' + idRemito,cisterna); |
23 | }, | 23 | }, |
24 | numeroHojaRuta: function() { | 24 | numeroHojaRuta: function() { |
25 | return $http.get(API_ENDPOINT.URL + '/hoja-ruta/numero-siguiente'); | 25 | return $http.get(API_ENDPOINT.URL + '/hoja-ruta/numero-siguiente'); |
26 | }, | 26 | }, |
27 | getRemitos: function(idVehiculo) { | 27 | getRemitos: function(idVehiculo) { |
28 | return $http.get(API_ENDPOINT.URL + '/remito/sin-hoja-ruta/' +idVehiculo); | 28 | return $http.get(API_ENDPOINT.URL + '/remito/sin-hoja-ruta/' +idVehiculo); |
29 | }, | 29 | }, |
30 | crearHojaRuta: function(hojaRuta) { | 30 | crearHojaRuta: function(hojaRuta) { |
31 | return $http.post(API_ENDPOINT.URL + '/hoja-ruta', hojaRuta); | 31 | return $http.post(API_ENDPOINT.URL + '/hoja-ruta', hojaRuta); |
32 | }, | 32 | }, |
33 | desasociarRemitos: function(remitos, idVehiculo, sinRemitos) { | ||
34 | var idsRemitos = []; | ||
35 | for (var i = 0; i < remitos.length; i++) { | ||
36 | idsRemitos.push(remitos[i].id); | ||
37 | } | ||
38 | return $http.post(API_ENDPOINT.URL + '/vehiculo/desasociar-remitos', | ||
39 | { | ||
40 | idsRemitos: idsRemitos, | ||
41 | idVehiculo: idVehiculo, | ||
42 | vehiculoSinRemitos: sinRemitos | ||
43 | }); | ||
44 | }, | ||
33 | obtenerRemitosDeCarga: function(remitos) { | 45 | obtenerRemitosDeCarga: function(remitos) { |
34 | var remitosRes = []; | 46 | var remitosRes = []; |
35 | for(var i = 0; i < remitos.cisternas.length; i++) { | 47 | for(var i = 0; i < remitos.cisternas.length; i++) { |
36 | procesoCistena(remitos.cisternas[i]); | 48 | procesoCistena(remitos.cisternas[i]); |
37 | } | 49 | } |
38 | function procesoCistena(cisterna) { | 50 | function procesoCistena(cisterna) { |
39 | for(var j = 0; j < cisterna.cisternaCarga.cisternaMovimientos.length; | 51 | for(var j = 0; j < cisterna.cisternaCarga.cisternaMovimientos.length; |
40 | j++) { | 52 | j++) { |
41 | procesoMovimiento( | 53 | procesoMovimiento( |
42 | cisterna.cisternaCarga.cisternaMovimientos[j]); | 54 | cisterna.cisternaCarga.cisternaMovimientos[j]); |
43 | } | 55 | } |
44 | } | 56 | } |
45 | function procesoMovimiento(movimiento) { | 57 | function procesoMovimiento(movimiento) { |
46 | if(movimiento.remito && !movimiento.remito.idHojaRuta) { | 58 | if(!movimiento.anulado && movimiento.remito && |
59 | !movimiento.remito.idHojaRuta) { | ||
47 | var remito = movimiento.remito; | 60 | var remito = movimiento.remito; |
48 | var yaEstaCargado = $filter('filter')(remitosRes, {id: remito.id}); | 61 | var yaEstaCargado = $filter('filter')(remitosRes, {id: remito.id}); |
49 | if(!yaEstaCargado.length && movimiento.metodo === 'carga') { | 62 | if(!yaEstaCargado.length && movimiento.metodo === 'carga') { |
50 | remitosRes.push(remito); | 63 | remitosRes.push(remito); |
51 | } | 64 | } |
52 | } | 65 | } |
53 | } | 66 | } |
54 | return remitosRes; | 67 | return remitosRes; |
55 | } | 68 | } |
56 | }; | 69 | }; |
57 | }]); | 70 | }]); |
58 | 71 |
src/views/foca-modal-crear-hoja-ruta.html
1 | <div class="modal-header"> | 1 | <div class="modal-header"> |
2 | <h4>-en desarrollo</h4> | 2 | <h4>-en desarrollo</h4> |
3 | <h4>Confeccionar hoja de ruta</h4> | 3 | <h4>Confeccionar hoja de ruta</h4> |
4 | Hoja de ruta Nº <strong ng-bind="[sucursal, numero] | comprobante"></strong> | 4 | Hoja de ruta Nº <strong ng-bind="[sucursal, numero] | comprobante"></strong> |
5 | Fecha: | 5 | Fecha: |
6 | <input | 6 | <input |
7 | type="date" | 7 | type="date" |
8 | ng-model="now" | 8 | ng-model="now" |
9 | class="form-control form-control-sm col-3 float-right" | 9 | class="form-control form-control-sm col-3 float-right" |
10 | /> | 10 | /> |
11 | <br> | 11 | <br> |
12 | </div> | 12 | </div> |
13 | <div class="modal-body"> | 13 | <div class="modal-body"> |
14 | <form class="row" name="formHojaRuta"> | 14 | <form class="row" name="formHojaRuta"> |
15 | 15 | ||
16 | 16 | ||
17 | <div class="col-2 form-group"> | 17 | <div class="col-2 form-group"> |
18 | <label>Vehículo</label> | 18 | <label>Vehículo</label> |
19 | </div> | 19 | </div> |
20 | <div class="col-4"> | 20 | <div class="col-4"> |
21 | <input | 21 | <input |
22 | class="form-control" | 22 | class="form-control" |
23 | readonly | 23 | readonly |
24 | ng-model="vehiculo.tractor" | 24 | ng-model="vehiculo.tractor" |
25 | > | 25 | > |
26 | </div> | 26 | </div> |
27 | <div class="col-2"> | 27 | <div class="col-2"> |
28 | <label>Transportista</label> | 28 | <label>Transportista</label> |
29 | </div> | 29 | </div> |
30 | <div class="col-4"> | 30 | <div class="col-4"> |
31 | <input | 31 | <input |
32 | class="form-control" | 32 | class="form-control" |
33 | readonly | 33 | readonly |
34 | ng-model="vehiculo.transportista.NOM" | 34 | ng-model="vehiculo.transportista.NOM" |
35 | > | 35 | > |
36 | </div> | 36 | </div> |
37 | <div class="col-2 form-group"> | 37 | <div class="col-2 form-group"> |
38 | <label>Chofer</label> | 38 | <label>Chofer</label> |
39 | </div> | 39 | </div> |
40 | <div class="col-4 input-group"> | 40 | <div class="col-4 input-group"> |
41 | <input | 41 | <input |
42 | class="form-control" | 42 | class="form-control" |
43 | ng-model="chofer.nombre" | 43 | ng-model="chofer.nombre" |
44 | ng-click="seleccionarChofer()" | 44 | ng-click="seleccionarChofer()" |
45 | ng-required="true" | 45 | ng-required="true" |
46 | > | 46 | > |
47 | <div class="input-group-append"> | 47 | <div class="input-group-append"> |
48 | <button | 48 | <button |
49 | class="brn btn-outline-secondary form-control" | 49 | class="brn btn-outline-secondary form-control" |
50 | ng-click="seleccionarChofer()" | 50 | ng-click="seleccionarChofer()" |
51 | ><i class="fa fa-search"></i> | 51 | ><i class="fa fa-search"></i> |
52 | </button> | 52 | </button> |
53 | </div> | 53 | </div> |
54 | </div> | 54 | </div> |
55 | <div class="col-2"> | 55 | <div class="col-2"> |
56 | <label>Tarifa</label> | 56 | <label>Tarifa</label> |
57 | </div> | 57 | </div> |
58 | <div class="col-4"> | 58 | <div class="col-4"> |
59 | <input | 59 | <input |
60 | class="form-control" | 60 | class="form-control" |
61 | ng-model="tarifaFlete" | 61 | ng-model="tarifaFlete" |
62 | ng-required="true" | 62 | ng-required="true" |
63 | foca-teclado | 63 | foca-teclado |
64 | foca-tipo-input | 64 | foca-tipo-input |
65 | > | 65 | > |
66 | </div> | 66 | </div> |
67 | </form> | 67 | </form> |
68 | <strong>Remitos:</strong> | 68 | <strong>Remitos:</strong> |
69 | <table class="table"> | 69 | <table class="table"> |
70 | <thead> | 70 | <thead> |
71 | <tr> | 71 | <tr> |
72 | <th>Remito Nº</th> | 72 | <th>Remito Nº</th> |
73 | <th>Cliente</th> | 73 | <th>Cliente</th> |
74 | <th>Domicilio</th> | 74 | <th>Domicilio</th> |
75 | </tr> | 75 | </tr> |
76 | </thead> | 76 | </thead> |
77 | <tbody> | 77 | <tbody> |
78 | <tr ng-show="!remitos.length"> | 78 | <tr ng-show="!remitos.length"> |
79 | <td colspan="3"> | 79 | <td colspan="3"> |
80 | No se han encontrado remitos. | 80 | No se han encontrado remitos. |
81 | </td> | 81 | </td> |
82 | </tr> | 82 | </tr> |
83 | <tr ng-repeat="remito in remitos"> | 83 | <tr ng-repeat="remito in remitos"> |
84 | <td ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></td> | 84 | <td ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></td> |
85 | <td ng-bind="remito.nombreCliente"></td> | 85 | <td ng-bind="remito.nombreCliente"></td> |
86 | <td ng-bind="remito.domicilioStamp"></td> | 86 | <td ng-bind="remito.domicilioStamp"></td> |
87 | </tr> | 87 | <td> |
88 | <div class="custom-control custom-checkbox"> | ||
89 | <input | ||
90 | type="checkbox" | ||
91 | ng-model="remito.checked" | ||
92 | class="custom-control-input" | ||
93 | id="{{remito.id}}"> | ||
94 | <label class="custom-control-label" for="{{remito.id}}"></label> | ||
95 | </div> | ||
96 | </td> | ||
97 | </tr> | ||
88 | </tbody> | 98 | </tbody> |
89 | </table> | 99 | </table> |
90 | </div> | 100 | </div> |
91 | <div class="modal-footer py-1"> | 101 | <div class="modal-footer py-1"> |
92 | <button | 102 | <button |
103 | class="btn btn-sm btn-danger" | ||
104 | type="button" | ||
105 | ng-click="eliminarRemitos()" | ||
106 | ng-disabled="minimoUnoChecked()">Eliminar</button> | ||
107 | <button | ||
93 | class="btn btn-sm btn-secondary" | 108 | class="btn btn-sm btn-secondary" |
94 | ladda="cargando" | 109 | ladda="cargando" |
95 | type="button" | 110 | type="button" |
96 | ng-click="cancelar()">Cancelar</button> | 111 | ng-click="cancelar()">Cancelar</button> |
97 | <button | 112 | <button |
98 | class="btn btn-sm btn-primary" | 113 | class="btn btn-sm btn-primary" |
99 | ladda="cargando" | 114 | ladda="cargando" |
100 | type="button" | 115 | type="button" |
101 | ng-disabled="!formHojaRuta.$valid || !remitos.length" | 116 | ng-disabled="!formHojaRuta.$valid || !remitos.length" |
102 | ng-click="aceptar()">Crear hoja ruta</button> | 117 | ng-click="aceptar()">Crear hoja ruta</button> |
103 | </div> | 118 | </div> |
104 | 119 |