Commit 6a7d373bab7564fe4b6e6a09cf56dac1ff2aff93
Exists in
master
Merge remote-tracking branch 'upstream/master'
Showing
7 changed files
Show diff stats
src/js/controller.js
1 | angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaController', [ | 1 | angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaController', [ |
2 | '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter', | 2 | '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter', |
3 | 'focaModalService', 'focaBotoneraLateralService', '$interval', | 3 | 'focaModalService', 'focaBotoneraLateralService', '$interval', |
4 | function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, | 4 | function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, |
5 | focaModalService, focaBotoneraLateralService, $interval | 5 | focaModalService, focaBotoneraLateralService, $interval |
6 | ) { | 6 | ) { |
7 | $scope.actividad = 'Logistica'; | 7 | $scope.actividad = 'Logistica'; |
8 | 8 | ||
9 | //Datos Pantalla | 9 | //Datos Pantalla |
10 | $scope.titulo = 'Logistica de Pedidos'; | 10 | $scope.titulo = 'Logistica de Pedidos'; |
11 | var transportista = { | 11 | var transportista = { |
12 | label: 'Vehículo', | 12 | label: 'Vehículo', |
13 | image: 'abmChofer.png' | 13 | image: 'abmChofer.png' |
14 | }; | 14 | }; |
15 | var fecha = { | 15 | var fecha = { |
16 | label: 'Fecha Reparto', | 16 | label: 'Fecha Reparto', |
17 | image: 'fechaDeReparto.png' | 17 | image: 'fechaDeReparto.png' |
18 | }; | 18 | }; |
19 | $scope.botonera = [fecha, transportista]; | 19 | $scope.botonera = [fecha, transportista]; |
20 | var cabecera = ''; | 20 | var cabecera = ''; |
21 | $scope.now = new Date(); | 21 | $scope.now = new Date(); |
22 | $scope.idVendedor = 0; | 22 | $scope.idVendedor = 0; |
23 | $scope.marcadores = []; | 23 | $scope.marcadores = []; |
24 | $scope.vehiculos = []; | 24 | $scope.vehiculos = []; |
25 | getSeguimiento(); | 25 | getSeguimiento(); |
26 | $scope.arrastrando = false; | 26 | $scope.arrastrando = false; |
27 | $scope.general = function() { | 27 | $scope.general = function() { |
28 | $scope.idVendedor = 0; | 28 | $scope.idVendedor = 0; |
29 | getSeguimiento(); | 29 | getSeguimiento(); |
30 | }; | 30 | }; |
31 | 31 | ||
32 | //SETEO BOTONERA LATERAL | 32 | //SETEO BOTONERA LATERAL |
33 | focaBotoneraLateralService.showSalir(true); | 33 | focaBotoneraLateralService.showSalir(true); |
34 | focaBotoneraLateralService.showPausar(false); | 34 | focaBotoneraLateralService.showPausar(false); |
35 | focaBotoneraLateralService.showGuardar(false); | 35 | focaBotoneraLateralService.showGuardar(false); |
36 | 36 | ||
37 | 37 | ||
38 | 38 | ||
39 | $scope.general = function() { | 39 | $scope.general = function() { |
40 | $scope.idVendedor = 0; | 40 | $scope.idVendedor = 0; |
41 | getSeguimiento(); | 41 | getSeguimiento(); |
42 | $scope.$broadcast('removeCabecera', cabecera); | 42 | $scope.$broadcast('removeCabecera', cabecera); |
43 | $scope.$broadcast('addCabecera',{ | 43 | $scope.$broadcast('addCabecera', { |
44 | label: 'General', | 44 | label: 'General', |
45 | valor: '' | 45 | valor: '' |
46 | }); | 46 | }); |
47 | }; | 47 | }; |
48 | 48 | ||
49 | $scope.cargar = function(idVehiculo, punto) { | 49 | $scope.cargar = function(idVehiculo, punto) { |
50 | if(!$scope.fechaReparto) { | 50 | if(!eligioFecha()) return; |
51 | focaModalService.alert('Primero seleccione fecha de reparto'); | ||
52 | return; | ||
53 | } | ||
54 | var idRemito; | 51 | var idRemito; |
55 | if(punto === -1) { | 52 | if(punto === -1) { |
56 | idRemito = -1; | 53 | idRemito = -1; |
57 | }else { | 54 | }else { |
58 | idRemito = JSON.parse(punto).notaPedido.remito.id; | 55 | idRemito = JSON.parse(punto).notaPedido.remito.id; |
59 | } | 56 | } |
60 | var modalInstance = $uibModal.open( | 57 | var modalInstance = $uibModal.open( |
61 | { | 58 | { |
62 | ariaLabelledBy: 'Busqueda de Vehiculo', | 59 | ariaLabelledBy: 'Busqueda de Vehiculo', |
63 | templateUrl: 'foca-detalle-vehiculo.html', | 60 | templateUrl: 'foca-detalle-vehiculo.html', |
64 | controller: 'focaDetalleVehiculo', | 61 | controller: 'focaDetalleVehiculo', |
65 | size: 'lg', | 62 | size: 'lg', |
66 | resolve: { | 63 | resolve: { |
67 | idVehiculo: function() {return idVehiculo;}, | 64 | idVehiculo: function() {return idVehiculo;}, |
68 | idRemito: function() {return idRemito;}, | 65 | idRemito: function() {return idRemito;}, |
69 | fechaReparto: function() {return $scope.fechaReparto;} | 66 | fechaReparto: function() {return $scope.fechaReparto;} |
70 | } | 67 | } |
71 | } | 68 | } |
72 | ); | 69 | ); |
73 | modalInstance.result.then(function() { | 70 | modalInstance.result.then(function() { |
74 | }, function() { | 71 | }, function() { |
75 | }); | 72 | }); |
76 | }; | 73 | }; |
77 | 74 | ||
78 | $scope.quitarVehiculo = function(vehiculo) { | 75 | $scope.quitarVehiculo = function(vehiculo) { |
79 | //TODO: Pasar validación a función | 76 | if(!eligioFecha() || vehiculoEnUso(vehiculo)) return; |
80 | $scope.fechaReparto.setHours(0, 0, 0, 0); | ||
81 | var idUsuario = focaLogisticaPedidoRutaService.idUsuario; | ||
82 | for(var i = 0; i < vehiculo.cisternas.length; i++) { | ||
83 | for(var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | ||
84 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; | ||
85 | if(cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto | ||
86 | .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso !== | ||
87 | idUsuario) | ||
88 | { | ||
89 | focaModalService.alert('El vehículo está siendo usado por otro usuario'); | ||
90 | return; | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + | 77 | focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + |
95 | vehiculo.codigo + '?').then(function() { | 78 | vehiculo.codigo + '?').then(function() { |
96 | eliminarVehiculo(vehiculo); | 79 | eliminarVehiculo(vehiculo); |
97 | }); | 80 | }); |
98 | }; | 81 | }; |
99 | 82 | ||
100 | $scope.hacerHojaRuta = function(vehiculo) { | 83 | $scope.hacerHojaRuta = function(vehiculo) { |
101 | if(!$scope.fechaReparto) { | 84 | if(!eligioFecha() || vehiculoEnUso(vehiculo)) return; |
102 | focaModalService.alert('Primero seleccione fecha de reparto'); | ||
103 | return; | ||
104 | } | ||
105 | //TODO: Pasar validación a función | ||
106 | $scope.fechaReparto.setHours(0, 0, 0, 0); | ||
107 | var idUsuario = focaLogisticaPedidoRutaService.idUsuario; | ||
108 | for(var i = 0; i < vehiculo.cisternas.length; i++) { | ||
109 | for(var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | ||
110 | var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; | ||
111 | if(cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto | ||
112 | .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso !== | ||
113 | idUsuario) | ||
114 | { | ||
115 | focaModalService.alert('El vehículo está siendo usado por otro usuario'); | ||
116 | return; | ||
117 | } | ||
118 | } | ||
119 | } | ||
120 | var modalInstance = $uibModal.open( | 85 | var modalInstance = $uibModal.open( |
121 | { | 86 | { |
122 | ariaLabelledBy: 'Creación hoja ruta', | 87 | ariaLabelledBy: 'Creación hoja ruta', |
123 | templateUrl: 'foca-modal-cerrar-vehiculo.html', | 88 | templateUrl: 'foca-modal-cerrar-vehiculo.html', |
124 | controller: 'focaModalCerrarVehiculo', | 89 | controller: 'focaModalCerrarVehiculo', |
125 | size: 'lg', | 90 | size: 'lg', |
126 | resolve: { | 91 | resolve: { |
127 | idVehiculo: function() {return vehiculo.id;} | 92 | idVehiculo: function() {return vehiculo.id;}, |
93 | fechaReparto: function() {return $scope.fechaReparto;} | ||
128 | } | 94 | } |
129 | } | 95 | } |
130 | ); | 96 | ); |
131 | modalInstance.result.then(function() { | 97 | modalInstance.result.then(function() { |
132 | 98 | ||
133 | }, function() { | 99 | }, function() { |
134 | //usar cuando se cancela el modal | 100 | //usar cuando se cancela el modal |
135 | }); | 101 | }); |
136 | }; | 102 | }; |
137 | 103 | ||
138 | $scope.arrastra = function() { | 104 | $scope.arrastra = function() { |
139 | $scope.arrastrando = true; | 105 | $scope.arrastrando = true; |
140 | $scope.$digest(); | 106 | $scope.$digest(); |
141 | }; | 107 | }; |
142 | 108 | ||
143 | $scope.noArrastra = function() { | 109 | $scope.noArrastra = function() { |
144 | $scope.arrastrando = false; | 110 | $scope.arrastrando = false; |
145 | $scope.$digest(); | 111 | $scope.$digest(); |
146 | }; | 112 | }; |
147 | 113 | ||
148 | $scope.individual = function() { | 114 | $scope.individual = function() { |
149 | $scope.idVendedor = -1; | 115 | $scope.idVendedor = -1; |
150 | }; | 116 | }; |
151 | 117 | ||
152 | $scope.mostrarDetalle = function() { | 118 | $scope.mostrarDetalle = function() { |
153 | $scope.detalle = true; | 119 | $scope.detalle = true; |
154 | }; | 120 | }; |
155 | 121 | ||
156 | $scope.salir = function() { | 122 | $scope.salir = function() { |
157 | $location.path('/'); | 123 | $location.path('/'); |
158 | }; | 124 | }; |
159 | 125 | ||
160 | $scope.search = function() { | 126 | $scope.search = function() { |
161 | getSeguimiento(); | 127 | getSeguimiento(); |
162 | }; | 128 | }; |
163 | 129 | ||
164 | $scope.fecha = function() { | 130 | $scope.fecha = function() { |
165 | getSeguimiento(); | 131 | getSeguimiento(); |
166 | }; | 132 | }; |
167 | 133 | ||
168 | $scope.seleccionarUnidad = function() { | 134 | $scope.seleccionarUnidad = function() { |
169 | var modalInstance = $uibModal.open( | 135 | var modalInstance = $uibModal.open( |
170 | { | 136 | { |
171 | ariaLabelledBy: 'Busqueda de Transportista', | 137 | ariaLabelledBy: 'Busqueda de Transportista', |
172 | templateUrl: 'modal-proveedor.html', | 138 | templateUrl: 'modal-proveedor.html', |
173 | controller: 'focaModalProveedorCtrl', | 139 | controller: 'focaModalProveedorCtrl', |
174 | size: 'lg', | 140 | size: 'lg', |
175 | resolve: { | 141 | resolve: { |
176 | transportista: function() { | 142 | transportista: function() { |
177 | return true; | 143 | return true; |
178 | } | 144 | } |
179 | } | 145 | } |
180 | } | 146 | } |
181 | ); | 147 | ); |
182 | modalInstance.result.then(function(transportista) { | 148 | modalInstance.result.then(function(transportista) { |
183 | $scope.seleccionarVehiculo(transportista.COD); | 149 | $scope.seleccionarVehiculo(transportista.COD); |
184 | }); | 150 | }); |
185 | }; | 151 | }; |
186 | 152 | ||
187 | $scope.seleccionarVehiculo = function(idTransportista) { | 153 | $scope.seleccionarVehiculo = function(idTransportista) { |
188 | var query = '/vehiculo/transportista/' + idTransportista; | 154 | var query = '/vehiculo/transportista/' + idTransportista; |
189 | var columnas = { | 155 | var columnas = { |
190 | nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], | 156 | nombre: ['Código', 'tractor', 'Semi', 'Capacidad'], |
191 | propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] | 157 | propiedad: ['codigo', 'tractor', 'semi', 'capacidadTotalCisternas'] |
192 | }; | 158 | }; |
193 | var titulo = 'Búsqueda de vehiculos'; | 159 | var titulo = 'Búsqueda de vehiculos'; |
194 | focaModalService.modal(columnas, query, titulo).then( | 160 | focaModalService.modal(columnas, query, titulo).then( |
195 | function(vehiculo) { | 161 | function(vehiculo) { |
196 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); | 162 | var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); |
197 | if(existe.length) { | 163 | if(existe.length) { |
198 | focaModalService.alert('El vehiculo ya ha sido cargado'); | 164 | focaModalService.alert('El vehiculo ya ha sido cargado'); |
199 | return; | 165 | return; |
200 | } | 166 | } |
201 | if(!vehiculo.cisternas.length) { | 167 | if(!vehiculo.cisternas.length) { |
202 | focaModalService.alert('El vehiculo no tiene cisternas'); | 168 | focaModalService.alert('El vehiculo no tiene cisternas'); |
203 | return; | 169 | return; |
204 | } | 170 | } |
205 | $scope.vehiculos.push(vehiculo); | 171 | $scope.vehiculos.push(vehiculo); |
206 | }, function() { | 172 | }, function() { |
207 | // funcion ejecutada cuando se cancela el modal | 173 | // funcion ejecutada cuando se cancela el modal |
208 | }); | 174 | }); |
209 | }; | 175 | }; |
210 | 176 | ||
211 | $scope.seleccionarFechaReparto = function() { | 177 | $scope.seleccionarFechaReparto = function() { |
212 | focaModalService.modalFecha('Fecha de reparto').then(function(fecha) { | 178 | focaModalService.modalFecha('Fecha de reparto').then(function(fecha) { |
213 | $scope.$broadcast('addCabecera',{ | 179 | $scope.$broadcast('addCabecera',{ |
214 | label: 'Fecha:', | 180 | label: 'Fecha:', |
215 | valor: fecha.toLocaleDateString() | 181 | valor: fecha.toLocaleDateString() |
216 | }); | 182 | }); |
217 | $scope.fechaReparto = fecha; | 183 | $scope.fechaReparto = fecha; |
218 | focaLogisticaPedidoRutaService.setFechaReparto(fecha); | 184 | focaLogisticaPedidoRutaService.setFechaReparto(fecha); |
219 | focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function(res) { | 185 | focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function(res) { |
220 | $scope.vehiculos = res.data; | 186 | $scope.vehiculos = res.data; |
221 | }); | 187 | }); |
222 | }); | 188 | }); |
223 | }; | 189 | }; |
224 | 190 | ||
225 | function getSeguimiento() { | 191 | function getSeguimiento() { |
226 | var desde = new Date('1900/01/01'); | 192 | var desde = new Date('1900/01/01'); |
227 | var hasta = new Date('2099/01/01'); | 193 | var hasta = new Date('2099/01/01'); |
228 | if($scope.fechaDesde) { | 194 | if($scope.fechaDesde) { |
229 | var fechaDesde = $scope.fechaDesde; | 195 | var fechaDesde = $scope.fechaDesde; |
230 | desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); | 196 | desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); |
231 | desde = new Date(desde); | 197 | desde = new Date(desde); |
232 | } | 198 | } |
233 | if($scope.fechaHasta) { | 199 | if($scope.fechaHasta) { |
234 | var fechaHasta = $scope.fechaHasta; | 200 | var fechaHasta = $scope.fechaHasta; |
235 | hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); | 201 | hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); |
236 | hasta = hasta.setDate(hasta.getDate() + 1); | 202 | hasta = hasta.setDate(hasta.getDate() + 1); |
237 | hasta = new Date(hasta); | 203 | hasta = new Date(hasta); |
238 | } | 204 | } |
239 | var datos = { | 205 | var datos = { |
240 | actividad: $scope.actividad, | 206 | actividad: $scope.actividad, |
241 | idUsuario: $scope.idVendedor, | 207 | idUsuario: $scope.idVendedor, |
242 | fechaDesde: desde, | 208 | fechaDesde: desde, |
243 | fechaHasta: hasta, | 209 | fechaHasta: hasta, |
244 | asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? | 210 | asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? |
245 | false : undefined) | 211 | false : undefined) |
246 | }; | 212 | }; |
247 | 213 | ||
248 | $scope.datosBuscados = { | 214 | $scope.datosBuscados = { |
249 | actividad: $scope.actividad, | 215 | actividad: $scope.actividad, |
250 | individual: $scope.idVendedor ? true : false | 216 | individual: $scope.idVendedor ? true : false |
251 | }; | 217 | }; |
252 | 218 | ||
253 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { | 219 | focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { |
254 | if(JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { | 220 | if(JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { |
255 | $scope.marcadores = datos.data; | 221 | $scope.marcadores = datos.data; |
256 | } | 222 | } |
257 | }); | 223 | }); |
258 | } | 224 | } |
259 | 225 | ||
260 | function eliminarVehiculo(vehiculo) { | 226 | function eliminarVehiculo(vehiculo) { |
261 | focaLogisticaPedidoRutaService.getRemitos(vehiculo.id).then(function(res) { | 227 | focaLogisticaPedidoRutaService.getRemitos(vehiculo.id).then(function(res) { |
262 | if(!focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data).length) { | 228 | if(!focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data).length) { |
263 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | 229 | $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); |
264 | }else { | 230 | }else { |
265 | focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + | 231 | focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + |
266 | 'tiene remitos asociados').then(function() { | 232 | 'tiene remitos asociados').then(function() { |
267 | $scope.hacerHojaRuta(vehiculo); | 233 | $scope.hacerHojaRuta(vehiculo); |
268 | }); | 234 | }); |
269 | } | 235 | } |
270 | }); | 236 | }); |
271 | } | 237 | } |
272 | $interval(function() { | 238 | |
273 | getSeguimiento(); | 239 | function eligioFecha() { |
274 | }, 5000); | 240 | if(!$scope.fechaReparto) { |
241 | focaModalService.alert('Primero seleccione fecha de reparto'); | ||
242 | return false; |
src/js/controllerCerrarVehiculo.js
1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
2 | .controller('focaModalCerrarVehiculo', [ | 2 | .controller('focaModalCerrarVehiculo', [ |
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 | 'fechaReparto', | ||
10 | function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService, | 11 | function($scope, $uibModalInstance, $uibModal, focaLogisticaPedidoRutaService, |
11 | idVehiculo, focaModalService, $filter) { | 12 | idVehiculo, focaModalService, $filter, fechaReparto) { |
12 | $scope.vehiculo = {}; | 13 | $scope.vehiculo = {}; |
13 | $scope.remitos = []; | 14 | $scope.remitos = []; |
14 | $scope.now = new Date(); | 15 | $scope.now = fechaReparto; |
15 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) { | 16 | focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo).then(function(res) { |
16 | $scope.vehiculo = res.data; | 17 | $scope.vehiculo = res.data; |
17 | }); | 18 | }); |
18 | focaLogisticaPedidoRutaService.getRemitos(idVehiculo).then(function(res) { | 19 | focaLogisticaPedidoRutaService.getRemitos(idVehiculo).then(function(res) { |
19 | $scope.remitos = focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data); | 20 | $scope.remitos = focaLogisticaPedidoRutaService.obtenerRemitosDeCarga(res.data); |
20 | }); | 21 | }); |
21 | focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { | 22 | focaLogisticaPedidoRutaService.numeroHojaRuta().then(function(res) { |
22 | $scope.sucursal = res.data.sucursal; | 23 | $scope.sucursal = res.data.sucursal; |
23 | $scope.numero = res.data.numeroHojaRuta; | 24 | $scope.numero = res.data.numeroHojaRuta; |
24 | }); | 25 | }); |
25 | $scope.cancelar = function() { | 26 | $scope.cancelar = function() { |
26 | $uibModalInstance.close(); | 27 | $uibModalInstance.close(); |
27 | }; | 28 | }; |
28 | $scope.aceptar = function() { | 29 | $scope.aceptar = function() { |
29 | var idsRemito = []; | 30 | var idsRemito = []; |
30 | $scope.remitos.forEach(function(remito) { | 31 | $scope.remitos.forEach(function(remito) { |
31 | idsRemito.push(remito.id); | 32 | idsRemito.push(remito.id); |
32 | }); | 33 | }); |
33 | var cierreDistribuicion = { | 34 | var cierreDistribuicion = { |
34 | idsRemito: idsRemito, | 35 | idsRemito: idsRemito, |
35 | fechaReparto: focaLogisticaPedidoRutaService.fecha | 36 | fechaReparto: focaLogisticaPedidoRutaService.fecha |
36 | }; | 37 | }; |
37 | focaLogisticaPedidoRutaService.cerrarDistribuicion(cierreDistribuicion) | 38 | focaLogisticaPedidoRutaService.cerrarDistribuicion(cierreDistribuicion) |
38 | .then(function() { | 39 | .then(function() { |
39 | focaModalService.alert('Vehículo cerrado con éxito'); | 40 | focaModalService.alert('Vehículo cerrado con éxito'); |
40 | } | 41 | } |
41 | ); | 42 | ); |
42 | }; | 43 | }; |
43 | $scope.seleccionarChofer = function() { | 44 | $scope.seleccionarChofer = function() { |
44 | var modalInstance = $uibModal.open( | 45 | var modalInstance = $uibModal.open( |
45 | { | 46 | { |
46 | ariaLabelledBy: 'Busqueda de Chofer', | 47 | ariaLabelledBy: 'Busqueda de Chofer', |
47 | templateUrl: 'modal-chofer.html', | 48 | templateUrl: 'modal-chofer.html', |
48 | controller: 'focaModalChoferController', | 49 | controller: 'focaModalChoferController', |
49 | size: 'lg' | 50 | size: 'lg' |
50 | } | 51 | } |
51 | ); | 52 | ); |
52 | 53 | ||
53 | modalInstance.result.then( | 54 | modalInstance.result.then( |
54 | function(chofer) { | 55 | function(chofer) { |
55 | $scope.chofer = chofer; | 56 | $scope.chofer = chofer; |
56 | }, function() { | 57 | }, function() { |
57 | // funcion ejecutada cuando se cancela el modal | 58 | // funcion ejecutada cuando se cancela el modal |
58 | } | 59 | } |
59 | ); | 60 | ); |
60 | }; | 61 | }; |
61 | $scope.eliminarRemitos = function() { | 62 | $scope.eliminarRemitos = function() { |
62 | var remitosDel = $filter('filter')($scope.remitos, {checked: true}); | 63 | var remitosDel = $filter('filter')($scope.remitos, {checked: true}); |
63 | focaModalService.alert('¿Seguro que desea desasociar estos remitos del vehículo?') | 64 | focaModalService.alert('¿Seguro que desea desasociar estos remitos del vehículo?') |
64 | .then(function() { | 65 | .then(function() { |
65 | eliminarRemitos(remitosDel); | 66 | eliminarRemitos(remitosDel); |
66 | } | 67 | } |
67 | ); | 68 | ); |
68 | }; | 69 | }; |
69 | $scope.minimoUnoChecked = function() { | 70 | $scope.minimoUnoChecked = function() { |
70 | var remitosChequeados = $filter('filter')($scope.remitos, {checked: true}); | 71 | var remitosChequeados = $filter('filter')($scope.remitos, {checked: true}); |
71 | return !remitosChequeados.length; | 72 | return !remitosChequeados.length; |
72 | }; | 73 | }; |
73 | function eliminarRemitos(remitosDel) { | 74 | function eliminarRemitos(remitosDel) { |
74 | var nuevosRemitos = $filter('filter')($scope.remitos, {checked: !true}); | 75 | var nuevosRemitos = $filter('filter')($scope.remitos, {checked: !true}); |
75 | focaLogisticaPedidoRutaService.desasociarRemitos(remitosDel, $scope.vehiculo.id, | 76 | focaLogisticaPedidoRutaService.desasociarRemitos(remitosDel, $scope.vehiculo.id, |
76 | nuevosRemitos ? true : false).then(function() { | 77 | nuevosRemitos ? true : false).then(function() { |
77 | focaModalService.alert('Remitos desasociados con éxito'); | 78 | focaModalService.alert('Remitos desasociados con éxito'); |
78 | $scope.remitos = nuevosRemitos; | 79 | $scope.remitos = nuevosRemitos; |
79 | }); | 80 | }); |
80 | } | 81 | } |
81 | }]); | 82 | }]); |
82 | 83 |
src/js/controllerDetalleVehiculo.js
1 | angular.module('focaLogisticaPedidoRuta') | File was deleted | |
2 | .controller('focaDetalleVehiculo', | ||
3 | ['$scope', | ||
4 | '$uibModalInstance', | ||
5 | 'idVehiculo', | ||
6 | 'idRemito', | ||
7 | 'focaModalService', | ||
8 | '$filter', | ||
9 | 'focaLogisticaPedidoRutaService', | ||
10 | function($scope, $uibModalInstance, idVehiculo, idRemito, focaModalService, $filter, | ||
11 | focaLogisticaPedidoRutaService | ||
12 | ) { | ||
13 | //seteo variables | ||
14 | $scope.cargandoDatos = true; | ||
15 | $scope.idRemito = idRemito; | ||
16 | $scope.articulos = []; | ||
17 | $scope.vehiculo = {}; | ||
18 | $scope.cisternas = []; | ||
19 | $scope.cisternasCarga = []; | ||
20 | $scope.remito = {}; | ||
21 | $scope.aCargar = []; | ||
22 | var cisternaMovimientos = []; | ||
23 | var promesaRemito; | ||
24 | var promesaVehiculo = focaLogisticaPedidoRutaService.obtenerVehiculoById(idVehiculo); | ||
25 | var promesaCisternas = focaLogisticaPedidoRutaService | ||
26 | .obtenerCisternasPorFecha(idVehiculo); | ||
27 | if(idRemito !== -1) { | ||
28 | promesaRemito = focaLogisticaPedidoRutaService.obtenerRemitoById(idRemito); | ||
29 | } | ||
30 | Promise.all([promesaVehiculo, promesaCisternas, promesaRemito]).then(function(res) { | ||
31 | $scope.cargandoDatos = false; | ||
32 | $scope.vehiculo = res[0].data; | ||
33 | $scope.cisternas = res[1].data; | ||
34 | if(!res[2]) return; | ||
35 | $scope.remito = res[2].data; | ||
36 | if($scope.remito.idUsuarioProceso) { | ||
37 | focaModalService.alert('Remito ya asignado'); | ||
38 | $uibModalInstance.close(); | ||
39 | } | ||
40 | $scope.articulos = $scope.remito.articulosRemito; | ||
41 | $scope.seleccionarArticulo($scope.articulos[0]); | ||
42 | var tieneUsuario = $scope.cisternas.filter(function(cisterna) { | ||
43 | if(cisterna.cisternaCarga) { | ||
44 | return cisterna.cisternaCarga.idUsuarioProceso !== | ||
45 | focaLogisticaPedidoRutaService.idUsuario; | ||
46 | } | ||
47 | }); | ||
48 | if(tieneUsuario.length) { | ||
49 | focaModalService.alert('Otro usario esta usando este vehículo'); | ||
50 | $uibModalInstance.close(); | ||
51 | return; | ||
52 | } | ||
53 | }); | ||
54 | $scope.aceptar = function() { | ||
55 | $scope.cargando = true; | ||
56 | for(var i = 0; i < $scope.cisternasCarga.length; i++) { | ||
57 | $scope.cisternasCarga[i].idUsuarioProceso = | ||
58 | focaLogisticaPedidoRutaService.idUsuario; | ||
59 | delete $scope.cisternasCarga[i].articulo; | ||
60 | } | ||
61 | var cisterna = { | ||
62 | cisternaMovimientos: cisternaMovimientos, | ||
63 | cisternaCargas: $scope.cisternasCarga, | ||
64 | idVehiculo: $scope.vehiculo.id, | ||
65 | fechaReparto: focaLogisticaPedidoRutaService.fecha | ||
66 | }; | ||
67 | focaLogisticaPedidoRutaService.guardarCisternas(cisterna, $scope.remito.id) | ||
68 | .then(function() { | ||
69 | focaModalService.alert('Cisternas cargadas con éxito').then(function() { | ||
70 | $scope.cargando = false; | ||
71 | $uibModalInstance.close(); | ||
72 | }); | ||
73 | }).catch(function(error) { | ||
74 | $scope.cargando = false; | ||
75 | $uibModalInstance.close(); | ||
76 | if (error.status === 403) { | ||
77 | focaModalService.alert('ERROR: ' + error.data); | ||
78 | return; | ||
79 | } | ||
80 | focaModalService.alert('Hubo un error al cargar las cisternas'); | ||
81 | }); | ||
82 | }; | ||
83 | $scope.cancelar = function() { | ||
84 | $uibModalInstance.close(); | ||
85 | }; | ||
86 | $scope.cargarACisternas = function() { | ||
87 | for(var i = 0; i < $scope.cisternas.length; i++) { | ||
88 | var cisterna = $scope.cisternas[i]; | ||
89 | var aCargar = parseFloat($scope.aCargar[i]); | ||
90 | var fechaReparto = focaLogisticaPedidoRutaService.fecha; | ||
91 | //validaciones | ||
92 | if(!aCargar) { | ||
93 | continue; | ||
94 | } | ||
95 | //cargar | ||
96 | if(cisterna.cisternaCarga.cantidad) { | ||
97 | cisterna.cisternaCarga.cantidad += aCargar; | ||
98 | }else { | ||
99 | cisterna.cisternaCarga.cantidad = aCargar; | ||
100 | cisterna.cisternaCarga.idProducto = $scope.articuloSeleccionado.idArticulo; | ||
101 | } | ||
102 | cisterna.disponible = cisterna.capacidad - cisterna.cisternaCarga.cantidad; | ||
103 | |||
104 | cisterna.cisternaCarga.articulo = { | ||
105 | DetArt: $scope.articuloSeleccionado.descripcion | ||
106 | }; | ||
107 | $filter('filter')($scope.articulos, {id: $scope.articuloSeleccionado.id})[0] | ||
108 | .cargado = true; | ||
109 | |||
110 | $scope.calcularPorcentaje(cisterna); | ||
111 | //Guardar | ||
112 | var now = new Date(); | ||
113 | var cisternaMovimiento = { | ||
114 | fecha: now.toISOString().slice(0, 19).replace('T', ' '), | ||
115 | cantidad: aCargar, | ||
116 | metodo: 'carga', | ||
117 | idCisternaCarga: cisterna.cisternaCarga.id, | ||
118 | idRemito: $scope.remito.id | ||
119 | }; | ||
120 | cisterna.cisternaCarga.fechaReparto = fechaReparto; | ||
121 | cisterna.cisternaCarga.idCisterna = cisterna.id; | ||
122 | $scope.cisternasCarga.push(cisterna.cisternaCarga); | ||
123 | cisternaMovimientos.push(cisternaMovimiento); | ||
124 | } | ||
125 | var articuloSiguiente = $scope.articulos.filter( | ||
126 | function(filter) { | ||
127 | return filter.cargado !== true; | ||
128 | } | ||
129 | ); | ||
130 | if(articuloSiguiente.length > 0) { | ||
131 | $scope.seleccionarArticulo(articuloSiguiente[0]); | ||
132 | } | ||
133 | }; | ||
134 | $scope.calcularPorcentaje = function(cisterna) { | ||
135 | if(!cisterna.cisternaCarga) { | ||
136 | cisterna.cisternaCarga = { | ||
137 | cantidad: 0 | ||
138 | }; | ||
139 | } | ||
140 | var porcentaje = (cisterna.cisternaCarga.cantidad * 100 / | ||
141 | cisterna.capacidad) + '%'; | ||
142 | var elementHtml = document.getElementById(cisterna.id); | ||
143 | if(elementHtml) { | ||
144 | elementHtml.style.width = porcentaje; | ||
145 | } | ||
146 | }; | ||
147 | $scope.seleccionarArticulo = function(articulo) { | ||
148 | $scope.articuloSeleccionado = articulo; | ||
149 | $scope.cisternaDisponible(); | ||
150 | $scope.autoCompletar(); | ||
151 | $scope.actualizarArticulo(); | ||
152 | }; | ||
153 | $scope.actualizarArticulo = function () { | ||
154 | $scope.articuloSeleccionado.cantidadCargada = 0; | ||
155 | for (var i = 0; i < $scope.aCargar.length; i++) { | ||
156 | $scope.articuloSeleccionado.cantidadCargada += | ||
157 | parseFloat($scope.aCargar[i]) || 0; | ||
158 | } | ||
159 | }; | ||
160 | $scope.autoCompletar = function() { | ||
161 | $scope.aCargar = []; | ||
162 | var disponible = $filter('filter')($scope.cisternas, {disabled: false}); | ||
163 | var index = $scope.cisternas.indexOf(disponible[0]); | ||
164 | $scope.aCargar[index] = $scope.articuloSeleccionado.cantidad; | ||
165 | }; | ||
166 | $scope.cisternaDisponible = function() { | ||
167 | for(var i = 0; i < $scope.cisternas.length; i++) { | ||
168 | if($scope.articuloSeleccionado.cantidad > $scope.cisternas[i].disponible) { | ||
169 | $scope.cisternas[i].disabled = true; | ||
170 | continue; | ||
171 | } | ||
172 | if($scope.cisternas[i].cisternaCarga && | ||
173 | $scope.cisternas[i].cisternaCarga.idProducto && | ||
174 | $scope.articuloSeleccionado.idArticulo !== | ||
175 | $scope.cisternas[i].cisternaCarga.idProducto) | ||
176 | { | ||
177 | $scope.cisternas[i].disabled = true; | ||
178 | continue; | ||
179 | } | ||
180 | $scope.cisternas[i].disabled = false; | ||
181 | } | ||
182 | }; | ||
183 | $scope.rellenarInput = function(input) { | ||
184 | if(!$scope.articuloSeleccionado) return; | ||
185 | if($scope.articuloSeleccionado.cantidad - | ||
186 | $scope.articuloSeleccionado.cantidadCargada === 0) { | ||
187 | return input; | ||
188 | } | ||
189 | if(!input) input = 0; | ||
190 | input = parseFloat(input); | ||
191 | input += parseFloat($scope.articuloSeleccionado.cantidad - | ||
192 | $scope.articuloSeleccionado.cantidadCargada); | ||
193 | return input; | ||
194 | }; | ||
195 | $scope.distribucionDisponible = function() { | ||
196 | if(!$scope.articuloSeleccionado || $scope.articuloSeleccionado.cantidad - | ||
197 | $scope.articuloSeleccionado.cantidadCargada !== 0 || | ||
198 | !$scope.tieneArticulosPendientes()) { | ||
199 | return false; | ||
200 | } | ||
201 | return true; | ||
202 | }; | ||
203 | $scope.tieneArticulosPendientes = function() { | ||
204 | var algunValorNegativo = $scope.aCargar.filter(function(p) { | ||
205 | return p < 0; | ||
206 | }); | ||
207 | if(algunValorNegativo.length) { | ||
208 | return false; | ||
209 | } | ||
210 | var articulosDescargados = $scope.articulos.filter(function(filter) { | ||
211 | return filter.cargado === true; | ||
212 | }); | ||
213 | if(articulosDescargados.length === $scope.articulos.length) { | ||
214 | $scope.aCargar = []; | ||
215 | return false; | ||
216 | } | ||
217 | return true; | ||
218 | }; | ||
219 | }]); | ||
220 | 1 | angular.module('focaLogisticaPedidoRuta') |
src/js/osm-directive.js
1 | angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() { | 1 | angular.module('focaLogisticaPedidoRuta').directive('focaLogistica', function() { |
2 | return { | 2 | return { |
3 | restrict: 'E', | 3 | restrict: 'E', |
4 | link: function(scope, el, attrs) { | 4 | link: function(scope, el, attrs) { |
5 | var contenedor = document.createElement('div'); | 5 | var contenedor = document.createElement('div'); |
6 | contenedor.className = 'border border-light rounded'; | 6 | contenedor.className = 'border border-light rounded'; |
7 | el.append(contenedor); | 7 | el.append(contenedor); |
8 | scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); | 8 | scope.map = L.map(contenedor).setView([attrs.latitud, attrs.longitud], attrs.zoom); |
9 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); | 9 | L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(scope.map); |
10 | }, | 10 | }, |
11 | controller: ['$scope', '$filter', function($scope, $filter) { | 11 | controller: ['$scope', '$filter', function($scope, $filter) { |
12 | $scope.markers = []; | 12 | $scope.markers = []; |
13 | $scope.$watch('marcadores', function() { | 13 | $scope.$watch('marcadores', function() { |
14 | for(var i in $scope.markers) { | 14 | for(var i in $scope.markers) { |
15 | $scope.map.removeLayer($scope.markers[i]); | 15 | $scope.map.removeLayer($scope.markers[i]); |
16 | } | 16 | } |
17 | $scope.markers = []; | 17 | $scope.markers = []; |
18 | 18 | ||
19 | angular.forEach($scope.marcadores, function(marcador) { | 19 | angular.forEach($scope.marcadores, function(marcador) { |
20 | var observacion = | 20 | var observacion = |
21 | 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + | 21 | 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + |
22 | ( | 22 | ( |
23 | marcador.notaPedido.vendedor ? | 23 | marcador.notaPedido.vendedor ? |
24 | marcador.notaPedido.vendedor.NomVen : | 24 | marcador.notaPedido.vendedor.NomVen : |
25 | '' | 25 | '' |
26 | ) + '<br/>'; | 26 | ) + '<br/>'; |
27 | observacion += 'Fecha: ' + | 27 | observacion += 'Fecha: ' + |
28 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + | 28 | $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + |
29 | marcador.fecha.slice(11,19) + '<br/>'; | 29 | marcador.fecha.slice(11,19) + '<br/>'; |
30 | observacion += 'Remito Nº: ' + $filter('comprobante')([ | 30 | observacion += 'Remito Nº: ' + $filter('comprobante')([ |
31 | marcador.notaPedido.remito.sucursal, | 31 | marcador.notaPedido.remito.sucursal, |
32 | marcador.notaPedido.remito.numeroRemito | 32 | marcador.notaPedido.remito.numeroRemito |
33 | ]) + '<br/>'; | 33 | ]) + '<br/>'; |
34 | observacion += 'Cliente: ' + | 34 | observacion += 'Cliente: ' + |
35 | marcador.notaPedido.cliente.NOM + '<br/>'; | 35 | marcador.notaPedido.cliente.NOM + '<br/>'; |
36 | 36 | ||
37 | // if($scope.parametros.individual) { | 37 | // if($scope.parametros.individual) { |
38 | observacion += | 38 | observacion += |
39 | 'Total: ' + $filter('currency')(marcador.notaPedido.remito.total, '$'); | 39 | 'Total: ' + $filter('currency')(marcador.notaPedido.remito.total, '$'); |
40 | observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; | 40 | observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; |
41 | 41 | ||
42 | if(marcador.distancia) { | 42 | if(marcador.distancia) { |
43 | observacion += '<br/>Distancia a casa central: ' + | 43 | observacion += '<br/>Distancia a casa central: ' + |
44 | marcador.distancia + 'km'; | 44 | marcador.distancia + 'km'; |
45 | } | 45 | } |
46 | observacion += '<br/>'; | 46 | observacion += '<br/>'; |
47 | observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ | 47 | observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ |
48 | 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ | 48 | 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ |
49 | JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; | 49 | JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; |
50 | var icon; | 50 | var icon; |
51 | if(marcador.notaPedido.remito.idUsuarioProceso) { | 51 | if(marcador.notaPedido.remito.idUsuarioProceso) { |
52 | //Asignado ROJO | 52 | //Asignado ROJO |
53 | icon = new L.Icon({ | 53 | icon = new L.Icon({ |
54 | iconUrl: 'img/marker-icon-2x-red.png', | 54 | iconUrl: 'img/marker-icon-2x-red.png', |
55 | shadowUrl: 'img/marker-shadow.png', | 55 | shadowUrl: 'img/marker-shadow.png', |
56 | iconSize: [25, 41], | 56 | iconSize: [25, 41], |
57 | iconAnchor: [12, 41], | 57 | iconAnchor: [12, 41], |
58 | popupAnchor: [1, -34], | 58 | popupAnchor: [1, -34], |
59 | shadowSize: [41, 41] | 59 | shadowSize: [41, 41] |
60 | }); | 60 | }); |
61 | }else { | 61 | }else { |
62 | //Sin asignar VERDE | 62 | //Sin asignar VERDE |
63 | icon = new L.Icon({ | 63 | icon = new L.Icon({ |
64 | iconUrl: 'img/marker-icon-2x-green.png', | 64 | iconUrl: 'img/marker-icon-2x-green.png', |
65 | shadowUrl: 'img/marker-shadow.png', | 65 | shadowUrl: 'img/marker-shadow.png', |
66 | iconSize: [25, 41], | 66 | iconSize: [25, 41], |
67 | iconAnchor: [12, 41], | 67 | iconAnchor: [12, 41], |
68 | popupAnchor: [1, -34], | 68 | popupAnchor: [1, -34], |
69 | shadowSize: [41, 41] | 69 | shadowSize: [41, 41] |
70 | }); | 70 | }); |
71 | } | 71 | } |
72 | $scope.markers.push( | 72 | $scope.markers.push( |
73 | L.marker([marcador.latitud, marcador.longitud], {icon: icon}) | 73 | L.marker( |
74 | [marcador.latitud, marcador.longitud], | ||
75 | {icon: icon, draggable: true}) | ||
74 | .addTo($scope.map) | 76 | .addTo($scope.map) |
75 | .bindPopup(observacion) | 77 | .bindPopup(observacion) |
76 | ); | 78 | ); |
77 | //abre marcador del primer punto | 79 | //abre marcador del primer punto |
78 | //$scope.markers[0].openPopup(); | 80 | //$scope.markers[0].openPopup(); |
79 | }); | 81 | }); |
80 | }); | 82 | }); |
81 | }], | 83 | }], |
82 | scope: { | 84 | scope: { |
83 | latitud: '=', | 85 | latitud: '=', |
84 | longitud: '=', | 86 | longitud: '=', |
85 | zoom: '=', | 87 | zoom: '=', |
86 | marcadores: '=', | 88 | marcadores: '=', |
87 | parametros: '=' | 89 | parametros: '=' |
88 | } | 90 | } |
89 | }; | 91 | }; |
90 | }); | 92 | }); |
91 | 93 |
src/js/service.js
1 | angular.module('focaLogisticaPedidoRuta') | 1 | angular.module('focaLogisticaPedidoRuta') |
2 | .factory( | 2 | .factory( |
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 | var url = API_ENDPOINT.URL; | 9 | var url = API_ENDPOINT.URL; |
10 | return { | 10 | return { |
11 | idUsuario: $cookies.get('idUsuario'), | 11 | idUsuario: $cookies.get('vendedorCobrador'), |
12 | obtenerActividad: function(parametros) { | 12 | obtenerActividad: function(parametros) { |
13 | return $http.post(url + '/seguimiento/filtros', parametros); | 13 | return $http.post(url + '/seguimiento/filtros', parametros); |
14 | }, | 14 | }, |
15 | obtenerVehiculoById: function(idVehiculo) { | ||
16 | return $http.get(url + '/vehiculo/' + idVehiculo); | ||
17 | }, | ||
18 | obtenerRemitoById: function(idRemito) { | ||
19 | return $http.get(url + '/remito/obtener/' + idRemito); | ||
20 | }, | ||
21 | guardarCisternas: function(cisterna, idRemito) { | ||
22 | return $http.post(url + '/cisterna/guardar/cargar/' + | ||
23 | this.idUsuario + '/' + idRemito,cisterna); | ||
24 | }, | ||
25 | numeroHojaRuta: function() { | 15 | numeroHojaRuta: function() { |
26 | return $http.get(url + '/hoja-ruta/numero-siguiente'); | 16 | return $http.get(url + '/hoja-ruta/numero-siguiente'); |
27 | }, | 17 | }, |
28 | getRemitos: function(idVehiculo) { | 18 | getRemitos: function(idVehiculo) { |
29 | return $http.get(url + '/remito/sin-hoja-ruta/' +idVehiculo); | 19 | return $http.get(url + '/remito/sin-hoja-ruta/' + idVehiculo); |
30 | }, | 20 | }, |
31 | cerrarDistribuicion: function(remitos) { | 21 | cerrarDistribuicion: function(remitos) { |
32 | return $http.post(url + '/vehiculo/cierre-distribuicion', remitos); | 22 | return $http.post(url + '/vehiculo/cierre-distribuicion', remitos); |
33 | }, | 23 | }, |
34 | desasociarRemitos: function(remitos, idVehiculo, sinRemitos) { | 24 | desasociarRemitos: function(remitos, idVehiculo, sinRemitos) { |
35 | var idsRemitos = []; | 25 | var idsRemitos = []; |
36 | for (var i = 0; i < remitos.length; i++) { | 26 | for (var i = 0; i < remitos.length; i++) { |
37 | idsRemitos.push(remitos[i].id); | 27 | idsRemitos.push(remitos[i].id); |
38 | } | 28 | } |
39 | return $http.post(url + '/vehiculo/desasociar-remitos', | 29 | return $http.post(url + '/vehiculo/desasociar-remitos', |
40 | { | 30 | { |
41 | idsRemitos: idsRemitos, | 31 | idsRemitos: idsRemitos, |
42 | idVehiculo: idVehiculo, | 32 | idVehiculo: idVehiculo, |
43 | vehiculoSinRemitos: sinRemitos | 33 | vehiculoSinRemitos: sinRemitos |
44 | }); | 34 | }); |
45 | }, | 35 | }, |
46 | obtenerRemitosDeCarga: function(remitos) { | 36 | obtenerRemitosDeCarga: function(remitos) { |
47 | var remitosRes = []; | 37 | var remitosRes = []; |
48 | for(var i = 0; i < remitos.cisternas.length; i++) { | 38 | for(var i = 0; i < remitos.cisternas.length; i++) { |
49 | procesoCistena(remitos.cisternas[i], this.fecha.toISOString()); | 39 | procesoCistena(remitos.cisternas[i], this.fecha.toISOString()); |
50 | } | 40 | } |
51 | function procesoCistena(cisterna, fecha) { | 41 | function procesoCistena(cisterna, fecha) { |
52 | for(var j = 0; j < cisterna.cisternasCarga.length; j++) { | 42 | for(var j = 0; j < cisterna.cisternasCarga.length; j++) { |
53 | for(var k = 0; k < cisterna.cisternasCarga[j].cisternaMovimientos | 43 | for(var k = 0; k < cisterna.cisternasCarga[j].cisternaMovimientos |
54 | .length; k++) | 44 | .length; k++) |
55 | { | 45 | { |
56 | if(cisterna.cisternasCarga[j].fechaReparto.substring(0, 10) === | 46 | if(cisterna.cisternasCarga[j].fechaReparto.substring(0, 10) === |
57 | fecha.substring(0, 10) && !cisterna.cisternasCarga[j] | 47 | fecha.substring(0, 10)) |
58 | .confirmado) | ||
59 | { | 48 | { |
60 | procesoMovimiento(cisterna.cisternasCarga[j] | 49 | procesoMovimiento(cisterna.cisternasCarga[j] |
61 | .cisternaMovimientos[k]); | 50 | .cisternaMovimientos[k]); |
62 | } | 51 | } |
63 | } | 52 | } |
64 | } | 53 | } |
65 | } | 54 | } |
66 | function procesoMovimiento(movimiento) { | 55 | function procesoMovimiento(movimiento) { |
67 | if(!movimiento.anulado && movimiento.remito && | 56 | if(!movimiento.anulado && movimiento.remito && |
68 | !movimiento.remito.idHojaRuta) { | 57 | !movimiento.remito.idHojaRuta) { |
69 | var remito = movimiento.remito; | 58 | var remito = movimiento.remito; |
70 | var yaEstaCargado = $filter('filter')(remitosRes, {id: remito.id}); | 59 | var yaEstaCargado = $filter('filter')(remitosRes, {id: remito.id}); |
71 | if(!yaEstaCargado.length && movimiento.metodo === 'carga') { | 60 | if(!yaEstaCargado.length && movimiento.metodo === 'carga') { |
72 | remitosRes.push(remito); | 61 | remitosRes.push(remito); |
73 | } | 62 | } |
74 | } | 63 | } |
75 | } | 64 | } |
76 | return remitosRes; | 65 | return remitosRes; |
77 | }, | 66 | }, |
78 | getVehiculosByIdUsuario: function() { | 67 | getVehiculosByIdUsuario: function() { |
79 | return $http.get(url + '/vehiculo/usuario/' + this.idUsuario); | 68 | return $http.get(url + '/vehiculo/usuario/' + this.idUsuario); |
80 | }, | 69 | }, |
81 | obtenerCisternasPorFecha: function(idVehiculo) { | ||
82 | return $http.post(url + '/cisterna/listar/fecha', | ||
83 | {idVehiculo: idVehiculo, fechaReparto: this.fecha}); | ||
84 | }, | ||
85 | getUnidadesByFecha: function() { | 70 | getUnidadesByFecha: function() { |
86 | return $http.post(url + '/vehiculo/listar/fecha', | 71 | return $http.post(url + '/vehiculo/listar/fecha', |
87 | {fecha: this.fecha}); | 72 | {fecha: this.fecha}); |
88 | }, | 73 | }, |
89 | setFechaReparto: function(fechaReparto) { | 74 | setFechaReparto: function(fechaReparto) { |
90 | this.fecha = fechaReparto; | 75 | this.fecha = fechaReparto; |
91 | }, | 76 | }, |
77 | obtenerVehiculoById: function(idVehiculo) { | ||
78 | return $http.get(url + '/vehiculo/' + idVehiculo); | ||
79 | } |
src/views/foca-detalle-vehiculo.html
1 | <div class="modal-header"> | File was deleted | |
2 | <h4>Detalle de carga</h4> | ||
3 | Transportista | ||
4 | <strong ng-bind="vehiculo.transportista.COD"></strong> | ||
5 | <strong ng-bind="vehiculo.transportista.NOM"></strong> | ||
6 | Unidad <strong ng-bind="vehiculo.codigo"></strong> | ||
7 | Tractor <strong ng-bind="vehiculo.tractor"></strong> | ||
8 | <br> | ||
9 | <div ng-show="idRemito !== -1"> | ||
10 | <span>Remito Nº</span> | ||
11 | <strong ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></strong> | ||
12 | <span>, Fecha</span> | ||
13 | <strong ng-bind="remito.fechaRemito | date: 'dd/MM/yyyy HH:mm'"></strong> | ||
14 | <span>, Cliente</span> | ||
15 | <strong ng-bind="remito.nombreCliente"></strong> | ||
16 | <span>, Domicilio entrega</span> | ||
17 | <strong ng-bind="remito.domicilioStamp"></strong> | ||
18 | </div> | ||
19 | </div> | ||
20 | <div class="modal-body"> | ||
21 | <div> | ||
22 | <table class="table table-sm" ng-show="idRemito !== -1"> | ||
23 | <thead> | ||
24 | <tr> | ||
25 | <th></th> | ||
26 | <th>Articulo</th> | ||
27 | <th>Cantidad</th> | ||
28 | <th>Cargado</th> | ||
29 | <th>Resta asignar</th> | ||
30 | </tr> | ||
31 | </thead> | ||
32 | <tbody> | ||
33 | <tr ng-repeat="(key, articulo) in articulos"> | ||
34 | <td><input | ||
35 | type="radio" | ||
36 | name="articuloRadio" | ||
37 | id="{{'articulo' + articulo.id}}" | ||
38 | ng-checked="articuloSeleccionado.id === articulo.id" | ||
39 | ng-disabled="articulo.cargado" | ||
40 | ng-click="seleccionarArticulo(articulo)" | ||
41 | ></td> | ||
42 | <td ng-bind="articulo.descripcion"></td> | ||
43 | <td ng-bind="articulo.cantidad"></td> | ||
44 | <td ng-bind="articulo.cantidadCargada || 0"></td> | ||
45 | <td ng-bind="articulo.cantidad - articulo.cantidadCargada"></td> | ||
46 | </tr> | ||
47 | </tbody> | ||
48 | </table> | ||
49 | <table class="table table-sm" ladda="cargandoDatos" data-spinner-color="#FF0000"> | ||
50 | <thead> | ||
51 | <tr> | ||
52 | <th width="10%">Cisterna</th> | ||
53 | <th>Capacidad</th> | ||
54 | <th>Articulo cargado</th> | ||
55 | <th width="20%">Asignado</th> | ||
56 | <th>Cargado / Capacidad Disponible</th> | ||
57 | </tr> | ||
58 | </thead> | ||
59 | <tbody> | ||
60 | <tr ng-repeat="(key, cisterna) in cisternas"> | ||
61 | <td class="py-3" ng-bind="cisterna.codigo"></td> | ||
62 | <td class="py-3" ng-bind="cisterna.capacidad"></td> | ||
63 | <td class="py-3" ng-bind="cisterna.cisternaCarga.articulo.DetArt || 'Sin asignar'"></td> | ||
64 | <td ng-if="idRemito != -1"> | ||
65 | <input | ||
66 | class="form-control" | ||
67 | foca-tipo-input | ||
68 | foca-teclado | ||
69 | placeholder="A cargar..." | ||
70 | ng-model="aCargar[key]" | ||
71 | ng-disabled="cisterna.disabled || !tieneArticulosPendientes()" | ||
72 | ng-focus="aCargar[key] = rellenarInput(aCargar[key]); actualizarArticulo()" | ||
73 | ng-change="actualizarArticulo()" | ||
74 | > | ||
75 | </td> | ||
76 | <td ng-if="idRemito == -1"> | ||
77 | <input | ||
78 | class="form-control" | ||
79 | placeholder="A cargar..." | ||
80 | readonly> | ||
81 | </td> | ||
82 | <td><div class="progress foca-alto-progress pl-0 pr-0 mt-1"> | ||
83 | <strong | ||
84 | class="mt-2 col-4 text-center position-absolute" | ||
85 | ng-bind="(cisterna.cisternaCarga.cantidad || 0) + '/' + | ||
86 | (cisterna.capacidad - cisterna.cisternaCarga.cantidad)"> | ||
87 | </strong> | ||
88 | <div | ||
89 | id="{{cisterna.id}}" | ||
90 | class="progress-bar" | ||
91 | role="progressbar" | ||
92 | aria-valuemin="0" | ||
93 | aria-valuemax="{{cisterna.capacidad}}" | ||
94 | ng-style="{'width':'{{calcularPorcentaje(cisterna)}}'}"> | ||
95 | </div> | ||
96 | </div> | ||
97 | </td> | ||
98 | </tr> | ||
99 | </tbody> | ||
100 | </table> | ||
101 | <div class="col-12"> | ||
102 | <button | ||
103 | class="form-control btn btn-success" | ||
104 | ladda="cargando" | ||
105 | data-spinner-color="#FF0000" | ||
106 | type="button" | ||
107 | ng-disabled="!distribucionDisponible()" | ||
108 | ng-class="{'btn-light': !distribucionDisponible()}" | ||
109 | ng-click="cargarACisternas(vehiculo)" | ||
110 | foca-focus="distribucionDisponible()"> | ||
111 | Aplicar distribución de cargas | ||
112 | </button> | ||
113 | </div> | ||
114 | </div> | ||
115 | </div> | ||
116 | <div class="modal-footer py-1"> | ||
117 | <button | ||
118 | class="btn btn-sm btn-secondary" | ||
119 | ladda="cargando" | ||
120 | type="button" | ||
121 | ng-click="cancelar()">Cancelar</button> | ||
122 | <button | ||
123 | class="btn btn-sm btn-primary" | ||
124 | ladda="cargando" | ||
125 | type="button" | ||
126 | ng-click="aceptar()" | ||
127 | ng-disabled="tieneArticulosPendientes() || idRemito === -1" | ||
128 | foca-focus="!tieneArticulosPendientes() && idRemito !== -1">Cargar</button> | ||
129 | </div> | ||
130 | 1 | <div class="modal-header"> |
src/views/foca-modal-cerrar-vehiculo.html
1 | <div class="modal-header"> | 1 | <div class="modal-header"> |
2 | <h5>En desarrollo</h5> | ||
3 | <h4>Cerrar distribución vehículo</h4> | 2 | <h4>Cerrar distribución vehículo</h4> |
4 | <div class="row"> | 3 | <div class="row"> |
5 | <div class="col-6 row"> | 4 | <div class="col-6 row"> |
6 | <label class="col-3 mt-2">Fecha:</label> | 5 | <label class="col-3 mt-2">Fecha:</label> |
7 | <input | 6 | <input |
8 | type="text" | 7 | type="text" |
9 | readonly | 8 | readonly |
10 | ng-model="now" | 9 | ng-model="now" |
11 | uib-datepicker-popup="dd/MM/yyyy" | 10 | uib-datepicker-popup="dd/MM/yyyy" |
12 | show-button-bar="false" | 11 | show-button-bar="false" |
13 | is-open="datepickerOpen" | 12 | is-open="datepickerOpen" |
14 | on-open-focus="false" | 13 | on-open-focus="false" |
15 | ng-focus="datepickerOpen = true" | ||
16 | class="form-control col-8"/> | 14 | class="form-control col-8"/> |
17 | </div> | 15 | </div> |
18 | </div> | 16 | </div> |
19 | </div> | 17 | </div> |
20 | <div class="modal-body"> | 18 | <div class="modal-body"> |
21 | <form class="row" name="formHojaRuta"> | 19 | <form class="row" name="formHojaRuta"> |
22 | 20 | ||
23 | <div class="col-2"> | 21 | <div class="col-2"> |
24 | <label>Transportista</label> | 22 | <label>Transportista</label> |
25 | </div> | 23 | </div> |
26 | <div class="col-4"> | 24 | <div class="col-4"> |
27 | <input | 25 | <input |
28 | class="form-control" | 26 | class="form-control" |
29 | readonly | 27 | readonly |
30 | ng-value="vehiculo.transportista.COD + ' ' + vehiculo.transportista.NOM" | 28 | ng-value="vehiculo.transportista.COD + ' ' + vehiculo.transportista.NOM" |
31 | > | 29 | > |
32 | </div> | 30 | </div> |
33 | <div class="col-2 form-group"> | 31 | <div class="col-2 form-group"> |
34 | <label>Unidad</label> | 32 | <label>Unidad</label> |
35 | </div> | 33 | </div> |
36 | <div class="col-4"> | 34 | <div class="col-4"> |
37 | <input | 35 | <input |
38 | class="form-control" | 36 | class="form-control" |
39 | readonly | 37 | readonly |
40 | ng-model="vehiculo.tractor" | 38 | ng-model="vehiculo.tractor" |
41 | > | 39 | > |
42 | </div> | 40 | </div> |
43 | </form> | 41 | </form> |
44 | <strong>Remitos:</strong> | 42 | <strong>Remitos:</strong> |
45 | <table class="table"> | 43 | <table class="table"> |
46 | <thead> | 44 | <thead> |
47 | <tr> | 45 | <tr> |
48 | <th>Remito Nº</th> | 46 | <th>Remito Nº</th> |
49 | <th>Cliente</th> | 47 | <th>Cliente</th> |
50 | <th>Domicilio de entrega</th> | 48 | <th>Domicilio de entrega</th> |
51 | <th>Eliminar</th> | 49 | <th>Eliminar</th> |
52 | </tr> | 50 | </tr> |
53 | </thead> | 51 | </thead> |
54 | <tbody> | 52 | <tbody> |
55 | <tr ng-show="!remitos.length"> | 53 | <tr ng-show="!remitos.length"> |
56 | <td colspan="3"> | 54 | <td colspan="3"> |
57 | No se han encontrado remitos. | 55 | No se han encontrado remitos. |
58 | </td> | 56 | </td> |
59 | </tr> | 57 | </tr> |
60 | <tr ng-repeat="remito in remitos"> | 58 | <tr ng-repeat="remito in remitos"> |
61 | <td ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></td> | 59 | <td ng-bind="[remito.sucursal, remito.numeroRemito] | comprobante"></td> |
62 | <td ng-bind="remito.nombreCliente"></td> | 60 | <td ng-bind="remito.nombreCliente"></td> |
63 | <td ng-bind="remito.domicilioStamp"></td> | 61 | <td ng-bind="remito.domicilioStamp"></td> |
64 | <td> | 62 | <td> |
65 | <div class="custom-control custom-checkbox"> | 63 | <div class="custom-control custom-checkbox"> |
66 | <input | 64 | <input |
67 | type="checkbox" | 65 | type="checkbox" |
68 | ng-model="remito.checked" | 66 | ng-model="remito.checked" |
69 | class="custom-control-input" | 67 | class="custom-control-input" |
70 | id="{{remito.id}}"> | 68 | id="{{remito.id}}"> |
71 | <label class="custom-control-label" for="{{remito.id}}"></label> | 69 | <label class="custom-control-label" for="{{remito.id}}"></label> |
72 | </div> | 70 | </div> |
73 | </td> | 71 | </td> |
74 | </tr> | 72 | </tr> |
75 | </tbody> | 73 | </tbody> |
76 | </table> | 74 | </table> |
77 | </div> | 75 | </div> |
78 | <div class="modal-footer py-1"> | 76 | <div class="modal-footer py-1"> |
79 | <button | 77 | <button |
80 | class="btn btn-sm btn-danger" | 78 | class="btn btn-sm btn-danger" |
81 | type="button" | 79 | type="button" |
82 | ng-click="eliminarRemitos()" | 80 | ng-click="eliminarRemitos()" |
83 | ng-disabled="minimoUnoChecked()">Eliminar</button> | 81 | ng-disabled="minimoUnoChecked()">Eliminar</button> |
84 | <button | 82 | <button |
85 | class="btn btn-sm btn-secondary" | 83 | class="btn btn-sm btn-secondary" |
86 | ladda="cargando" | 84 | ladda="cargando" |
87 | type="button" | 85 | type="button" |
88 | ng-click="cancelar()">Cancelar</button> | 86 | ng-click="cancelar()">Cancelar</button> |
89 | <button | 87 | <button |
90 | class="btn btn-sm btn-primary" | 88 | class="btn btn-sm btn-primary" |
91 | ladda="cargando" | 89 | ladda="cargando" |
92 | type="button" | 90 | type="button" |
93 | ng-disabled="!formHojaRuta.$valid || !remitos.length" | 91 | ng-disabled="!formHojaRuta.$valid || !remitos.length" |
94 | ng-click="aceptar()">Cerrar distribución</button> | 92 | ng-click="aceptar()">Cerrar distribución</button> |
95 | </div> | 93 | </div> |
96 | 94 |