All
This commit is contained in:
@@ -37,7 +37,7 @@ try {
|
|||||||
WHERE (periodo_id, facultad.facultad_id) = (:periodo_id, COALESCE(:facultad_id, facultad.facultad_id))
|
WHERE (periodo_id, facultad.facultad_id) = (:periodo_id, COALESCE(:facultad_id, facultad.facultad_id))
|
||||||
),
|
),
|
||||||
fechas AS (
|
fechas AS (
|
||||||
SELECT fechas_clase(h.horario_id) as registro_fecha_ideal, h.horario_id
|
SELECT fechas_clase(h.horario_id, true) as registro_fecha_ideal, h.horario_id
|
||||||
FROM horarios h
|
FROM horarios h
|
||||||
),
|
),
|
||||||
sin_registro AS (
|
sin_registro AS (
|
||||||
@@ -74,11 +74,6 @@ try {
|
|||||||
|
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$last_query = [
|
|
||||||
'query' => $db->getLastQuery(),
|
|
||||||
];
|
|
||||||
|
|
||||||
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||||
} else {
|
} else {
|
||||||
http_response_code(405);
|
http_response_code(405);
|
||||||
@@ -89,7 +84,7 @@ try {
|
|||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'error' => $th->getMessage(),
|
'error' => $th->getMessage(),
|
||||||
'query' => $db->getLastQuery(),
|
// 'query' => $db->getLastQuery(),
|
||||||
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR);
|
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR);
|
||||||
exit;
|
exit;
|
||||||
} catch (Exception $th) {
|
} catch (Exception $th) {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ $params = array(':id' => $user->user['id'], ':per' => $_POST['id']);
|
|||||||
$user->print_to_log('Actualizando periodo from ' . $user->periodo_id . ' to ' . $_POST['id']);
|
$user->print_to_log('Actualizando periodo from ' . $user->periodo_id . ' to ' . $_POST['id']);
|
||||||
|
|
||||||
query("SELECT FU_UPDATEPERIODO(:id, :per)", $params);
|
query("SELECT FU_UPDATEPERIODO(:id, :per)", $params);
|
||||||
$user->periodo_id = $params[':per'];
|
|
||||||
|
|
||||||
$_SESSION['user'] = serialize($user);
|
$_SESSION['user'] = serialize($user);
|
||||||
header("Location: {$_POST["target"]}");
|
header("Location: {$_POST["target"]}");
|
||||||
|
|||||||
@@ -28,7 +28,11 @@ try {
|
|||||||
->get('salon_view');
|
->get('salon_view');
|
||||||
|
|
||||||
// step 3: get horarios
|
// step 3: get horarios
|
||||||
|
|
||||||
|
$fecha = "'2023-10-13':DATE";
|
||||||
|
|
||||||
$data = array_map(
|
$data = array_map(
|
||||||
|
|
||||||
fn($ruta) => array_merge(
|
fn($ruta) => array_merge(
|
||||||
[
|
[
|
||||||
'horarios' => $db
|
'horarios' => $db
|
||||||
@@ -37,9 +41,9 @@ try {
|
|||||||
->join('salon_view', 'salon_view.salon_id = horario_view.salon_id')
|
->join('salon_view', 'salon_view.salon_id = horario_view.salon_id')
|
||||||
->join('horario_profesor', 'horario_profesor.horario_id = horario_view.horario_id')
|
->join('horario_profesor', 'horario_profesor.horario_id = horario_view.horario_id')
|
||||||
->join('profesor', 'profesor.profesor_id = horario_profesor.profesor_id')
|
->join('profesor', 'profesor.profesor_id = horario_profesor.profesor_id')
|
||||||
->join('registro', '(registro.profesor_id, registro.horario_id, registro.registro_fecha_ideal) = (profesor.profesor_id, horario_view.horario_id, CURRENT_DATE)', 'LEFT')
|
->join('registro', "(registro.profesor_id, registro.horario_id, registro.registro_fecha_ideal) = (profesor.profesor_id, horario_view.horario_id, $fecha)", 'LEFT')
|
||||||
->where('CURRENT_DATE BETWEEN periodo.periodo_fecha_inicio AND periodo.periodo_fecha_fin')
|
->where("$fecha BETWEEN periodo.periodo_fecha_inicio AND periodo.periodo_fecha_fin")
|
||||||
->where('horario_dia = EXTRACT(DOW FROM CURRENT_DATE)')
|
->where("horario_dia = EXTRACT(DOW FROM $fecha)")
|
||||||
->where('bloque_horario.id', $_GET['bloque_horario_id'])
|
->where('bloque_horario.id', $_GET['bloque_horario_id'])
|
||||||
->where('id_espacio_padre', $ruta['id_espacio_sgu'])
|
->where('id_espacio_padre', $ruta['id_espacio_sgu'])
|
||||||
->get('horario_view', null, '*, horario_view.horario_id, profesor.profesor_id'),
|
->get('horario_view', null, '*, horario_view.horario_id, profesor.profesor_id'),
|
||||||
@@ -61,7 +65,7 @@ try {
|
|||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'error' => $th->getMessage(),
|
'error' => $th->getMessage(),
|
||||||
'query' => $db->getLastQuery(),
|
// 'query' => $db->getLastQuery(),
|
||||||
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||||
exit;
|
exit;
|
||||||
} catch (Exception $th) {
|
} catch (Exception $th) {
|
||||||
|
|||||||
243
auditoria.php
243
auditoria.php
@@ -242,114 +242,114 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- refresh -->
|
<!-- refresh -->
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-hover table-striped table-bordered table-sm">
|
<table class="table table-hover table-striped table-bordered table-sm">
|
||||||
<thead class="thead-dark">
|
<thead class="thead-dark">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col"
|
<th scope="col"
|
||||||
class="text-center align-middle px-2 d-flex align-items-center justify-content-center">
|
class="text-center align-middle px-2 d-flex align-items-center justify-content-center">
|
||||||
<button @click="store.registros.invertir" class="btn btn-light btn-sm text-primary mr-3"
|
<button @click="store.registros.invertir" class="btn btn-light btn-sm text-primary mr-3"
|
||||||
v-if="store.registros.relevant.length > 1">
|
v-if="store.registros.relevant.length > 1">
|
||||||
<i class="ing-cambiar ing-rotate-90"></i>
|
<i class="ing-cambiar ing-rotate-90"></i>
|
||||||
</button>
|
</button>
|
||||||
<span style="white-space: nowrap;">Fecha</span>
|
<span style="white-space: nowrap;">Fecha</span>
|
||||||
</th>
|
</th>
|
||||||
|
|
||||||
<th scope="col" class="text-center align-middle px-2" width="10%">Salón</th>
|
<th scope="col" class="text-center align-middle px-2" width="10%">Salón</th>
|
||||||
<th scope="col" class="text-center align-middle px-2">Profesor</th>
|
<th scope="col" class="text-center align-middle px-2">Profesor</th>
|
||||||
|
|
||||||
<th scope="col" class="text-center align-middle px-2" width="7%">Horario</th>
|
<th scope="col" class="text-center align-middle px-2" width="7%">Horario</th>
|
||||||
<th scope="col" class="text-center align-middle px-2">Registro</th>
|
<th scope="col" class="text-center align-middle px-2">Registro</th>
|
||||||
<th scope="col" class="text-center align-middle px-2">Supervisor</th>
|
<th scope="col" class="text-center align-middle px-2">Supervisor</th>
|
||||||
<? if ($user->acceso == 'w') { ?>
|
<? if ($user->acceso == 'w') { ?>
|
||||||
<th scope="col" class="text-center align-middle px-2" width="10%">Justificar</th>
|
<th scope="col" class="text-center align-middle px-2" width="10%">Justificar</th>
|
||||||
<? } ?>
|
<? } ?>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-if="store.registros.relevant.length == 0">
|
<tr v-if="store.registros.relevant.length == 0">
|
||||||
<td colspan="7" class="text-center">No hay clases en este horario</td>
|
<td colspan="7" class="text-center">No hay clases en este horario</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-for="registro in store.registros.relevant?.slice((store.current.page - 1) * store.current.perPage, store.current.page * store.current.perPage)"
|
<tr v-for="registro in store.registros.relevant?.slice((store.current.page - 1) * store.current.perPage, store.current.page * store.current.perPage)"
|
||||||
:key="`${registro.registro_id}-${registro.registro_fecha_ideal}-${registro.horario_id}-${registro.profesor_id}-${registro.salon_id}`">
|
:key="`${registro.registro_id}-${registro.registro_fecha_ideal}-${registro.horario_id}-${registro.profesor_id}-${registro.salon_id}`">
|
||||||
<td class="text-center align-middle px-2">{{ registro.registro_fecha_ideal }}
|
<td class="text-center align-middle px-2">{{ registro.registro_fecha_ideal }}
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center align-middle px-2">{{ registro.salon }}</td>
|
<td class="text-center align-middle px-2">{{ registro.salon }}</td>
|
||||||
<td class="align-middle px-2">
|
<td class="align-middle px-2">
|
||||||
<strong>{{ registro.profesor_clave }}</strong>
|
<strong>{{ registro.profesor_clave }}</strong>
|
||||||
{{ registro.profesor_nombre }}
|
{{ registro.profesor_nombre }}
|
||||||
<button type="button" class="ml-3 btn btn-sm btn-outline-primary"
|
<button type="button" class="ml-3 btn btn-sm btn-outline-primary"
|
||||||
@click="store.current.clase_vista = registro" data-toggle="modal"
|
@click="store.current.clase_vista = registro" data-toggle="modal"
|
||||||
data-target="#ver-detalle">
|
data-target="#ver-detalle">
|
||||||
<i class="ing-ojo"></i>
|
<i class="ing-ojo"></i>
|
||||||
Ver detalle
|
Ver detalle
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
|
||||||
<td class="text-center align-middle px-2">{{ registro.horario_hora?.slice(0,5) }} -
|
<td class="text-center align-middle px-2">{{ registro.horario_hora?.slice(0,5) }} -
|
||||||
{{registro.horario_fin?.slice(0,5) }}</td>
|
{{registro.horario_fin?.slice(0,5) }}</td>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<td class="text-center align-middle px-2">
|
<td class="text-center align-middle px-2">
|
||||||
<div v-if="registro.registro_fecha">
|
<div v-if="registro.registro_fecha">
|
||||||
<div class="col-12">
|
|
||||||
Registro <small>{{ registro.registro_fecha?.slice(11,19) }}</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
<strong>
|
|
||||||
<div class="col-12">
|
|
||||||
<span class="text-dark ing-2x"><i class="ing-cancelar"></i></span>
|
|
||||||
</div>
|
|
||||||
</strong>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
<!-- Sí checó supervisor -->
|
|
||||||
<td class="text-center align-middle px-2">
|
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="row">
|
Registro <small>{{ registro.registro_fecha?.slice(11,19) }}</small>
|
||||||
<div class="col-12">
|
</div>
|
||||||
<span class="mr-2" :class="`text-${registro.estado_color}`">
|
</div>
|
||||||
<i :class="`${registro.estado_icon} ing-2x`"></i>
|
<div v-else>
|
||||||
</span>
|
<strong>
|
||||||
<strong v-if="registro.usuario_nombre">{{ registro.usuario_nombre
|
<div class="col-12">
|
||||||
}}</strong>
|
<span class="text-dark ing-2x"><i class="ing-cancelar"></i></span>
|
||||||
</div>
|
|
||||||
<div class="col-12" v-if="registro.registro_fecha_supervisor">
|
|
||||||
Hora
|
|
||||||
<small>{{ registro.registro_fecha_supervisor?.slice(11,19) }}</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 "
|
</strong>
|
||||||
@click="store.registros.mostrarComentario(registro.registro_id)"
|
</div>
|
||||||
v-if="registro.comentario" style="cursor: pointer;">
|
</td>
|
||||||
<strong class="badge border border-primary">Observaciones:</strong>
|
|
||||||
<small
|
<!-- Sí checó supervisor -->
|
||||||
class="text-truncate">{{registro.comentario?.slice(0,25)}}{{registro.comentario.length
|
<td class="text-center align-middle px-2">
|
||||||
> 10 ? '...' : ''}}</small>
|
<div class="col-12">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<span class="mr-2" :class="`text-${registro.estado_color}`">
|
||||||
|
<i :class="`${registro.estado_icon} ing-2x`"></i>
|
||||||
|
</span>
|
||||||
|
<strong v-if="registro.usuario_nombre">{{ registro.usuario_nombre
|
||||||
|
}}</strong>
|
||||||
|
</div>
|
||||||
|
<div class="col-12" v-if="registro.registro_fecha_supervisor">
|
||||||
|
Hora
|
||||||
|
<small>{{ registro.registro_fecha_supervisor?.slice(11,19) }}</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-12 "
|
||||||
|
@click="store.registros.mostrarComentario(registro.registro_id)"
|
||||||
|
v-if="registro.comentario" style="cursor: pointer;">
|
||||||
|
<strong class="badge border border-primary">Observaciones:</strong>
|
||||||
|
<small
|
||||||
|
class="text-truncate">{{registro.comentario?.slice(0,25)}}{{registro.comentario.length
|
||||||
|
> 10 ? '...' : ''}}</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<? if ($user->acceso == 'w') { ?>
|
||||||
|
<td class="text-center align-middle px-2">
|
||||||
|
<div class="col-auto">
|
||||||
|
<button class="btn btn-link text-center mx-2 btn-sm" data-toggle="modal"
|
||||||
|
:class="`text-${registro.registro_justificada ? 'success' : 'primary'}`"
|
||||||
|
data-target="#justificar" :class="{ 'active': registro.comentario }"
|
||||||
|
@click="set_justificar(registro.horario_id, registro.profesor_id, registro.registro_fecha_ideal)">
|
||||||
|
<i :class="`ing-${registro.registro_justificada ? 'finalistas' : 'reporte-resultados'}`"
|
||||||
|
style="font-size: 2rem;"></i>
|
||||||
|
<span class="sr-only">{{ registro.registro_justificada ? 'Justificada' :
|
||||||
|
'Justificar' }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<? if ($user->acceso == 'w') { ?>
|
<? } ?>
|
||||||
<td class="text-center align-middle px-2">
|
</tr>
|
||||||
<div class="col-auto">
|
</tbody>
|
||||||
<button class="btn btn-link text-center mx-2 btn-sm" data-toggle="modal"
|
</table>
|
||||||
:class="`text-${registro.registro_justificada ? 'success' : 'primary'}`"
|
</div>
|
||||||
data-target="#justificar" :class="{ 'active': registro.comentario }"
|
|
||||||
@click="set_justificar(registro.horario_id, registro.profesor_id, registro.registro_fecha_ideal)">
|
|
||||||
<i :class="`ing-${registro.registro_justificada ? 'finalistas' : 'reporte-resultados'}`"
|
|
||||||
style="font-size: 2rem;"></i>
|
|
||||||
<span class="sr-only">{{ registro.registro_justificada ? 'Justificada' :
|
|
||||||
'Justificar' }}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<? } ?>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- page -->
|
<!-- page -->
|
||||||
<nav v-if="store.registros.relevant.length > 0" class="mt-3 col-12">
|
<nav v-if="store.registros.relevant.length > 0" class="mt-3 col-12">
|
||||||
@@ -579,32 +579,37 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<h2 class="text-center">¿Desea justificar la asistencia?</h2>
|
<h2 class="text-center">¿Desea justificar la asistencia?</h2>
|
||||||
<br>
|
<br>
|
||||||
<div class="custom-control custom-switch">
|
<div class="row">
|
||||||
<input type="checkbox" class="custom-control-input form-control-lg my-auto"
|
<div class="col-12 text-center">
|
||||||
id="está-justificada" v-model="store.current.justificada.registro_justificada"
|
Justificar <strong v-if="store.current.justificada.estado_supervisor_id"
|
||||||
@click="store.current.justificada.justificacion = ''">
|
|
||||||
<label class="custom-control-label" for="está-justificada">Justificar
|
|
||||||
<strong v-if="store.current.justificada.estado_supervisor_id"
|
|
||||||
:class="`text-${store.current.justificada.estado_color}`"
|
:class="`text-${store.current.justificada.estado_color}`"
|
||||||
class="text-uppercase">
|
class="text-uppercase">
|
||||||
{{store.current.justificada.nombre.toUpperCase()}}
|
{{store.current.justificada.nombre.toUpperCase()}}</strong> del día <span
|
||||||
</strong>
|
class="text-muted">{{store.current.justificada.registro_fecha_ideal}}</span> a
|
||||||
del día
|
las <span
|
||||||
<span class="text-muted">{{store.current.justificada.registro_fecha_ideal}}</span>
|
|
||||||
a las
|
|
||||||
<span
|
|
||||||
class="text-muted">{{store.current.justificada.horario_hora?.slice(0,5)}}</span>
|
class="text-muted">{{store.current.justificada.horario_hora?.slice(0,5)}}</span>
|
||||||
para el profesor
|
para el profesor <span
|
||||||
<span class="text-muted">{{store.current.justificada.profesor_nombre}}</span>
|
class="text-muted">{{store.current.justificada.profesor_nombre}}</span>
|
||||||
</label>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr v-if="store.current.justificada.registro_justificada">
|
<div class="row mt-3">
|
||||||
<div class="input-group" v-if="store.current.justificada.registro_justificada">
|
<div class="col-12">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" value="" id="observaciones" v-model="store.current.observaciones">
|
||||||
|
<label class="form-check-label" for="observaciones">
|
||||||
|
¿Deseas añadir observaciones?
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr v-if="store.current.observaciones">
|
||||||
|
<div class="input-group" v-if="store.current.observaciones">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<span class="input-group-text text-white bg-primary">Observación</span>
|
<span class="input-group-text text-white bg-primary">Observaciones</span>
|
||||||
</div>
|
</div>
|
||||||
<textarea class="form-control" aria-label="Observación"
|
<textarea class="form-control" aria-label="Observación"
|
||||||
placeholder="Puedes justificar sin observación" rows="2"
|
placeholder="Puedes justificar sin observaciones" rows="2"
|
||||||
v-model="store.current.justificada.justificacion"></textarea>
|
v-model="store.current.justificada.justificacion"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -617,7 +622,7 @@
|
|||||||
Cancelar
|
Cancelar
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="btn btn-primary" data-dismiss="modal" @click="store.justificar">
|
<button type="button" class="btn btn-primary" data-dismiss="modal" @click="store.justificar">
|
||||||
Aceptar
|
Justificar
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,8 +18,38 @@ require_once($ruta ?? '') . "vendor/autoload.php";
|
|||||||
|
|
||||||
class Login
|
class Login
|
||||||
{
|
{
|
||||||
public ?string $acceso;
|
private function es_usuario(): bool
|
||||||
public function __construct(public array $user, public array $facultad, public array $rol, public bool $admin, public ?int $periodo_id, public bool $supervisor, public bool $jefe_carrera, public bool $profesor)
|
{
|
||||||
|
global $db;
|
||||||
|
return $db->where('usuario_clave', $this->user['clave'])->has("usuario");
|
||||||
|
}
|
||||||
|
public function __get($property)
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
return match ($property) {
|
||||||
|
'acceso' => $this->access(),
|
||||||
|
'profesor' => $db->where('profesor_clave', preg_replace('/\D/','', $this->user['clave']))->getOne("profesor")['profesor_id'] ?? null,
|
||||||
|
'jefe_de_carrera' => $db->where('usuario_id', $this->user["id"])->has('usuario_carrera'),
|
||||||
|
'periodo_id' => $db->where('usuario_id', $this->user["id"])->getOne('usuario')["periodo_id"],
|
||||||
|
'admin' => $this->es_usuario() and $db->where('usuario_id', $this->user["id"])->getOne('usuario')["usuario_admin"],
|
||||||
|
'facultad' => $this->es_usuario()
|
||||||
|
? $db
|
||||||
|
->where('usuario_id', $this->user["id"])
|
||||||
|
->join('facultad', 'facultad.facultad_id = usuario.facultad_id', 'LEFT')
|
||||||
|
->getOne('usuario', 'facultad.facultad_nombre as facultad, facultad.facultad_id')
|
||||||
|
: array ('facultad' => null, 'facultad_id' => null),
|
||||||
|
'rol' => $this->es_usuario()
|
||||||
|
? $db
|
||||||
|
->join('rol', 'rol.rol_id = usuario.rol_id')
|
||||||
|
->where('usuario_id', $this->user["id"])
|
||||||
|
->getOne('usuario', 'rol.rol_titulo as rol, rol.rol_id')
|
||||||
|
: $db
|
||||||
|
->where('rol_titulo', 'docente', 'ILIKE')
|
||||||
|
->getOne('rol', 'rol.rol_titulo as rol, rol.rol_id'),
|
||||||
|
default => throw new Exception("Propiedad no definida"),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public function __construct(public array $user)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public function print_to_log(string $desc, array $old = null, array $new = null): void
|
public function print_to_log(string $desc, array $old = null, array $new = null): void
|
||||||
@@ -31,40 +61,17 @@ class Login
|
|||||||
$desc .= " |#| NEW:" . json_encode($new);
|
$desc .= " |#| NEW:" . json_encode($new);
|
||||||
$log->appendLog($this->user["id"], $this->user["nombre"], $desc);
|
$log->appendLog($this->user["id"], $this->user["nombre"], $desc);
|
||||||
}
|
}
|
||||||
public function access(string $pagina = null): void
|
public function access(string $pagina = null): string|null
|
||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
$user = $db
|
if ($this->admin)
|
||||||
->join('rol', 'rol.rol_id = usuario.rol_id')
|
return "w";
|
||||||
->join('facultad', 'facultad.facultad_id = usuario.facultad_id', 'LEFT')
|
|
||||||
->where('usuario_id', $this->user["id"])
|
|
||||||
->getOne('usuario');
|
|
||||||
|
|
||||||
$this->admin = $user["usuario_admin"];
|
|
||||||
|
|
||||||
$this->rol = array(
|
|
||||||
'id' => $user["rol_id"],
|
|
||||||
'rol' => $user["rol_titulo"]
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->facultad = array(
|
|
||||||
'facultad_id' => $user["facultad_id"],
|
|
||||||
'facultad' => $user["facultad_nombre"],
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($this->admin) {
|
|
||||||
$this->acceso = "w";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
# print_r( $access );
|
|
||||||
$acceso = $db
|
$acceso = $db
|
||||||
->where('id', $this->user["id"])
|
->where('id', $this->user["id"])
|
||||||
->where('pagina_ruta', $pagina ?? substr(basename($_SERVER['PHP_SELF']), 0, -4))
|
->where('pagina_ruta', $pagina ?? substr(basename($_SERVER['PHP_SELF']), 0, -4))
|
||||||
->getOne('permiso_view');
|
->getOne('permiso_view');
|
||||||
|
|
||||||
$this->acceso = isset($acceso["tipo"]) ? $acceso["tipo"] : null;
|
return isset($acceso["tipo"]) ? $acceso["tipo"] : null;
|
||||||
|
|
||||||
}
|
}
|
||||||
private static function validaUsuario($user, $pass): bool
|
private static function validaUsuario($user, $pass): bool
|
||||||
{
|
{
|
||||||
@@ -84,69 +91,26 @@ class Login
|
|||||||
}
|
}
|
||||||
public static function validUser(string $user, string $pass): Login|array
|
public static function validUser(string $user, string $pass): Login|array
|
||||||
{
|
{
|
||||||
if (Login::validaUsuario($user, $pass) === false) {
|
|
||||||
return [
|
|
||||||
'error' => true,
|
|
||||||
'msg' => 'Error al autenticar usuario'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
|
if (!Login::validaUsuario($user, $pass))
|
||||||
|
return ['error' => true, 'msg' => 'Error al autenticar usuario'];
|
||||||
|
|
||||||
if ($db->has("FS_VALIDACLAVEULSA('$user')")) {
|
if ($db->has("FS_VALIDACLAVEULSA('$user')")) {
|
||||||
#die (Login::validaUsuario($user, $pass));
|
$fs = $db->querySingle('SELECT * FROM FS_VALIDACLAVEULSA(?)', [$user]);
|
||||||
$fs_validaclaveulsa = $db->querySingle(
|
return new Login(user: ['id' => $fs["id"], 'nombre' => $fs["nombre"], 'clave' => $fs["clave"]]);
|
||||||
'SELECT * FROM FS_VALIDACLAVEULSA(?)',
|
}
|
||||||
[$user]
|
|
||||||
);
|
|
||||||
|
|
||||||
$user = array(
|
$profesorClave = preg_replace('/\D/', '', $user);
|
||||||
'id' => $fs_validaclaveulsa["id"],
|
if ($db->where('profesor_clave', $profesorClave)->has("profesor")) {
|
||||||
'nombre' => $fs_validaclaveulsa["nombre"],
|
$profesor = $db->where('profesor_clave', $profesorClave)->getOne("profesor");
|
||||||
'clave' => $db->where('usuario_id', $fs_validaclaveulsa["id"])->getOne("usuario")["usuario_clave"]
|
return new Login(user: ['id' => $profesor["profesor_id"], 'nombre' => $profesor["profesor_nombre"], 'clave' => $profesor["profesor_clave"]]);
|
||||||
);
|
}
|
||||||
$facultad = array(
|
|
||||||
'facultad_id' => $fs_validaclaveulsa["facultad_id"],
|
|
||||||
'facultad' => $fs_validaclaveulsa["facultad"],
|
|
||||||
);
|
|
||||||
$rol = array(
|
|
||||||
'id' => $fs_validaclaveulsa["rol_id"],
|
|
||||||
'rol' => $fs_validaclaveulsa["rol"]
|
|
||||||
);
|
|
||||||
$supervisor = $db
|
|
||||||
->join('rol', 'rol.rol_id = usuario.rol_id')
|
|
||||||
->where('usuario_id', $user["id"])
|
|
||||||
->where('rol.rol_titulo', 'Supervisor')
|
|
||||||
->has('usuario');
|
|
||||||
$jefe_carrera = $db->where('usuario_id', $user["id"])->has('usuario_carrera');
|
|
||||||
|
|
||||||
$admin = $fs_validaclaveulsa["is_admin"];
|
return ['error' => true, 'msg' => 'Usuario no encontrado'];
|
||||||
$periodo = $fs_validaclaveulsa["periodo_id"];
|
|
||||||
|
|
||||||
return new Login($user, $facultad, $rol, $admin, $periodo, $supervisor, $jefe_carrera, false);
|
|
||||||
} else if ($db->where('profesor_clave', preg_replace('/^do0*/', '', $user), 'ilike')->has("profesor")) {
|
|
||||||
$profesor = $db->where('profesor_clave', preg_replace('/^do0*/', '', $user), 'ilike')->getOne("profesor");
|
|
||||||
$user = array(
|
|
||||||
'id' => $profesor["profesor_clave"],
|
|
||||||
'nombre' => $profesor["profesor_nombre"],
|
|
||||||
);
|
|
||||||
$facultad = array(
|
|
||||||
'facultad_id' => null,
|
|
||||||
'facultad' => null,
|
|
||||||
);
|
|
||||||
$rol = array(
|
|
||||||
'id' => null,
|
|
||||||
'rol' => 'Docente'
|
|
||||||
);
|
|
||||||
|
|
||||||
// CREATE A COOKIE FOR THE REST OF THE day for example: 23:00 then duration will be 1 hour
|
|
||||||
setcookie("profesor", $user["id"], strtotime('today midnight') + 86400, "/");
|
|
||||||
return new Login($user, $facultad, $rol, admin: false, periodo_id: null, supervisor: false, jefe_carrera: false, profesor: true);
|
|
||||||
} else
|
|
||||||
return [
|
|
||||||
'error' => true,
|
|
||||||
'msg' => 'Usuario no encontrado'
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function log_out(): void
|
public static function log_out(): void
|
||||||
{
|
{
|
||||||
session_start();
|
session_start();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require_once 'class/c_login.php';
|
|||||||
$error = isset($_SESSION["error"]);
|
$error = isset($_SESSION["error"]);
|
||||||
unset($_SESSION["error"]);
|
unset($_SESSION["error"]);
|
||||||
if ($error) $errorDesc = "El usuario y/o contraseña son incorrectos.";
|
if ($error) $errorDesc = "El usuario y/o contraseña son incorrectos.";
|
||||||
|
// session_destroy();
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="es" prefix="og: http://ogp.me/ns#">
|
<html lang="es" prefix="og: http://ogp.me/ns#">
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const store = reactive({
|
|||||||
modal_state: "Cargando datos...",
|
modal_state: "Cargando datos...",
|
||||||
justificada: null,
|
justificada: null,
|
||||||
fechas_clicked: false,
|
fechas_clicked: false,
|
||||||
|
observaciones: false,
|
||||||
},
|
},
|
||||||
facultades: {
|
facultades: {
|
||||||
data: [],
|
data: [],
|
||||||
@@ -127,6 +128,7 @@ const store = reactive({
|
|||||||
async justificar() {
|
async justificar() {
|
||||||
if (!store.current.justificada)
|
if (!store.current.justificada)
|
||||||
return;
|
return;
|
||||||
|
store.current.justificada.registro_justificada = true;
|
||||||
let data;
|
let data;
|
||||||
try {
|
try {
|
||||||
const res = await fetch('action/action_justificar.php', {
|
const res = await fetch('action/action_justificar.php', {
|
||||||
@@ -276,6 +278,7 @@ createApp({
|
|||||||
set_justificar(horario_id, profesor_id, registro_fecha_ideal) {
|
set_justificar(horario_id, profesor_id, registro_fecha_ideal) {
|
||||||
store.current.justificada = store.registros.relevant.find((registro) => registro.horario_id === horario_id && registro.profesor_id === profesor_id && registro.registro_fecha_ideal === registro_fecha_ideal);
|
store.current.justificada = store.registros.relevant.find((registro) => registro.horario_id === horario_id && registro.profesor_id === profesor_id && registro.registro_fecha_ideal === registro_fecha_ideal);
|
||||||
store.current.clone_justificada = JSON.parse(JSON.stringify(store.current.justificada));
|
store.current.clone_justificada = JSON.parse(JSON.stringify(store.current.justificada));
|
||||||
|
store.current.observaciones = false;
|
||||||
},
|
},
|
||||||
cancelar_justificacion() {
|
cancelar_justificacion() {
|
||||||
Object.assign(store.current.justificada, store.current.clone_justificada);
|
Object.assign(store.current.justificada, store.current.clone_justificada);
|
||||||
|
|||||||
@@ -6,10 +6,15 @@ if (!isset($_SESSION['user'])){
|
|||||||
}
|
}
|
||||||
|
|
||||||
$user = unserialize($_SESSION['user']);
|
$user = unserialize($_SESSION['user']);
|
||||||
|
print_r($user);
|
||||||
|
print_r($user->profesor);
|
||||||
|
print_r($user->acceso);//null sin permisos, w o r
|
||||||
|
//profesor, admin, rol, facultad
|
||||||
if (!$user->profesor && !$user->admin){
|
if (!$user->profesor && !$user->admin){
|
||||||
die(header('Location: index.php'));
|
die(header('Location: index.php'));
|
||||||
}
|
}
|
||||||
$user->access();
|
|
||||||
|
|
||||||
//if (!$user->admin && in_array($user->acceso, ['n']))
|
//if (!$user->admin && in_array($user->acceso, ['n']))
|
||||||
//die(header('Location: main.php?error=1'));
|
//die(header('Location: main.php?error=1'));
|
||||||
$user->print_to_log('Reposiciones');
|
$user->print_to_log('Reposiciones');
|
||||||
@@ -42,8 +47,7 @@ else{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Materias
|
// Materias
|
||||||
//$id_prof = $user->user["id"];
|
$id_prof = $user->user["id"];
|
||||||
$id_prof = 2142;
|
|
||||||
//$facultad_id = 28;
|
//$facultad_id = 28;
|
||||||
$materias_rs = $db->query('SELECT * FROM fs_materiasprofesor(:id)', [':id' => $id_prof]);
|
$materias_rs = $db->query('SELECT * FROM fs_materiasprofesor(:id)', [':id' => $id_prof]);
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
<?
|
<?
|
||||||
$redirect = $_SERVER['PHP_SELF'];
|
$redirect = $_SERVER['PHP_SELF'];
|
||||||
include "import/html_header.php";
|
include "import/html_header.php";
|
||||||
// 200.0.0.1/checador_otros/admin_checdor/[this_page].php => ruta = [this_page].php
|
|
||||||
global $user;
|
global $user;
|
||||||
html_header(
|
html_header(
|
||||||
"Registro de asistencia - Vicerrectoría Académica",
|
"Registro de asistencia - Vicerrectoría Académica",
|
||||||
|
|||||||
@@ -85,8 +85,9 @@ const store = reactive({
|
|||||||
maxPages: 10,
|
maxPages: 10,
|
||||||
perPage: 10,
|
perPage: 10,
|
||||||
modal_state: "Cargando datos...",
|
modal_state: "Cargando datos...",
|
||||||
justificada: null,
|
justificada: null as Registro | null,
|
||||||
fechas_clicked: false,
|
fechas_clicked: false,
|
||||||
|
observaciones: false,
|
||||||
},
|
},
|
||||||
facultades: {
|
facultades: {
|
||||||
data: [] as Facultad[],
|
data: [] as Facultad[],
|
||||||
@@ -205,7 +206,14 @@ const store = reactive({
|
|||||||
},
|
},
|
||||||
async justificar() {
|
async justificar() {
|
||||||
if (!store.current.justificada) return;
|
if (!store.current.justificada) return;
|
||||||
let data;
|
store.current.justificada.registro_justificada = true
|
||||||
|
let data: {
|
||||||
|
justificador_nombre: string;
|
||||||
|
justificador_clave: string;
|
||||||
|
justificador_facultad: string;
|
||||||
|
justificador_rol: string;
|
||||||
|
registro_fecha_justificacion: Date;
|
||||||
|
};
|
||||||
try {
|
try {
|
||||||
const res = await fetch('action/action_justificar.php', {
|
const res = await fetch('action/action_justificar.php', {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
@@ -357,6 +365,7 @@ createApp({
|
|||||||
set_justificar(horario_id: Number, profesor_id: Number, registro_fecha_ideal: Date) {
|
set_justificar(horario_id: Number, profesor_id: Number, registro_fecha_ideal: Date) {
|
||||||
store.current.justificada = store.registros.relevant.find((registro: Registro) => registro.horario_id === horario_id && registro.profesor_id === profesor_id && registro.registro_fecha_ideal === registro_fecha_ideal)
|
store.current.justificada = store.registros.relevant.find((registro: Registro) => registro.horario_id === horario_id && registro.profesor_id === profesor_id && registro.registro_fecha_ideal === registro_fecha_ideal)
|
||||||
store.current.clone_justificada = JSON.parse(JSON.stringify(store.current.justificada))
|
store.current.clone_justificada = JSON.parse(JSON.stringify(store.current.justificada))
|
||||||
|
store.current.observaciones = false
|
||||||
},
|
},
|
||||||
cancelar_justificacion() {
|
cancelar_justificacion() {
|
||||||
Object.assign(store.current.justificada, store.current.clone_justificada)
|
Object.assign(store.current.justificada, store.current.clone_justificada)
|
||||||
|
|||||||
Reference in New Issue
Block a user