<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org">

<head th:replace="~{layouts/common.html :: head}"></head>

<body id="page-top">

	<!-- Navigation -->
	<nav th:replace="~{layouts/common.html :: navbar}"></nav>
 
 	<!-- Content -->
	<div class="content uv-content d-flex" id="uv-wrapper">
		<div class="bg-light border-right" id="uv-sidebar-wrapper" th:replace="~{layouts/sidebar.html :: sidebar}"></div>
		
		<div class="container uv-home-section navVisible" id="uv-content-wrapper">
			<div class="uv-loading-spinner" th:text="#{global.loading}"></div>
			<div class="col-sm-12"></div>
			<div class="uv-container">
				<div class="uv-table-group">
					<h5><i class="fas fa-exclamation-triangle" style="color:orange;"></i>&nbsp; ¡No toques nada si no sabes lo que estas haciendo! &nbsp;<i class="fas fa-exclamation-triangle" style="color:orange;"></i></h5> 
				</div>
				<div class="uv-table-group-procedure" style="padding-left:20px;padding-top:40px;">
					<div th:if="${err != null}">
						<span class="alert alert-warning">Ha habido un error al ejecutar la acción.</span>
						<br>
						<br>
					</div>
					<div th:if="${ok != null}">
						<span class="alert alert-success">La acción se ha ejecutado correctamente, <span th:text="${ok}"></span> entradas afectadas</span>
						<br>
						<br>
					</div>
				</div>

				<div class="uv-table-group-procedure-info" style="margin-bottom:20px;">
					<div class="uv-table-title">
						<h6 class="uv-table-header-h6" th:text="'Importador de datos'"></h6>
						<hr class="uv-procedure-hr">
						<span th:text="'Importa los datos desde el año indicado (>=), de Arya y UQserver a SAIC. Ojo, no elimina, sólo carga.'"></span>
					</div>
				</div>
				<form enctype='multipart/form-data' method="POST" action="/admin/parse/do">
					<div class="uv-table-group-procedure row" style="padding:20px;cursor:auto;">
						<div class="col-3" id="databaseContainer">
							<label>Bases de datos</label>
							<select class="selectpicker" id="databaseSelector" name="database" data-live-search="true" data-width="100%" data-actions-box="true" th:attr="data-none-selected-text=#{global.selectors.noData}" required>
						        <option disabled selected>Selecciona una opción</option>
						        <option value="grado">Grado</option>
						        <option value="master">Máster</option>
						        <option value="doctorado">Doctorado</option>
						        <option value="pas">PAS</option>
						        <option value="evalprof">Evaluación profesorado</option>
						        <option value="otros">Otros</option>
						    </select>
						</div>
						<div class="col-3">
							<label>Tabla</label>
							<div class="subselect" id="gradoSelector">
								<select class="form-control" name="table" required style="cursor:pointer;">
							        <option disabled selected>Selecciona una opción</option>
							        <option value="dades1er">Estudiantes primero</option>
							        <option value="dades3er">Estudiantes tercero</option>
							        <option value="dadesGraduats">Graduados</option>
							        <option value="profes">Profesores</option>
							    </select>
							</div>
							<div class="subselect" id="masterSelector">
							    <select class="form-control" name="table" required style="cursor:pointer;">
							        <option disabled selected>Selecciona una opción</option>
							        <option value="data">Estudiantes</option>
							        <option value="datag">Graduados</option>
							        <option value="profes">Profesores</option>
							    </select>
							</div>
							<div class="subselect" id="doctoradoSelector">
							    <select class="form-control" name="table" required style="cursor:pointer;">
							        <option disabled selected>Selecciona una opción</option>
							        <option value="estud">Estudiantes</option>
							        <option value="etesi">Graduados</option>
							        <option value="prof">Profesores</option>
							        <option value="tasas">Tasas</option>
							        <option value="inds">Indicadores</option>
							        <option value="recom">Recomendaciones</option>
							    </select>
							</div>
							<div class="subselect" id="evalprofSelector">
							    <select class="form-control" name="table" required style="cursor:pointer;">
							        <option disabled selected>Selecciona una opción</option>
							        <option value="evalprof">Evaluación del profesorado</option>
							    </select>
							</div>
							<div class="subselect" id="otrosSelector">
							    <select class="form-control" name="table" required style="cursor:pointer;">
							        <option disabled selected>Selecciona una opción</option>
							        <option value="otros">Otros (Profesorado + Tasas)</option>
							        <option value="docentia">Docentia</option>
							        <option value="enquestes">Encuestas (asignaturas)</option>
							    </select>
							</div>
							<div class="subselect" id="pasSelector">
							    <select class="form-control" name="table" required style="cursor:pointer;">
							        <option disabled selected>Selecciona una opción</option>
							        <option value="pas">PAS</option>
							    </select>
							</div>
						</div>
						<div class="col-2">
							<label>Año (>=)</label>
							<input class="form-control" type="number" value="" name="year">
						</div>
					</div>
					<div class="uv-table-group-procedure" style="padding-left:20px;padding-top:20px;cursor:auto;">
						<input class="btn btn-primary" type="submit" value="Importar">
					</div>
				</form>
				<div class="uv-table-group-procedure row">
					<div class="col-4">
						<div class="uv-table-group-procedure-info" style="margin-bottom:20px;margin-top:30px;cursor:auto;">
							<div class="uv-table-title">
								<h6 class="uv-table-header-h6" th:text="'Precarga de datos'"></h6>
								<hr class="uv-procedure-hr">
								<span th:text="'Carga los ficheros de texto a las tablas intermedias en Arya'"></span>
							</div>
						</div>
						<form enctype='multipart/form-data' method="POST" action="/admin/parse/action" id="preload_form">
							<div class="uv-table-group-procedure row" style="padding:20px;">
								<select class="selectpicker" name="action" data-live-search="true" data-width="100%" data-actions-box="true" th:attr="data-none-selected-text=#{global.selectors.noData}" required>
							        <option disabled selected>Selecciona el conjunto de ficheros a cargar</option>
							        <option value="precargaEvalprof">Evaluación de profesorado</option>
							        <option value="precargaMaster">Máster</option>
							        <option value="precargaDoctorado">Doctorado</option>
							    </select>
							    <div class="uv-table-group-procedure" style="padding-left:20px;padding-top:20px;">
									<input class="btn btn-primary" type="submit" value="Ejecutar" form="preload_form">
								</div>
							</div>
						</form>
					</div>
					<div class="col-4">
						<div class="uv-table-group-procedure-info" style="margin-bottom:20px;margin-top:30px;cursor:auto;">
							<div class="uv-table-title">
								<h6 class="uv-table-header-h6" th:text="'Acciones sobre datos de encuestas'"></h6>
								<hr class="uv-procedure-hr">
								<span th:text="'Acciones de corrección sobre datos de encuestas'"></span>
							</div>
						</div>
						<form enctype='multipart/form-data' method="POST" action="/admin/parse/action" id="actions_form">
							<div class="uv-table-group-procedure row" style="padding:20px;">
								<select class="selectpicker" name="action" data-live-search="true" data-width="100%" data-actions-box="true" th:attr="data-none-selected-text=#{global.selectors.noData}" required>
							        <option disabled selected>Selecciona una acción</option>
							        <option value="mediasCentroNP">Eliminar medias de centro para titulaciones no adscritas</option>
							        <option value="bienalesProfesGrado">Corregir bienalidad profesorado (Solo para curso no completo) [Grado]</option>
							        <option value="bienalesProfesMaster">Corregir bienalidad profesorado (Solo para curso no completo) [Máster] </option>
							        <option value="bienalesPas">Corregir bienalidad PAS (Solo para curso no completo)</option>
							        
							    </select>
							    <div class="uv-table-group-procedure" style="padding-left:20px;padding-top:20px;">
									<input class="btn btn-primary" type="submit" value="Ejecutar" form="actions_form">
								</div>
							</div>
						</form>
					</div>
				</div>
				<div class="uv-table-group-procedure-info" style="margin-bottom:20px;margin-top:30px;">
					<div class="uv-table-title">
						<h6 class="uv-table-header-h6" th:text="'Eliminar datos de encuestas'"></h6>
						<hr class="uv-procedure-hr">
						<span th:text="'Se eliminan permanentemente de la base de datos. (Año=0 para eliminar todos los registros)'"></span>
					</div>
				</div>
				<form enctype='multipart/form-data' method="POST" action="/admin/parse/delete" id="delete_form">
					<div class="uv-table-group-procedure row" style="padding:20px;cursor:auto;">
						<div class="col-4">
							<label>Encuesta</label>
							<select class="selectpicker" name="action" data-live-search="true" data-width="100%" data-actions-box="true" th:attr="data-none-selected-text=#{global.selectors.noData}" required>
						        <option disabled selected>Selecciona una encuesta</option>
						        <option value="dades_1er">[Grado] Estudiantes primero (dades_1er)</option>
						        <option value="dades_3er">[Grado] Estudiantes tercero (dades_3er)</option>
						        <option value="dades_graduats">[Grado] Graduados (dades_graduats)</option>
						        <option value="profes">[Grado] Profesores (profes)</option>
						        <option value="data">[Master] Estudiantes (data)</option>
						        <option value="data_g">[Master] Graduados (data_g)</option>
						        <option value="profes_tancades">[Master] Profesores (profes_tancades)</option>
						        <option value="estud">[Doctorado] Estudiantes (doc_estud)</option>
						        <option value="etesi">[Doctorado] Graduados (doc_etesi)</option>
						        <option value="prof">[Doctorado] Profesores (doc_prof)</option>
						        <option value="doc_inds">[Doctorado] Indicadores (doc_inds)</option>
						        <option value="doc_tasas">[Doctorado] Tasas (doc_tasas)</option>
						        <option value="doc_recom">[Doctorado] Recomendaciones (doc_recom)</option>
						        <option value="evalprof">[Evaluación del profesorado] (evalprof)</option>
						        <option value="dadespas">[PAS] (dadespas)</option>
						        <option value="otros">[Otros] Profesorado + Tasas</option>
						        <option value="docentia">[Docentia]</option>
						        <option value="enquestes">[Encuestas] Asignaturas para encuestas. SAE/SAEM (enquestes)</option>
						    </select>
					    </div>
					    <div class="col-3">
					    	<label>Año</label>
							<input class="form-control" type="number" value="" name="year">
					    </div>
					</div>
					<div class="uv-table-group-procedure" style="padding-left:20px;padding-top:20px;">
						<input class="btn btn-primary" type="submit" value="Ejecutar" form="delete_form">
					</div>
				</form>
			</div>
		</div>
	</div>
	
	<!-- contactModal -->
	<div th:replace="~{layouts/common.html :: contactModal}"></div>
	
	<!-- Footer -->
	<footer class="uv-footer uv-footer-text" th:replace="~{layouts/common.html :: footer}"></footer>
	
	<script th:src="@{/js/jquery/jquery.min.js}"></script>
	<script th:src="@{/js/popper.js}"></script>
	<script th:src="@{/js/bootstrap/bootstrap.min.js}"></script>
	<script th:src="@{/js/fa/all.js}"></script>
	<script th:src="@{/js/jquery/jquery.dataTables.min.js}"></script>
	<script th:src="@{/js/jquery/jquery.dataTables.responsive.min.js}"></script>
	<script th:src="@{/js/jquery/jquery.dataTables.rowReorder.min.js}"></script>
	<script th:src="@{/js/bootstrap/dataTables.bootstrap4.min.js}"></script>
	<script th:src="@{/js/jquery-easing/jquery.easing.min.js}"></script>
	<script th:src="@{/js/saic.js}"></script>
	<script th:src="@{/js/datepicker/bootstrap-datepicker.min.js}"></script>
	<script th:src="@{/js/bootstrap-select/bootstrap-select.js}"></script>
	<script th:src="@{/js/bootstrap-select/i18n/defaults-es_ES.js}" th:if="${#locale.language} == 'es'"></script>
	<script th:src="@{/js/bootstrap-select/i18n/defaults-ca_CA.js}" th:if="${#locale.language} != 'es'"></script>
	
	<script type="text/javascript">

		$( document ).ready(function(){ 
			layout = new Layout("");
			layout.initTableLayout({paging:false});
			layout.closeLoadingSpinner(".uv-loading-spinner");
			$('.subselect').hide();
			$('.subselect  > select').attr('disabled', true);
			
			$('#databaseSelector').change(function(){
				console.log($(this).val());
				$('.subselect').hide();
				$('.subselect > select').attr('disabled', true);
				$('#'+$(this).val()+'Selector  > select').attr('disabled', false);
				$('#'+$(this).val()+'Selector').show();
			});
			
		});
		
		
		
	</script>

</body>

</html>
