Initial state

This commit is contained in:
2023-05-16 10:16:21 -06:00
commit c3c0108143
167 changed files with 20135 additions and 0 deletions

813
carreras.php Normal file
View File

@@ -0,0 +1,813 @@
<?php
require_once 'class/c_login.php';
require_once 'include/bd_pdo.php';
if (!isset($_SESSION['user'])){
header('Location: index.php');
exit;
}
else
$user = unserialize($_SESSION['user']);
$user->access('facultades');
if(!$user->admin && $user->acceso == 'n'){
header('Location: main.php?error=1');
}else{
$user->print_to_log('Carreras');
}
if(!$user->admin && $user->facultad['facultad_id']!=$_GET['facultad']){
header('Location: carreras.php?facultad='.$user->facultad['facultad_id']);
$mal=true;
}
$mal=false;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Carreras</title>
<link rel="stylesheet" href="css/jquery-ui.css">
<link rel="stylesheet" href="css/calendar.css">
<link rel="stylesheet" href="css/toggle.css" type="text/css">
<?php
include 'import/html_css_files.php';
?>
</head>
<body>
<?php
if(isset($_GET['facultad'])){
$facultad=query("SELECT facultad_nombre FROM facultad WHERE facultad_id = :facultad", array(":facultad" => $_GET['facultad']), true);
$fs_carreras = query(
"SELECT * FROM fs_carreras(:idfacultad, null, null)",
array(':idfacultad' => $_GET['facultad']),
single:false
);
}
include "import/html_header.php";
html_header(
"CARRERAS | " . $facultad['facultad_nombre'],
"Gestión de Checador "
);
$user->access('facultades');
$fs_niveles = query(
"SELECT * FROM nivel", null, false
);
$fs_periodos = query(
"SELECT * FROM fs_periodos(:idfacultad) WHERE estado = 'Activo' ",
array(':idfacultad' => $_GET['facultad']),
false
);
$fs_tiempoLic = query(
"SELECT * FROM fs_tiempo_checado(:idfacultad, 1)",
array(':idfacultad' => $_GET['facultad']),
true
);
$fs_tiempoPos = query(
"SELECT * FROM fs_tiempo_checado(:idfacultad, 2)",
array(':idfacultad' => $_GET['facultad']),
true
);
?>
<main class="content marco">
<?php #if($mal==true){ ?>
<div class="row">
<div class="col-12 text-left">
<a href="facultades.php" title="Volver">
<button type="button" class="btn btn-outline-secondary"><span class="ing-regresar ing-fw"></span>Volver</button>
</a>
</div>
</div>
<?php #} ?>
<div id="message"></div>
<ul class="nav nav-tabs mt-3" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="periodo-tab" data-toggle="tab" data-target="#periodo" type="button" role="tab" aria-controls="periodo" aria-selected="true">Periodo</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="carrera-tab" data-toggle="tab" data-target="#carrera" type="button" role="tab" aria-controls="carrera" aria-selected="false">Carrera</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="carrera-tab" data-toggle="tab" data-target="#tiempos" type="button" role="tab" aria-controls="tiempos" aria-selected="false">Tiempos</button>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<!-- PERIODOS -->
<div class="tab-pane fade show active" id="periodo" role="tabpanel" aria-labelledby="periodo-tab">
<div class="row mt-3">
<?php if($user->acceso == 'w') {?>
<div class="col-12 text-right">
<button type="button" class="btn btn-outline-secondary" data-toggle="modal" data-target="#modal_periodo" data-tipo="1"><span class="ing-mas ing-fw"></span>Agregar periodo</button>
</div>
<?php }?>
</div>
<!-- Tabla -->
<div class="row mt-3">
<div class="col-12 table-responsive">
<table class="table table-sm table-striped table-white">
<thead class="thead-dark">
<tr>
<th>Estado</th>
<th>Nivel</th>
<th>Periodo</th>
<th>Inicio</th>
<th>Fin</th>
<?php if($user->acceso == 'w') {?>
<th>Acciones</th>
<?php }?>
</tr>
</thead>
<tbody>
<?php foreach($fs_periodos as $periodo){
$title=$periodo['estado'];
if($title=='Activo')
$color="success";
else
$color="danger";
?>
<tr data-id="<?= $periodo['id']?>" id="<?= $periodo['id']?>" >
<td class="text-<?= $color ?> text-center" title="<?= $title?>">
<span class="ing-bullet"></span>
</td>
<td class="text-primary">
<?= $periodo['nivel']?>
</td>
<td class="text-primary">
<?= $periodo['periodo']?>
</td>
<td class="text-primary">
<?= $periodo['inicio']?>
</td>
<td class="text-primary">
<?= $periodo['fin']?>
</td>
<?php if($user->acceso == 'w') {?>
<td class="text-center icono-acciones">
<a href="#" data-toggle="modal" data-target="#modal_periodo" data-tipo="2" title="Editar"><span class="ing-editar ing-fw"></span></a>
</td>
<?php }?>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
<!-- CARRERAS -->
<div class="tab-pane fade" id="carrera" role="tabpanel" aria-labelledby="carrera-tab">
<div class="row mt-3">
<?php if($user->acceso == 'w') {?>
<div class="col-12 text-right">
<button type="button" class="btn btn-outline-secondary" data-toggle="modal" data-target="#modal" data-tipo="1"><span class="ing-mas ing-fw"></span>Crear carrera</button>
</div>
<?php }?>
</div>
<!-- Tabla -->
<div class="row mt-3">
<div class="col-12 table-responsive">
<table class="table table-sm table-striped table-white">
<thead class="thead-dark">
<tr>
<th>Estado</th>
<th>Nivel</th>
<th>Carrera</th>
<?php if($user->acceso == 'w') {?>
<th>Acciones</th>
<?php }?>
</tr>
</thead>
<tbody>
<?php
foreach($fs_carreras as $carrera){
$color = "danger";
$title = "Inactiva";
if($carrera["carrera_activa"]==1){
$color ="success";
$title="Activa";
}
$nivel='Licenciatura';
if($carrera['nivel_id']==2)
$nivel='Posgrado';
?>
<tr data-id="<?php echo $carrera['carrera_id'];?>" id="<?php echo $carrera['carrera_id'];?>">
<td class="text-<?php echo $color;?> text-center" title="<?php echo $title;?>">
<span class="ing-bullet"></span>
</td>
<td class="text-primary"><?php echo $nivel;?></td>
<td class="text-primary"><?php echo $carrera["carrera_nombre"];?></td>
<?php if($user->acceso == 'w') {?>
<td class="text-center icono-acciones">
<a href="#" data-toggle="modal" data-target="#modal" data-tipo="2" title="Editar"><span class="ing-editar ing-fw"></span></a>
</td>
<?php }?>
</tr>
<?php }?>
</tbody>
</table>
</div>
</div>
</div>
<!-- Tiempos -->
<div class="tab-pane fade" id="tiempos" role="tabpanel" aria-labelledby="tiempos-tab">
<p class="mt-4">Asigna los minutos de tolerancia antes y después del horario de clase</p>
<form action="" method="post" id="formaModalTiempos" onsubmit="return valida_camposT()">
<input type="hidden" name="facultadT" id="facultadT">
<h3 class="text-center">Licenciatura</h3>
<div class="row mt-3" style="border:solid 2px; border-radius: 8px;">
<div class="offset-1 col-2 text-center">
Antes
<input id="antesL" name="antesL" type="number" class="form-control text-center" maxlenth="10">
<div class="invalid-feedback">
Debe ser un numero mayor que 0
</div>
min
</div>
<div class="col-2 text-center bg-light mt-4 mb-4">
<h5 class="mt-2">Hora de clase</h5>
</div>
<div class="col-2 text-center">
Despues
<input id="despuesL" name="despuesL" type="number" class="form-control text-center" maxlenth="10">
<div class="invalid-feedback">
Debe ser un numero mayor que 0
</div>
min
</div>
<div class="col-2 text-center retardoLic">
Retardos
<input id="retardoL" name="retardoL" type="number" class="form-control text-center" maxlenth="10">
<div class="invalid-feedback">
Debe ser un numero mayor que 0
</div>
min
</div>
<div class="col-3 text-center">
¿Tiene retardos?<br>
<div class="custom-control custom-switch mt-2">
<input type="checkbox" class="custom-control-input tipo-switch" name="retardoLic" id="retardoLic" value="1">
<label class="custom-control-label" for="retardoLic">Si</label>
</div>
</div>
</div>
<br><br>
<h3 class="text-center">Posgrado</h3>
<div class="row mt-3" style="border:solid 2px; border-radius: 8px;">
<div class="offset-1 col-2 text-center">
Antes
<input id="antesP" name="antesP" type="number" class="form-control text-center" maxlenth="10">
<div class="invalid-feedback">
Debe ser un numero mayor que 0
</div>
min
</div>
<div class="col-2 text-center bg-light mt-4 mb-4">
<h5 class="mt-2">Hora de clase</h5>
</div>
<div class="col-2 text-center">
Despues
<input id="despuesP" name="despuesP" type="number" class="form-control text-center" maxlenth="10">
<div class="invalid-feedback">
Debe ser un numero mayor que 0
</div>
min
</div>
<div class="col-2 text-center retardoPos">
Retardo
<input id="retardoP" name="retardoP" type="number" class="form-control text-center" maxlenth="10">
<div class="invalid-feedback">
Debe ser un numero mayor que 0
</div>
min
</div>
<div class="col-3 text-center">
¿Tiene retardos?<br>
<div class="custom-control custom-switch mt-2">
<input type="checkbox" class="custom-control-input tipo-switch" name="retardoPos" id="retardoPos" value="1">
<label class="custom-control-label" for="retardoPos"></label>
</div>
</div>
</div>
<br>
</form>
<div class="form-group row mt-3">
<div class="offset-4 col-8">
<button class="btn btn-outline-primary" id="submitBtnT">
<span class="ing-aceptar ing-fw"></span> Guardar
</button>
<button type="reset" id="reset" class="btn btn-outline-danger" data-dismiss="modal">
<span class="ing-cancelar ing-fw"></span> Limpiar
</button>
</div>
</div>
</div>
</div>
</main>
<!-- Footer -->
<?php
include "import/html_footer.php";
?>
<!-- Modal -->
<div class="modal fade" id="modal_periodo" tabindex="-1" role="dialog" arialabelledby="modal" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="col-12 modal-title text-center">
<span id="modalLabelP">
Editar periodo
</span>
<button type="button" class="close text-white" data-dismiss="modal" aria-label="close">
<span aria-hidden="true">&times;</span>
</button>
</h4>
</div>
<div class="modal-body">
<form action="" method="post" id="formaModalP" onsubmit="return valida_camposP()">
<input type="hidden" name="idP" id="idP">
<input type="hidden" name="facultadP" id="facultadP" value="<?php echo $_GET['facultad']; ?>">
<div class="form-box">
<div class="form-group row">
<label for="nombreP" class="col-4 col-form-label">Nombre *</label>
<div class="col-8">
<input id="nombreP" name="nombreP" type="text" class="form-control" maxlength="100">
<div class="invalid-feedback" id="nombreP-error">Campo obligatorio</div>
</div>
</div>
<div class="form-group row">
<label for="inicio" class="col-4 col-form-label">Fecha de inicio *</label>
<div class="col-8">
<input id="fecha_inicial" name="fecha_inicial" type="text" class="form-control date-picker" placeholder="dd/mm/aaaa" maxlength="10" required="required" readonly="">
<div class="invalid-feedback">Debe seleccionar una fecha</div>
</div>
</div>
<div class="form-group row">
<label for="fin" class="col-4 col-form-label">Fecha de fin *</label>
<div class="col-8">
<input id="fecha_final" name="fecha_final" type="text" class="form-control date-picker" placeholder="dd/mm/aaaa" maxlength="10" required="required" readonly="">
<div class="invalid-feedback">Debe seleccionar una fecha</div>
</div>
</div>
<div class="form-group row">
<label for="nivelP" class="col-4 col-form-label">Nivel *</label>
<div class="col-8">
<div class="datalist datalist-select mb-1 w-100">
<div class="datalist-input">Mostrar todos</div>
<span class="ing-buscar icono"></span>
<ul style="display:none">
<?php foreach($fs_niveles as $pnivel){?>
<li data-id="<?php echo $pnivel['nivel_id']?>" class="pl-4"><?php echo $pnivel['nivel_nombre'] ?></li>
<?php }?>
</ul>
<input type="hidden" id="nivelP" name="nivelP" value="">
</div>
<div class="invalid-feedback">Debe seleccionar un nivel</div>
</div>
</div>
<div class="form-group row">
<label for="estadoP" class="col-4 col-form-label">Estado *</label>
<div class="col-4">
<div class="form-check form-check-inline">
<input class="form-check-input radio-lg" type="radio" id="estado_activoP" name="estadoP" value="1" checked="checked">
<label for="estado_activoP" class="col-form-label">Activo</label>
</div>
</div>
<div class="col-4">
<div class="form-check form-check-inline">
<input class="form-check-input radio-lg" type="radio" id="estado_inactivoP" name="estadoP" value="2">
<label for="estado_inactivoP" class="col-form-label">Inactivo</label>
</div>
</div>
</div>
<div class="from-group row">
<div class="offset-4 col-8">
<button type="submit" class="btn btn-outline-primary" id="submitBtnP" data-tipo="1">
<span class="ing-aceptar ing-fw"></span> Guardar
</button>
<button type="reset" class="btn btn-outline-danger" data-dismiss="modal">
<span class="ing-cancelar ing-fw"></span> Cancelar
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="modal fade" id="modal" tabindex="-1" role="dialog" arialabelledby="modal" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="col-12 modal-title text-center">
<span id="modalLabel">
Editar nombre de Carrera
</span>
<button type="button" class="close text-white" data-dismiss="modal" aria-label="close">
<span aria-hidden="true">&times;</span>
</button>
</h4>
</div>
<div class="modal-body">
<form action="" method="post" id="formaModal" onsubmit="return valida_campos()">
<input type="hidden" name="id" id="id">
<input type="hidden" name="facultad" id="facultad" value="<?php echo $_GET['facultad']; ?>">
<div class="form-box">
<div class="form-group row">
<label for="nivel" class="col-4 col-form-label">Nivel *</label>
<div class="col-8">
<div class="datalist datalist-select mb-1 w-100">
<div class="datalist-input">Mostrar todos</div>
<span class="ing-buscar icono"></span>
<ul style="display:none">
<?php foreach($fs_niveles as $pnivel){?>
<li data-id="<?php echo $pnivel['nivel_id']?>" class="pl-4"><?php echo $pnivel['nivel_nombre'] ?></li>
<?php }?>
</ul>
<input type="hidden" id="nivel" name="nivel" value="">
</div>
</div>
</div>
<div class="form-group row">
<label for="nombre" class="col-4 col-form-label">Nombre *</label>
<div class="col-8">
<input id="nombre" name="nombre" type="text" class="form-control" maxlength="100">
<div class="invalid-feedback" id="nombre-error">Campo obligatorio</div>
</div>
</div>
<div class="form-group row">
<label for="estado" class="col-4 col-form-label">Estado *</label>
<div class="col-4">
<div class="form-check form-check-inline">
<input class="form-check-input radio-lg" type="radio" id="estado_activo" name="estado" value="1" checked="checked">
<label for="estado_activo" class="col-form-label">Activo</label>
</div>
</div>
<div class="col-4">
<div class="form-check form-check-inline">
<input class="form-check-input radio-lg" type="radio" id="estado_inactivo" name="estado" value="0">
<label for="estado_inactivo" class="col-form-label">Inactivo</label>
</div>
</div>
</div>
<div class="from-group row">
<div class="offset-4 col-8">
<button type="submit" class="btn btn-outline-primary" id="submitBtn" data-tipo="1">
<span class="ing-aceptar ing-fw"></span> Guardar
</button>
<button type="reset" class="btn btn-outline-danger" id="reset" data-dismiss="modal">
<span class="ing-cancelar ing-fw"></span> Cancelar
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/jquery-ui.js"></script>
<script src="js/bootstrap/bootstrap.min.js"></script>
<script src="js/datalist.js"></script>
<script src="js/datepicker-es.js"></script>
<script src="js/toggle.js"></script>
<?php
require_once 'js/messages.php';
?>
<script>
$('#retardoLic').change(function(){
if($(this).is(':checked')){
$('.retardoLic').show();
}
else{
$('.retardoLic').hide();
$('#retardoL').val("0");
}
});
$('#retardoPos').change(function(){
if($(this).is(':checked')){
$('.retardoPos').show();
}
else{
$('.retardoPos').hide();
$('#retardoP').val("0");
}
});
$('#reset').on('click', function(){
$('#antesL').val("<?= -1*($fs_tiempoLic['desde_asistencia'] ?? 0) ?>");
$('#despuesL').val("<?= ($fs_tiempoLic['hasta_asistencia'] ?? 1)-1 ?>");
$('#retardoL').val("<?= ($fs_tiempoLic['hasta_retardo'] ?? 0) - ($fs_tiempoLic['hasta_asistencia'] ?? 0) ?>");
$('#antesP').val("<?= -1*($fs_tiempoPos['desde_asistencia'] ?? 0) ?>");
$('#despuesP').val("<?= ($fs_tiempoPos['hasta_asistencia'] ?? 1)-1 ?>");
$('#retardoP').val("<?= ($fs_tiempoPos['hasta_retardo'] ?? 0) - ($fs_tiempoPos['hasta_asistencia'] ?? 0) ?>");
<?php
if(($fs_tiempoLic['hasta_asistencia'] ?? 0) == ($fs_tiempoLic['hasta_retardo'] ?? 0)){ ?>
$('.retardoLic').hide();
$('#retardoL').val("0");
$('#retardoLic').prop("checked", false).change();
<?php }
else{ ?>
$('#retardoLic').prop("checked", true).change();
<?php }
if(($fs_tiempoPos['hasta_asistencia'] ?? 0) == ($fs_tiempoPos['hasta_retardo'] ?? 0)){ ?>
$('.retardoPos').hide();
$('#retardoP').val("0");
$('#retardoPos').prop("checked", false).change();
<?php }
else{ ?>
$('#retardoPos').prop("checked", true).change();
<?php }
?>
$('#antesL').removeClass("is-invalid");
$('#despuesL').removeClass("is-invalid");
$('#retardoL').removeClass("is-invalid");
$('#antesP').removeClass("is-invalid");
$('#despuesP').removeClass("is-invalid");
$('#retardoP').removeClass("is-invalid");
});
$(".date-picker").datepicker($.datepicker.regional["es"]);
$(".date-picker").datepicker({
dateFormat: "dd/mm/yyyy",
changeMonth: true,
});
$('#submitBtnT').on('click', function(){
//$('#antesL').addClass("is-invalid");
$('#formaModalTiempos').submit();
});
var today = new Date();
function valida_camposT(){
var error=false;
if($('#antesL').val()==""){
$('#antesL').addClass("is-invalid");
error=true;
}
if($('#antesL').val()<0){
$('#antesL').addClass("is-invalid");
error=true;
}
if(isNaN($('#antesL').val())){
$('#antesL').addClass("is-invalid");
error=true;
}
if($('#despuesL').val()==""){
$('#despuesL').addClass("is-invalid");
error=true;
}
if($('#despuesL').val()<0){
$('#despuesL').addClass("is-invalid");
error=true;
}
if(isNaN($('#despuesL').val())){
$('#despuesL').addClass("is-invalid");
error=true;
}
if($('#retardoL').val()==""){
$('#retardoL').addClass("is-invalid");
error=true;
}
if($('#retardoL').val()<0){
$('#retardoL').addClass("is-invalid");
error=true;
}
if(isNaN($('#retardoL').val())){
$('#retardoL').addClass("is-invalid");
error=true;
}
if($('#antesP').val()==""){
$('#antesP').addClass("is-invalid");
error=true;
}
if(isNaN($('#antesP').val())){
$('#antesP').addClass("is-invalid");
error=true;
}
if($('#despuesP').val()==""){
$('#despuesP').addClass("is-invalid");
error=true;
}
if(isNaN($('#despuesP').val())){
$('#despuesP').addClass("is-invalid");
error=true;
}
if($('#retardoP').val()==""){
$('#retardoP').addClass("is-invalid");
error=true;
}
if(isNaN($('#retardoP').val())){
$('#retardoP').addClass("is-invalid");
error=true;
}
if(!error){
$('#formaModalTiempos').prop("action", "./action/action_tiempos_update.php");
}else{
return false;
}
}
function valida_camposP(){
var error=false;
if($("#fecha_inicial").val()==""){
$("#fecha_inicial").addClass("is-invalid");
error=true;
}
if($("#fecha_final").val()==""){
$("#fecha_final").addClass("is-invalid");
error=true;
}
if($("#nombreP").val()==""){
$("#nombreP").addClass("is-invalid");
$("#nombreP-error").html("Campo obligatorio");
error=true;
}
if($("#nombreP").val()[0]==" "){
$("#nombreP").addClass("is-invalid");
$("#nombreP-error").html("No puede haber espacios al inicio");
error=true;
}
if($("#nivelP").val()==""){
error=true;
$("#nivelP").addClass("is-invalid");
}
if(error){
return false;
}else{
var btn = $("#submitBtnP");
if(btn.data("tipo")==2)//update
$("#formaModalP").prop("action", "./action/action_periodos_update.php");
else{//insert
$("#formaModalP").prop("action", "./action/action_periodos_insert.php");
}
}
}
<?php if(!$fs_carreras && !$fs_periodos){ ?>
triggerMessage("No se encontraron carreras ni periodos en esta facultad", "Error");
<?php } else if(!$fs_carreras){?>
triggerMessage("No se encontraron carreras en esta facultad", "Error");
<?php } else if(!$fs_periodos){?>
triggerMessage("No se encontraron periodos en esta facultad", "Error");
<?php }?>
function valida_campos(){
var error=false;
if($("#nombre").val()==""){
$("#nombre").addClass("is-invalid");
$("#nombre-error").html("Campo obligatorio");
error=true;
}
if($("#nombre").val()[0]==" "){
$("#nombre").addClass("is-invalid");
$("#nombre-error").html("No puede haber espacios al inicio");
error=true;
}
if($("#nivel").val()==""){
error=true;
}
if($('#estado_activo').prop('checked') == false && $('#estado_inactivo').prop('checked') == false){
error=true;
}
if(error){
return false;
}else{
var btn = $('#submitBtn');
if(btn.data("tipo")==2)//update
$("#formaModal").prop("action", "./action/action_carreras_update.php");
else//insert
$("#formaModal").prop("action", "./action/action_carreras_insert.php");
}
}
$('#modal_periodo').on('show.bs.modal', function(event){//datos periodo
var button = $(event.relatedTarget);
var tipo = button.data('tipo');
$("#nombreP").removeClass("is-invalid");
if(tipo==1){//crear
$('#modalLabelP').html("Agregar periodo");
$("#submitBtnP").data("tipo", 1);
$("#fecha_inicial").datepicker("setDate", today);
$("#fecha_final").datepicker("setDate", today);
$("#nombreP").val("");
$("#estado_activoP").prop("checked", true);
setDatalist("#nivelP",1);
$("li").removeClass("selected");
var fi = $("#fecha_inicial").datepicker("getDate");
//$("#fecha_final").datepicker("option", "minDate", fi);
}else{//editar
$('#modalLabelP').html("Editar periodo");
$("#submitBtnP").data("tipo", 2);
var id = $(event.relatedTarget).parents("tr").data("id");
var fac = $("#facultadP").val();
$.ajax({
url:"action/action_periodos_select.php",
type:"post",
dataType:"json",
data:{idfacultad: fac, idperiodo: id},
success:function(result){
//console.log(result);
$("#idP").val(result["id"]);
$("#facultadP").val(result["facultad_id"]);
$("#nombreP").val(result["periodo"]);
var date = new Date(result["inicio"])
date.setDate(date.getDate() + 1);
$("#fecha_inicial").datepicker("setDate", date);
date = new Date(result["fin"])
date.setDate(date.getDate() + 1);
$("#fecha_final").datepicker("setDate", date);
//$(".datalist-input").html(result["nivel"]);
setDatalist("#nivelP",result["nivel_id"]);
var fi = $("#fecha_inicial").datepicker("getDate");
//$("#fecha_final").datepicker("option", "minDate", fi);
var ff = $("#fecha_final").datepicker("getDate");
//$("#fecha_inicial").datepicker("option", "maxDate", ff);
if(result['estado']=="Activo"){
$('#estado_activoP').prop('checked', true);
}else{
$('#estado_inactivoP').prop('checked', true);
}
},
error: function(){console.log("Error")}
});
}
})
$('#modal').on('show.bs.modal', function(event){
var button = $(event.relatedTarget);
var tipo = button.data('tipo');
var modal = $(this);
$("#nombre").removeClass("is-invalid");
if(tipo == 1){//crear
$("#submitBtn").data('tipo', 1);
$("#modalLabel").html("Crear Carrera");
$("#nombre").val("");
$('#estado_activo').prop('checked', true);
$('li').removeClass('selected');
$(".datalist-input").html("Mostrar todas");
$("#nivel").val("");
}else{//editar
$("#submitBtn").data('tipo', 2);
$("#modalLabel").html("Editar Carrera");
$("#nombre").val("");
$('#estado_activo').prop('checked', true);
var id = $(event.relatedTarget).parents("tr").data("id");
var fac = $("#facultad").val();
$.ajax({
url:"action/action_carreras_select.php",
type:"post",
dataType:"json",
data:{idfacultad: fac, idcarrera: id},
success:function(result){
//console.log(result);
$("#id").val(result["carrera_id"]);
$("#nombre").val(result["carrera_nombre"])
if(result['carrera_activa']==1){
$('#estado_activo').prop('checked', true);
}else{
$('#estado_inactivo').prop('checked', true);
}
setDatalist("#nivel", result["nivel_id"]);
},
error: function(){console.log("Error")}
});
}
});
$(document).ready(function(){
$('#antesL').val("<?= -1*($fs_tiempoLic['desde_asistencia'] ?? 0) ?>");
$('#despuesL').val("<?= ($fs_tiempoLic['hasta_asistencia'] ?? 1)-1 ?>");
$('#retardoL').val("<?= ($fs_tiempoLic['hasta_retardo'] ?? 1) - ($fs_tiempoLic['hasta_asistencia'] ?? 0) ?>");
$('#antesP').val("<?= -1*($fs_tiempoPos['desde_asistencia'] ?? 0) ?>");
$('#despuesP').val("<?= ($fs_tiempoPos['hasta_asistencia'] ?? 1) -1 ?>");
$('#retardoP').val("<?= ($fs_tiempoPos['hasta_retardo'] ?? 1) - ($fs_tiempoPos['hasta_asistencia'] ?? 0) ?>");
$('#facultadT').val("<?= $_GET['facultad'] ?>");
<?php
if(($fs_tiempoLic['hasta_asistencia'] ?? 0) == ($fs_tiempoLic['hasta_retardo'] ?? 0)){ ?>
$('.retardoLic').hide();
$('#retardoL').val("0");
$('#retardoLic').prop("checked", false).change();
<?php }
else{ ?>
$('#retardoLic').prop("checked", true).change();
<?php }
if(($fs_tiempoPos['hasta_asistencia'] ?? 0) == ($fs_tiempoPos['hasta_retardo'] ?? 0)){ ?>
$('.retardoPos').hide();
$('#retardoP').val("0");
$('#retardoPos').prop("checked", false).change();
<?php }
else{ ?>
$('#retardoPos').prop("checked", true).change();
<?php }
?>
});
</script>
</body>
</html>