Fix page materias.php

This commit is contained in:
2023-08-16 19:19:41 +00:00
parent 9ce1dee313
commit 6147315925

View File

@@ -45,16 +45,16 @@ if ($user->admin) {
$sql = "SELECT * FROM fs_materias(:nombre, :carrera, :facultad)";
if (isset($_POST["desc"])) {
$desc = $_POST["desc"];
$filter_desc = trim(filter_input(INPUT_POST, "desc", FILTER_SANITIZE_STRING, array('flags' => FILTER_FLAG_STRIP_LOW)));
}else{
$desc=null;
$filter_desc = htmlspecialchars($desc, ENT_QUOTES, 'UTF-8');
} else {
$desc = null;
}
if (isset($_POST["carrera"])) {
$pcarrera = $_POST["carrera"];
$filter_carrera = trim(filter_input(INPUT_POST, "carrera", FILTER_SANITIZE_STRING, array('flags' => FILTER_FLAG_STRIP_LOW)));
}else{
$pcarrera=null;
$filter_carrera = htmlspecialchars($pcarrera, ENT_QUOTES, 'UTF-8');
} else {
$pcarrera = null;
}
if ($pcarrera == "") {
@@ -104,11 +104,15 @@ if ($user->admin) {
if ($nivel_ac != $carrera["nivel_id"]) {
$nivel_ac = $carrera["nivel_id"];
?>
<li data-id="" class="not-selectable"><?php echo $carrera["nivel_nombre"]; ?></li>
<li data-id="" class="not-selectable">
<?php echo $carrera["nivel_nombre"]; ?>
</li>
<?php
}
?>
<li data-id="<?php echo $carrera["carrera_nombre"]; ?>" class="pl-4 <?= !(isset($filter_carrera) && $carrera["carrera_nombre"] == $filter_carrera) ?: 'selected'; ?>"><?= $carrera["carrera_nombre"] ?></li>
<li data-id="<?php echo $carrera["carrera_nombre"]; ?>"
class="pl-4 <?= !(isset($filter_carrera) && $carrera["carrera_nombre"] == $filter_carrera) ?: 'selected'; ?>">
<?= $carrera["carrera_nombre"] ?></li>
<?php
}
@@ -141,16 +145,15 @@ if ($user->admin) {
<?php
if ($pcarrera == "") {
?>
<p> Se muestran los primeros <strong><?php echo $max_count; ?></strong> resultados. Utiliza los filtros para encontrar la materia que buscas.</p>
<p> Se muestran los primeros <strong>
<?php echo $max_count; ?>
</strong> resultados. Utiliza los filtros para encontrar la materia que buscas.</p>
<?php } ?>
<table class="table table-sm table-striped table-white">
<thead class="thead-dark">
<tr>
<th>Nombre</th>
<th>Carrera</th>
<?php if ($user->acceso == 'w') { ?>
<th>Acciones</th>
<?php } ?>
</tr>
</thead>
<tbody>
@@ -160,13 +163,12 @@ if ($user->admin) {
?>
<tr data-id="<?php echo $materia["materia_id"]; ?>" id="<?php echo $materia["materia_id"]; ?>">
<td class="text-primary"><?php echo $materia["materia_nombre"]; ?></td>
<td class="text-primary"><?php echo $materia["carrera_nombre"]; ?></td>
<?php if ($user->acceso == 'w') { ?>
<td class="text-center icono-acciones">
<a href="#" data-toggle="modal" data-target="#modal" data-tipo="3" title="Editar"><span class="ing-editar ing-fw"></span></a>
<td class="text-primary">
<?php echo $materia["materia_nombre"]; ?>
</td>
<td class="text-primary">
<?php echo $materia["carrera_nombre"]; ?>
</td>
<?php } ?>
</tr>
<?php
@@ -198,7 +200,8 @@ if ($user->admin) {
</h4>
</div>
<div class="modal-body">
<form action="./action/action_materias_update.php" method="post" id="formaModal" onsubmit="return valida_campos()">
<form action="./action/action_materias_update.php" method="post" id="formaModal"
onsubmit="return valida_campos()">
<input type="hidden" name="id" id="id">
<div class="form-box">
<div class="form-group row">
@@ -250,14 +253,14 @@ if ($user->admin) {
triggerMessage("No se encontraron materias con estos datos", "Error");
<?php } ?>
$(document).on("click", ".btn-reset", function(event) {
$(document).on("click", ".btn-reset", function (event) {
var forma = $(this).parents("form");
forma.find("input[type=text]").val("");
setDatalistFirst("#filter_carrera");
forma.submit();
});
$('#modal').on('show.bs.modal', function(event) {
$('#modal').on('show.bs.modal', function (event) {
var id = $(event.relatedTarget).parents("tr").data("id");
$.ajax({
url: "action/action_materias_select.php",
@@ -266,11 +269,11 @@ if ($user->admin) {
data: {
idmateria: id
},
success: function(result) {
success: function (result) {
$("#nombre").val(result[0]["materia_nombre"]);
$("#id").val(result[0]["materia_id"]);
},
error: function() {
error: function () {
console.log("Error")
}
});