diff --git a/action/puesto.php b/action/puesto.php new file mode 100644 index 0000000..5e137f6 --- /dev/null +++ b/action/puesto.php @@ -0,0 +1,77 @@ + '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() + ]); +} \ No newline at end of file diff --git a/action/reposicion_select.php b/action/reposicion_select.php index a8d4193..42e8f2d 100644 --- a/action/reposicion_select.php +++ b/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."; diff --git a/js/auditoría.js b/js/auditoría.js index f00bfc8..191039c 100644 --- a/js/auditoría.js +++ b/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'); diff --git a/reposiciones_autorizar.php b/reposiciones_autorizar.php index b51efbd..81cd3f3 100644 --- a/reposiciones_autorizar.php +++ b/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!= ""){ } ?> + 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'); diff --git a/reposiciones_crear.php b/reposiciones_crear.php index 5e8d99c..1945ed0 100644 --- a/reposiciones_crear.php +++ b/reposiciones_crear.php @@ -570,6 +570,7 @@ $fecha_fin_db = $date->format('Y-m-d'); + = 0) ) return false; return store.profesor_selected.es_reposicion diff --git a/ts/auditoría.ts b/ts/auditoría.ts index 7ca51ee..ee2b5fc 100644 --- a/ts/auditoría.ts +++ b/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'); }