Commit 8e1b86ffa9d426b87f5cc9b496912c34591d4160

Authored by Marcelo Puebla
Exists in master

Merge branch 'develop' of git.focasoftware.com:npm/foca-logistica-pedido-ruta

# Conflicts:
#	src/js/controller.js
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 //Datos Pantalla 8 //Datos Pantalla
9 $scope.titulo = 'Logistica de Pedidos'; 9 $scope.titulo = 'Logistica de Pedidos';
10 10
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: 'FechaEntrega.png' 17 image: 'FechaEntrega.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 setearFecha(new Date()); 32 setearFecha(new Date());
33 33
34 //SETEO BOTONERA LATERAL 34 //SETEO BOTONERA LATERAL
35 focaBotoneraLateralService.showSalir(true); 35 focaBotoneraLateralService.showSalir(true);
36 focaBotoneraLateralService.showPausar(false); 36 focaBotoneraLateralService.showPausar(false);
37 focaBotoneraLateralService.showGuardar(false); 37 focaBotoneraLateralService.showGuardar(false);
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 (!eligioFecha()) return; 50 if (!eligioFecha()) return;
51 var idRemito; 51 var idRemito;
52 if (punto === -1) { 52 if (punto === -1) {
53 idRemito = -1; 53 idRemito = -1;
54 } else { 54 } else {
55 idRemito = JSON.parse(punto).notaPedido.remito.id; 55 idRemito = JSON.parse(punto).notaPedido.remito.id;
56 } 56 }
57 $uibModal.open( 57 $uibModal.open(
58 { 58 {
59 ariaLabelledBy: 'Busqueda de Vehiculo', 59 ariaLabelledBy: 'Busqueda de Vehiculo',
60 templateUrl: 'foca-detalle-vehiculo.html', 60 templateUrl: 'foca-detalle-vehiculo.html',
61 controller: 'focaDetalleVehiculo', 61 controller: 'focaDetalleVehiculo',
62 size: 'lg', 62 size: 'lg',
63 resolve: { 63 resolve: {
64 idVehiculo: function () { return idVehiculo; }, 64 idVehiculo: function () { return idVehiculo; },
65 idRemito: function () { return idRemito; }, 65 idRemito: function () { return idRemito; },
66 fechaReparto: function () { return $scope.fechaReparto; } 66 fechaReparto: function () { return $scope.fechaReparto; }
67 } 67 }
68 } 68 }
69 ); 69 );
70 }; 70 };
71 71
72 $scope.quitarVehiculo = function (vehiculo) { 72 $scope.quitarVehiculo = function (vehiculo) {
73 if (!eligioFecha() || vehiculoEnUso(vehiculo)) return; 73 if (!eligioFecha() || vehiculoEnUso(vehiculo)) return;
74 74
75 focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + 75 focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' +
76 vehiculo.codigo + ' de ' + vehiculo.transportista.NOM + '?').then(function () { 76 vehiculo.codigo + ' de ' + vehiculo.transportista.NOM + '?').then(function () {
77 eliminarVehiculo(vehiculo); 77 eliminarVehiculo(vehiculo);
78 }); 78 });
79 }; 79 };
80 80
81 $scope.hacerHojaRuta = function (vehiculo, cerrar) { 81 $scope.hacerHojaRuta = function (vehiculo, cerrar) {
82 if (!eligioFecha() || vehiculoEnUso(vehiculo)) return; 82 if (!eligioFecha() || vehiculoEnUso(vehiculo)) return;
83 var modalInstance = $uibModal.open( 83 var modalInstance = $uibModal.open(
84 { 84 {
85 ariaLabelledBy: 'Creación hoja ruta', 85 ariaLabelledBy: 'Creación hoja ruta',
86 templateUrl: 'foca-modal-cerrar-vehiculo.html', 86 templateUrl: 'foca-modal-cerrar-vehiculo.html',
87 controller: 'focaModalCerrarVehiculo', 87 controller: 'focaModalCerrarVehiculo',
88 size: 'lg', 88 size: 'lg',
89 resolve: { 89 resolve: {
90 idVehiculo: function () { return vehiculo.id; }, 90 idVehiculo: function () { return vehiculo.id; },
91 fechaReparto: function () { return $scope.fechaReparto; }, 91 fechaReparto: function () { return $scope.fechaReparto; },
92 cerrar: function () { return cerrar; } 92 cerrar: function () { return cerrar; }
93 } 93 }
94 } 94 }
95 ); 95 );
96 modalInstance.result.then(function () { 96 modalInstance.result.then(function () {
97 97
98 }, function () { 98 }, function () {
99 //usar cuando se cancela el modal 99 //usar cuando se cancela el modal
100 }); 100 });
101 }; 101 };
102 102
103 $scope.arrastra = function () { 103 $scope.arrastra = function () {
104 $scope.arrastrando = true; 104 $scope.arrastrando = true;
105 $scope.$digest(); 105 $scope.$digest();
106 }; 106 };
107 107
108 $scope.noArrastra = function () { 108 $scope.noArrastra = function () {
109 $scope.arrastrando = false; 109 $scope.arrastrando = false;
110 $scope.$digest(); 110 $scope.$digest();
111 }; 111 };
112 112
113 $scope.individual = function () { 113 $scope.individual = function () {
114 $scope.idVendedor = -1; 114 $scope.idVendedor = -1;
115 }; 115 };
116 116
117 $scope.mostrarDetalle = function () { 117 $scope.mostrarDetalle = function () {
118 $scope.detalle = true; 118 $scope.detalle = true;
119 }; 119 };
120 120
121 $scope.salir = function () { 121 $scope.salir = function () {
122 $location.path('/'); 122 $location.path('/');
123 }; 123 };
124 124
125 $scope.search = function () { 125 $scope.search = function () {
126 getSeguimiento(); 126 getSeguimiento();
127 }; 127 };
128 128
129 $scope.fecha = function () { 129 $scope.fecha = function () {
130 getSeguimiento(); 130 getSeguimiento();
131 }; 131 };
132 132
133 $scope.seleccionarVehículo = function () { 133 $scope.seleccionarVehículo = function () {
134 var parametrosModal = { 134 var parametrosModal = {
135 titulo: 'Búsqueda de Transportista', 135 titulo: 'Búsqueda de Transportista',
136 query: '/transportista', 136 query: '/transportista',
137 columnas: [ 137 columnas: [
138 { 138 {
139 nombre: 'Código', 139 nombre: 'Código',
140 propiedad: 'COD' 140 propiedad: 'COD'
141 }, 141 },
142 { 142 {
143 nombre: 'Nombre', 143 nombre: 'Nombre',
144 propiedad: 'NOM' 144 propiedad: 'NOM'
145 }, 145 },
146 { 146 {
147 nombre: 'CUIT', 147 nombre: 'CUIT',
148 propiedad: 'CUIT' 148 propiedad: 'CUIT'
149 } 149 }
150 ] 150 ]
151 }; 151 };
152 focaModalService.modal(parametrosModal).then(function (transportista) { 152 focaModalService.modal(parametrosModal).then(function (transportista) {
153 $scope.selectVehiculo(transportista.COD, transportista.NOM); 153 $scope.selectVehiculo(transportista.COD, transportista.NOM);
154 }); 154 });
155 }; 155 };
156 156
157 <<<<<<< HEAD
158 $scope.selectVehiculo = function (idTransportista, nombreTransportista) {
159 =======
160 $scope.busquedaAvanzada = function () {
161 var modalInstance = $uibModal.open(
162 {
163 ariaLabelledBy: 'Busqueda Avanzada',
164 templateUrl: 'foca-modal-busqueda-avanzada.html',
165 controller: 'focaModalBusquedaAvanzadaController',
166 resolve: {
167 parametrosModal: function () {
168 return {
169 remitos: $scope.marcadores
170 };
171 }
172 }
173 }
174 );
175 modalInstance.result.then(function(data) {
176 actualizarMarcadores(data);
177 }, function () {
178 // funcion ejecutada cuando se cancela el modal
179 }
157 $scope.selectVehiculo = function (idTransportista, nombreTransportista) { 180 );
158 var parametrosModal = { 181 };
159 columnas: [ 182
160 { 183 $scope.selectVehiculo = function(idTransportista, nombreTransportista) {
161 propiedad: 'codigo', 184 >>>>>>> 5309ab05fe911513dc48620950d4119937687802
162 nombre: 'Código' 185 var parametrosModal = {
163 }, 186 columnas: [
164 { 187 {
165 propiedad: 'tractor', 188 propiedad: 'codigo',
166 nombre: 'tractor' 189 nombre: 'Código'
167 }, 190 },
168 { 191 {
169 propiedad: 'semi', 192 propiedad: 'tractor',
170 nombre: 'Semi' 193 nombre: 'tractor'
171 }, 194 },
172 { 195 {
173 propiedad: 'capacidadTotalCisternas', 196 propiedad: 'semi',
174 nombre: 'Capacidad' 197 nombre: 'Semi'
175 } 198 },
176 ], 199 {
177 query: '/vehiculo/transportista/' + idTransportista, 200 propiedad: 'capacidadTotalCisternas',
178 titulo: 'Búsqueda de vehiculos', 201 nombre: 'Capacidad'
179 subTitulo: idTransportista + '-' + nombreTransportista 202 }
180 }; 203 ],
181 focaModalService.modal(parametrosModal).then( 204 query: '/vehiculo/transportista/' + idTransportista,
182 function (vehiculo) { 205 titulo: 'Búsqueda de vehiculos',
183 var existe = $filter('filter')($scope.vehiculos, { id: vehiculo.id }); 206 subTitulo: idTransportista + '-' + nombreTransportista
184 if (existe.length) { 207 };
185 focaModalService.alert('El vehiculo ya ha sido cargado'); 208 focaModalService.modal(parametrosModal).then(
186 return; 209 function (vehiculo) {
187 } 210 var existe = $filter('filter')($scope.vehiculos, { id: vehiculo.id });
188 if (!vehiculo.cisternas.length) { 211 if (existe.length) {
189 focaModalService.alert('El vehiculo no tiene cisternas'); 212 focaModalService.alert('El vehiculo ya ha sido cargado');
190 return; 213 return;
191 } 214 }
192 $scope.vehiculos.push(vehiculo); 215 if (!vehiculo.cisternas.length) {
193 }, function () { 216 focaModalService.alert('El vehiculo no tiene cisternas');
194 // funcion ejecutada cuando se cancela el modal 217 return;
195 }); 218 }
196 }; 219 $scope.vehiculos.push(vehiculo);
197
198 $scope.seleccionarFechaReparto = function () { 220 }, function () {
199 focaModalService.modalFecha('Fecha de reparto').then(function (fecha) { 221 // funcion ejecutada cuando se cancela el modal
200 setearFecha(fecha); 222 });
201 }); 223 };
202 }; 224 <<<<<<< HEAD
203 225
226 $scope.seleccionarFechaReparto = function () {
227 focaModalService.modalFecha('Fecha de reparto').then(function (fecha) {
228 =======
229 $scope.seleccionarFechaReparto = function() {
230 focaModalService.modalFecha('Fecha de reparto').then(function(fecha) {
231 >>>>>>> 5309ab05fe911513dc48620950d4119937687802
232 setearFecha(fecha);
233 });
234 };
235
236 function actualizarMarcadores (filtros) {
237 var marcadores = [];
238 if (filtros.cliente && filtros.remito === undefined) {
239
240 $scope.marcadores.forEach( function (marcador) {
241 if (marcador.notaPedido.cliente.NOM === filtros.cliente) {
242 marcadores.push(marcador);
243 }
244 });
245
246 if (marcadores.length === 0) {
247 focaModalService.alert('No se encontraron coincidencias en la busqueda')
248 .then(function (data) {
249 if (data) {
250 $scope.marcadoresFiltro = marcadores;
251 }
252 });
253 $scope.$broadcast('cleanCabecera');
254 setearFecha(new Date());
255 return;
256 } else {
257 $scope.marcadoresFiltro = marcadores;
258 $scope.$broadcast('addCabecera', {
259 label: 'Cliente:',
260 valor: filtros.cliente
261 });
262 }
263 } else {
264 $scope.marcadores.forEach( function (marcador) {
265 if (filtros.remito.id === marcador.notaPedido.remito.id) {
266 marcadores.push(marcador);
267 }
268 });
269 if (marcadores.length === 0) {
270 focaModalService.alert('No se encontraron coincidencias en la busqueda')
271 .then(function (data) {
272 if (data) {
273 $scope.marcadoresFiltro = marcadores;
274 }
275 });
276 $scope.$broadcast('cleanCabecera');
277 setearFecha(new Date());
278 return;
204 function setearFecha(fecha) { 279 } else {
205 $scope.fechaReparto = fecha; 280 $scope.marcadoresFiltro = marcadores;
206 focaLogisticaPedidoRutaService.setFechaReparto(fecha); 281 $scope.$broadcast('addCabecera', {
207 focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function (res) { 282 label: 'Cliente:',
208 $scope.vehiculos = res.data; 283 valor: filtros.cliente
209 $scope.$broadcast('addCabecera', { 284 });
210 label: 'Fecha:', 285 }
211 valor: fecha.toLocaleDateString() 286 }
212 }); 287 }
213 }); 288
214 } 289 function setearFecha(fecha) {
215 290 $scope.fechaReparto = fecha;
216 function getSeguimiento() { 291 focaLogisticaPedidoRutaService.setFechaReparto(fecha);
217 var desde = new Date('1900/01/01'); 292 focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function (res) {
218 var hasta = new Date('2099/01/01'); 293 $scope.vehiculos = res.data;
219 if ($scope.fechaDesde) { 294 $scope.$broadcast('addCabecera', {
220 var fechaDesde = $scope.fechaDesde; 295 label: 'Fecha:',
221 desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); 296 valor: fecha.toLocaleDateString()
222 desde = new Date(desde); 297 });
223 } 298 });
224 if ($scope.fechaHasta) { 299 }
225 var fechaHasta = $scope.fechaHasta; 300
226 hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); 301 function getSeguimiento() {
227 hasta = hasta.setDate(hasta.getDate() + 1); 302 var desde = new Date('1900/01/01');
228 hasta = new Date(hasta); 303 var hasta = new Date('2099/01/01');
229 } 304 if ($scope.fechaDesde) {
230 var datos = { 305 var fechaDesde = $scope.fechaDesde;
231 actividad: $scope.actividad, 306 desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0));
232 idUsuario: $scope.idVendedor, 307 desde = new Date(desde);
233 fechaDesde: desde, 308 }
234 fechaHasta: hasta, 309 if ($scope.fechaHasta) {
235 asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? 310 var fechaHasta = $scope.fechaHasta;
236 false : undefined) 311 hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0));
237 }; 312 hasta = hasta.setDate(hasta.getDate() + 1);
238 313 hasta = new Date(hasta);
239 $scope.datosBuscados = { 314 }
240 actividad: $scope.actividad, 315 var datos = {
241 individual: $scope.idVendedor ? true : false 316 actividad: $scope.actividad,
242 }; 317 idUsuario: $scope.idVendedor,
243 318 fechaDesde: desde,
244 focaLogisticaPedidoRutaService.obtenerActividad(datos) 319 fechaHasta: hasta,
245 .then(function (datos) { 320 asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ?
246 if (JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { 321 false : undefined)
322 };
247 $scope.marcadores = datos.data; 323
248 } 324 $scope.datosBuscados = {
249 }); 325 actividad: $scope.actividad,
250 } 326 individual: $scope.idVendedor ? true : false
251 327 };
252 function eliminarVehiculo(vehiculo) { 328
253 focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(vehiculo.id).then(function (res) { 329 <<<<<<< HEAD
254 if (!res.data.length) { 330 focaLogisticaPedidoRutaService.obtenerActividad(datos)
255 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); 331 .then(function (datos) {
256 } else { 332 if (JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) {
257 focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + 333 $scope.marcadores = datos.data;
258 'tiene remitos asociados').then(function () { 334 }
259 $scope.hacerHojaRuta(vehiculo, true); 335 });
260 }); 336 =======
261 } 337 focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) {
262 }); 338 if (!angular.equals($scope.marcadores, datos.data)) {
263 } 339 $scope.marcadores = datos.data;
264 340 $scope.marcadoresFiltro = $scope.marcadores;
265 function eligioFecha() { 341 }
266 if (!$scope.fechaReparto) { 342 });
267 focaModalService.alert('Primero seleccione fecha de reparto'); 343 >>>>>>> 5309ab05fe911513dc48620950d4119937687802
268 return false; 344 }
269 } 345
270 return true; 346 function eliminarVehiculo(vehiculo) {
271 } 347 focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(vehiculo.id).then(function (res) {
272 348 if (!res.data.length) {
273 function vehiculoEnUso(vehiculo) { 349 $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1);
274 var idUsuario = focaLogisticaPedidoRutaService.idUsuario; 350 } else {
275 for (var i = 0; i < vehiculo.cisternas.length; i++) { 351 focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' +
276 for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { 352 'tiene remitos asociados').then(function () {
277 var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; 353 $scope.hacerHojaRuta(vehiculo, true);
278 if (cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto 354 });
279 .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso && 355 }
280 cisternaCarga.idUsuarioProceso !== idUsuario) { 356 });
281 focaModalService.alert('El vehículo está siendo usado por otro usuario'); 357 }
282 return true; 358
283 } 359 function eligioFecha() {
284 } 360 if (!$scope.fechaReparto) {
285 } 361 focaModalService.alert('Primero seleccione fecha de reparto');
286 return false; 362 return false;
287 } 363 }
288 $interval(function () { 364 return true;
289 getSeguimiento(); 365 }
290 }, 5000); 366
291 } 367 function vehiculoEnUso(vehiculo) {
292 ]); 368 var idUsuario = focaLogisticaPedidoRutaService.idUsuario;
293 369 for (var i = 0; i < vehiculo.cisternas.length; i++) {
370 for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) {
371 var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j];
372 if (cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto
373 .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso &&
374 cisternaCarga.idUsuarioProceso !== idUsuario) {
375 focaModalService.alert('El vehículo está siendo usado por otro usuario');
376 return true;
377 }
378 }
379 }
380 return false;
381 }
382 <<<<<<< HEAD
383 $interval(function () {
384 getSeguimiento();
385 }, 5000);
386 =======
387 // $interval(function() {
388 // getSeguimiento();
389 // }, 5000);
390 >>>>>>> 5309ab05fe911513dc48620950d4119937687802
391 }
392 ]);
src/js/controllerBusquedaAvanzada.js
File was created 1 angular.module('focaLogisticaPedidoRuta') .controller('focaModalBusquedaAvanzadaController', [
2 '$scope', 'focaLogisticaPedidoRutaService', '$uibModal', '$filter',
3 'focaModalService', '$uibModalInstance', 'parametrosModal',
4 function($scope, focaLogisticaPedidoRutaService, $uibModal, $filter,
5 focaModalService, $uibModalInstance, parametrosModal
6 ) {
7 $scope.cliente = '';
8 $scope.seleccionarCliente = function (key) {
9 if (key !== 13) {
10 return;
11 }
12 focaModalService.modal({
13 titulo: 'Clientes',
14 searchText: $scope.cliente,
15 query: '/cliente',
16 size: 'md',
17 columnas: [
18 {
19 propiedad: 'COD',
20 nombre: 'Codigo'
21 },
22 {
23 propiedad: 'NOM',
24 nombre: 'Nombre'
25 },
26 {
27 propiedad: 'CUIT',
28 nombre: 'CUIT'
29 }
30 ],
31 }).then(function (res) {
32 $scope.cliente = res.NOM;
33 }).catch(function (e) {
34 console.log(e);
35 });
36 };
37
38 $scope.seleccionarRemito = function () {
39 var modalInstance = $uibModal.open(
40 {
41 ariaLabelledBy: 'Busqueda de Remito',
42 templateUrl: 'foca-modal-remito.html',
43 controller: 'focaModalRemitoController',
44 size: 'lg',
45 resolve: { usadoPor: function () { return 'remito'; } }
46 }
47 );
48 modalInstance.result.then(function(remito) {
49 $scope.remito = remito;
50 $scope.remito.numero = $filter('rellenarDigitos')(remito.lugar, 4) + '-' +
51 $filter('rellenarDigitos')(remito.numeroRemito, 6);
52 $scope.cliente = remito.cliente.NOM;
53 }, function () {
54 // funcion ejecutada cuando se cancela el modal
55 }
56 );
57 };
58
59 $scope.cancel = function () {
60 $uibModalInstance.dismiss('close');
61 };
62
63 $scope.buscar = function () {
64 $uibModalInstance.close(datos());
65 };
66
67 function datos () {
68 var datos = {
69 cliente: $scope.cliente,
70 remito: $scope.remito
71 };
72 return datos;
73 }
74 }
75 ]);
76
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', '$compile', 'focaModalService', 11 controller: ['$scope', '$filter', '$compile', 'focaModalService',
12 function($scope, $filter, $compile, focaModalService) { 12 function($scope, $filter, $compile, focaModalService) {
13 $scope.markers = []; 13 $scope.markers = [];
14 $scope.verProductos = function(id) { 14 $scope.verProductos = function(id) {
15 var parametrosModal = { 15 var parametrosModal = {
16 titulo: 'Productos', 16 titulo: 'Productos',
17 query: '/articulos/remito/' + id, 17 query: '/articulos/remito/' + id,
18 soloMostrar: true, 18 soloMostrar: true,
19 size: 'md', 19 size: 'md',
20 columnas: [ 20 columnas: [
21 { 21 {
22 nombre: 'Producto', 22 nombre: 'Producto',
23 propiedad: 'descripcion' 23 propiedad: 'descripcion'
24 }, 24 },
25 { 25 {
26 nombre: 'Cantidad', 26 nombre: 'Cantidad',
27 propiedad: 'cantidad' 27 propiedad: 'cantidad'
28 } 28 }
29 ] 29 ]
30 }; 30 };
31 focaModalService.modal(parametrosModal).then(); 31 focaModalService.modal(parametrosModal).then();
32 }; 32 };
33 $scope.$watch('marcadores', function() { 33 $scope.$watch('marcadores', function() {
34 for(var i in $scope.markers) { 34 for(var i in $scope.markers) {
35 $scope.map.removeLayer($scope.markers[i]); 35 $scope.map.removeLayer($scope.markers[i]);
36 } 36 }
37 $scope.markers = []; 37 $scope.markers = [];
38 38
39 angular.forEach($scope.marcadores, function(marcador) { 39 angular.forEach($scope.marcadores, function(marcador) {
40 var observacion = 40 var observacion =
41 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' + 41 'Vendedor: ' + marcador.notaPedido.idVendedor + ' - ' +
42 ( 42 (
43 marcador.notaPedido.vendedor ? 43 marcador.notaPedido.vendedor ?
44 marcador.notaPedido.vendedor.NOM : 44 marcador.notaPedido.vendedor.NOM :
45 '' 45 ''
46 ) + '<br/>'; 46 ) + '<br/>';
47 observacion += 'Fecha: ' + 47 observacion += 'Fecha: ' +
48 $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' + 48 $filter('date')(marcador.fecha.slice(0,10), 'dd/MM/yyyy') + ' ' +
49 marcador.fecha.slice(11,19) + '<br/>'; 49 marcador.fecha.slice(11,19) + '<br/>';
50 observacion += 'Remito Nº: ' + $filter('comprobante')([ 50 observacion += 'Remito Nº: ' + $filter('comprobante')([
51 marcador.notaPedido.remito.sucursal, 51 marcador.notaPedido.remito.sucursal,
52 marcador.notaPedido.remito.numeroRemito 52 marcador.notaPedido.remito.numeroRemito
53 ]) + '<br/>'; 53 ]) + '<br/>';
54 observacion += 'Cliente: ' + 54 observacion += 'Cliente: ' +
55 marcador.notaPedido.cliente.NOM; 55 marcador.notaPedido.cliente.NOM;
56 56
57 // if($scope.parametros.individual) { 57 // if($scope.parametros.individual) {
58 observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion; 58 observacion = 'Orden: ' + marcador.orden + '<br/>' + observacion;
59 59
60 if (marcador.distancia) { 60 if (marcador.distancia) {
61 observacion += '<br/>Distancia a casa central: ' + 61 observacion += '<br/>Distancia a casa central: ' +
62 marcador.distancia + 'km'; 62 marcador.distancia + 'km';
63 } 63 }
64 var icon; 64 var icon;
65 if (marcador.notaPedido.remito.idUsuarioProceso) { 65 if (marcador.notaPedido.remito.idUsuarioProceso) {
66 observacion += '<br/>'; 66 observacion += '<br/>';
67 observacion += '<strong>'; 67 observacion += '<strong>';
68 observacion += 'Fecha de entrega: ' + marcador.notaPedido.remito 68 observacion += 'Fecha de entrega: ' + marcador.notaPedido.remito
69 .cisternaMovimientos[0].cisternaCarga.fechaReparto.substring(0, 10); 69 .cisternaMovimientos[0].cisternaCarga.fechaReparto.substring(0, 10);
70 observacion += '<br/>'; 70 observacion += '<br/>';
71 observacion += 'Vehículo: ' + marcador.notaPedido.remito 71 observacion += 'Vehículo: ' + marcador.notaPedido.remito
72 .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.codigo; 72 .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.codigo;
73 observacion += '<br/>'; 73 observacion += '<br/>';
74 observacion += 'Transportista: ' + marcador.notaPedido.remito 74 observacion += 'Transportista: ' + marcador.notaPedido.remito
75 .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.transportista 75 .cisternaMovimientos[0].cisternaCarga.cisterna.vehiculo.transportista
76 .NOM; 76 .NOM;
77 observacion += '</strong>'; 77 observacion += '</strong>';
78 //Asignado ROJO 78 //Asignado ROJO
79 icon = new L.Icon({ 79 icon = new L.Icon({
80 iconUrl: 'img/marker-icon-2x-red.png', 80 iconUrl: 'img/marker-icon-2x-red.png',
81 shadowUrl: 'img/marker-shadow.png', 81 shadowUrl: 'img/marker-shadow.png',
82 iconSize: [25, 41], 82 iconSize: [25, 41],
83 iconAnchor: [12, 41], 83 iconAnchor: [12, 41],
84 popupAnchor: [1, -34], 84 popupAnchor: [1, -34],
85 shadowSize: [41, 41] 85 shadowSize: [41, 41]
86 }); 86 });
87 } else { 87 } else {
88 observacion += '<br/>'; 88 observacion += '<br/>';
89 observacion += '<i class="fa fa-map-marker fa-3x" aria-hidden="true"'+ 89 observacion += '<i class="fa fa-map-marker marcador fa-4x" aria-hidden="true"'+
90 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+ 90 'class="form-control" ondragend="dropEnd()" ondragstart=\'drag(event, '+
91 JSON.stringify(marcador)+')\' draggable="true"></i>(Arrastrar icono)'; 91 JSON.stringify(marcador)+')\' draggable="true"></i><br><b>(Arrastrar icono)</b>';
92 observacion += '<button title="Ver productos" class="btn btn-secondary' + 92 observacion += '<button title="Ver productos" class="btn btn-secondary' +
93 ' float-right mt-2"'+ 93 ' float-right informacion"'+
94 'ng-click="verProductos('+marcador.notaPedido.remito.id+')">' + 94 'ng-click="verProductos('+marcador.notaPedido.remito.id+')">' +
95 '<i class="fa fa-info" aria-hidden="true"></i>' + 95 '<i class="fa fa-info" aria-hidden="true"></i>' +
96 '</button>'; 96 '</button>';
97 97
98 //Sin asignar VERDE 98 //Sin asignar VERDE
99 icon = new L.Icon({ 99 icon = new L.Icon({
100 iconUrl: 'img/marker-icon-2x-green.png', 100 iconUrl: 'img/marker-icon-2x-green.png',
101 shadowUrl: 'img/marker-shadow.png', 101 shadowUrl: 'img/marker-shadow.png',
102 iconSize: [25, 41], 102 iconSize: [25, 41],
103 iconAnchor: [12, 41], 103 iconAnchor: [12, 41],
104 popupAnchor: [1, -34], 104 popupAnchor: [1, -34],
105 shadowSize: [41, 41] 105 shadowSize: [41, 41]
106 }); 106 });
107 } 107 }
108 108
109 //COMPILO HTML PARA QUE FUNCIONE BOTON EN POPUP 109 //COMPILO HTML PARA QUE FUNCIONE BOTON EN POPUP
110 observacion = '<div>' + observacion + '</div>'; 110 observacion = '<div class="disable-selection">' + observacion + '</div>';
111 var compiledHtml = $compile(angular.element(observacion))($scope); 111 var compiledHtml = $compile(angular.element(observacion))($scope);
112 112
113 $scope.markers.push( 113 $scope.markers.push(
114 L.marker( 114 L.marker(
115 [marcador.latitud, marcador.longitud], {icon: icon}) 115 [marcador.latitud, marcador.longitud], {icon: icon})
116 .addTo($scope.map) 116 .addTo($scope.map)
117 .bindPopup(compiledHtml[0]) 117 .bindPopup(compiledHtml[0])
118 .bindTooltip('Haga click para seleccionar') 118 .bindTooltip('Haga click para seleccionar')
119 ); 119 );
120 //abre marcador del primer punto 120 //abre marcador del primer punto
121 //$scope.markers[0].openPopup(); 121 //$scope.markers[0].openPopup();
122 }); 122 });
123 }); 123 });
124 }], 124 }],
125 scope: { 125 scope: {
126 latitud: '=', 126 latitud: '=',
127 longitud: '=', 127 longitud: '=',
128 zoom: '=', 128 zoom: '=',
129 marcadores: '=', 129 marcadores: '=',
130 parametros: '=' 130 parametros: '='
131 } 131 }
132 }; 132 };
133 }); 133 });
134 134
src/views/foca-logistica-pedido-ruta.html
1 <div class="foca-logistica-pedido-ruta" id="scope"> 1 <div class="foca-logistica-pedido-ruta" id="scope">
2 <div class="row"> 2 <div class="row">
3 <foca-cabecera-facturador 3 <foca-cabecera-facturador
4 titulo="titulo" 4 titulo="titulo"
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> 8 </div>
9 <div class="row px-5 py-2 botonera-secundaria position-relative"> 9 <div class="row px-5 py-2 botonera-secundaria position-relative">
10 <div class="col-10"> 10 <div class="col-10">
11 <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador> 11 <foca-botonera-facturador botones="botonera" max="6" class="row"></foca-botonera-facturador>
12 </div> 12 </div>
13 <div class="col-2 pl-0 position-absolute right-0"> 13 <div class="col-2 px-0 position-absolute right-0">
14 <strong>Filtros: </strong> 14 <strong>Ver Remitos</strong>
15 <br> 15 <br>
16 <span>Fecha Desde</span> 16 <span>Fecha Desde</span>
17 <input 17 <input
18 type="text" 18 type="text"
19 readonly 19 readonly
20 ng-model="fechaDesde" 20 ng-model="fechaDesde"
21 class="form-control form-control-sm" 21 class="form-control form-control-sm"
22 uib-datepicker-popup="dd/MM/yyyy" 22 uib-datepicker-popup="dd/MM/yyyy"
23 show-button-bar="false" 23 show-button-bar="false"
24 is-open="fechaDesdeOpen" 24 is-open="fechaDesdeOpen"
25 on-open-focus="false" 25 on-open-focus="false"
26 ng-focus="fechaDesdeOpen = true" 26 ng-focus="fechaDesdeOpen = true"
27 ng-change="search()" 27 ng-change="search()"
28 /> 28 />
29 <span>Fecha Hasta</span> 29 <span>Fecha Hasta</span>
30 <input 30 <input
31 type="text" 31 type="text"
32 readonly 32 readonly
33 ng-model="fechaHasta" 33 ng-model="fechaHasta"
34 class="form-control form-control-sm" 34 class="form-control form-control-sm"
35 uib-datepicker-popup="dd/MM/yyyy" 35 uib-datepicker-popup="dd/MM/yyyy"
36 show-button-bar="false" 36 show-button-bar="false"
37 is-open="fechaHastaOpen" 37 is-open="fechaHastaOpen"
38 on-open-focus="false" 38 on-open-focus="false"
39 ng-focus="fechaHastaOpen = true" 39 ng-focus="fechaHastaOpen = true"
40 ng-change="search()" 40 ng-change="search()"
41 /> 41 />
42 <div class="custom-control custom-radio"> 42 <div class="custom-control custom-radio pt-4">
43 <input 43 <input
44 type="radio" 44 type="radio"
45 class="custom-control-input" 45 class="custom-control-input"
46 id="idTodos" 46 id="idTodos"
47 name="filtro" 47 name="filtro"
48 ng-model="filtroEstado" 48 ng-model="filtroEstado"
49 ng-change="search()" 49 ng-change="search()"
50 checked> 50 checked>
51 <label class="custom-control-label pb-3" for="idTodos"></label> 51 <label class="custom-control-label pb-3" for="idTodos"></label>
52 <img src="img/marker-icon-grey.png"> 52 <img src="img/marker-icon-grey.png">
53 <strong>Todos</strong> 53 <strong>Todos</strong>
54 </div> 54 </div>
55 <div class="custom-control custom-radio"> 55 <div class="custom-control custom-radio">
56 <input 56 <input
57 type="radio" 57 type="radio"
58 class="custom-control-input" 58 class="custom-control-input"
59 id="idSinAsignar" 59 id="idSinAsignar"
60 name="filtro" 60 name="filtro"
61 ng-model="filtroEstado" 61 ng-model="filtroEstado"
62 ng-change="search()" 62 ng-change="search()"
63 ng-value="false"> 63 ng-value="false">
64 <label class="custom-control-label pb-3" for="idSinAsignar"></label> 64 <label class="custom-control-label pb-3" for="idSinAsignar"></label>
65 <img src="img/marker-icon-green.png"> 65 <img src="img/marker-icon-green.png">
66 <strong>Sin asignar</strong> 66 <strong>Sin asignar</strong>
67 </div> 67 </div>
68 <div class="custom-control custom-radio"> 68 <div class="custom-control custom-radio">
69 <input 69 <input
70 type="radio" 70 type="radio"
71 class="custom-control-input" 71 class="custom-control-input"
72 id="idAsignado" 72 id="idAsignado"
73 name="filtro" 73 name="filtro"
74 ng-model="filtroEstado" 74 ng-model="filtroEstado"
75 ng-change="search()" 75 ng-change="search()"
76 ng-value="true"> 76 ng-value="true">
77 <label class="custom-control-label pb-3" for="idAsignado"></label> 77 <label class="custom-control-label pb-3" for="idAsignado"></label>
78 <img src="img/marker-icon-red.png"> 78 <img src="img/marker-icon-red.png">
79 <strong>Asignado</strong> 79 <strong>Asignado</strong>
80 </div> 80 </div>
81 <div class="pt-4">
82 <button
83 ladda="searchLoading"
84 class="btn btn-outline-light"
85 type="button"
86 ng-click="busquedaAvanzada()"
87 >
88 <span class="text-dark text-truncate">
89 Búsqueda Avanzada
90 <i class="fa fa-search" aria-hidden="true"></i>
91 </span>
92 </button>
93 </div>
81 </div> 94 </div>
82 </div> 95 </div>
83 <div class="row px-5"> 96 <div class="row px-5">
84 <div class="col-10"> 97 <div class="col-10">
85 <foca-logistica 98 <foca-logistica
86 latitud="-34.7152975" 99 latitud="-34.7152975"
87 longitud="-65.9053867" 100 longitud="-65.9053867"
88 zoom="5" 101 zoom="5"
89 marcadores="marcadores" 102 marcadores="marcadoresFiltro"
90 parametros= "datosBuscados" 103 parametros= "datosBuscados"
91 /> 104 />
92 </div> 105 </div>
93 <div class="row"> 106 <div class="col-12 p-0">
94 <div 107 <div class="py-2 row">
95 class="container col-auto" 108 <div class="col-sm-3" ng-repeat="vehiculo in vehiculos">
96 ng-repeat="vehiculo in vehiculos" 109 <div
97 ng-click="mostrarDetalleVehiculo(vehiculo)" 110 style="width: 15rem;"
98 > 111 class="card bg-secondary text-white m-2">
99 <div> 112 <div class="card-body text-center">
100 <div class="col-md-3 col-sm-6"> 113 <p class="card-text">{{vehiculo.transportista.NOM.trim()}}</p>
101 <div class="progress-circle" ng-class="{'arrastrando': arrastrando}"> 114 <p class="card-text"></p>
102 <span class="progress-left"> 115 <p class="card-text">{{vehiculo.codigo}}</p>
103 <span class="progress-bar"></span>
104 </span>
105 <span class="progress-right">
106 <span class="progress-bar"></span>
107 </span>
108 <div class="progress-value py-4 px-3 d-flex align-content-between flex-wrap">
109 <small class="w-100">
110 <small>
111 <small>
112 {{vehiculo.transportista.NOM.trim()}}
113 </small>
114 </small>
115 </small>
116 <small class="w-100">
117 {{vehiculo.codigo}}
118 </small>
119 </div>
120 </div> 116 </div>
121 </div> 117 <div class="card-footer" ng-hide="arrastrando">
122 <div class="row ml-2"> 118 <div class="row justify-content-around">
123 <div class="col-3 position-absolute"> 119 <div class="col-3 ml-2">
124 <img 120 <i
125 src="img/hojaRutaVolante.png" 121 class="fa fa-trash fa-lg"
126 width="100%"> 122 uib-tooltip="Eliminar vehiculo"
127 </div> 123 ng-click="quitarVehiculo(vehiculo)">
128 <div class="col-3" 124 </i>
129 uib-tooltip="Confirmar distribuición" 125 </div>
130 ng-click="hacerHojaRuta(vehiculo)"></div> 126 <div class="col-3">
131 <div class="col-3"> 127 <i
132 <i 128 class="fa fa-eye fa-lg"
133 class="fa fa-eye fa-2x" 129 uib-tooltip="Ver cisternas"
134 uib-tooltip="Ver cisternas" 130 ng-click="cargar(vehiculo.id, -1)">
135 ng-click="cargar(vehiculo.id, -1)"> 131 </i>
136 </i> 132 </div>
133 <div class="col-3">
134 <i
135 class="fa fa-save fa-lg"
136 uib-tooltip="Confirmar distribuición"
137 ng-click="hacerHojaRuta(vehiculo)">
138 </i>
139 </div>
140 </div>
src/views/foca-modal-busqueda-avanzada.html
File was created 1 <div class="modal-header">
2 <div class="row">
3 <div class="col-12">
4 <h5>Búsqueda avanzada:</h5>
5 </div>
6 </div>
7 </div>
8 <div class="modal-body">
9 <div class="row">
10 <div class="col-12">
11 <h6>Remitos del cliente:</h6>
12 </div>
13 <div class="col-12">
14 <div class="input-group">
15 <input
16 class="form-control"
17 ng-model="cliente"
18 ng-keypress="seleccionarCliente($event.keyCode)"
19 placeholder="Ingrese un cliente"
20 />
21 <button
22 ng-show="cliente !== ''"
23 type="button"
24 class="clear-input"
25 ng-click="cliente = '';"
26 ><i class="fa fa-times"></i>
27 </button>
28 <div class="input-group-append">
29 <button
30 ladda="searchLoading"
31 class="btn btn-outline-secondary form-control"
32 type="button"
33 ng-click="seleccionarCliente(13)">
34 <i class="fa fa-search" aria-hidden="true"></i>
35 </button>
36 </div>
37 </div>
38 </div>
39 </div>
40 <div class="row pt-3">
41 <div class="col-12">
42 <h6>Remito Nº</h6>
43 </div>
44 <div class="col-12">
45 <div class="input-group">
46 <input
47 class="form-control"
48 ng-model="remito.numero"
49 ng-click="seleccionarRemito()"
50 readonly/>
51 <div class="input-group-append">
52 <button
53 ladda="searchLoading"
54 class="btn btn-outline-secondary form-control"
55 type="button"
56 ng-click="seleccionarRemito()">
57 <i class="fa fa-search" aria-hidden="true"></i>
58 </button>
59 </div>
60 </div>
61 </div>
62 </div>
63 </div>
64 <div class="modal-footer py-1">
65 <button
66 class="btn btn-sm btn-secondary"
67 type="button"
68 data-dismiss="modal"
69 ng-click="cancel()">Cancelar
70 </button>
71 <button
72 class="btn btn-sm btn-primary"
73 type="button"
74 ng-click="buscar()">Buscar
75 </button>
76 </div>
77