angular.module('controladores',[]) .controller('InicioController', ['$scope', 'Utilidades', function($scope, Utilidades, ){ $scope.inscrito = {}; $scope.enviar = function(){ Utilidades.ejecutarPut('api/contacto/', $scope.inscrito, function(response){ $('#modalEnviado').modal('show'); $scope.inscrito = {}; }, null); } }]) .controller('BingoController', ['$scope', 'Utilidades', '$interval', '$location', function($scope, Utilidades, $interval,$location){ $scope.id_tarjeton = ''; $scope.bingo = []; $scope.tablero = [[0,0,0,0,0],[0,0,0,0,0],[0,0,'-',0,0],[0,0,0,0,0],[0,0,0,0,0]]; $scope.mostrarTablero = false; $scope.selectCasilla = function(num){ if (num != '-'){ var pos = -1; var posi = -1; for (var i = 0; i < $scope.bingo.length; i++){ pos = $scope.bingo[i].indexOf(num); if (pos != -1){ posi = i; i = $scope.bingo.length; } } if ($scope.tablero[posi][pos]){ $scope.tablero[posi][pos] = 0; } else { $scope.tablero[posi][pos] = 1; } } }; $scope.casillaSeleccionada = function(num){ var pos = -1; var posi = -1; for (var i = 0; i < $scope.bingo.length; i++){ pos = $scope.bingo[i].indexOf(num); if (pos != -1){ posi = i; i = $scope.bingo.length; } } if (posi != -1 && pos != -1 && $scope.tablero[posi][pos]){ return 'casilla-seleccionada'; } return ''; }; $scope.limpiar = function(){ $scope.tablero = [[0,0,0,0,0],[0,0,0,0,0],[0,0,'-',0,0],[0,0,0,0,0],[0,0,0,0,0]]; }; $scope.gritarBingo = function(){ Utilidades.ejecutarPut('api/cantar_bingo/' + $scope.id_tarjeton, null, function(response){ console.log(response); $scope.respuesta = response.data.contenido.resp; $('#modalGritarBingo').modal('show'); }, null); }; function cargar(){ $scope.id_tarjeton = $location.search().idtr; Utilidades.ejecutarGet('api/tarjeton/' + $scope.id_tarjeton, function(response){ $scope.bingo = response; $scope.mostrarTablero = true; }, null); } cargar(); }]) .controller('InscritosController', ['$scope', 'Utilidades', '$interval', '$location', function($scope, Utilidades, $interval,$location){ $scope.inscritos = []; function cargar(){ var id_url = $location.search().idurl; Utilidades.ejecutarGet('api/inscritos/' + id_url, function(response){ $scope.inscritos = response; }, null); }; cargar(); }]) .controller('InscripcionController', ['$scope', 'Utilidades', '$interval', '$location', function($scope, Utilidades, $interval,$location){ $scope.inscrito = {}; $scope.valido = false; $scope.tipos_doc = [{titulo: 'Cédula de ciudadanía', value: 'CC'}/*, {titulo: 'Cédula de extranjería', value: 'CE'}, {titulo: 'Pasaporte', value: 'PP'}*/]; $scope.continuar = function(){ $('#modalConfirmar').modal('show'); } $scope.inscribir = function(){ Utilidades.ejecutarPut('api/inscribir_participante/', $scope.inscrito, function(response){ $scope.inscrito = {}; $('#modalRegistrado').modal('show'); }, null); } function cargar(){ $scope.inscrito.codigo_bingo = $location.search().cod; Utilidades.ejecutarGet('api/validar_codigo_bingo/' + $scope.inscrito.codigo_bingo, function(response){ $scope.valido = response.valido; }, null); }; cargar(); }]) .controller('GeneradorController', ['$scope', 'Utilidades', '$interval', '$location', function($scope, Utilidades, $interval, $location){ $scope.b = []; $scope.i = []; $scope.n = []; $scope.g = []; $scope.o = []; $scope.generados = []; $scope.ultimos = []; $scope.tarjetones = []; $scope.premios = []; $scope.premios_id = []; $scope.premioActual = ''; $scope.premioActualId = -1; $scope.tarjetonActual = []; $scope.tarjetones = []; $scope.premios = []; $scope.victoriosos = []; $scope.balota = ''; $scope.estado = 0; $scope.tiempo = [0,0,0]; $scope.codigo = ''; $scope.iniciar = function(){ $scope.estado = 1; $scope.cronometro = $interval(function() { $scope.contar(); }, 1000); $scope.consultaGanadores = $interval(function() { $scope.consultarGritos(); }, 1000); }; $scope.contar = function(){ $scope.tiempo[2]++; if ($scope.tiempo[2] == 60){ $scope.tiempo[2] = 0; $scope.tiempo[1]++; } if ($scope.tiempo[1] == 60){ $scope.tiempo[1] = 0; $scope.tiempo[0]++; } }; $scope.generar = function(){ if ($scope.generados.length < 75){ var gen = 0; do { gen = Math.floor(Math.random() * (76 - 1)) + 1; } while($scope.generados.indexOf(gen) > -1); $scope.ultimos.push(gen); $scope.generados.push(gen); if ($scope.ultimos.length > 10){ $scope.ultimos.shift(); } $scope.balota = gen <= 15 ? 'B' + gen : (gen <= 30 ? 'I' + gen : (gen <= 45 ? 'N' + gen : (gen <= 60 ? 'G' + gen : 'O' + gen))); stop = $interval(function() { $scope.balota = ''; $interval.cancel(stop); }, 3450); } }; $scope.clases = function(num){ var c = ''; if ($scope.generados.indexOf(num) > -1){ c += 'generado'; } var ultimos = $scope.ultimos.indexOf(num); if ($scope.ultimos.length && ultimos == $scope.ultimos.length - 1){ c += ' ultima'; } else if (ultimos > -1){ c += ' ultimos'; } /* if ($scope.balota && $scope.balota.includes(num) > -1){ c += ' balota'; }*/ return c; }; $scope.clases_tarjeton = function(val){ return val == 1 ? 'sombreada' : ''; }; $scope.jugarTarjeton = function(index){ $interval.cancel($scope.consultaGanadores); $scope.tarjetonActual = $scope.tarjetones[index]; $scope.premioActual = $scope.premios[index]; $scope.premioActualId = $scope.premios_id[index]; $scope.estado = 0; $scope.tiempo = [0,0,0]; $scope.generados = []; $scope.ultimos = []; $interval.cancel($scope.cronometro); }; $scope.consultarGritos = function(){ Utilidades.ejecutarGetSinCarga('api/get_gritos/' + $scope.codigo, function(response){ if (response.length){ $scope.ganadores = response; $interval.cancel($scope.consultaGanadores); $('#modalGritoBingo').modal('show'); } }, null); }; $scope.aprobar = function(indice, ganador){ $scope.victoriosos.push({nombres: ganador.nombres, apellidos: ganador.apellidos, premio: $scope.premioActual}); Utilidades.ejecutarGet('api/aprobar/' + ganador.id + '/' + $scope.premioActualId, function(response){ $scope.ganadores.splice(indice, 1); if (!$scope.ganadores.length){ $scope.consultaGanadores = $interval(function() { $scope.consultarGritos(); }, 1000); } }, null); }; $scope.denegar = function(indice, perdedor){ Utilidades.ejecutarGet('api/denegar/' + perdedor.id, function(response){ $scope.ganadores.splice(indice, 1); if (!$scope.ganadores.length){ $scope.consultaGanadores = $interval(function() { $scope.consultarGritos(); }, 1000); } }, null); }; function cargar(){ $scope.codigo = $location.search().cod; Utilidades.ejecutarGet('api/premios/0/' + $scope.codigo, function(response){ for (var i = 0; i < response.length; i++){ $scope.tarjetones.push(response[i].figura); $scope.premios.push(response[i].premio); $scope.premios_id.push(response[i].id); } $scope.tarjetonActual = $scope.tarjetones[0]; $scope.premioActual = $scope.premios[0]; $scope.premioActualId = $scope.premios_id[0]; }, null); for (var i = 1; i <= 15; i++){ $scope.b.push(i); $scope.i.push(i + 15); $scope.n.push(i + 30); $scope.g.push(i + 45); $scope.o.push(i + 60); } }; cargar(); }]) .controller('ConfirmadoController', ['$scope', 'Utilidades', function($scope, Utilidades){ }]) .controller('VotacionesController', ['$scope', 'Utilidades', '$interval', '$location', function($scope, Utilidades, $interval,$location){ $scope.inscrito = {}; $scope.voto_blanco_consejo = false; $scope.voto_blanco_junta = false; $scope.logueado = false; $scope.votos = {junta: [], consejo: []}; $scope.tipos_doc = [{titulo: 'Cédula de ciudadanía', value: 'CC'}/*, {titulo: 'Cédula de extranjería', value: 'CE'}, {titulo: 'Pasaporte', value: 'PP'}*/]; $scope.candidatosJunta = []; $scope.candidatosConsejo = []; $scope.continuar = function(){ $('#modalConfirmar').modal('show'); }; $scope.votarBlancoJunta = function(){ $scope.voto_blanco_junta = $scope.voto_blanco_junta ? false : true; }; $scope.votarBlancoConsejo = function(){ $scope.voto_blanco_consejo = $scope.voto_blanco_consejo ? false : true; }; $scope.votar = function(){ $scope.inscrito.junta = $scope.votos.junta; $scope.inscrito.consejo = $scope.votos.consejo; Utilidades.ejecutarPut('api/votar/', $scope.inscrito, function(response){ if (response.data.contenido.resp == -1){ $scope.inscrito = {}; $scope.logueado = false; $('#modalVotado').modal('show'); } else if (response.data.contenido.resp == -2){ $scope.inscrito = {}; $scope.logueado = false; $('#modalNoRegistrado').modal('show'); } else if (response.data.contenido.resp == -3){ $scope.inscrito = {}; $scope.logueado = false; $('#modalCerrada').modal('show'); } else { $scope.redireccionar(); } }, null); }; $scope.entrar = function(){ Utilidades.ejecutarPut('api/votantes', $scope.inscrito, function(response){ if (response.data.contenido.resp == -1){ $scope.inscrito = {}; $scope.votos = {junta: [], consejo: []}; $('#modalVotado').modal('show'); } else if (response.data.contenido.resp == -2){ $scope.inscrito = {}; $scope.votos = {junta: [], consejo: []}; $('#modalNoRegistrado').modal('show'); } else if (response.data.contenido.resp == -3){ $scope.inscrito = {}; $scope.votos = {junta: [], consejo: []}; $('#modalCerrada').modal('show'); } else if (response.data.contenido.id_votante){ $scope.inscrito.id_votante = response.data.contenido.id_votante; $scope.inscrito.nombres = response.data.contenido.nombres; $scope.logueado = true; } }, null); }; $scope.redireccionar = function(){ window.location = Utilidades.getUrl() + '/voto_finalizado'; }; $scope.redireccionar_registro = function(){ window.location = Utilidades.getUrl() + '/inscripcion_votacion'; }; function cargar(){ //$scope.inscrito.codigo_votacion = $location.search().cod; Utilidades.ejecutarGet('api/candidatos/'/* + $scope.inscrito.codigo_votacion*/, function(response){ for (var i = 0; i < response.junta_vigilancia.length; i++){ $scope.candidatosJunta.push({id: response.junta_vigilancia[i].id, value: response.junta_vigilancia[i].nombres}); } for (var i = 0; i < response.consejo_administrativo.length; i++){ $scope.candidatosConsejo.push({id: response.consejo_administrativo[i].id, value: response.consejo_administrativo[i].nombres}); } }, null); }; cargar(); }]) .controller('EnlacesCopeincaController', ['$scope', 'Utilidades', function($scope, Utilidades){ }]) .controller('VotacionesConsejoController', ['$scope', 'Utilidades', '$interval', '$location', function($scope, Utilidades, $interval,$location){ $scope.candidatos = []; $scope.inscrito = {}; $scope.votos = []; $scope.logueado = false; $scope.finalizado = false; $scope.entrar = function(){ Utilidades.ejecutarPut('api/get_inscrito_consejo', $scope.inscrito, function(response){ if (response.data.contenido.resp == 2){ $scope.inscrito = {}; $('#modalVotado').modal('show'); } else if (response.data.contenido.resp == 3){ $scope.inscrito = {}; $('#modalNoRegistrado').modal('show'); }/* else if (response.data.contenido.resp == -3){ $scope.inscrito = {}; $scope.votos = {junta: [], consejo: []}; $('#modalCerrada').modal('show'); }*/ else if (response.data.contenido.inscrito){ $scope.inscrito = response.data.contenido.inscrito; $scope.logueado = true; } }, null); }; $scope.seleccionar = function(id_voto){ if (id_voto == -1){ $scope.votos = []; $scope.votos.push(id_voto); } else { $scope.deseleccionar(-1); if ($scope.isSelected(id_voto)){ $scope.deseleccionar(id_voto); } else if ($scope.votos.length < 5){ $scope.votos.push(id_voto); } } }; $scope.deseleccionar = function(id_voto){ let pos = $scope.votos.indexOf(id_voto); if (pos >= 0){ $scope.votos.splice(pos, 1); } }; $scope.isSelected = function(id_candidato){ return $scope.votos.indexOf(id_candidato) > -1; }; $scope.votar = function(){ Utilidades.ejecutarPut('api/votar_consejo', {votos: $scope.votos, id_inscrito: $scope.inscrito.id}, function(response){ $scope.inscrito = {}; $scope.finalizado = true; $scope.logueado = false; }, null); }; function cargar(){ Utilidades.ejecutarGet('api/inscritos_consejo', function(response){ $scope.candidatos = response; }, null); }; cargar(); }]) .controller('VotacionesJuntaController', ['$scope', 'Utilidades', '$interval', '$location', function($scope, Utilidades, $interval,$location){ $scope.candidatos = []; $scope.inscrito = {}; $scope.votos = []; $scope.logueado = false; $scope.finalizado = false; $scope.entrar = function(){ Utilidades.ejecutarPut('api/get_inscrito_junta', $scope.inscrito, function(response){ if (response.data.contenido.resp == 2){ $scope.inscrito = {}; $('#modalVotado').modal('show'); } else if (response.data.contenido.resp == 3){ $scope.inscrito = {}; $('#modalNoRegistrado').modal('show'); }/* else if (response.data.contenido.resp == -3){ $scope.inscrito = {}; $scope.votos = {junta: [], consejo: []}; $('#modalCerrada').modal('show'); }*/ else if (response.data.contenido.inscrito){ $scope.inscrito = response.data.contenido.inscrito; $scope.logueado = true; } }, null); }; $scope.seleccionar = function(id_voto){ if (id_voto == -1){ $scope.votos = []; $scope.votos.push(id_voto); } else { $scope.deseleccionar(-1); if ($scope.isSelected(id_voto)){ $scope.deseleccionar(id_voto); } else if ($scope.votos.length < 2){ $scope.votos.push(id_voto); } } }; $scope.deseleccionar = function(id_voto){ let pos = $scope.votos.indexOf(id_voto); if (pos >= 0){ $scope.votos.splice(pos, 1); } }; $scope.isSelected = function(id_candidato){ return $scope.votos.indexOf(id_candidato) > -1; }; $scope.votar = function(){ Utilidades.ejecutarPut('api/votar_junta', {votos: $scope.votos, id_inscrito: $scope.inscrito.id}, function(response){ $scope.inscrito = {}; $scope.finalizado = true; $scope.logueado = false; }, null); }; function cargar(){ Utilidades.ejecutarGet('api/inscritos_junta', function(response){ $scope.candidatos = response; }, null); }; cargar(); }]) .controller('ResultadosConsejoController', ['$scope', 'Utilidades', function($scope, Utilidades){ $scope.candidatosConsejo = []; $scope.total_votos = function(){ var suma = 0; for (var i = 0; i < $scope.candidatosConsejo.length; i++){ suma += parseInt($scope.candidatosConsejo[i].votos); } return suma; }; $scope.porcentaje = function(votos){ var valor = 0; if ($scope.total_votos() > 0){ valor = votos * 100 / $scope.total_votos(); return parseFloat(valor).toFixed(2); } return valor; } function cargar(){ //$scope.inscrito.codigo_votacion = $location.search().cod; Utilidades.ejecutarGet('api/resultados_consejo', function(response){ $scope.candidatosConsejo = response; }, null); }; cargar(); }]) .controller('ResultadosJuntaController', ['$scope', 'Utilidades', function($scope, Utilidades){ $scope.candidatosJunta = []; $scope.total_votos = function(){ var suma = 0; for (var i = 0; i < $scope.candidatosJunta.length; i++){ suma += parseInt($scope.candidatosJunta[i].votos); } return suma; }; $scope.porcentaje = function(votos){ var valor = 0; if ($scope.total_votos() > 0){ valor = votos * 100 / $scope.total_votos(); return parseFloat(valor).toFixed(2); } return valor; } function cargar(){ //$scope.inscrito.codigo_votacion = $location.search().cod; Utilidades.ejecutarGet('api/resultados_junta', function(response){ $scope.candidatosJunta = response; }, null); }; cargar(); }]) .controller('ResultadosController', ['$scope', 'Utilidades', function($scope, Utilidades){ $scope.candidatosJunta = []; $scope.candidatosConsejo = []; $scope.registrados = []; $scope.votados = []; function cargar(){ //$scope.inscrito.codigo_votacion = $location.search().cod; Utilidades.ejecutarGet('api/resultados_votacion/'/* + $scope.inscrito.codigo_votacion*/, function(response){ $scope.candidatosJunta = response.junta_vigilancia; $scope.candidatosConsejo = response.consejo_administrativo; }, null); Utilidades.ejecutarGet('api/votantes/', function(response){ $scope.votantes = response; $scope.registrados = response.filter(x => x.email); $scope.votados = response.filter(x => x.voto == 1); for (var i = 0; i < $scope.votantes.length; i++){ $scope.votantes[i].fecha = new Date($scope.votantes[i].fecha); } }, null); }; cargar(); }]) .controller('InscripcionVotacionController', ['$scope', 'Utilidades', '$interval', function($scope, Utilidades, $interval){ $scope.inscrito = {}; $scope.inscribir = function(){ Utilidades.ejecutarPut('api/inscribir_votante/', $scope.inscrito, function(response){ $scope.inscrito = {}; if (response.data.contenido.resp == -1){ $('#modalCerrada').modal('show'); } else { stop = $interval(function() { $('#modalRegistrado').modal('show');; $interval.cancel(stop); }, 500); } }, null); } $scope.validar = function(){ //$scope.inscrito.codigo_votacion = $location.search().cod; Utilidades.ejecutarGet('api/validar_cedula_votante/' + $scope.inscrito.num_doc, function(response){ if (response.resp == -1){ $('#modalCerrada').modal('show'); } else if (response.resp == -2) { $('#modalDenegado').modal('show'); } else { if (response && response.identificacion){ $scope.inscrito = response; $('#modalConfirmar').modal('show'); } else { $('#modalDenegado').modal('show'); } } }, null); }; }]) .controller('InscripcionCopeincaController', ['$scope', 'Utilidades', '$interval', function($scope, Utilidades, $interval){ $scope.inscrito = {}; $scope.inscritos = []; $scope.inscritos_consejo = []; $scope.inscritos_junta = []; $scope.foto = {filename: "", base64: ""}; $scope.listado_csv = {filename: "", base64: ""}; $scope.subir_foto = function(ins){ $scope.inscrito = ins; $('#modalFoto').modal('show'); } $scope.asignar_foto = function(){ Utilidades.ejecutarPut('api/asignar_foto', $scope.inscrito, function(response){ $scope.inscrito = {}; $scope.foto = {filename: "", base64: ""}; cargar(); }, null); } $scope.asistio = function(id_inscrito){ Utilidades.ejecutarGet('api/asistio/' + id_inscrito, function(response){ cargar(); }, null); } $scope.no_asistio = function(id_inscrito){ Utilidades.ejecutarGet('api/no_asistio/' + id_inscrito, function(response){ cargar(); }, null); } $scope.inscribir = function(){ Utilidades.ejecutarPut('api/inscribir_copeinca', $scope.inscrito, function(response){ if (response.data.contenido.resp == -1){ $('#modalDenegado').modal('show'); } else { $('#modalRegistrado').modal('show'); $scope.inscrito = {}; cargar(); } }, null); } $scope.inscribir_csv = function(){ Utilidades.ejecutarPut('api/inscribir_copeinca_csv', $scope.listado_csv, function(response){ $scope.listado_csv = {filename: "", base64: ""}; cargar(); }, null); } $scope.modal_reiniciar_todo = function(){ $('#modalBorrarTodo').modal('show'); } $scope.reiniciar_todo = function(){ Utilidades.ejecutarPut('api/reiniciar_todo', {}, function(response){ cargar(); }, null); } $scope.eliminar = function(inscrito){ Utilidades.ejecutarGet('api/eliminar_inscrito_copeinca/' + inscrito.id, function(response){ cargar(); }, null); } $scope.candidato_consejo = function(inscrito){ Utilidades.ejecutarGet('api/inscribir_consejo/' + inscrito.id, function(response){ cargar(); }, null); } $scope.candidato_junta = function(inscrito){ Utilidades.ejecutarGet('api/inscribir_junta/' + inscrito.id, function(response){ cargar(); }, null); } $scope.eliminar_consejo = function(inscrito){ Utilidades.ejecutarGet('api/eliminar_consejo/' + inscrito.id, function(response){ cargar(); }, null); } $scope.eliminar_junta = function(inscrito){ Utilidades.ejecutarGet('api/eliminar_junta/' + inscrito.id, function(response){ cargar(); }, null); } $scope.es_candidato = function(inscrito){ if ($scope.inscritos_consejo.find(x => x.num_doc == inscrito.num_doc) || $scope.inscritos_junta.find(x => x.num_doc == inscrito.num_doc)){ return true; } return false; } $scope.reiniciar_votos = function(){ Utilidades.ejecutarGet('api/reiniciar_votos', function(response){ cargar(); }, null); } function cargar(){ $scope.inscritos = []; $scope.inscritos_consejo = []; $scope.inscritos_junta = []; Utilidades.ejecutarGet('api/inscritos_copeinca', function(response){ $scope.inscritos = response; }, null); Utilidades.ejecutarGet('api/inscritos_consejo', function(response){ $scope.inscritos_consejo = response; }, null); Utilidades.ejecutarGet('api/inscritos_junta', function(response){ $scope.inscritos_junta = response; }, null); }; cargar(); }]) .controller('MocionesController', ['$scope', 'Utilidades', '$location', function($scope, Utilidades, $location){ $scope.inscrito = {}; $scope.mocion = {}; $scope.opcionesMocion = [{id: 1, value: 'Apruebo'}, {id: 2, value: 'No apruebo'}]; $scope.entrar = function(){ Utilidades.ejecutarPut('api/validar_voto_mocion', $scope.inscrito, function(response){ if (response.data.contenido.resp == -1){ $scope.inscrito = {}; $('#modalVotado').modal('show'); } else if (response.data.contenido.resp == -2){ $scope.inscrito = {}; $('#modalNoRegistrado').modal('show'); } else if (response.data.contenido.resp == -3){ $scope.inscrito = {}; $('#modalCerrada').modal('show'); } else if (response.data.contenido.votante.id && response.data.contenido.mocion.id){ $scope.inscrito.id_votante = response.data.contenido.votante.id; $scope.inscrito.nombres = response.data.contenido.votante.nombres; $scope.mocion = response.data.contenido.mocion; $scope.logueado = true; } }, null); }; $scope.validar = function(){ Utilidades.ejecutarPut('api/validar_voto_mocion/', $scope.inscrito, function(response){ if (response && response.identificacion){ $scope.inscrito = response; $('#modalConfirmar').modal('show'); } else { $('#modalDenegado').modal('show'); } }, null); }; $scope.votar = function(){ Utilidades.ejecutarPut('api/votar_mocion/', $scope.inscrito, function(response){ $scope.redireccionar(); }, null); }; $scope.redireccionar = function(){ window.location = Utilidades.getUrl() + '/voto_finalizado'; }; function cargar(){ $scope.inscrito.codigo_mocion = $location.search().cod; }; cargar(); }]) .controller('VotosMocionesController', ['$scope', 'Utilidades', function($scope, Utilidades){ $scope.mociones = []; function cargar(){ //$scope.inscrito.codigo_votacion = $location.search().cod; Utilidades.ejecutarGet('api/votos_mociones', function(response){ $scope.mociones = response; }, null); }; cargar(); }]) .controller('VotoFinalizadoController', ['$scope', 'Utilidades', function($scope, Utilidades){ }]) .controller('MenuController', ['$scope', '$rootScope', '$location', 'Utilidades', function($scope, $rootScope, $location, Utilidades){ $rootScope.cargando = 1; $scope.tab = 0; $scope.pags = {}; $scope.pags['/inicio'] = 1; $scope.pags['/bingo'] = 2; $scope.pags['/confirmado'] = 3; $scope.pags['/reconfirmado'] = 4; $scope.pags['/inscripcion'] = 5; $scope.pags['/generador'] = 6; $scope.pags['/inscripcion_votacion'] = 7; $scope.pags['/resultados_votacion'] = 8; $scope.pags['/votaciones'] = 9; $scope.pags['/voto_finalizado'] = 10; $scope.pags['/mociones'] = 11; $scope.pags['/votos_mociones'] = 12; $scope.pags['/inscripcion_copeinca'] = 13; $scope.pags['/votaciones_consejo'] = 14; $scope.pags['/votaciones_junta'] = 15; $scope.pags['/resultados_consejo'] = 16; $scope.pags['/resultados_junta'] = 17; $scope.pags['/enlaces_copeinca'] = 18; $scope.titulos = ['', 'Inicio', 'Bingo', 'Asistencia confirmada', 'Asistencia confirmada', 'Inscripciones Bingo', 'Generador de balotas', 'Inscripciones votación', 'Resultados votación', 'Votaciones', 'Voto finalizado', 'Mociones', 'Resultados mociones', 'Inscripciones Copeinca', 'Votaciones Consejo de Administración', 'Votaciones Junta de Vigilancia', 'Resultados Consejo de Administración', 'Resultados Junta de Vigilancia', 'Enlaces Copeinca']; $scope.$on('$locationChangeStart', function(next, current) { var actualUrl = $location.path(); if (actualUrl == undefined || actualUrl == null || actualUrl == '/' || actualUrl == ''){ $scope.setTab($scope.pags['/inicio']); } else if ($scope.pags[actualUrl] != undefined || $scope.pags[actualUrl] != null || $scope.pags[actualUrl] != '') { $scope.setTab($scope.pags[actualUrl]); } $rootScope.titulo = $scope.titulos[$scope.tab] + ' - Metrobingos'; }); $scope.setTab = function(pTab){ $scope.tab = pTab; }; $scope.isSelected = function(pTab){ return $scope.tab === pTab; }; $scope.hayEventosVigentes = function(){ return $scope.hayEventos; }; function validarRutaInicial(){ if (!$location.path() || $location.path() == '/'){ window.location = Utilidades.getUrl() + '/inicio'; $scope.setTab($scope.pags['/inicio']); } } validarRutaInicial(); $rootScope.cargando--; }]) .controller('ErrorController', ['$scope', 'Utilidades', function($scope, Utilidades){}])