controller.js 1.58 KB
angular.module('focaAdminSeguimiento') .controller('focaAdminSeguimientoController', [
    '$scope', 'focaAdminSeguimientoService', '$location', '$routeParams',
    function($scope, focaAdminSeguimientoService, $location, $routeParams) {
        $scope.actividad = '';

        $scope.now = new Date();

        if ($routeParams.parametro === 'nota-pedido') {
            $scope.actividad = 'Nota de pedido';
        } 
        
        if ($routeParams.parametro === 'hoja-ruta') {
            $scope.actividad = 'Entrega de producto';
        }

        $scope.idUsuario = 0;
        $scope.marcadores = [];
        getSeguimiento();

        $scope.general = function() {
            $scope.idUsuario = 0;
            getSeguimiento();
        };

        $scope.individual = function() {
            $scope.idUsuario = -1;
        };

        $scope.salir = function() {
            $location.path('/');
        };

        $scope.search = function(key) {
            if (key === 13) {
                $scope.idUsuario = $scope.idUsuarioInput;
                getSeguimiento();
            }
        };

        $scope.fecha = function() {
            getSeguimiento();
        };
        
        function getSeguimiento () {
            var datos = {
                actividad: $scope.actividad,
                idUsuario: $scope.idUsuario,
                fechaDesde: $scope.now,
                fechaHasta: $scope.now
            };

            focaAdminSeguimientoService.obtenerActividad(datos).then(function(datos) {
                $scope.marcadores = datos.data;
            });
        }
    }
]);