Alejandro Rosales 2 лет назад
Родитель
Сommit
a2fa9058d5
7 измененных файлов с 100 добавлено и 43 удалено
  1. 77 0
      action/puesto.php
  2. 9 3
      action/reposicion_select.php
  3. 2 17
      js/auditoría.js
  4. 8 2
      reposiciones_autorizar.php
  5. 1 0
      reposiciones_crear.php
  6. 1 1
      supervisor.php
  7. 2 20
      ts/auditoría.ts

+ 77 - 0
action/puesto.php

@@ -0,0 +1,77 @@
+<?php
+
+require_once "{$_SERVER['DOCUMENT_ROOT']}/class/c_login.php";
+header('Content-Type: application/json');
+
+if (!Login::is_logged()) {
+    header('HTTP/1.1 401 Unauthorized');
+    echo json_encode(['error' => 'No se ha iniciado sesión']);
+    exit();
+}
+$user = Login::get_user();
+
+try {
+    switch ($_SERVER['REQUEST_METHOD']) {
+        case 'GET':
+            // Fetch all puestos
+            $facultad_id = $user->facultad['facultad_id'] ?? -1;
+            $puestos = $db->orderBy('puesto_id', 'desc')
+                ->where('facultad_id', $facultad_id)
+                ->get('puesto');
+            echo json_encode($puestos);
+            break;
+
+        case 'POST':
+            $raw_input = file_get_contents('php://input');
+            $input_data = json_decode($raw_input, true);
+
+            if (!$input_data || !isset($input_data['puesto_nombre'])) {
+                header('HTTP/1.1 400 Bad Request');
+                echo json_encode(['error' => 'Datos inválidos']);
+                exit();
+            }
+
+            $puesto_id = $db->insert('puestos', ['puesto_nombre' => $input_data['puesto_nombre']]);
+            echo json_encode(['msg' => 'Puesto creado exitosamente', 'puesto_id' => $puesto_id]);
+            break;
+
+        case 'PUT':
+            $raw_input = file_get_contents('php://input');
+            $input_data = json_decode($raw_input, true);
+
+            if (!$input_data || !isset($input_data['puesto_id'], $input_data['puesto_nombre'])) {
+                header('HTTP/1.1 400 Bad Request');
+                echo json_encode(['error' => 'Datos inválidos']);
+                exit();
+            }
+
+            $db->where('puesto_id', $input_data['puesto_id'])->update('puestos', ['puesto_nombre' => $input_data['puesto_nombre']]);
+            echo json_encode(['msg' => 'Puesto actualizado exitosamente']);
+            break;
+
+        case 'DELETE':
+            $raw_input = file_get_contents('php://input');
+            $input_data = json_decode($raw_input, true);
+
+            if (!$input_data || !isset($input_data['puesto_id'])) {
+                header('HTTP/1.1 400 Bad Request');
+                echo json_encode(['error' => 'Datos inválidos']);
+                exit();
+            }
+
+            $db->where('puesto_id', $input_data['puesto_id'])->delete('puestos');
+            echo json_encode(['msg' => 'Puesto eliminado exitosamente']);
+            break;
+
+        default:
+            header('HTTP/1.1 405 Method Not Allowed');
+            echo json_encode(['error' => 'Método no permitido']);
+            break;
+    }
+} catch (PDOException $e) {
+    echo json_encode([
+        'error' => $e->getMessage(),
+        'query' => $db->getLastQuery(),
+        'exception' => $e->getTraceAsString()
+    ]);
+}

+ 9 - 3
action/reposicion_select.php

@@ -23,9 +23,15 @@ $user = unserialize($_SESSION['user']);
 
     
     try{
-        $rs = $db->querySingle('SELECT * from fs_reposicion(:id, NULL, NULL, NULL, NULL, NULL, NULL, NULL)',
-            [':id' => $id]
-        );
+        if($user->rol["rol_id"] == 9){//es coordinador
+            $rs = $db->querySingle('SELECT * from fs_reposicion(:id, NULL, :fac, NULL, NULL, NULL, NULL, NULL, NULL)',
+                [':id' => $id, ":fac"=>$user->facultad["facultad_id"] ]
+            );
+        }else{//supervisor 
+            $rs = $db->querySingle('SELECT * from fs_reposicion(:id, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)',
+                [':id' => $id]
+            );
+        }
 
     }catch(Exception $e){
         $return["error"] = "Ocurrió un error al leer los datos de la reposición.";

+ 2 - 17
js/auditoría.js

@@ -291,23 +291,7 @@ createApp({
         Object.assign(store.current.justificada, store.current.clone_justificada);
         delete store.current.clone_justificada;
     },
-    get profesores() {
-        return store.registros.data
-            .map((registro) => ({
-            profesor_id: registro.profesor_id,
-            profesor_nombre: registro.profesor_nombre,
-            profesor_correo: registro.profesor_correo,
-            profesor_clave: registro.profesor_clave,
-            profesor_grado: registro.profesor_grado,
-        }))
-            .reduce((acc, current) => {
-            if (!acc.some(item => item.profesor_id === current.profesor_id)) {
-                acc.push(current);
-            }
-            return acc;
-        }, [])
-            .sort((a, b) => a.profesor_nombre.localeCompare(b.profesor_nombre));
-    },
+    profesores: [],
     async mounted() {
         $('div.modal#cargando').modal('show');
         // await store.registros.fetch()
@@ -315,6 +299,7 @@ createApp({
         await store.estados.fetch();
         await store.bloques_horario.fetch();
         await store.filters.switchFechas();
+        this.profesores = await (await fetch('action/action_profesor.php')).json();
         $('div.modal#cargando').modal('hide');
     }
 }).mount('#app');

+ 8 - 2
reposiciones_autorizar.php

@@ -88,13 +88,19 @@ if($user->periodo_id!= ""){
     $repEdo_rs = $db->query('SELECT * FROM fs_estado_reposicion' );
 
     $repoParams = array();
-    $query = "NULL,";//carrera, prof
+    $query = "NULL,";//jefe carrera
     /*if($user->jefe_carrera){
         $query .= ":jefe, ";
         $repoParams[":jefe"] = $user->user["id"];
     }else{
         $query .= "NULL, ";
     }*/
+    if($user->rol["rol_id"] == 9){//es coordinador
+        $query .= ":facultad, ";
+        $repoParams[":facultad"] = $user->facultad["facultad_id"];
+    }else{//supervisor
+        $query .= "NULL, ";
+    }
     if((isset($_POST["prof"]) && is_numeric($_POST["prof"])) ){
         $query .= ":prof,";
         $repoParams[":prof"] = filter_input(INPUT_POST, "prof", FILTER_SANITIZE_NUMBER_INT);//limpia texto
@@ -540,6 +546,7 @@ if($user->periodo_id!= ""){
         }
         ?>
     </main>
+    <? include "import/html_footer.php"; ?>
 </body>
 
     <?php
@@ -605,7 +612,6 @@ if($user->periodo_id!= ""){
 
         $('#modal_aprobar').on('show.bs.modal', function (event) {
             var button = $(event.relatedTarget); // Button that triggered the modal
-            console.log("Abre:"+button.data("tipo"));
             var id = button.parents("tr").data("id");
             var edo = button.data('tipo');
 

+ 1 - 0
reposiciones_crear.php

@@ -570,6 +570,7 @@ $fecha_fin_db = $date->format('Y-m-d');
             </div>
         </div>
     </main>
+    <? include "import/html_footer.php"; ?>
     
     <?php
     //--Manejo de errores y mensajes de exito

+ 1 - 1
supervisor.php

@@ -787,7 +787,7 @@
 
             },
             get clase_vista() {
-                if (!store.profesor_selected.horario_id || !store.profesor_selected.profesor_id)
+                if (!store.profesor_selected.horario_id || !(store.profesor_selected.profesor_id >= 0) )
                     return false;
 
                 return store.profesor_selected.es_reposicion

+ 2 - 20
ts/auditoría.ts

@@ -377,26 +377,7 @@ createApp({
         Object.assign(store.current.justificada, store.current.clone_justificada)
         delete store.current.clone_justificada
     },
-    get profesores() {
-        return store.registros.data
-            .map((registro: Registro) => ({
-                profesor_id: registro.profesor_id,
-                profesor_nombre: registro.profesor_nombre,
-                profesor_correo: registro.profesor_correo,
-                profesor_clave: registro.profesor_clave,
-                profesor_grado: registro.profesor_grado,
-            }))
-            .reduce((acc: Profesor[], current: Profesor) => {
-                if (!acc.some(item => item.profesor_id === current.profesor_id)) {
-                    acc.push(current);
-                }
-                return acc;
-            }, [])
-            .sort((a: Profesor, b: Profesor) =>
-                a.profesor_nombre.localeCompare(b.profesor_nombre)
-            );
-
-    },
+    profesores: [] as Profesor[],
     async mounted() {
         $('div.modal#cargando').modal('show');
 
@@ -405,6 +386,7 @@ createApp({
         await store.estados.fetch()
         await store.bloques_horario.fetch()
         await store.filters.switchFechas()
+        this.profesores = await (await fetch('action/action_profesor.php')).json() as Profesor[];
 
         $('div.modal#cargando').modal('hide');
     }