This commit is contained in:
2023-09-26 18:41:50 +00:00
parent 0a89692029
commit a2fa9058d5
7 changed files with 100 additions and 43 deletions

77
action/puesto.php Normal file
View File

@@ -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()
]);
}

View File

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

View File

@@ -291,23 +291,7 @@ createApp({
Object.assign(store.current.justificada, store.current.clone_justificada); Object.assign(store.current.justificada, store.current.clone_justificada);
delete store.current.clone_justificada; delete store.current.clone_justificada;
}, },
get profesores() { 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));
},
async mounted() { async mounted() {
$('div.modal#cargando').modal('show'); $('div.modal#cargando').modal('show');
// await store.registros.fetch() // await store.registros.fetch()
@@ -315,6 +299,7 @@ createApp({
await store.estados.fetch(); await store.estados.fetch();
await store.bloques_horario.fetch(); await store.bloques_horario.fetch();
await store.filters.switchFechas(); await store.filters.switchFechas();
this.profesores = await (await fetch('action/action_profesor.php')).json();
$('div.modal#cargando').modal('hide'); $('div.modal#cargando').modal('hide');
} }
}).mount('#app'); }).mount('#app');

View File

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

View File

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

View File

@@ -787,7 +787,7 @@
}, },
get clase_vista() { 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 false;
return store.profesor_selected.es_reposicion return store.profesor_selected.es_reposicion

View File

@@ -377,26 +377,7 @@ createApp({
Object.assign(store.current.justificada, store.current.clone_justificada) Object.assign(store.current.justificada, store.current.clone_justificada)
delete store.current.clone_justificada delete store.current.clone_justificada
}, },
get profesores() { profesores: [] as Profesor[],
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)
);
},
async mounted() { async mounted() {
$('div.modal#cargando').modal('show'); $('div.modal#cargando').modal('show');
@@ -405,6 +386,7 @@ createApp({
await store.estados.fetch() await store.estados.fetch()
await store.bloques_horario.fetch() await store.bloques_horario.fetch()
await store.filters.switchFechas() await store.filters.switchFechas()
this.profesores = await (await fetch('action/action_profesor.php')).json() as Profesor[];
$('div.modal#cargando').modal('hide'); $('div.modal#cargando').modal('hide');
} }