controller.js 1.45 KB
angular.module('focaBotoneraPrincipal')
    .controller('focaBotoneraPrincipalController', [
        '$scope', '$rootScope', '$timeout', '$location', '$localStorage',
        'botones', 'focaModalService', 'APP', 'focaBotoneraLateralService',
        function ($scope, $rootScope, $timeout, $location, $localStorage,
            botones, focaModalService, APP, focaBotoneraLateralService) {
            $scope.paginas = [];
            var botonesPorPagina = 10;
            if (APP === 'distribuidor' || APP === 'transportista') {
                botonesPorPagina = 3;
            }
            for (var i = 0; i < botones.data.length; i += botonesPorPagina) {
                $scope.paginas.push(botones.data.slice(i, i + botonesPorPagina));
            }

            focaBotoneraLateralService.showGuardar(false);
            focaBotoneraLateralService.showPausar(false);
            focaBotoneraLateralService.showSalir(false);
            focaBotoneraLateralService.showCancelar(false);

            $scope.rutas = $localStorage.rutas? JSON.parse($localStorage.rutas) : [];

            $scope.irA = function (accion) {
                $location.path(accion);
            };

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

            $scope.showTerminal = function () {
                var key = $localStorage.terminalKey;
                focaModalService.info('Su terminal es: ' + key);
            };

        }
    ]);