Commit b89f9e9f5158f91b9c3d752594ef47524f0d52a0
1 parent
170aba0064
Exists in
develop
Change
Codigo identado
Showing
1 changed file
with
308 additions
and
330 deletions
Show diff stats
src/js/controller.js
| 1 | -angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaController', [ | |
| 2 | - '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter', | |
| 3 | - 'focaModalService', 'focaBotoneraLateralService', '$interval', | |
| 4 | - function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, | |
| 5 | - focaModalService, focaBotoneraLateralService, $interval | |
| 6 | - ) { | |
| 7 | - $scope.actividad = 'Logistica'; | |
| 8 | - //Datos Pantalla | |
| 9 | - $scope.titulo = 'Logistica de Pedidos'; | |
| 1 | +angular.module('focaLogisticaPedidoRuta').controller('focaLogisticaPedidoRutaController', [ | |
| 2 | + '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter', | |
| 3 | + 'focaModalService', 'focaBotoneraLateralService', '$interval', | |
| 4 | + function ($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, | |
| 5 | + focaModalService, focaBotoneraLateralService, $interval | |
| 6 | + ) { | |
| 7 | + $scope.actividad = 'Logistica'; | |
| 8 | + //Datos Pantalla | |
| 9 | + $scope.titulo = 'Logistica de Pedidos'; | |
| 10 | 10 | |
| 11 | - var transportista = { | |
| 12 | - label: 'Vehículo', | |
| 13 | - image: 'abmChofer.png' | |
| 14 | - }; | |
| 15 | - var fecha = { | |
| 16 | - label: 'Fecha Reparto', | |
| 17 | - image: 'FechaEntrega.png' | |
| 18 | - }; | |
| 19 | - $scope.botonera = [fecha, transportista]; | |
| 20 | - var cabecera = ''; | |
| 21 | - $scope.now = new Date(); | |
| 22 | - $scope.idVendedor = 0; | |
| 23 | - $scope.marcadores = []; | |
| 24 | - $scope.vehiculos = []; | |
| 25 | - getSeguimiento(); | |
| 26 | - $scope.arrastrando = false; | |
| 27 | - $scope.general = function() { | |
| 28 | - $scope.idVendedor = 0; | |
| 29 | - getSeguimiento(); | |
| 30 | - }; | |
| 11 | + const transportista = { label: 'Vehículo', image: 'abmChofer.png' }; | |
| 12 | + const fecha = { label: 'Fecha Reparto', image: 'FechaEntrega.png' }; | |
| 13 | + $scope.botonera = [fecha, transportista]; | |
| 14 | + var cabecera = ''; | |
| 15 | + $scope.now = new Date(); | |
| 16 | + $scope.idVendedor = 0; | |
| 17 | + $scope.marcadores = []; | |
| 18 | + $scope.vehiculos = []; | |
| 19 | + getSeguimiento(); | |
| 20 | + $scope.arrastrando = false; | |
| 21 | + $scope.general = function () { | |
| 22 | + $scope.idVendedor = 0; | |
| 23 | + getSeguimiento(); | |
| 24 | + }; | |
| 31 | 25 | |
| 32 | - setearFecha(new Date()); | |
| 26 | + setearFecha(new Date()); | |
| 33 | 27 | |
| 34 | - //SETEO BOTONERA LATERAL | |
| 35 | - focaBotoneraLateralService.showSalir(true); | |
| 36 | - focaBotoneraLateralService.showPausar(false); | |
| 37 | - focaBotoneraLateralService.showGuardar(false); | |
| 28 | + //SETEO BOTONERA LATERAL | |
| 29 | + focaBotoneraLateralService.showSalir(true); | |
| 30 | + focaBotoneraLateralService.showPausar(false); | |
| 31 | + focaBotoneraLateralService.showGuardar(false); | |
| 38 | 32 | |
| 39 | - $scope.general = function() { | |
| 40 | - $scope.idVendedor = 0; | |
| 41 | - getSeguimiento(); | |
| 42 | - $scope.$broadcast('removeCabecera', cabecera); | |
| 43 | - $scope.$broadcast('addCabecera', { | |
| 44 | - label: 'General', | |
| 45 | - valor: '' | |
| 46 | - }); | |
| 47 | - }; | |
| 33 | + $scope.general = function () { | |
| 34 | + $scope.idVendedor = 0; | |
| 35 | + getSeguimiento(); | |
| 36 | + $scope.$broadcast('removeCabecera', cabecera); | |
| 37 | + $scope.$broadcast('addCabecera', { | |
| 38 | + label: 'General', | |
| 39 | + valor: '' | |
| 40 | + }); | |
| 41 | + }; | |
| 48 | 42 | |
| 49 | - $scope.cargar = function(idVehiculo, punto) { | |
| 50 | - if (!eligioFecha()) return; | |
| 51 | - var idRemito; | |
| 52 | - if (punto === -1) { | |
| 53 | - idRemito = -1; | |
| 54 | - } else { | |
| 55 | - idRemito = JSON.parse(punto).notaPedido.remito.id; | |
| 56 | - } | |
| 57 | - $uibModal.open( | |
| 58 | - { | |
| 59 | - ariaLabelledBy: 'Busqueda de Vehiculo', | |
| 60 | - templateUrl: 'foca-detalle-vehiculo.html', | |
| 61 | - controller: 'focaDetalleVehiculo', | |
| 62 | - size: 'lg', | |
| 63 | - resolve: { | |
| 64 | - idVehiculo: function() {return idVehiculo;}, | |
| 65 | - idRemito: function() {return idRemito;}, | |
| 66 | - fechaReparto: function() {return $scope.fechaReparto;} | |
| 67 | - } | |
| 68 | - } | |
| 69 | - ); | |
| 70 | - }; | |
| 43 | + $scope.cargar = function (idVehiculo, punto) { | |
| 44 | + if (!eligioFecha()) return; | |
| 45 | + const idRemito = (punto === -1) ? -1 : JSON.parse(punto).notaPedido.remito.id; | |
| 46 | + $uibModal.open( | |
| 47 | + { | |
| 48 | + ariaLabelledBy: 'Busqueda de Vehiculo', | |
| 49 | + templateUrl: 'foca-detalle-vehiculo.html', | |
| 50 | + controller: 'focaDetalleVehiculo', | |
| 51 | + size: 'lg', | |
| 52 | + resolve: { | |
| 53 | + idVehiculo: function () { return idVehiculo; }, | |
| 54 | + idRemito: function () { return idRemito; }, | |
| 55 | + fechaReparto: function () { return $scope.fechaReparto; } | |
| 56 | + } | |
| 57 | + } | |
| 58 | + ); | |
| 59 | + }; | |
| 71 | 60 | |
| 72 | - $scope.quitarVehiculo = function(vehiculo) { | |
| 73 | - if (!eligioFecha() || vehiculoEnUso(vehiculo)) return; | |
| 61 | + $scope.quitarVehiculo = function (vehiculo) { | |
| 62 | + if (!eligioFecha() || vehiculoEnUso(vehiculo)) return; | |
| 63 | + focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + | |
| 64 | + vehiculo.codigo + ' de ' + vehiculo.transportista.NOM + '?').then(function () { | |
| 65 | + eliminarVehiculo(vehiculo); | |
| 66 | + }); | |
| 67 | + }; | |
| 74 | 68 | |
| 75 | - focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + | |
| 76 | - vehiculo.codigo + ' de ' + vehiculo.transportista.NOM + '?').then(function() { | |
| 77 | - eliminarVehiculo(vehiculo); | |
| 78 | - }); | |
| 79 | - }; | |
| 69 | + $scope.hacerHojaRuta = function (vehiculo, cerrar) { | |
| 70 | + if (!eligioFecha() || vehiculoEnUso(vehiculo)) return; | |
| 71 | + var modalInstance = $uibModal.open( | |
| 72 | + { | |
| 73 | + ariaLabelledBy: 'Creación hoja ruta', | |
| 74 | + templateUrl: 'foca-modal-cerrar-vehiculo.html', | |
| 75 | + controller: 'focaModalCerrarVehiculo', | |
| 76 | + size: 'lg', | |
| 77 | + resolve: { | |
| 78 | + idVehiculo: function () { return vehiculo.id; }, | |
| 79 | + fechaReparto: function () { return $scope.fechaReparto; }, | |
| 80 | + cerrar: function () { return cerrar; } | |
| 81 | + } | |
| 82 | + } | |
| 83 | + ); | |
| 84 | + modalInstance.result | |
| 85 | + .then(function () { }, function () { }); | |
| 86 | + }; | |
| 80 | 87 | |
| 81 | - $scope.hacerHojaRuta = function(vehiculo, cerrar) { | |
| 82 | - if (!eligioFecha() || vehiculoEnUso(vehiculo)) return; | |
| 83 | - var modalInstance = $uibModal.open( | |
| 84 | - { | |
| 85 | - ariaLabelledBy: 'Creación hoja ruta', | |
| 86 | - templateUrl: 'foca-modal-cerrar-vehiculo.html', | |
| 87 | - controller: 'focaModalCerrarVehiculo', | |
| 88 | - size: 'lg', | |
| 89 | - resolve: { | |
| 90 | - idVehiculo: function() {return vehiculo.id;}, | |
| 91 | - fechaReparto: function() {return $scope.fechaReparto;}, | |
| 92 | - cerrar: function() {return cerrar;} | |
| 93 | - } | |
| 94 | - } | |
| 95 | - ); | |
| 96 | - modalInstance.result.then(function() { | |
| 97 | - | |
| 98 | - }, function() { | |
| 99 | - //usar cuando se cancela el modal | |
| 100 | - }); | |
| 101 | - }; | |
| 88 | + $scope.arrastra = function () { | |
| 89 | + $scope.arrastrando = true; | |
| 90 | + $scope.$digest(); | |
| 91 | + }; | |
| 102 | 92 | |
| 103 | - $scope.arrastra = function() { | |
| 104 | - $scope.arrastrando = true; | |
| 105 | - $scope.$digest(); | |
| 106 | - }; | |
| 93 | + $scope.noArrastra = function () { | |
| 94 | + $scope.arrastrando = false; | |
| 95 | + $scope.$digest(); | |
| 96 | + }; | |
| 107 | 97 | |
| 108 | - $scope.noArrastra = function() { | |
| 109 | - $scope.arrastrando = false; | |
| 110 | - $scope.$digest(); | |
| 111 | - }; | |
| 98 | + $scope.individual = function () { | |
| 99 | + $scope.idVendedor = -1; | |
| 100 | + }; | |
| 112 | 101 | |
| 113 | - $scope.individual = function() { | |
| 114 | - $scope.idVendedor = -1; | |
| 115 | - }; | |
| 102 | + $scope.mostrarDetalle = function () { | |
| 103 | + $scope.detalle = true; | |
| 104 | + }; | |
| 116 | 105 | |
| 117 | - $scope.mostrarDetalle = function() { | |
| 118 | - $scope.detalle = true; | |
| 119 | - }; | |
| 106 | + $scope.salir = function () { | |
| 107 | + $location.path('/'); | |
| 108 | + }; | |
| 120 | 109 | |
| 121 | - $scope.salir = function() { | |
| 122 | - $location.path('/'); | |
| 123 | - }; | |
| 110 | + $scope.search = function () { | |
| 111 | + getSeguimiento(); | |
| 112 | + }; | |
| 124 | 113 | |
| 125 | - $scope.search = function() { | |
| 126 | - getSeguimiento(); | |
| 127 | - }; | |
| 114 | + $scope.fecha = function () { | |
| 115 | + getSeguimiento(); | |
| 116 | + }; | |
| 128 | 117 | |
| 129 | - $scope.fecha = function() { | |
| 130 | - getSeguimiento(); | |
| 131 | - }; | |
| 118 | + $scope.seleccionarVehículo = function () { | |
| 119 | + var parametrosModal = { | |
| 120 | + titulo: 'Búsqueda de Transportista', | |
| 121 | + query: '/transportista', | |
| 122 | + columnas: [ | |
| 123 | + { | |
| 124 | + nombre: 'Código', | |
| 125 | + propiedad: 'COD' | |
| 126 | + }, | |
| 127 | + { | |
| 128 | + nombre: 'Nombre', | |
| 129 | + propiedad: 'NOM' | |
| 130 | + }, | |
| 131 | + { | |
| 132 | + nombre: 'CUIT', | |
| 133 | + propiedad: 'CUIT' | |
| 134 | + } | |
| 135 | + ] | |
| 136 | + }; | |
| 137 | + focaModalService.modal(parametrosModal) | |
| 138 | + .then(function (transportista) { | |
| 139 | + $scope.selectVehiculo(transportista.COD, transportista.NOM); | |
| 140 | + }); | |
| 141 | + }; | |
| 132 | 142 | |
| 133 | - $scope.seleccionarVehículo = function() { | |
| 134 | - var parametrosModal = { | |
| 135 | - titulo: 'Búsqueda de Transportista', | |
| 136 | - query: '/transportista', | |
| 137 | - columnas: [ | |
| 138 | - { | |
| 139 | - nombre: 'Código', | |
| 140 | - propiedad: 'COD' | |
| 141 | - }, | |
| 142 | - { | |
| 143 | - nombre: 'Nombre', | |
| 144 | - propiedad: 'NOM' | |
| 145 | - }, | |
| 146 | - { | |
| 147 | - nombre: 'CUIT', | |
| 148 | - propiedad: 'CUIT' | |
| 149 | - } | |
| 150 | - ] | |
| 151 | - }; | |
| 152 | - focaModalService.modal(parametrosModal).then(function(transportista) { | |
| 153 | - $scope.selectVehiculo(transportista.COD, transportista.NOM); | |
| 154 | - }); | |
| 155 | - }; | |
| 143 | + $scope.seleccionarRemito = function () { | |
| 144 | + var modalInstance = $uibModal.open( | |
| 145 | + { | |
| 146 | + ariaLabelledBy: 'Busqueda de Remito', | |
| 147 | + templateUrl: 'foca-modal-remito.html', | |
| 148 | + controller: 'focaModalRemitoController', | |
| 149 | + size: 'lg', | |
| 150 | + resolve: { usadoPor: function () { return 'remito'; } } | |
| 151 | + } | |
| 152 | + ); | |
| 153 | + modalInstance.result | |
| 154 | + .then(function (remito) { | |
| 155 | + $scope.remito = remito; | |
| 156 | + $scope.remito.numero = $filter('rellenarDigitos')(remito.lugar, 4) + '-' + | |
| 157 | + $filter('rellenarDigitos')(remito.numeroRemito, 6); | |
| 158 | + $scope.cliente = remito.cliente.NOM; | |
| 159 | + }, function () { }); | |
| 160 | + }; | |
| 156 | 161 | |
| 157 | - $scope.seleccionarRemito = function () { | |
| 158 | - var modalInstance = $uibModal.open( | |
| 159 | - { | |
| 160 | - ariaLabelledBy: 'Busqueda de Remito', | |
| 161 | - templateUrl: 'foca-modal-remito.html', | |
| 162 | - controller: 'focaModalRemitoController', | |
| 163 | - size: 'lg', | |
| 164 | - resolve: { usadoPor: function () { return 'remito'; } } | |
| 165 | - } | |
| 166 | - ); | |
| 167 | - modalInstance.result.then(function(remito) { | |
| 168 | - $scope.remito = remito; | |
| 169 | - $scope.remito.numero = $filter('rellenarDigitos')(remito.lugar, 4) + '-' + | |
| 170 | - $filter('rellenarDigitos')(remito.numeroRemito, 6); | |
| 171 | - $scope.cliente = remito.cliente.NOM; | |
| 172 | - }, function () { | |
| 173 | - // funcion ejecutada cuando se cancela el modal | |
| 174 | - } | |
| 175 | - ); | |
| 176 | - }; | |
| 162 | + $scope.selectVehiculo = function (idTransportista, nombreTransportista) { | |
| 163 | + var parametrosModal = { | |
| 164 | + columnas: [ | |
| 165 | + { | |
| 166 | + propiedad: 'codigo', | |
| 167 | + nombre: 'Código' | |
| 168 | + }, | |
| 169 | + { | |
| 170 | + propiedad: 'tractor', | |
| 171 | + nombre: 'tractor' | |
| 172 | + }, | |
| 173 | + { | |
| 174 | + propiedad: 'semi', | |
| 175 | + nombre: 'Semi' | |
| 176 | + }, | |
| 177 | + { | |
| 178 | + propiedad: 'capacidadTotalCisternas', | |
| 179 | + nombre: 'Capacidad' | |
| 180 | + } | |
| 181 | + ], | |
| 182 | + query: '/vehiculo/transportista/' + idTransportista, | |
| 183 | + titulo: 'Búsqueda de vehiculos', | |
| 184 | + subTitulo: idTransportista + '-' + nombreTransportista | |
| 185 | + }; | |
| 186 | + focaModalService.modal(parametrosModal) | |
| 187 | + .then( | |
| 188 | + function (vehiculo) { | |
| 189 | + var existe = $filter('filter')($scope.vehiculos, { id: vehiculo.id }); | |
| 190 | + if (existe.length) { | |
| 191 | + focaModalService.alert('El vehiculo ya ha sido cargado'); | |
| 192 | + return; | |
| 193 | + } | |
| 194 | + if (!vehiculo.cisternas.length) { | |
| 195 | + focaModalService.alert('El vehiculo no tiene cisternas'); | |
| 196 | + return; | |
| 197 | + } | |
| 198 | + $scope.vehiculos.push(vehiculo); | |
| 199 | + }, function () { }); | |
| 200 | + }; | |
| 177 | 201 | |
| 178 | - $scope.selectVehiculo = function(idTransportista, nombreTransportista) { | |
| 179 | - var parametrosModal = { | |
| 180 | - columnas: [ | |
| 181 | - { | |
| 182 | - propiedad: 'codigo', | |
| 183 | - nombre: 'Código' | |
| 184 | - }, | |
| 185 | - { | |
| 186 | - propiedad: 'tractor', | |
| 187 | - nombre: 'tractor' | |
| 188 | - }, | |
| 189 | - { | |
| 190 | - propiedad: 'semi', | |
| 191 | - nombre: 'Semi' | |
| 192 | - }, | |
| 193 | - { | |
| 194 | - propiedad: 'capacidadTotalCisternas', | |
| 195 | - nombre: 'Capacidad' | |
| 196 | - } | |
| 197 | - ], | |
| 198 | - query: '/vehiculo/transportista/' + idTransportista, | |
| 199 | - titulo: 'Búsqueda de vehiculos', | |
| 200 | - subTitulo: idTransportista + '-' + nombreTransportista | |
| 201 | - }; | |
| 202 | - focaModalService.modal(parametrosModal).then( | |
| 203 | - function(vehiculo) { | |
| 204 | - var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); | |
| 205 | - if (existe.length) { | |
| 206 | - focaModalService.alert('El vehiculo ya ha sido cargado'); | |
| 207 | - return; | |
| 208 | - } | |
| 209 | - if (!vehiculo.cisternas.length) { | |
| 210 | - focaModalService.alert('El vehiculo no tiene cisternas'); | |
| 211 | - return; | |
| 212 | - } | |
| 213 | - $scope.vehiculos.push(vehiculo); | |
| 214 | - }, function() { | |
| 215 | - // funcion ejecutada cuando se cancela el modal | |
| 216 | - }); | |
| 217 | - }; | |
| 218 | - $scope.seleccionarFechaReparto = function() { | |
| 219 | - focaModalService.modalFecha('Fecha de reparto').then(function(fecha) { | |
| 220 | - setearFecha(fecha); | |
| 221 | - }); | |
| 222 | - }; | |
| 202 | + $scope.seleccionarFechaReparto = function () { | |
| 203 | + focaModalService.modalFecha('Fecha de reparto') | |
| 204 | + .then(function (fecha) { | |
| 205 | + setearFecha(fecha); | |
| 206 | + }); | |
| 207 | + }; | |
| 223 | 208 | |
| 224 | - function actualizarMarcadores (filtros) { | |
| 225 | - var marcadores = []; | |
| 226 | - if (filtros.cliente && filtros.remito === undefined) { | |
| 209 | + function actualizarMarcadores(filtros) { | |
| 210 | + var marcadores = []; | |
| 211 | + if (filtros.cliente && filtros.remito === undefined) { | |
| 227 | 212 | |
| 228 | - $scope.marcadores.forEach( function (marcador) { | |
| 229 | - if (marcador.notaPedido.cliente.NOM === filtros.cliente) { | |
| 230 | - marcadores.push(marcador); | |
| 231 | - } | |
| 232 | - }); | |
| 213 | + $scope.marcadores.forEach(function (marcador) { | |
| 214 | + if (marcador.notaPedido.cliente.NOM === filtros.cliente) { | |
| 215 | + marcadores.push(marcador); | |
| 216 | + } | |
| 217 | + }); | |
| 233 | 218 | |
| 234 | - if (marcadores.length === 0) { | |
| 235 | - focaModalService.alert('No se encontraron coincidencias en la busqueda') | |
| 236 | - .then(function (data) { | |
| 237 | - if (data) { | |
| 238 | - $scope.marcadoresFiltro = marcadores; | |
| 239 | - } | |
| 240 | - }); | |
| 241 | - $scope.$broadcast('cleanCabecera'); | |
| 242 | - setearFecha(new Date()); | |
| 243 | - return; | |
| 244 | - } else { | |
| 245 | - $scope.marcadoresFiltro = marcadores; | |
| 246 | - $scope.$broadcast('addCabecera', { | |
| 247 | - label: 'Cliente:', | |
| 248 | - valor: filtros.cliente | |
| 249 | - }); | |
| 250 | - } | |
| 251 | - } else { | |
| 252 | - $scope.marcadores.forEach( function (marcador) { | |
| 253 | - if (filtros.remito.id === marcador.notaPedido.remito.id) { | |
| 254 | - marcadores.push(marcador); | |
| 255 | - } | |
| 256 | - }); | |
| 257 | - if (marcadores.length === 0) { | |
| 258 | - focaModalService.alert('No se encontraron coincidencias en la busqueda') | |
| 259 | - .then(function (data) { | |
| 260 | - if (data) { | |
| 261 | - $scope.marcadoresFiltro = marcadores; | |
| 262 | - } | |
| 263 | - }); | |
| 264 | - $scope.$broadcast('cleanCabecera'); | |
| 265 | - setearFecha(new Date()); | |
| 266 | - return; | |
| 267 | - } else { | |
| 268 | - $scope.marcadoresFiltro = marcadores; | |
| 269 | - $scope.$broadcast('addCabecera', { | |
| 270 | - label: 'Cliente:', | |
| 271 | - valor: filtros.cliente | |
| 272 | - }); | |
| 273 | - } | |
| 274 | - } | |
| 219 | + if (marcadores.length === 0) { | |
| 220 | + focaModalService.alert('No se encontraron coincidencias en la busqueda') | |
| 221 | + .then(function (data) { | |
| 222 | + if (data) $scope.marcadoresFiltro = marcadores; | |
| 223 | + }); | |
| 224 | + $scope.$broadcast('cleanCabecera'); | |
| 225 | + setearFecha(new Date()); | |
| 226 | + return; | |
| 227 | + } else { | |
| 228 | + $scope.marcadoresFiltro = marcadores; | |
| 229 | + $scope.$broadcast('addCabecera', { | |
| 230 | + label: 'Cliente:', | |
| 231 | + valor: filtros.cliente | |
| 232 | + }); | |
| 275 | 233 | } |
| 276 | - | |
| 277 | - function setearFecha(fecha) { | |
| 278 | - $scope.fechaReparto = fecha; | |
| 279 | - focaLogisticaPedidoRutaService.setFechaReparto(fecha); | |
| 280 | - focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function(res){ | |
| 281 | - $scope.vehiculos = res.data; | |
| 282 | - $scope.$broadcast('addCabecera', { | |
| 283 | - label: 'Fecha:', | |
| 284 | - valor: fecha.toLocaleDateString() | |
| 285 | - }); | |
| 234 | + } else { | |
| 235 | + $scope.marcadores.forEach(function (marcador) { | |
| 236 | + if (filtros.remito.id === marcador.notaPedido.remito.id) marcadores.push(marcador); | |
| 237 | + }); | |
| 238 | + if (marcadores.length === 0) { | |
| 239 | + focaModalService.alert('No se encontraron coincidencias en la busqueda') | |
| 240 | + .then(function (data) { | |
| 241 | + if (data) $scope.marcadoresFiltro = marcadores; | |
| 286 | 242 | }); |
| 243 | + $scope.$broadcast('cleanCabecera'); | |
| 244 | + setearFecha(new Date()); | |
| 245 | + return; | |
| 246 | + } else { | |
| 247 | + $scope.marcadoresFiltro = marcadores; | |
| 248 | + $scope.$broadcast('addCabecera', { | |
| 249 | + label: 'Cliente:', | |
| 250 | + valor: filtros.cliente | |
| 251 | + }); | |
| 287 | 252 | } |
| 253 | + } | |
| 254 | + } | |
| 288 | 255 | |
| 289 | - function getSeguimiento() { | |
| 290 | - var desde = new Date('1900/01/01'); | |
| 291 | - var hasta = new Date('2099/01/01'); | |
| 292 | - if ($scope.fechaDesde) { | |
| 293 | - var fechaDesde = $scope.fechaDesde; | |
| 294 | - desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); | |
| 295 | - desde = new Date(desde); | |
| 296 | - } | |
| 297 | - if ($scope.fechaHasta) { | |
| 298 | - var fechaHasta = $scope.fechaHasta; | |
| 299 | - hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); | |
| 300 | - hasta = hasta.setDate(hasta.getDate() + 1); | |
| 301 | - hasta = new Date(hasta); | |
| 302 | - } | |
| 303 | - var datos = { | |
| 304 | - actividad: $scope.actividad, | |
| 305 | - idUsuario: $scope.idVendedor, | |
| 306 | - fechaDesde: desde, | |
| 307 | - fechaHasta: hasta, | |
| 308 | - asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? | |
| 309 | - false : undefined) | |
| 310 | - }; | |
| 256 | + function setearFecha(fecha) { | |
| 257 | + $scope.fechaReparto = fecha; | |
| 258 | + focaLogisticaPedidoRutaService.setFechaReparto(fecha); | |
| 259 | + focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function (res) { | |
| 260 | + $scope.vehiculos = res.data; | |
| 261 | + $scope.$broadcast('addCabecera', { | |
| 262 | + label: 'Fecha:', | |
| 263 | + valor: fecha.toLocaleDateString() | |
| 264 | + }); | |
| 265 | + }); | |
| 266 | + } | |
| 311 | 267 | |
| 312 | - $scope.datosBuscados = { | |
| 313 | - actividad: $scope.actividad, | |
| 314 | - individual: $scope.idVendedor ? true : false | |
| 315 | - }; | |
| 268 | + function getSeguimiento() { | |
| 269 | + var desde = new Date('1900/01/01'); | |
| 270 | + var hasta = new Date('2099/01/01'); | |
| 271 | + if ($scope.fechaDesde) { | |
| 272 | + var fechaDesde = $scope.fechaDesde; | |
| 273 | + desde = new Date(new Date(fechaDesde.setHours(0)).setMinutes(0)); | |
| 274 | + desde = new Date(desde); | |
| 275 | + } | |
| 276 | + if ($scope.fechaHasta) { | |
| 277 | + var fechaHasta = $scope.fechaHasta; | |
| 278 | + hasta = new Date(new Date(fechaHasta.setHours(0)).setMinutes(0)); | |
| 279 | + hasta = hasta.setDate(hasta.getDate() + 1); | |
| 280 | + hasta = new Date(hasta); | |
| 281 | + } | |
| 282 | + var datos = { | |
| 283 | + actividad: $scope.actividad, | |
| 284 | + idUsuario: $scope.idVendedor, | |
| 285 | + fechaDesde: desde, | |
| 286 | + fechaHasta: hasta, | |
| 287 | + asignacion: $scope.filtroEstado ? true : ($scope.filtroEstado !== undefined ? | |
| 288 | + false : undefined) | |
| 289 | + }; | |
| 316 | 290 | |
| 317 | - focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { | |
| 318 | - if (!angular.equals($scope.marcadores, datos.data)) { | |
| 319 | - $scope.marcadores = datos.data; | |
| 320 | - $scope.marcadoresFiltro = $scope.marcadores; | |
| 321 | - } | |
| 322 | - }); | |
| 291 | + $scope.datosBuscados = { | |
| 292 | + actividad: $scope.actividad, | |
| 293 | + individual: $scope.idVendedor ? true : false | |
| 294 | + }; | |
| 295 | + | |
| 296 | + focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function (datos) { | |
| 297 | + if (!angular.equals($scope.marcadores, datos.data)) { | |
| 298 | + $scope.marcadores = datos.data; | |
| 299 | + $scope.marcadoresFiltro = $scope.marcadores; | |
| 323 | 300 | } |
| 301 | + }); | |
| 302 | + } | |
| 324 | 303 | |
| 325 | - function eliminarVehiculo(vehiculo) { | |
| 326 | - focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(vehiculo.id).then(function(res) { | |
| 327 | - if (!res.data.length) { | |
| 328 | - $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | |
| 329 | - } else { | |
| 330 | - focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + | |
| 331 | - 'tiene remitos asociados').then(function() { | |
| 332 | - $scope.hacerHojaRuta(vehiculo, true); | |
| 333 | - }); | |
| 334 | - } | |
| 304 | + function eliminarVehiculo(vehiculo) { | |
| 305 | + focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(vehiculo.id).then(function (res) { | |
| 306 | + if (!res.data.length) { | |
| 307 | + $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); | |
| 308 | + } else { | |
| 309 | + focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + | |
| 310 | + 'tiene remitos asociados').then(function () { | |
| 311 | + $scope.hacerHojaRuta(vehiculo, true); | |
| 335 | 312 | }); |
| 336 | 313 | } |
| 314 | + }); | |
| 315 | + } | |
| 337 | 316 | |
| 338 | - function eligioFecha() { | |
| 339 | - if (!$scope.fechaReparto) { | |
| 340 | - focaModalService.alert('Primero seleccione fecha de reparto'); | |
| 341 | - return false; | |
| 342 | - } | |
| 343 | - return true; | |
| 344 | - } | |
| 317 | + function eligioFecha() { | |
| 318 | + if (!$scope.fechaReparto) { | |
| 319 | + focaModalService.alert('Primero seleccione fecha de reparto'); | |
| 320 | + return false; | |
| 321 | + } | |
| 322 | + return true; | |
| 323 | + } | |
| 345 | 324 | |
| 346 | - function vehiculoEnUso(vehiculo) { | |
| 347 | - var idUsuario = focaLogisticaPedidoRutaService.idUsuario; | |
| 348 | - for(var i = 0; i < vehiculo.cisternas.length; i++) { | |
| 349 | - for(var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | |
| 350 | - var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; | |
| 351 | - if (cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto | |
| 352 | - .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso && | |
| 353 | - cisternaCarga.idUsuarioProceso !== idUsuario) | |
| 354 | - { | |
| 355 | - focaModalService.alert('El vehículo está siendo usado por otro usuario'); | |
| 356 | - return true; | |
| 357 | - } | |
| 358 | - } | |
| 359 | - } | |
| 360 | - return false; | |
| 325 | + function vehiculoEnUso(vehiculo) { | |
| 326 | + var idUsuario = focaLogisticaPedidoRutaService.idUsuario; | |
| 327 | + for (var i = 0; i < vehiculo.cisternas.length; i++) { | |
| 328 | + for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { | |
| 329 | + var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; | |
| 330 | + if (cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto | |
| 331 | + .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso && | |
| 332 | + cisternaCarga.idUsuarioProceso !== idUsuario) { | |
| 333 | + focaModalService.alert('El vehículo está siendo usado por otro usuario'); | |
| 334 | + return true; | |
| 335 | + } | |
| 361 | 336 | } |
| 362 | - // $interval(function() { | |
| 363 | - // getSeguimiento(); | |
| 364 | - // }, 5000); | |
| 337 | + } | |
| 338 | + return false; | |
| 365 | 339 | } |
| 340 | + // $interval(function() { | |
| 341 | + // getSeguimiento(); | |
| 342 | + // }, 5000); | |
| 343 | + } | |
| 366 | 344 | ]); |