diff --git a/src/js/controller.js b/src/js/controller.js index 0a2590d..9ce54ef 100644 --- a/src/js/controller.js +++ b/src/js/controller.js @@ -1,7 +1,7 @@ -angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaController', [ +angular.module('focaLogisticaPedidoRuta').controller('focaLogisticaPedidoRutaController', [ '$scope', 'focaLogisticaPedidoRutaService', '$location', '$uibModal', '$filter', - 'focaModalService', 'focaBotoneraLateralService', '$interval', - function($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, + 'focaModalService', 'focaBotoneraLateralService', '$interval', + function ($scope, focaLogisticaPedidoRutaService, $location, $uibModal, $filter, focaModalService, focaBotoneraLateralService, $interval ) { $scope.actividad = 'Logistica'; @@ -24,7 +24,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo $scope.vehiculos = []; getSeguimiento(); $scope.arrastrando = false; - $scope.general = function() { + $scope.general = function () { $scope.idVendedor = 0; getSeguimiento(); }; @@ -36,7 +36,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo focaBotoneraLateralService.showPausar(false); focaBotoneraLateralService.showGuardar(false); - $scope.general = function() { + $scope.general = function () { $scope.idVendedor = 0; getSeguimiento(); $scope.$broadcast('removeCabecera', cabecera); @@ -46,7 +46,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo }); }; - $scope.cargar = function(idVehiculo, punto) { + $scope.cargar = function (idVehiculo, punto) { if (!eligioFecha()) return; var idRemito; if (punto === -1) { @@ -61,24 +61,24 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo controller: 'focaDetalleVehiculo', size: 'lg', resolve: { - idVehiculo: function() {return idVehiculo;}, - idRemito: function() {return idRemito;}, - fechaReparto: function() {return $scope.fechaReparto;} + idVehiculo: function () { return idVehiculo; }, + idRemito: function () { return idRemito; }, + fechaReparto: function () { return $scope.fechaReparto; } } } ); }; - $scope.quitarVehiculo = function(vehiculo) { + $scope.quitarVehiculo = function (vehiculo) { if (!eligioFecha() || vehiculoEnUso(vehiculo)) return; focaModalService.confirm('Esta seguro que desea eliminar el vehículo ' + - vehiculo.codigo + ' de ' + vehiculo.transportista.NOM + '?').then(function() { + vehiculo.codigo + ' de ' + vehiculo.transportista.NOM + '?').then(function () { eliminarVehiculo(vehiculo); }); }; - $scope.hacerHojaRuta = function(vehiculo, cerrar) { + $scope.hacerHojaRuta = function (vehiculo, cerrar) { if (!eligioFecha() || vehiculoEnUso(vehiculo)) return; var modalInstance = $uibModal.open( { @@ -87,50 +87,50 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo controller: 'focaModalCerrarVehiculo', size: 'lg', resolve: { - idVehiculo: function() {return vehiculo.id;}, - fechaReparto: function() {return $scope.fechaReparto;}, - cerrar: function() {return cerrar;} + idVehiculo: function () { return vehiculo.id; }, + fechaReparto: function () { return $scope.fechaReparto; }, + cerrar: function () { return cerrar; } } } ); - modalInstance.result.then(function() { - - }, function() { + modalInstance.result.then(function () { + + }, function () { //usar cuando se cancela el modal }); }; - $scope.arrastra = function() { + $scope.arrastra = function () { $scope.arrastrando = true; $scope.$digest(); }; - $scope.noArrastra = function() { + $scope.noArrastra = function () { $scope.arrastrando = false; $scope.$digest(); }; - $scope.individual = function() { + $scope.individual = function () { $scope.idVendedor = -1; }; - $scope.mostrarDetalle = function() { + $scope.mostrarDetalle = function () { $scope.detalle = true; }; - $scope.salir = function() { + $scope.salir = function () { $location.path('/'); }; - $scope.search = function() { + $scope.search = function () { getSeguimiento(); }; - $scope.fecha = function() { + $scope.fecha = function () { getSeguimiento(); }; - $scope.seleccionarVehículo = function() { + $scope.seleccionarVehículo = function () { var parametrosModal = { titulo: 'Búsqueda de Transportista', query: '/transportista', @@ -149,12 +149,12 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo } ] }; - focaModalService.modal(parametrosModal).then(function(transportista) { + focaModalService.modal(parametrosModal).then(function (transportista) { $scope.selectVehiculo(transportista.COD, transportista.NOM); }); }; - $scope.selectVehiculo = function(idTransportista, nombreTransportista) { + $scope.selectVehiculo = function (idTransportista, nombreTransportista) { var parametrosModal = { columnas: [ { @@ -179,8 +179,8 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo subTitulo: idTransportista + '-' + nombreTransportista }; focaModalService.modal(parametrosModal).then( - function(vehiculo) { - var existe = $filter('filter')($scope.vehiculos, {id: vehiculo.id}); + function (vehiculo) { + var existe = $filter('filter')($scope.vehiculos, { id: vehiculo.id }); if (existe.length) { focaModalService.alert('El vehiculo ya ha sido cargado'); return; @@ -190,13 +190,13 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo return; } $scope.vehiculos.push(vehiculo); - }, function() { + }, function () { // funcion ejecutada cuando se cancela el modal }); }; - $scope.seleccionarFechaReparto = function() { - focaModalService.modalFecha('Fecha de reparto').then(function(fecha) { + $scope.seleccionarFechaReparto = function () { + focaModalService.modalFecha('Fecha de reparto').then(function (fecha) { setearFecha(fecha); }); }; @@ -204,7 +204,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo function setearFecha(fecha) { $scope.fechaReparto = fecha; focaLogisticaPedidoRutaService.setFechaReparto(fecha); - focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function(res){ + focaLogisticaPedidoRutaService.getUnidadesByFecha(fecha).then(function (res) { $scope.vehiculos = res.data; $scope.$broadcast('addCabecera', { label: 'Fecha:', @@ -241,20 +241,21 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo individual: $scope.idVendedor ? true : false }; - focaLogisticaPedidoRutaService.obtenerActividad(datos).then(function(datos) { - if (JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { - $scope.marcadores = datos.data; - } - }); + focaLogisticaPedidoRutaService.obtenerActividad(datos) + .then(function (datos) { + if (JSON.stringify(datos.data) !== JSON.stringify($scope.marcadores)) { + $scope.marcadores = datos.data; + } + }); } function eliminarVehiculo(vehiculo) { - focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(vehiculo.id).then(function(res) { + focaLogisticaPedidoRutaService.getRemitosByIdVehiculo(vehiculo.id).then(function (res) { if (!res.data.length) { $scope.vehiculos.splice($scope.vehiculos.indexOf(vehiculo), 1); } else { focaModalService.alert('No ha sido posible eliminar el vehiculo porque ' + - 'tiene remitos asociados').then(function() { + 'tiene remitos asociados').then(function () { $scope.hacerHojaRuta(vehiculo, true); }); } @@ -271,13 +272,12 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo function vehiculoEnUso(vehiculo) { var idUsuario = focaLogisticaPedidoRutaService.idUsuario; - for(var i = 0; i < vehiculo.cisternas.length; i++) { - for(var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { + for (var i = 0; i < vehiculo.cisternas.length; i++) { + for (var j = 0; j < vehiculo.cisternas[i].cisternasCarga.length; j++) { var cisternaCarga = vehiculo.cisternas[i].cisternasCarga[j]; if (cisternaCarga.fechaReparto.substring(0, 10) === $scope.fechaReparto .toISOString().substring(0, 10) && cisternaCarga.idUsuarioProceso && - cisternaCarga.idUsuarioProceso !== idUsuario) - { + cisternaCarga.idUsuarioProceso !== idUsuario) { focaModalService.alert('El vehículo está siendo usado por otro usuario'); return true; } @@ -285,7 +285,7 @@ angular.module('focaLogisticaPedidoRuta') .controller('focaLogisticaPedidoRutaCo } return false; } - $interval(function() { + $interval(function () { getSeguimiento(); }, 5000); }