Pārlūkot izejas kodu

Fix page materias.php

Alejandro Rosales 2 gadi atpakaļ
vecāks
revīzija
6147315925
1 mainītis faili ar 37 papildinājumiem un 34 dzēšanām
  1. 37 34
      materias.php

+ 37 - 34
materias.php

@@ -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 == "") {
@@ -72,7 +72,7 @@ if ($user->admin) {
     );
 
     //print_r($fs_materias);
-
+    
     ?>
     <main class="content marco">
 
@@ -85,8 +85,8 @@ if ($user->admin) {
                             <label for="filter_desc" class="col-4 col-form-label">Materia</label>
                             <div class="col-8 col-sm-4">
                                 <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 class="form-group row">
@@ -103,13 +103,17 @@ 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>
-                                            <?php
+                                                ?>
+                                                <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>
-                                        <?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>
+                                            <?php
 
                                         }
                                         ?>
@@ -140,17 +144,16 @@ if ($user->admin) {
             <div class="col-12 table-responsive">
                 <?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>
@@ -158,17 +161,16 @@ if ($user->admin) {
                         if ($fs_materias) {
                             foreach ($fs_materias as $materia) {
 
-                        ?>
+                                ?>
                                 <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>
-                                    <?php } ?>
+                                    <td class="text-primary">
+                                        <?php echo $materia["materia_nombre"]; ?>
+                                    </td>
+                                    <td class="text-primary">
+                                        <?php echo $materia["carrera_nombre"]; ?>
+                                    </td>
                                 </tr>
-                        <?php
+                                <?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">
@@ -247,17 +250,17 @@ if ($user->admin) {
         <?php if ($facultad == -1 && !$user->admin) { ?>
             triggerMessage("No se encontraron materias en tu facultad", "Error");
         <?php } else if (!$fs_materias) { ?>
-            triggerMessage("No se encontraron materias con estos datos", "Error");
+                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")
                 }
             });