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)"; $sql = "SELECT * FROM fs_materias(:nombre, :carrera, :facultad)";
if (isset($_POST["desc"])) { if (isset($_POST["desc"])) {
$desc = $_POST["desc"]; $desc = $_POST["desc"];
$filter_desc = trim(filter_input(INPUT_POST, "desc", FILTER_SANITIZE_STRING, array('flags' => FILTER_FLAG_STRIP_LOW))); $filter_desc = htmlspecialchars($desc, ENT_QUOTES, 'UTF-8');
}else{ } else {
$desc=null; $desc = null;
} }
if (isset($_POST["carrera"])) { if (isset($_POST["carrera"])) {
$pcarrera = $_POST["carrera"]; $pcarrera = $_POST["carrera"];
$filter_carrera = trim(filter_input(INPUT_POST, "carrera", FILTER_SANITIZE_STRING, array('flags' => FILTER_FLAG_STRIP_LOW))); $filter_carrera = htmlspecialchars($pcarrera, ENT_QUOTES, 'UTF-8');
}else{ } else {
$pcarrera=null; $pcarrera = null;
} }
if ($pcarrera == "") { if ($pcarrera == "") {
@@ -72,7 +72,7 @@ if ($user->admin) {
); );
//print_r($fs_materias); //print_r($fs_materias);
?> ?>
<main class="content marco"> <main class="content marco">
@@ -85,8 +85,8 @@ if ($user->admin) {
<label for="filter_desc" class="col-4 col-form-label">Materia</label> <label for="filter_desc" class="col-4 col-form-label">Materia</label>
<div class="col-8 col-sm-4"> <div class="col-8 col-sm-4">
<input id="filter_desc" name="desc" type="text" class="form-control" <?php if (isset($filter_desc)) { <input id="filter_desc" name="desc" type="text" class="form-control" <?php if (isset($filter_desc)) {
echo 'value="' . $filter_desc . '"'; echo 'value="' . $filter_desc . '"';
} ?>> } ?>>
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
@@ -103,13 +103,17 @@ if ($user->admin) {
if ($nivel_ac != $carrera["nivel_id"]) { if ($nivel_ac != $carrera["nivel_id"]) {
$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 <?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"]; ?>"
<?php class="pl-4 <?= !(isset($filter_carrera) && $carrera["carrera_nombre"] == $filter_carrera) ?: 'selected'; ?>">
<?= $carrera["carrera_nombre"] ?></li>
<?php
} }
?> ?>
@@ -140,17 +144,16 @@ if ($user->admin) {
<div class="col-12 table-responsive"> <div class="col-12 table-responsive">
<?php <?php
if ($pcarrera == "") { 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 } ?> <?php } ?>
<table class="table table-sm table-striped table-white"> <table class="table table-sm table-striped table-white">
<thead class="thead-dark"> <thead class="thead-dark">
<tr> <tr>
<th>Nombre</th> <th>Nombre</th>
<th>Carrera</th> <th>Carrera</th>
<?php if ($user->acceso == 'w') { ?>
<th>Acciones</th>
<?php } ?>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -158,17 +161,16 @@ if ($user->admin) {
if ($fs_materias) { if ($fs_materias) {
foreach ($fs_materias as $materia) { foreach ($fs_materias as $materia) {
?> ?>
<tr data-id="<?php echo $materia["materia_id"]; ?>" id="<?php echo $materia["materia_id"]; ?>"> <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">
<td class="text-primary"><?php echo $materia["carrera_nombre"]; ?></td> <?php echo $materia["materia_nombre"]; ?>
<?php if ($user->acceso == 'w') { ?> </td>
<td class="text-center icono-acciones"> <td class="text-primary">
<a href="#" data-toggle="modal" data-target="#modal" data-tipo="3" title="Editar"><span class="ing-editar ing-fw"></span></a> <?php echo $materia["carrera_nombre"]; ?>
</td> </td>
<?php } ?>
</tr> </tr>
<?php <?php
} }
} }
@@ -198,7 +200,8 @@ if ($user->admin) {
</h4> </h4>
</div> </div>
<div class="modal-body"> <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"> <input type="hidden" name="id" id="id">
<div class="form-box"> <div class="form-box">
<div class="form-group row"> <div class="form-group row">
@@ -247,17 +250,17 @@ if ($user->admin) {
<?php if ($facultad == -1 && !$user->admin) { ?> <?php if ($facultad == -1 && !$user->admin) { ?>
triggerMessage("No se encontraron materias en tu facultad", "Error"); triggerMessage("No se encontraron materias en tu facultad", "Error");
<?php } else if (!$fs_materias) { ?> <?php } else if (!$fs_materias) { ?>
triggerMessage("No se encontraron materias con estos datos", "Error"); triggerMessage("No se encontraron materias con estos datos", "Error");
<?php } ?> <?php } ?>
$(document).on("click", ".btn-reset", function(event) { $(document).on("click", ".btn-reset", function (event) {
var forma = $(this).parents("form"); var forma = $(this).parents("form");
forma.find("input[type=text]").val(""); forma.find("input[type=text]").val("");
setDatalistFirst("#filter_carrera"); setDatalistFirst("#filter_carrera");
forma.submit(); forma.submit();
}); });
$('#modal').on('show.bs.modal', function(event) { $('#modal').on('show.bs.modal', function (event) {
var id = $(event.relatedTarget).parents("tr").data("id"); var id = $(event.relatedTarget).parents("tr").data("id");
$.ajax({ $.ajax({
url: "action/action_materias_select.php", url: "action/action_materias_select.php",
@@ -266,11 +269,11 @@ if ($user->admin) {
data: { data: {
idmateria: id idmateria: id
}, },
success: function(result) { success: function (result) {
$("#nombre").val(result[0]["materia_nombre"]); $("#nombre").val(result[0]["materia_nombre"]);
$("#id").val(result[0]["materia_id"]); $("#id").val(result[0]["materia_id"]);
}, },
error: function() { error: function () {
console.log("Error") console.log("Error")
} }
}); });