diff --git a/action/action_carreras.php b/action/action_carreras.php index 658b3f6..b0c8fcb 100644 --- a/action/action_carreras.php +++ b/action/action_carreras.php @@ -14,7 +14,8 @@ $ruta = "../"; require_once "../include/bd_pdo.php"; $facultad_id = $user->facultad['facultad_id']; $carreras = $db->query( - "SELECT * FROM carrera + "SELECT carrera_id, carrera_nombre, clave_carrera + FROM carrera WHERE (facultad_id = :facultad_id OR :facultad_id IS NULL) ORDER BY carrera_nombre DESC", @@ -23,4 +24,4 @@ $carreras = $db->query( // $user->print_to_log("Crea carrera", old: $_POST); -die(json_encode($carreras)); +die(json_encode($carreras)); \ No newline at end of file diff --git a/action/action_facultad.php b/action/action_facultad.php index 33fa342..c22ee32 100644 --- a/action/action_facultad.php +++ b/action/action_facultad.php @@ -26,9 +26,14 @@ try { exit; } }); - // step 1: get subrutas - $data = $db->get('facultad'); - + $data = $db->query(<< $user->facultad['facultad_id']] + ); echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); } else { http_response_code(405); diff --git a/action/action_grupo.php b/action/action_grupo.php index 257a4aa..4e230ea 100644 --- a/action/action_grupo.php +++ b/action/action_grupo.php @@ -1,21 +1,41 @@ 'No se ha iniciado sesión']); + exit(); +} $ruta = "../"; require_once("../include/bd_pdo.php"); -extract($_POST); -$params = ['per' => $_POST['periodo'], 'fac' => $_POST['facultad'], 'car' => $_POST['carrera']]; -$user->print_to_log("Acceso a grupos", old: $params); -$grupos = queryAll("SELECT DISTINCT LENGTH(GRUPO), GRUPO FROM fs_horario_basic WHERE PERIODO_ID = COALESCE(:per, PERIODO_ID) AND FACULTAD_ID = COALESCE(:fac, FACULTAD_ID) AND CARRERA_ID = COALESCE(:car, CARRERA_ID) ORDER BY LENGTH(GRUPO), GRUPO", $params); +if (!isset($_GET['carrera_id'])) { + echo json_encode([ + 'status' => 'error', + 'error' => 'No se ha especificado una carrera' + ]); + exit(); +} -$grupos = array_map(fn ($grupo) => $grupo['grupo'], $grupos); +$grupos = $db->query(<< $user->periodo_id, + ':facultad_id' => $user->facultad['facultad_id'], + ':carrera_id' => $_GET['carrera_id'] + ] +); -echo json_encode([ - 'status' => 'success', - 'grupos' => $grupos -]); +echo json_encode(array_map(fn($grupo) => $grupo['horario_grupo'], $grupos)); \ No newline at end of file diff --git a/action/action_horario.php b/action/action_horario.php index 477ed4c..2718015 100644 --- a/action/action_horario.php +++ b/action/action_horario.php @@ -17,20 +17,34 @@ $user = unserialize($_SESSION['user']); // check method try { if ($_SERVER['REQUEST_METHOD'] === 'GET') { - if (!isset($_GET['profesor_id'])) { + if (!(isset($_GET['profesor_id']) || isset($_GET['grupo']))) { throw new Exception('missing parameters'); } - $data = $db->query( - "SELECT *, (EXTRACT(EPOCH FROM (horario_fin - horario_hora) ) / EXTRACT(EPOCH FROM interval '15 minute'))::INT AS bloques + if (isset($_GET['profesor_id'])) { + $data = $db->query( + "SELECT *, (EXTRACT(EPOCH FROM (horario_fin - horario_hora) ) / EXTRACT(EPOCH FROM interval '15 minute'))::INT AS bloques FROM horario_view JOIN horario_profesor ON horario_profesor.horario_id = horario_view.horario_id WHERE horario_profesor.profesor_id = :profesor_id AND (facultad_id = :facultad_id OR :facultad_id IS NULL)", - [ - 'profesor_id' => $_GET['profesor_id'], - 'facultad_id' => $user->facultad['facultad_id'], - ] - ); + [ + 'profesor_id' => $_GET['profesor_id'], + 'facultad_id' => $user->facultad['facultad_id'], + ] + ); + } else if (isset($_GET['grupo'])) { + $data = $db->query( + "SELECT *, (EXTRACT(EPOCH FROM (horario_fin - horario_hora) ) / EXTRACT(EPOCH FROM interval '15 minute'))::INT AS bloques + FROM horario_view + WHERE substring(horario_grupo, 7, 3) = (CAST(:grupo AS INT) + 1)::varchar + AND (facultad_id = :facultad_id OR :facultad_id IS NULL) AND carrera_id = :carrera_id", + [ + 'grupo' => $_GET['grupo'], + 'facultad_id' => $user->facultad['facultad_id'], + 'carrera_id' => $_GET['carrera_id'], + ] + ); + } $last_query = [ 'query' => $db->getLastQuery(), diff --git a/action/action_materias.php b/action/action_materias.php index 504e971..fdedd32 100644 --- a/action/action_materias.php +++ b/action/action_materias.php @@ -1,26 +1,30 @@ 'No se ha iniciado sesión'])); $user = unserialize($_SESSION['user']); -if (($access = $user->access('asistencia')) == 'n') - die(json_encode(['error' => true])); - -$user->print_to_log('Consultar materias'); -$materias = queryAll( - "SELECT id, nombre FROM FS_MATERIA WHERE carrera = COALESCE(:carrera, carrera) ORDER BY nombre", - [':carrera' => empty($carrera) ? null : $carrera] +$ruta = "../"; +require_once "../include/bd_pdo.php"; +$facultad_id = $user->facultad['facultad_id']; +$materias = $db->query(<< $facultad_id) ); -?> - 'success', - 'materias' => $materias, -]); ?> \ No newline at end of file +// $user->print_to_log("Crea carrera", old: $_POST); + +die(json_encode($materias)); \ No newline at end of file diff --git a/action/carrera.php b/action/carrera.php new file mode 100644 index 0000000..7aed854 --- /dev/null +++ b/action/carrera.php @@ -0,0 +1,36 @@ + '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']; + $carreras = $db->query(<< $facultad_id]); + echo json_encode($carreras); + 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() + ]); +} \ No newline at end of file diff --git a/action/puesto.php b/action/puesto.php index c51a638..bbdffb1 100644 --- a/action/puesto.php +++ b/action/puesto.php @@ -26,7 +26,7 @@ try { ->join('puesto_usuario', 'puesto_usuario.usuario_id = usuario.usuario_id', 'LEFT') ->getOne('usuario', ['usuario.usuario_id', 'usuario_nombre', 'usuario_clave']), ), - $db->orderBy('puesto_id', 'desc') + $db->orderBy('puesto.nombre', 'desc') ->where('facultad_id', $facultad_id) ->get(tableName: 'puesto', numRows: count($carreras), columns: 'puesto_id, nombre'), ); @@ -61,7 +61,7 @@ try { $raw_input = file_get_contents('php://input'); $input_data = json_decode($raw_input, true); - if (!$input_data || !isset($input_data['puesto_id'], $input_data['materias'], $input_data['usuario_id'])) { + if (!$input_data || !isset($input_data['puesto_id'], $input_data['materias'])) { header('HTTP/1.1 400 Bad Request'); echo json_encode(['error' => 'Datos inválidos']); exit(); @@ -77,10 +77,11 @@ try { ]); } - $db->insert('puesto_usuario', [ - 'puesto_id' => $input_data['puesto_id'], - 'usuario_id' => $input_data['usuario_id'], - ]); + if (isset($input_data['usuario_id'])) + $db->insert('puesto_usuario', [ + 'puesto_id' => $input_data['puesto_id'], + 'usuario_id' => $input_data['usuario_id'], + ]); echo json_encode(['msg' => 'Puesto actualizado exitosamente']); break; @@ -95,7 +96,7 @@ try { exit(); } - $db->where('puesto_id', $input_data['puesto_id'])->delete('puestos'); + $db->where('puesto_id', $input_data['puesto_id'])->delete('puesto'); echo json_encode(['msg' => 'Puesto eliminado exitosamente']); break; diff --git a/action/reposicion_autoriza.php b/action/reposicion_autoriza.php index d74f68c..363168e 100644 --- a/action/reposicion_autoriza.php +++ b/action/reposicion_autoriza.php @@ -7,12 +7,14 @@ $ruta = "../"; require_once "../class/c_login.php"; // check if the session is started -$user = Login::get_user(); +if (!isset($_SESSION['user'])) + die('No se ha iniciado sesión'); + +$user = unserialize($_SESSION['user']); $pag = "../reposiciones_autorizar.php"; - if(!isset($_POST["id"]) || !isset($_POST["edo"]) ){ header("Location: ".$pag."?error=0"); exit(); @@ -21,30 +23,31 @@ if(!isset($_POST["id"]) || !isset($_POST["edo"]) ){ $id_repo = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto $edo = filter_input(INPUT_POST, "edo", FILTER_SANITIZE_NUMBER_INT);//limpia texto if(isset($_POST["salon"]) && $_POST["salon"] != "") - $salon = trim(filter_input(INPUT_POST, "salon", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto + $salon = filter_input(INPUT_POST, "salon", FILTER_SANITIZE_NUMBER_INT);//limpia texto -$motivo = ""; -if(isset($_POST["motivo"]) && $_POST["motivo"] != "") - $motivo = trim($_POST["motivo"]); if($edo == 4){//cancelación + $motivo = ""; + if(isset($_POST["motivo"]) && $_POST["motivo"] != "") + $motivo = trim($_POST["motivo"]); $db->querySingle('SELECT fu_reposicion_cancela(:id, :motivo)', [':id' => $id_repo, ':motivo' => $motivo] ); }else{ if(!empty($salon)){ - $db->querySingle('SELECT fu_reposicion(:id, NULL, NULL, NULL, :sal, :edo, NULL, NULL, NULL, NULL)', + $db->querySingle('SELECT fu_reposicion_solicitud(:id, NULL, NULL, NULL, :sal, :edo, NULL, NULL, NULL, NULL)', [':id' => $id_repo, ':sal' => $salon, ':edo' => $edo] ); }else{ - $db->querySingle('SELECT fu_reposicion(:id, NULL, NULL, NULL, NULL, :edo, NULL, NULL, NULL, NULL)', + $db->querySingle('SELECT fu_reposicion_solicitud(:id, NULL, NULL, NULL, NULL, :edo, NULL, NULL, NULL, NULL)', [':id' => $id_repo, ':edo' => $edo] ); } } //Obtener datos del usuario que creó la reposición y mandar correo -/*$stmt = $pdo->prepare('Select * from fs_reposicion(:id, :periodo, NULL, NULL, NULL, NULL, NULL, 0, 1)'); +/*$stmt = $pdo->prepare('Select * from +:id, :periodo, NULL, NULL, NULL, NULL, NULL, 0, 1)'); $stmt->bindParam(":id", $id_repo); $stmt->bindParam(":periodo", $_SESSION["periodo_id"]); if(!$stmt->execute()){ diff --git a/action/reposicion_delete.php b/action/reposicion_delete.php index 04637e1..8c69187 100644 --- a/action/reposicion_delete.php +++ b/action/reposicion_delete.php @@ -7,17 +7,20 @@ $ruta = "../"; require_once "../class/c_login.php"; // check if the session is started -$user = Login::get_user(); +if (!isset($_SESSION['user'])) + die('No se ha iniciado sesión'); + +$user = unserialize($_SESSION['user']); //--- Objeto para validar usuario. El id de usuario lo lee desde sesión -if(!isset($_POST["id"], $_POST["prof"])){ +if(!isset($_POST["id"])){ $return["error"] = "Error! No se recibió la información necesaria."; }else{ $id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto - $prof = $user["id"]; + $creador = $user->user["id"]; try{ - $db->query('SELECT * from fd_reposicion(:id, :prof)', [":id"=> $id, ":prof"=>$prof]); + $db->query('SELECT * from fd_reposicion_solicitud(:id, :creador)', [":id"=> $id, ":creador"=>$creador]); $return["ok"] = "La reposición se borró correctamente"; }catch(Exception $e){ diff --git a/action/reposicion_select.php b/action/reposicion_select.php index 42e8f2d..f2b32f9 100644 --- a/action/reposicion_select.php +++ b/action/reposicion_select.php @@ -55,7 +55,17 @@ $user = unserialize($_SESSION['user']); $return["materia"] = $rs["materia_id"]; $return["materia_desc"] = $rs["materia_nombre"]; $return["salon"] = $rs["salon_id"]; - $return["salon_desc"] = $rs["salon"]=="" ? "-Pendiente-": $rs["salon"]; + if($rs["salon_id"]==""){ + $return["salon_desc"] = "Pendiente"; + }else{ + $salon_json = json_decode($rs["salon_array"], true); + if($salon_json[0]== "UNIVERSIDAD LA SALLE"){ + unset($salon_json[0]); + } + $return["salon_desc"] = join(" / ",$salon_json); + } + + //$return["salon_desc"] = $rs["salon"]=="" ? "-Pendiente-": $rs["salon"]; $return["ciclo"] = $rs["ciclo"]; $return["bloque"] = $rs["bloque"]; $return["profesor"] = $rs["profesor_id"]; @@ -69,6 +79,7 @@ $user = unserialize($_SESSION['user']); $return["dia"] = date('w', strtotime($rs["fecha_clase"])); $return["motivo_cancelacion"] = $rs["motivo_cancelacion"]; $return["estado"] = $rs["estado_reposicion_id"]; + $return["facultad"] = $rs["facultad_nombre"]; } echo json_encode($return); ?> diff --git a/action/rutas_salón_horario.php b/action/rutas_salón_horario.php index db99750..db2ba51 100644 --- a/action/rutas_salón_horario.php +++ b/action/rutas_salón_horario.php @@ -60,7 +60,6 @@ try { 'reposicion_hora', 'salon_reposicion.salon as reposicion_salon', ]; - $data = array_map( fn($ruta) => array_merge( [ @@ -77,6 +76,8 @@ try { ->where('horario_dia = EXTRACT(DOW FROM CURRENT_DATE)') ->where('bloque_horario.id', $_GET['bloque_horario_id']) ->where('salon_view.id_espacio_padre', $ruta['id_espacio_sgu']) + ->orderBy('horario_hora') + ->orderBy('salon_view.salon') ->get( 'horario_view', columns: $columns diff --git a/action/usuarios.php b/action/usuarios.php new file mode 100644 index 0000000..c3e77ad --- /dev/null +++ b/action/usuarios.php @@ -0,0 +1,28 @@ + 'No se ha iniciado sesión'])); + +$user = unserialize($_SESSION['user']); + +$ruta = "../"; +require_once "../include/bd_pdo.php"; +$facultad_id = $user->facultad['facultad_id']; +$materias = $db->query(<< $facultad_id) +); + +// $user->print_to_log("Crea carrera", old: $_POST); + +die(json_encode($materias)); \ No newline at end of file diff --git a/auditoria.php b/auditoria.php index f62b77d..5dd9e69 100644 --- a/auditoria.php +++ b/auditoria.php @@ -218,7 +218,16 @@
-
+
+
+ +
+
+ +
-
+
@@ -313,7 +322,8 @@ - {{ registro.usuario_nombre }} + {{ registro.usuario_nombre + }}
Hora @@ -452,7 +462,8 @@
Horario: - {{ clase_vista.horario_hora?.slice(0, 5) }} - {{clase_vista.horario_fin?.slice(0, 5) }} + {{ clase_vista.horario_hora?.slice(0, 5) }} - + {{clase_vista.horario_fin?.slice(0, 5) }}
Salón: @@ -602,20 +613,8 @@ class="text-muted">{{store.current.justificada.profesor_nombre}}
-
-
-
- - -
-
-
- -
-
+
+
Observaciones
@@ -632,7 +631,10 @@ Cancelar -
diff --git a/consultar_horario.php b/consultar_horario.php index 7b8dbb6..5a1c0f2 100644 --- a/consultar_horario.php +++ b/consultar_horario.php @@ -37,29 +37,99 @@ $write = $user->admin || in_array($user->acceso, ['r']); include("import/html_header.php"); html_header("Consultar horario", "Sistema de gestión de checador"); ?> -
+
- -
-
- -
-
- - + + +
+
diff --git a/js/horario.js b/js/horario.js index 09ea4ad..b84d5a3 100644 --- a/js/horario.js +++ b/js/horario.js @@ -14,10 +14,32 @@ const profesores = reactive({ return this.data.find((profesor) => profesor.profesor_clave === profesores.clave); }, }); -const horarios = reactive({ +const facultades = reactive({ data: [], fetch: async function () { - if (profesores.current) { + const facultades = await fetch('action/action_facultad.php').then(response => response.json()); + const carreras = await fetch(`action/carrera.php`).then(response => response.json()); + this.data = await Promise.all(facultades.map(async (facultad) => ({ + ...facultad, + carreras: await Promise.all(carreras.filter((carrera) => carrera.facultad_id === facultad.facultad_id).map(async (carrera) => { + const grupos = await fetch(`action/action_grupo.php?carrera_id=${carrera.carrera_id}`).then(response => response.json()); + return { + ...carrera, + grupos, + }; + })), + }))); + this.data = this.data.filter((facultad) => facultad.carreras.length > 0); + } +}); +const horarios = reactive({ + data: [], + fetch: async function (grupo = null, carrera_id = null) { + if (grupo && carrera_id) { + const response = await fetch(`action/action_horario.php?grupo=${grupo}&carrera_id=${carrera_id}`); + this.data = await response.json(); + } + else if (profesores.current) { const response = await fetch(`action/action_horario.php?profesor_id=${profesores.current.profesor_id}`); this.data = await response.json(); } @@ -76,7 +98,9 @@ const horarios = reactive({ const app = createApp({ profesores, horarios, + facultades, mounted: async function () { await profesores.fetch(); + await facultades.fetch(); } }).mount('#app'); diff --git a/js/puestos.js b/js/puestos.js index c0020ca..13bcd0d 100644 --- a/js/puestos.js +++ b/js/puestos.js @@ -15,6 +15,31 @@ const app = createApp({ }); const data = await res.json(); this.puestos.push(data); + // order by puesto.nombre + this.puestos.sort((a, b) => a.nombre.localeCompare(b.nombre)); + } + catch (error) { + alert(`Error: ${error}`); + } + }, + to_delete: null, + async eliminarPuesto(puesto_id) { + try { + const res = await fetch('action/puesto.php', { + method: 'DELETE', + body: JSON.stringify({ + puesto_id + }) + }); + const data = await res.json(); + this.message = data.msg; + // after 3 seconds, remove the message + setTimeout(() => { + this.message = null; + }, 3000); + this.puestos = this.puestos.filter((p) => p.puesto_id !== puesto_id); + // order by puesto.nombre + this.puestos.sort((a, b) => a.nombre.localeCompare(b.nombre)); } catch (error) { alert(`Error: ${error}`); diff --git a/logs.php b/logs.php index 643d0ba..ef86831 100644 --- a/logs.php +++ b/logs.php @@ -49,7 +49,7 @@ where('momento::DATE = CURRENT_DATE') + ->where('momento::DATE = ' . (isset($_GET['fecha']) ? "'{$_GET['fecha']}'" : 'CURRENT_DATE')) ->orderBy('momento', 'desc') ->get('log_registro'); diff --git a/puestos.php b/puestos.php index b895b5c..e956ee7 100644 --- a/puestos.php +++ b/puestos.php @@ -26,164 +26,243 @@ global $user; html_header( - "Puestos de la {$user->facultad['facultad']}", + is_null($user->facultad['facultad_id']) ? "Puestos" : "Puestos de la {$user->facultad['facultad']}", "Sistema de gestión de checador", ); - ?> + if (!is_null($user->facultad['facultad_id'])) { + ?> -
+
- -
- -
-
-
-
-
- {{puesto.nombre}} -
-
- -
- -
-
- ({{puesto.encargado.usuario_clave}}) {{ puesto.encargado.usuario_nombre }} -
-
- Selecciona un encargado -
- -
    -
  • - ( {{usuario.usuario_clave}} ) {{ usuario.usuario_nombre }} -
  • -
- -
+ +
+ +
+ +
+
+
+
+

+ + +

-
-
- Materias Asignadas {{puesto.materias.length}} -
    -
  • -
    -
    - + +
    +
    + +
    + +
    +
    + ({{puesto.encargado.usuario_clave}}) {{ puesto.encargado.usuario_nombre }}
    -
    - {{materia.clave_materia}} - {{materia.materia_nombre}} +
    + Selecciona un encargado
    + +
      +
    • + ( {{usuario.usuario_clave}} ) {{ usuario.usuario_nombre }} +
    • +
    +
    -
  • -
- -
-
- -
- -
-
- Selecciona una carrera
- -
    -
  • - Todas las carreras -
  • -
  • - ( {{carrera.clave_carrera}} ) {{ carrera.carrera_nombre }} -
  • -
- -
-
-
- - + +
+
+ Selecciona una carrera +
+ +
    +
  • + Todas las carreras +
  • +
  • + ( {{carrera.clave_carrera}} ) {{ carrera.carrera_nombre }} +
  • +
+ +
+
+
+ + -
- - -
- -
-
-
+ :id="`materias-${puesto.puesto_id}`" autocomplete="off"> +
+ + + +
+
+ Materias Asignadas {{puesto.materias.length}} +
    +
  • +
    +
    + +
    +
    + {{materia.clave_materia}} - {{materia.materia_nombre}} +
    +
    +
  • +
+ +
- -
- + + +
+ +
+
+
+
+
+ Sin Facultad Asociada +
+
+
Atención
+

No tienes una facultad asociada a tu perfil. El rol + rol['rol'] ?> no tiene acceso a esta sección. +

+
+
+
+
+
+ diff --git a/reposiciones_autorizar.php b/reposiciones_autorizar.php index 81cd3f3..9aef146 100644 --- a/reposiciones_autorizar.php +++ b/reposiciones_autorizar.php @@ -9,7 +9,7 @@ if (!isset($_SESSION['user'])){ $user = Login::get_user(); $user->access(); -echo $user; +//echo $user; /*print_r($user); print_r($user->user["id"]); echo "****|"; @@ -53,7 +53,7 @@ if($user->periodo_id!= ""){ $carrera_rs = $db->query('SELECT * FROM fs_profesor_facultad(NULL, :periodo)', [ ':periodo' => $user->periodo_id]); } - $salones_rs = $db->query('SELECT * FROM salon_view WHERE tiene_salones IS true'); + $salones_rs = $db->query('SELECT * from salon_view where es_salon is true'); //Periodo $periodo_rs = $db->querySingle('SELECT periodo_fecha_inicio, periodo_fecha_fin FROM periodo WHERE periodo_id = :periodo_id', [':periodo_id' => $user->periodo_id]); @@ -227,7 +227,7 @@ if($user->periodo_id!= ""){ Autorizadas por Vicerrectoría
@@ -303,7 +303,8 @@ if($user->periodo_id!= ""){ @@ -313,13 +314,13 @@ if($user->periodo_id!= ""){ jefe_carrera || $user->admin) && $reposicion["estado_reposicion_id"] == 1){?> + if((!$user->jefe_carrera || $user->admin || !$coordinador) && $reposicion["estado_reposicion_id"] == 1){?> jefe_carrera || $user->admin) && $reposicion["estado_reposicion_id"] >= 2){?> + else if(($supervisor || $user->admin) && $reposicion["estado_reposicion_id"] == 2){?> - + @@ -375,6 +376,14 @@ if($user->periodo_id!= ""){

+
+
+

Dependencia

+
+
+

+
+

Materia

@@ -461,13 +470,18 @@ if($user->periodo_id!= ""){ - + -
    +
    @@ -610,6 +624,27 @@ if($user->periodo_id!= ""){ $("#motivo").val("") }); + + + $('#dlSalon').on('change', function() { + const selectedValue = $(this).val(); + //console.log(selectedValue) + const selectedOption = $(`option[value="${selectedValue}"]`); + //console.log(selectedOption.length) + + const salonesList = $('#salones'); + + if (selectedOption.length) { + const salonId = selectedOption.data('id'); + $('#salon').val(salonId); + //const salonNombre = selectedOption.data('nombre'); + //salonesList.html(`
  • ${salonNombre}
  • `); + } else { + $('#salon').val(''); + //salonesList.empty(); + } + }); + $('#modal_aprobar').on('show.bs.modal', function (event) { var button = $(event.relatedTarget); // Button that triggered the modal var id = button.parents("tr").data("id"); @@ -619,7 +654,6 @@ if($user->periodo_id!= ""){ $("#edo").val(edo); $("#id").val(id); - $.ajax({ url: './action/reposicion_select.php', @@ -631,8 +665,9 @@ if($user->periodo_id!= ""){ triggerMessage(result["error"], "Error"); $('#modal_aprobar').modal("hide"); }else{ - + $("#dlSalon").val(""); $("#modal_aprobar .rep-prof").text(result["profesor_nombre"]); + $("#modal_aprobar .rep-fac").text(result["facultad"]); $("#modal_aprobar .rep-mat").text(result["materia_desc"]); $("#modal_aprobar .rep-ciclo").text(result["ciclo"]); $("#modal_aprobar .rep-bloque").text(result["bloque"]); @@ -663,23 +698,30 @@ if($user->periodo_id!= ""){ if(edo == 1){// 1 ver $("#modalLabel").text("Detalle de reposición"); $(".aprobar-block").hide(); + + /*if(parseInt($("#modal_aprobar .rep-aula").data("aula")) != 1){//tipo aula 1 (salon normal) - ver + $("#salon-ver").hide(); + $("#salon-editar").show(); + }else{ + $("#salon-ver").show(); + $("#salon-editar").hide(); + }*/ $("#salon-ver").show(); $("#salon-editar").hide(); }else{ - if(parseInt($("#modal_aprobar .rep-aula").data("aula")) == 1){//tipo aula 1 (salon normal) - ver - $("#modalLabel").text("Detalle de reposición"); - $(".aprobar-block").hide(); + $("#modalLabel").text("Aprobar reposición"); + $(".aprobar-block").show(); + + if(edo == 2 && parseInt($("#modal_aprobar .rep-aula").data("aula")) == 1){//tipo aula 1 (salon normal) - ver + $("#salon-ver").show(); + $("#salon-editar").hide(); + }else if(edo == 3 && parseInt($("#modal_aprobar .rep-aula").data("aula")) != 1){//aprobar (con salón especial) $("#salon-ver").show(); $("#salon-editar").hide(); }else{ - $("#modalLabel").text("Aprobar reposición"); - $(".aprobar-block").show(); - if(edo == 3){//aprobar (con salón) - $("#salon-ver").hide(); - $("#salon-editar").show(); - - } + $("#salon-ver").hide(); + $("#salon-editar").show(); } } diff --git a/reposiciones_crear.php b/reposiciones_crear.php index 1945ed0..708666b 100644 --- a/reposiciones_crear.php +++ b/reposiciones_crear.php @@ -24,7 +24,6 @@ if ($user->acceso === null && !$user->admin){ exit(); } - //if (!$user->admin && in_array($user->acceso, ['n'])) //die(header('Location: main.php?error=1')); //$user->print_to_log('Reposiciones'); @@ -34,51 +33,59 @@ $write = true; // $en_fecha = $db->querySingle("SELECT ESTA_EN_PERIODO(NOW()::DATE, :periodo_id)", [':periodo_id' => $user->periodo_id])['esta_en_periodo']; -if($user->jefe_carrera){ +//if($user->jefe_carrera){ - $prof_rs = $db->query('SELECT DISTINCT * FROM fs_profesores(null, null, :fac) ORDER BY PROFESOR_NOMBRE', [':fac' => $user->facultad["facultad_id"]]); -} + //$prof_rs = $db->query('SELECT DISTINCT * FROM fs_profesores(null, null, :fac) ORDER BY PROFESOR_NOMBRE', [':fac' => $user->facultad["facultad_id"]]); + $prof_rs = $db->query('SELECT DISTINCT PROFESOR.* FROM PUESTO_USUARIO + JOIN PUESTO_MATERIA USING (PUESTO_ID) + JOIN HORARIO_VIEW USING (MATERIA_ID) + JOIN HORARIO_PROFESOR USING (HORARIO_ID) + JOIN PROFESOR USING (PROFESOR_ID) + WHERE USUARIO_ID = :usr', [':usr' => $user->user["id"]]); +//} //Duraciones $duracion_rs = $db->query("select * from duracion order by duracion_interval"); -//Periodo -$periodo_rs = $db->querySingle('SELECT periodo_fecha_inicio, periodo_fecha_fin FROM periodo WHERE periodo_id = :periodo_id', [':periodo_id' => $user->periodo_id]); -$periodo_fin = $periodo_rs["periodo_fecha_fin"]; -if(strtotime($periodo_rs["periodo_fecha_inicio"])>strtotime(date("Y-m-d")) ) - $fecha_man = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_inicio"])); -else{ - $dias = 3; - if( intval(date("w")) >=3 && intval(date("w"))<=5 )//Mie a Vie - $dias+=3; - else if( intval(date("w")) ==6 )//Sab - $dias+=2; - else if( intval(date("w")) ==0 )//Do - $dias+=1; - - $fecha_man = date("d/m/Y", strtotime("+".$dias." day")); +if(!is_null($user->periodo_id)){ + //Periodo + $periodo_rs = $db->querySingle('SELECT periodo_fecha_inicio, periodo_fecha_fin FROM periodo WHERE periodo_id = :periodo_id', [':periodo_id' => $user->periodo_id]); + $periodo_fin = $periodo_rs["periodo_fecha_fin"]; + if(strtotime($periodo_rs["periodo_fecha_inicio"])>strtotime(date("Y-m-d")) ) + $fecha_man = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_inicio"])); + else{ + $dias = 3; + if( intval(date("w")) >=3 && intval(date("w"))<=5 )//Mie a Vie + $dias+=3; + else if( intval(date("w")) ==6 )//Sab + $dias+=2; + else if( intval(date("w")) ==0 )//Do + $dias+=1; + + $fecha_man = date("d/m/Y", strtotime("+".$dias." day")); + } + /* + // Materias + $id_prof = $user->profesor; + //$facultad_id = 28; + $materias_rs = $db->query('SELECT * FROM fs_materiasprofesor(:id)', [':id' => $id_prof]); + */ + if(isset($_POST["fecha_inicial"])) + $fecha_ini = $_POST["fecha_inicial"]; + else + $fecha_ini = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_inicio"])); + + if(isset($_POST["fecha_final"])) + $fecha_fin = $_POST["fecha_final"]; + else + $fecha_fin = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_fin"])); + + $date = DateTime::createFromFormat('d/m/Y', $fecha_ini); + $fecha_ini_db = $date->format('Y-m-d'); + + $date = DateTime::createFromFormat('d/m/Y', $fecha_fin); + $fecha_fin_db = $date->format('Y-m-d'); } -/* -// Materias -$id_prof = $user->profesor; -//$facultad_id = 28; -$materias_rs = $db->query('SELECT * FROM fs_materiasprofesor(:id)', [':id' => $id_prof]); -*/ -if(isset($_POST["fecha_inicial"])) - $fecha_ini = $_POST["fecha_inicial"]; -else - $fecha_ini = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_inicio"])); - -if(isset($_POST["fecha_final"])) - $fecha_fin = $_POST["fecha_final"]; -else - $fecha_fin = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_fin"])); - -$date = DateTime::createFromFormat('d/m/Y', $fecha_ini); -$fecha_ini_db = $date->format('Y-m-d'); - -$date = DateTime::createFromFormat('d/m/Y', $fecha_fin); -$fecha_fin_db = $date->format('Y-m-d'); ?> @@ -132,7 +139,7 @@ $fecha_fin_db = $date->format('Y-m-d');
    - + periodo_id)) { ?>
    @@ -160,8 +167,8 @@ $fecha_fin_db = $date->format('Y-m-d'); query('SELECT * FROM fs_reposiciones_solicitud(:f_ini, :f_fin, :usr ,NULL, NULL)', [':f_ini' => $fecha_ini_db, ':f_fin' => $fecha_fin_db, ':usr' => $user->user["id"]]); - + $reposiciones_rs = $db->query('SELECT * FROM fs_reposiciones_solicitud(:f_ini, :f_fin, :usr ,NULL, NULL)', [':f_ini' => $fecha_ini_db, ':f_fin' => $fecha_fin_db, ':usr' => $user->user["id"]]); + } ?>
    @@ -245,11 +252,17 @@ $fecha_fin_db = $date->format('Y-m-d');
    - + periodo_id)){ ?> +
    +

    Selecciona un periodo

    +
    +

    No tienes reposiciones disponibles que cumplan con los filtros

    - +