Initial state
This commit is contained in:
43
action/action_asistencias.php
Normal file
43
action/action_asistencias.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
extract($_POST);
|
||||
|
||||
$initial_date = DateTime::createFromFormat('d/m/Y', $fecha_inicial);
|
||||
$final_date = DateTime::createFromFormat('d/m/Y', $fecha_final);
|
||||
|
||||
if ($initial_date > $final_date) {
|
||||
echo json_encode(['error' => 'La fecha inicial no puede ser mayor a la fecha final']);
|
||||
die;
|
||||
}
|
||||
// Nombre del profesor es opcional
|
||||
$params = [
|
||||
':carrera' => empty($carrera) ? null : $carrera,
|
||||
':periodo' => $periodo,
|
||||
':nombre' => empty($nombre) ? null : $nombre,
|
||||
':clave' => empty($clave) ? null : $clave,
|
||||
':initial_date' => $initial_date->format('Y-m-d'),
|
||||
':final_date' => $final_date->format('Y-m-d'),
|
||||
':facultad' => $facultad,
|
||||
];
|
||||
|
||||
$response = json_encode(
|
||||
[
|
||||
"retardo" => query("SELECT FS_HAS_RETARDO(:facultad) retardo", [
|
||||
'facultad' => $facultad
|
||||
]),
|
||||
"reporte" => queryAll(
|
||||
"SELECT * FROM fs_asistencia_reporte(:carrera, :periodo, :clave, :nombre, :facultad, :initial_date, :final_date) where total > 0",
|
||||
$params
|
||||
)
|
||||
]
|
||||
);
|
||||
$user->print_to_log("Genera reporte de asistencias", old: $params);
|
||||
echo $response;
|
||||
100
action/action_asistencias_excel.php
Normal file
100
action/action_asistencias_excel.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../vendor/autoload.php";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
$user->print_to_log('Genera excel de asistencias');
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
//crea imagen
|
||||
$drawing = new \PhpOffice\PhpSpreadsheet\Worksheet\Drawing();
|
||||
$drawing->setName('La Salle');
|
||||
$drawing->setDescription('La Salle');
|
||||
$drawing->setPath('../imagenes/logo.png'); // put your path and image here
|
||||
$drawing->setCoordinates('A1');
|
||||
$drawing->setHeight(100);
|
||||
$drawing->setOffsetX(10);
|
||||
//agrega imagen
|
||||
$drawing->setWorksheet($spreadsheet->getActiveSheet());
|
||||
|
||||
|
||||
// In POST
|
||||
/** Array
|
||||
* * nombre
|
||||
* * clave
|
||||
* * id
|
||||
* * total
|
||||
* * asistencias
|
||||
* * faltas
|
||||
* * justificaciones
|
||||
* * retardos
|
||||
*/
|
||||
|
||||
$retardo = query("SELECT COALESCE(FS_HAS_RETARDO(:facultad), FALSE) AS retardo", [':facultad' => $user->facultad['facultad_id']])['retardo'];
|
||||
extract($_POST);
|
||||
|
||||
$row = 6;
|
||||
|
||||
$sheet->setCellValue("A$row", 'Clave');
|
||||
$sheet->setCellValue("B$row", 'Profesor');
|
||||
$sheet->setCellValue("C$row", 'Asistencias');
|
||||
$sheet->setCellValue("D$row", 'Faltas');
|
||||
$sheet->setCellValue("E$row", 'Justificaciones');
|
||||
$sheet->setCellValue("F$row", 'Retardos');
|
||||
$sheet->setCellValue("G$row", 'Total');
|
||||
|
||||
// $row++;
|
||||
$col = 0;
|
||||
# die(print_r($asistencias, true));
|
||||
foreach (json_decode($asistencias, true) as $profesor) {
|
||||
$row++;
|
||||
$sheet->setCellValue("A$row", $profesor['profesor_clave']);
|
||||
$sheet->setCellValue("B$row", $profesor['profesor_nombre']);
|
||||
$sheet->setCellValue("C$row", $profesor['asistencias']);
|
||||
$sheet->setCellValue("D$row", $profesor['faltas']);
|
||||
$sheet->setCellValue("E$row", $profesor['justificaciones']);
|
||||
$sheet->setCellValue("F$row", $profesor['retardos']);
|
||||
$sheet->setCellValue("G$row", $profesor['total']);
|
||||
}
|
||||
|
||||
# Style
|
||||
$sheet->getStyle("A6:G$row")->getBorders()->getAllBorders()->setBorderStyle(\PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN);
|
||||
$sheet->getStyle("A6:G$row")->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
||||
$sheet->getStyle("A6:G$row")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
||||
$sheet->getStyle("A6:G$row")->getAlignment()->setWrapText(true);
|
||||
$sheet->getStyle("A6:G$row")->getFont()->setSize(12);
|
||||
$sheet->getStyle("A6:G$row")->getFont()->setName('Indivisa Sans');
|
||||
# Autosize columns
|
||||
foreach (range('A', 'G') as $column) {
|
||||
$sheet->getColumnDimension($column)->setAutoSize(true);
|
||||
}
|
||||
# filters in the column
|
||||
$sheet->setAutoFilter("A6:G6");
|
||||
|
||||
if (!$retardo) # hide column
|
||||
$sheet->getColumnDimension('F')->setVisible(false);
|
||||
|
||||
#$writer = new Xlsx($spreadsheet);
|
||||
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||
# $writer->save('asistencias.xlsx');
|
||||
|
||||
// download
|
||||
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
||||
header('Content-Disposition: attachment;filename="asistencias.xlsx"');
|
||||
header('Cache-Control: max-age=0');
|
||||
|
||||
// cache expires in 60 seconds (1 minute)
|
||||
header('Expires: mon 26 jul 1997 05:00:00 gmt');
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
header('Cache-Control: cache, must-revalidate');
|
||||
header('Pragma: public');
|
||||
|
||||
$writer->save('php://output');
|
||||
9
action/action_avisos_delete.php
Normal file
9
action/action_avisos_delete.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
$ruta = '../';
|
||||
require_once '../include/bd_pdo.php';
|
||||
global $pdo;
|
||||
|
||||
$sql = "SELECT fu_update_estado_aviso(false, :id)";
|
||||
$params = [':id' => $_POST['id']];
|
||||
echo json_encode(query($sql, $params, false));
|
||||
?>
|
||||
32
action/action_avisos_insert.php
Normal file
32
action/action_avisos_insert.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
$ruta = '../';
|
||||
require_once '../include/bd_pdo.php';
|
||||
global $pdo;
|
||||
|
||||
print_r($_POST);
|
||||
|
||||
$profesores = [];
|
||||
if(isset($_POST['tipo'])){
|
||||
foreach($_POST['tipo'] as $tipo){
|
||||
$profesores_carrera = query("SELECT profesor_id FROM fs_profesor_carrera(:carrera_id)", [':carrera_id' => $tipo], false);
|
||||
foreach($profesores_carrera as $profesor){
|
||||
array_push($profesores, $profesor['profesor_id']);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
foreach($_POST['usuario'] as $profesor){
|
||||
array_push($profesores, $profesor);
|
||||
}
|
||||
$sql = "SELECT fi_aviso(:fecha_inicial, :fecha_final, :texto, :facultad)";
|
||||
$params = [':fecha_inicial' => $_POST['fecha_inicial'], ':fecha_final' => $_POST['fecha_final'], ':texto' => $_POST['texto'], ':facultad' => $_POST['facultad']];
|
||||
$aviso_id = query($sql, $params, true);
|
||||
|
||||
$sql = "SELECT fi_aviso_profesor(:aviso_id, :profesor_id)";
|
||||
foreach($profesores as $profesor_id){
|
||||
$params = [':aviso_id' => $aviso_id['fi_aviso'], ':profesor_id' => $profesor_id];
|
||||
query($sql, $params, false);
|
||||
}
|
||||
header("Location: ../avisos.php");
|
||||
exit();
|
||||
?>
|
||||
52
action/action_avisos_update.php
Normal file
52
action/action_avisos_update.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
$ruta = '../';
|
||||
require_once '../include/bd_pdo.php';
|
||||
global $pdo;
|
||||
|
||||
$aviso = query("SELECT * FROM fs_aviso(:id, null, null, null, 0, null)", [':id' => $_POST['aviso_id']], true);
|
||||
if(isset($_POST['fecha_final'])){
|
||||
$fecha_fin = $_POST['fecha_final'];
|
||||
}else{
|
||||
$fecha_fin = $aviso['aviso_fecha_final'];
|
||||
}
|
||||
if(isset($_POST['texto'])){
|
||||
$texto = $_POST['texto'];
|
||||
}else{
|
||||
$texto = $aviso['aviso_texto'];
|
||||
}
|
||||
if(isset($_POST['fecha_inicial'])){
|
||||
$fecha_inicio = $_POST['fecha_inicial'];
|
||||
}else{
|
||||
$fecha_inicio = $aviso['aviso_fecha_inicial'];
|
||||
}
|
||||
|
||||
$sql = "SELECT fu_update_aviso(:id, :fecha_fin, :texto, :fecha_inicio)";
|
||||
$params = [':id' => $_POST['aviso_id'], ':fecha_fin' => $fecha_fin, ':texto' => $texto, ':fecha_inicio' => $fecha_inicio];
|
||||
query($sql, $params, true);
|
||||
|
||||
query("SELECT fd_aviso_profesor(:aviso_id)", [':aviso_id' => $_POST['aviso_id']], false);
|
||||
|
||||
$profesores = [];
|
||||
if(isset($_POST['tipo'])){
|
||||
foreach($_POST['tipo'] as $tipo){
|
||||
$profesores_carrera = query("SELECT profesor_id FROM fs_profesor_carrera(:carrera_id)", [':carrera_id' => $tipo], false);
|
||||
foreach($profesores_carrera as $profesor){
|
||||
array_push($profesores, $profesor['profesor_id']);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach($_POST['usuario'] as $profesor){
|
||||
array_push($profesores, $profesor);
|
||||
}
|
||||
$sql = "SELECT fi_aviso_profesor(:aviso_id, :profesor_id)";
|
||||
foreach($profesores as $profesor_id){
|
||||
$params = [':aviso_id' => $_POST['aviso_id'], ':profesor_id' => $profesor_id];
|
||||
query($sql, $params, false);
|
||||
}
|
||||
|
||||
header("Location: ../avisos.php");
|
||||
exit();
|
||||
?>
|
||||
24
action/action_carreras.php
Normal file
24
action/action_carreras.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
|
||||
$nivel = $db->where("id", $_POST['periodo'])->getOne("fs_periodo", "nivel_id");
|
||||
$carreras = $db
|
||||
->where("nivel", $nivel)
|
||||
->where("facultad", $_POST['facultad'])
|
||||
->get("fs_carrera", null, "id, carrera");
|
||||
|
||||
$user->print_to_log("Crea carrera", old: $_POST);
|
||||
|
||||
die(json_encode($carreras));
|
||||
19
action/action_carreras_insert.php
Normal file
19
action/action_carreras_insert.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
$sql = "SELECT fi_carrera(:nombre, :idfacultad, :idnivel, true, :estado)";
|
||||
$params = [':nombre' => mb_strtoupper($_POST['nombre']), ':idfacultad' => $_POST['facultad'], ':idnivel' => $_POST['nivel'], ':estado' => $_POST['estado']];
|
||||
|
||||
print_r($_POST);
|
||||
echo json_encode(query($sql, $params, true));
|
||||
$user->print_to_log("Crea carrera", new: $params);
|
||||
header("Location: ../carreras.php?facultad=" . $_POST['facultad']);
|
||||
exit();
|
||||
16
action/action_carreras_select.php
Normal file
16
action/action_carreras_select.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
$sql = "SELECT * FROM fs_carreras(:idfacultad, :idcarrera, null)";
|
||||
$params = [':idfacultad' => $_POST['idfacultad'], ':idcarrera' => $_POST['idcarrera']];
|
||||
$user->print_to_log("Crea carrera", old: $params);
|
||||
echo json_encode(query($sql, $params, true));
|
||||
19
action/action_carreras_update.php
Normal file
19
action/action_carreras_update.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
$old = query("SELECT * FROM FS_CARRERA WHERE ID = :id", [':id' => $_POST['id']]);
|
||||
$sql = "SELECT fu_updatecarrera(:idcarrera, :nombre, :activa, :idnivel)";
|
||||
print_r($_POST);
|
||||
$params = [':idcarrera' => $_POST['id'], ':nombre' => mb_strtoupper($_POST['nombre']), ':activa' => $_POST['estado'], ':idnivel' => $_POST['nivel']];
|
||||
query($sql, $params, true);
|
||||
$user->print_to_log("Actualiza carrera.", old: $old, new: $params);
|
||||
header("Location: ../carreras.php?facultad=" . $_POST['facultad']);
|
||||
exit();
|
||||
15
action/action_diasfestivos_borra.php
Normal file
15
action/action_diasfestivos_borra.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
#$sql = "SELECT * FROM diasfestivos WHERE diasfestivos_id = :id";
|
||||
$sql = "DELETE FROM diasfestivos WHERE diasfestivos_id = :id";
|
||||
$params = [':id' => $_POST['id']];
|
||||
echo json_encode(query($sql, $params, false));
|
||||
48
action/action_diasfestivos_insert.php
Normal file
48
action/action_diasfestivos_insert.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
print_r($_POST);
|
||||
if ($_POST['periodo'] == 0) {
|
||||
$periodo = null;
|
||||
} else {
|
||||
$periodo = $_POST['periodo'];
|
||||
}
|
||||
if (isset($_POST['rango'])) {
|
||||
$diaInicio = new DateTime(date("Y-m-d", strtotime(str_replace("/", "-", $_POST['diaFestivo']))));
|
||||
$diaFin = new DateTime(date("Y-m-d", strtotime(str_replace("/", "-", $_POST['diaFestivoFin']))));
|
||||
$cantidad = $diaFin->diff($diaInicio);
|
||||
$date = date("Y-m-d", strtotime(str_replace("/", "-", $_POST['diaFestivo'])));
|
||||
for ($dias = 0; $dias <= $cantidad->days; $dias++) {
|
||||
$sql = "SELECT fi_diasfestivos(:periodo, :dia)";
|
||||
$params = [':periodo' => $periodo, ':dia' => $date];
|
||||
query($sql, $params, false);
|
||||
$date = date("Y-m-d", strtotime($date . "+ 1 days"));
|
||||
}
|
||||
header("Location: ../días_festivos.php");
|
||||
exit();
|
||||
} else {
|
||||
$sql = "SELECT * FROM fs_diasfestivos(null, :dia)";
|
||||
$params = [':dia' => $_POST['diaFestivo']];
|
||||
$dia_general = query($sql, $params, false);
|
||||
$sql = "SELECT * FROM fs_diasfestivos(null, null, :periodo, :dia)";
|
||||
$params = [':periodo' => $periodo, ":dia" => $_POST['diaFestivo']];
|
||||
$dia = query($sql, $params, false);
|
||||
if (!$dia && !$dia_general) { //no hay repetidos
|
||||
$sql = "SELECT fi_diasfestivos(:periodo, :dia)";
|
||||
$id = query($sql, $params, false);
|
||||
header("Location: ../días_festivos.php");
|
||||
exit();
|
||||
} else {
|
||||
header("Location: ../días_festivos.php?error=1");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
19
action/action_diasfestivos_select.php
Normal file
19
action/action_diasfestivos_select.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
$params = [':id' => $_POST['id']];
|
||||
if ($_POST['periodo'] == 0) {
|
||||
$sql = "SELECT * FROM fs_diasfestivos(:id, null)";
|
||||
} else {
|
||||
$sql = "SELECT * FROM fs_diasfestivos(null, :id, null, null)";
|
||||
}
|
||||
echo json_encode(query($sql, $params, true));
|
||||
31
action/action_diasfestivos_update.php
Normal file
31
action/action_diasfestivos_update.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
if ($_POST['periodo'] == 0) {
|
||||
$periodo = null;
|
||||
} else
|
||||
$periodo = $_POST['periodo'];
|
||||
$sql = "SELECT * FROM fs_diasfestivos(null, :dia) WHERE diasfestivos_id != :id";
|
||||
$params = [':dia' => $_POST['diaFestivo'], ':id' => $_POST['id']];
|
||||
$dia_general = query($sql, $params, false);
|
||||
$sql = "SELECT * FROM fs_diasfestivos(null, null, :periodo, :dia) WHERE diasfestivos_id != :id";
|
||||
$params = [':periodo' => $periodo, ':dia' => $_POST['diaFestivo'], ':id' => $_POST['id']];
|
||||
$dia = query($sql, $params, false);
|
||||
if (!$dia && !$dia_general) { //no hay repetidos
|
||||
$sql = "SELECT fu_update_diasfestivos(:id, :dia, :periodo)";
|
||||
query($sql, $params, false);
|
||||
header("Location: ../días_festivos.php");
|
||||
exit();
|
||||
} else { //es repetido
|
||||
header("Location: ../días_festivos.php?error=1");
|
||||
exit();
|
||||
}
|
||||
11
action/action_facultad.php
Normal file
11
action/action_facultad.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
$ruta = "../";
|
||||
require '../include/bd_pdo.php';
|
||||
23
action/action_facultades_insert.php
Normal file
23
action/action_facultades_insert.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
$sql = "SELECT fi_facultad(:nombre, :activa)";
|
||||
$params = [':nombre' => mb_strtoupper($_POST['nombre']), ':activa' => $_POST['estado']];
|
||||
$fac_id = query($sql, $params, true);
|
||||
$sql = "SELECT fi_tiempo_checado(:idfacultad, :idnivel, :antes, :despues, :retardo)";
|
||||
$params = [':idfacultad' => $fac_id['fi_facultad'], ':idnivel' => 1, ':antes' => -15, ':despues' => 16, ':retardo' => 31];
|
||||
query($sql, $params, false);
|
||||
$params = [':idfacultad' => $fac_id['fi_facultad'], ':idnivel' => 2, ':antes' => -15, ':despues' => 16, ':retardo' => 31];
|
||||
query($sql, $params, false);
|
||||
print_r($fac_id);
|
||||
header("Location: ../carreras.php?facultad=" . $fac_id['fi_facultad']);
|
||||
exit();
|
||||
15
action/action_facultades_select.php
Normal file
15
action/action_facultades_select.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
$sql = "SELECT * FROM facultad WHERE facultad_id = :idFacultad";
|
||||
$params = [':idFacultad' => $_POST['id_facultad']];
|
||||
echo json_encode(query($sql, $params, false));
|
||||
17
action/action_facultades_update.php
Normal file
17
action/action_facultades_update.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
$sql = "SELECT fu_updatefacultad(:nombre, :activa, :id)";
|
||||
$params = [':nombre' => mb_strtoupper($_POST['nombre']), ':activa' => $_POST['estado'], ':id' => $_POST['id']];
|
||||
query($sql, $params, false);
|
||||
header("Location: ../facultades.php");
|
||||
exit();
|
||||
24
action/action_grupo.php
Normal file
24
action/action_grupo.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
$ruta = "../";
|
||||
require_once("../include/bd_pdo.php");
|
||||
extract($_POST);
|
||||
$params = ['per' => $periodo, 'fac' => $facultad, 'car' => $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);
|
||||
$grupos = array_map(function ($grupo) {
|
||||
return $grupo['grupo'];
|
||||
}, $grupos);
|
||||
|
||||
echo json_encode([
|
||||
'status' => 'success',
|
||||
'grupos' => $grupos
|
||||
]);
|
||||
35
action/action_horario.php
Normal file
35
action/action_horario.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$ruta = "../";
|
||||
require_once("../include/bd_pdo.php");
|
||||
|
||||
extract($_POST);
|
||||
|
||||
$dias = array("domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado");
|
||||
$horarios = $db
|
||||
->get("fs_horario($periodo, $carrera, '$grupo', true)");
|
||||
|
||||
// get each id from $horarios (might be duplicate)
|
||||
|
||||
try {
|
||||
$horarios = array_map(function ($horario) use ($dias, $db) {
|
||||
$horario['profesores'] = array_map(
|
||||
fn ($profesor) =>
|
||||
$db->where("id", $profesor)->getOne("fs_profesor"),
|
||||
explode(",", substr($horario['profesores'], 1, -1))
|
||||
);
|
||||
$horario['dia'] = $dias[$horario['dia']];
|
||||
return $horario;
|
||||
}, $horarios);
|
||||
} catch (Exception $e) {
|
||||
die(json_encode([
|
||||
"status" => "error",
|
||||
"message" => $e->getMessage(),
|
||||
]));
|
||||
}
|
||||
?>
|
||||
<?= json_encode([
|
||||
"status" => "success",
|
||||
"horario" => $horarios,
|
||||
]) ?>
|
||||
41
action/action_horario_create.php
Normal file
41
action/action_horario_create.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
|
||||
extract($_POST);
|
||||
|
||||
$params = [
|
||||
"hora" => $hora,
|
||||
"salon" => $salón,
|
||||
"facultad_id" => $facultad,
|
||||
"periodo" => $periodo,
|
||||
"grupo" => $grupo,
|
||||
"materia_id" => $materia,
|
||||
"dia" => $día,
|
||||
"duracion" => $duración,
|
||||
"profesores" => "{{$profesores}}",
|
||||
];
|
||||
|
||||
header("Content-Type: application/json");
|
||||
$user->print_to_log("Creación de horario", new: $params);
|
||||
|
||||
try {
|
||||
$db->insert("fs_horario", $params);
|
||||
} catch (Exception $e) {
|
||||
die(json_encode([
|
||||
"status" => "error",
|
||||
"message" => "No se pudo crear el horario",
|
||||
]));
|
||||
}
|
||||
die(json_encode([
|
||||
"status" => "success",
|
||||
"message" => "Horario creado correctamente",
|
||||
]));
|
||||
38
action/action_horario_delete.php
Normal file
38
action/action_horario_delete.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
extract($_POST);
|
||||
try {
|
||||
$old = $db
|
||||
->where('horario_id', $id)
|
||||
->getOne('horario');
|
||||
|
||||
$user->print_to_log("Eliminación de horario", old: $old);
|
||||
|
||||
$horario = $db
|
||||
->where('id', $id)
|
||||
->delete('fs_horario');
|
||||
} catch (Exception $e) {
|
||||
// if message contains "Integrity constraint violation"
|
||||
$message = (strpos($e->getMessage(), 'Foreign') !== false)
|
||||
? "No se puede eliminar el registro, tiene datos asociados"
|
||||
: "Error al eliminar el registro";
|
||||
|
||||
die(json_encode([
|
||||
"status" => "error",
|
||||
"message" => $message,
|
||||
"response" => $e->getMessage(),
|
||||
]));
|
||||
}
|
||||
|
||||
die(json_encode([
|
||||
"status" => "success",
|
||||
"message" => "Horario eliminado correctamente",
|
||||
]));
|
||||
51
action/action_horario_excel.php
Normal file
51
action/action_horario_excel.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
require_once "../include/func_excel.php";
|
||||
|
||||
extract($_POST);
|
||||
|
||||
# $carrera;
|
||||
# $facultad;
|
||||
|
||||
$horarios = json_decode($data, true);
|
||||
|
||||
// make sure profesores are in the database
|
||||
foreach ($horarios as $horario) {
|
||||
$params = [
|
||||
'materia' => $horario['materia'],
|
||||
'carrera' => $carrera,
|
||||
];
|
||||
$horario['materia'] = query("SELECT FI_MATERIA(:materia, :carrera) id", $params)['id'];
|
||||
|
||||
$params = [
|
||||
'clave' => $horario['clave'],
|
||||
'nombre' => $horario['nombre'],
|
||||
'correo' => $horario['correo'],
|
||||
'grado' => $horario['grado'],
|
||||
'facultad' => $facultad,
|
||||
];
|
||||
|
||||
$horario['profesor'] = query("SELECT FI_PROFESOR(:nombre, :clave, :facultad, :correo, :grado) id", $params)['id'];
|
||||
$horario = array_diff_key($horario, array_flip(['clave', 'nombre', 'correo', 'grado', '']));
|
||||
$horario['periodo'] = $periodo;
|
||||
$horario['facultad'] = $facultad;
|
||||
|
||||
try {
|
||||
query(
|
||||
"SELECT FI_HORARIO(:horario::VARCHAR, :profesor::INT, :materia::INT, :facultad::INT, :periodo::INT, :grupo::VARCHAR, :salon::VARCHAR)",
|
||||
$horario
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
die(json_encode([
|
||||
"status" => "error",
|
||||
"sql" => $e->getMessage(),
|
||||
"message" => "Error al cargar el archivo",
|
||||
]));
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?= json_encode([
|
||||
"status" => "success",
|
||||
"message" => "Horarios guardado con éxito",
|
||||
]) ?>
|
||||
4
action/action_horario_profesor.php
Normal file
4
action/action_horario_profesor.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
die(json_encode([
|
||||
'message' => 'ok',
|
||||
]));
|
||||
48
action/action_horario_update.php
Normal file
48
action/action_horario_update.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
// check if the session is started
|
||||
if (!isset($_SESSION['user']))
|
||||
die(json_encode(['error' => 'No se ha iniciado sesión']));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
$horario = array_map(fn ($value) => $_POST[$value], array_filter([
|
||||
"hora" => "hora",
|
||||
"dia" => "día",
|
||||
"salon" => "salón",
|
||||
"duracion" => "duración",
|
||||
], fn ($value) => !empty($_POST[$value])));
|
||||
|
||||
if (!empty($_POST['profesores']))
|
||||
$horario["profesores"] = "{ {$_POST['profesores']} }";
|
||||
|
||||
try {
|
||||
$id = $_POST['id'] ?? 0;
|
||||
|
||||
$old = $db
|
||||
->where("horario_id", $id)
|
||||
->getOne("horario");
|
||||
|
||||
$horario = $db
|
||||
->where("id", $id)
|
||||
->update("fs_horario", $horario);
|
||||
|
||||
$new = $db
|
||||
->orderBy("horario_id", "DESC")
|
||||
->getOne("horario");
|
||||
|
||||
$user->print_to_log("Actualización de horario", old: $old, new: $new);
|
||||
} catch (Exception $e) {
|
||||
die(json_encode([
|
||||
"status" => "error",
|
||||
"message" => $e->getMessage(),
|
||||
'POST' => $_POST,
|
||||
]));
|
||||
}
|
||||
|
||||
die(json_encode([
|
||||
"status" => "success",
|
||||
]));
|
||||
33
action/action_justificar.php
Normal file
33
action/action_justificar.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
extract($_POST);
|
||||
|
||||
/* print_r($claves);
|
||||
exit; */
|
||||
|
||||
$fecha = DateTime::createFromFormat('d/m/Y', $fecha);
|
||||
|
||||
if (isset($hora)) {
|
||||
$claves = [[
|
||||
'clave' => $clave,
|
||||
'hora' => $hora,
|
||||
'id' => $id
|
||||
]];
|
||||
}
|
||||
foreach ($claves as $horario)
|
||||
try {
|
||||
$profesor_id = $horario["clave"];
|
||||
query("SELECT fi_registrar_asistencia(:id::INT, FALSE, ARRAY[ NOW(), :fecha::DATE + :hora::TIME ]::TIMESTAMP[], :profesor_id::INT, TRUE)", [
|
||||
":fecha" => $fecha->format('Y-m-d'),
|
||||
":hora" => $horario["hora"],
|
||||
":id" => $horario["id"],
|
||||
":profesor_id" => $profesor_id
|
||||
]);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
die( json_encode(["error" => $e->getMessage()]) );
|
||||
}
|
||||
|
||||
die(json_encode(["success" => true]));
|
||||
40
action/action_login.php
Normal file
40
action/action_login.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/*
|
||||
* Valida usuario con la BD y devuelve contraseña para validar con PHP
|
||||
*
|
||||
* Recibe:
|
||||
* POST: usuario, password
|
||||
*
|
||||
* Error:
|
||||
* 0 - No se recibieron datos
|
||||
* 1 - Usuario/Contraseña incorrectos
|
||||
* 2 - Usuario no esta en BD
|
||||
* 3 - No existe usuario
|
||||
*
|
||||
* Success:
|
||||
* Redirecciona a inicio.php
|
||||
*/
|
||||
include_once("../include/nocache.php"); //continue on error
|
||||
$ruta = "../";
|
||||
require_once("../include/bd_pdo.php"); //die on error
|
||||
require_once("../class/c_login.php");
|
||||
require_once("../include/util.php");
|
||||
require_once("../include/nusoap/nusoap.php");
|
||||
|
||||
if (!isset($_POST["username"]) || !isset($_POST["passwd"]))
|
||||
die(header("Location: ../index.php?error=0"));
|
||||
|
||||
$usr = trim(filter_input(INPUT_POST, "username")); //limpia texto
|
||||
$pass = $_POST["passwd"];
|
||||
|
||||
$user = Login::validUser($usr, $pass);
|
||||
|
||||
if ($user === false) {
|
||||
$_SESSION['error'] = true;
|
||||
header("Location: ../");
|
||||
} else {
|
||||
$_SESSION['user'] = serialize($user);
|
||||
header("Location: ../main.php");
|
||||
}
|
||||
|
||||
exit;
|
||||
26
action/action_materias.php
Normal file
26
action/action_materias.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
extract($_POST);
|
||||
# print_r($_POST); exit;
|
||||
|
||||
if (!isset($_SESSION['user']))
|
||||
die(header('Location: index.php'));
|
||||
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
if (!$user->admin && ($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]
|
||||
);
|
||||
?>
|
||||
|
||||
<?= json_encode([
|
||||
'status' => 'success',
|
||||
'materias' => $materias,
|
||||
]); ?>
|
||||
8
action/action_materias_select.php
Normal file
8
action/action_materias_select.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
$sql="SELECT * FROM materia WHERE materia_id = :idMateria";
|
||||
$params = ['idMateria' => $_POST['idmateria']];
|
||||
echo json_encode(query($sql, $params, false));
|
||||
?>
|
||||
11
action/action_materias_update.php
Normal file
11
action/action_materias_update.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
|
||||
$sql = "UPDATE materia SET materia_nombre = :nombre WHERE materia_id = :id";
|
||||
$params = array(':nombre' => mb_strtoupper($_POST["nombre"]), ':id' => $_POST["id"]);
|
||||
$hecho = query($sql, $params, false);
|
||||
header("Location: ../materias.php");
|
||||
exit();
|
||||
?>
|
||||
17
action/action_new_horario.php
Normal file
17
action/action_new_horario.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<!-- fi_horario(
|
||||
p_hora character varying,
|
||||
p_materia character varying,
|
||||
p_clave character varying,
|
||||
p_nombre character varying,
|
||||
p_grado character varying,
|
||||
p_correo character varying,
|
||||
p_facultad integer,
|
||||
p_carrera integer,
|
||||
p_grupo character varying DEFAULT NULL::character varying,
|
||||
p_salon character varying DEFAULT NULL::character varying) -->
|
||||
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
|
||||
$sql = "SELECT fi_horario(:hora, :materia, :clave, :nombre, :grado, :correo, :facultad, :carrera, :grupo, :salon)";
|
||||
17
action/action_periodos_insert.php
Normal file
17
action/action_periodos_insert.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
$sql = "SELECT fi_periodo(:fecha_inicio, :fecha_fin, :estado, :nombre, :nivel, :facultad)";
|
||||
$params = [
|
||||
':fecha_inicio' => $_POST['fecha_inicial'],
|
||||
':fecha_fin' => $_POST['fecha_final'],
|
||||
':estado' => $_POST['estadoP'],
|
||||
':nombre' => mb_strtoupper($_POST['nombreP']),
|
||||
':nivel' => $_POST['nivelP'],
|
||||
':facultad' => $_POST['facultadP']
|
||||
];
|
||||
echo json_encode(query($sql, $params, true));
|
||||
header("Location: ../carreras.php?facultad=".$_POST['facultadP']);
|
||||
exit();
|
||||
?>
|
||||
8
action/action_periodos_select.php
Normal file
8
action/action_periodos_select.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
$sql = "SELECT * FROM fs_periodo WHERE facultad_id = :idfacultad AND id = :idperiodo";
|
||||
$params = [':idfacultad' => $_POST['idfacultad'], ':idperiodo' => $_POST['idperiodo']];
|
||||
echo json_encode(query($sql, $params, true));
|
||||
?>
|
||||
18
action/action_periodos_update.php
Normal file
18
action/action_periodos_update.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
print_r($_POST);
|
||||
$sql = "SELECT fu_update_periodo(:periodo_id, :fecha_inicio, :fecha_final, :estado, :nombre, :nivel)";
|
||||
$params = [
|
||||
':periodo_id' => $_POST['idP'],
|
||||
':fecha_inicio' => $_POST['fecha_inicial'],
|
||||
':fecha_final' => $_POST['fecha_final'],
|
||||
':estado' => $_POST['estadoP'],
|
||||
':nombre' => mb_strtoupper($_POST['nombreP']),
|
||||
':nivel' => $_POST['nivelP']
|
||||
];
|
||||
echo json_encode(query($sql, $params, true));
|
||||
header("Location: ../carreras.php?facultad=".$_POST['facultadP']);
|
||||
exit();
|
||||
?>
|
||||
27
action/action_periodousuario_update.php
Normal file
27
action/action_periodousuario_update.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../class/c_login.php";
|
||||
|
||||
if (!isset($_SESSION['user'])) {
|
||||
header('Location: index.php');
|
||||
exit;
|
||||
} else
|
||||
$user = unserialize($_SESSION['user']);
|
||||
|
||||
$params = array(':id' => $user->user['id'], ':per' => $_POST['id']);
|
||||
$user->print_to_log('Actualizando periodo from ' . $user->periodo . ' to ' . $_POST['id']);
|
||||
|
||||
query("SELECT FU_UPDATEPERIODO(:id, :per)", $params);
|
||||
$user->periodo = $params[':per'];
|
||||
|
||||
# if the user is admin, also update the facultad in user object
|
||||
if ($user->admin) {
|
||||
$facultad = query("SELECT FACULTAD_ID id, FACULTAD f FROM FS_PERIODO WHERE ID = :id", [':id' => $user->periodo]);
|
||||
$user->facultad = array(
|
||||
'facultad_id' => $facultad["id"],
|
||||
'facultad' => $facultad["f"],
|
||||
);
|
||||
}
|
||||
|
||||
$_SESSION['user'] = serialize($user);
|
||||
header("Location: {$_POST["target"]}");
|
||||
40
action/action_permisos_update.php
Normal file
40
action/action_permisos_update.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
if(isset($_POST['lectura']))
|
||||
$ver = $_POST['lectura'];
|
||||
if(isset($_POST['editar']))
|
||||
$editar = $_POST['editar'];
|
||||
foreach($editar as $edit){
|
||||
$edit_separado = explode("_", $edit);
|
||||
$completo[]=$edit_separado;
|
||||
}
|
||||
#echo "<br><br><br><br>";
|
||||
#print_r($ver);
|
||||
#print_r($editar);
|
||||
query("SELECT fd_permiso()", null, false);
|
||||
foreach($ver as $lectura){
|
||||
$igual=false;
|
||||
$ver_separado = explode("_", $lectura);
|
||||
#print_r($ver_separado);
|
||||
foreach($completo as $comp){
|
||||
if($ver_separado[0] == $comp[0] && $ver_separado[1] == $comp[1]){
|
||||
#echo " igual";
|
||||
$igual=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#echo "<br>";
|
||||
if(!$igual)
|
||||
$completo[]=$ver_separado;
|
||||
}
|
||||
#print_r($completo);
|
||||
foreach($completo as $actual){
|
||||
$sql = "SELECT fi_permiso(:pagina, :rol, :tipo)";
|
||||
$params = [':pagina' => $actual['0'], ':rol' => $actual['1'], ':tipo' => $actual['2']];
|
||||
query($sql, $params, false);
|
||||
}
|
||||
header("Location: ../permisos.php");
|
||||
exit();
|
||||
?>
|
||||
14
action/action_profesor.php
Normal file
14
action/action_profesor.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once("../include/bd_pdo.php");
|
||||
|
||||
extract($_GET);
|
||||
|
||||
$profesores = $db
|
||||
->where("facultad_id", $facultad ?? 0)
|
||||
->get("fs_profesor");
|
||||
|
||||
echo json_encode([
|
||||
"status" => "success",
|
||||
"profesores" => $profesores
|
||||
]);
|
||||
40
action/action_profesor_faltas.php
Normal file
40
action/action_profesor_faltas.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
|
||||
// die(print_r($_POST, true));
|
||||
|
||||
extract($_POST);
|
||||
// if hora fin is null, then subtract half an hour from hora inicio and set hora fin to hora inicio + half an hour
|
||||
$hora_fin = empty($hora_fin) ? $hora_inicio : $hora_fin;
|
||||
|
||||
$hora_inicio = date('H:i:s', strtotime($hora_inicio < '07:00' ? '07:00' : $hora_inicio) - 1800);
|
||||
$hora_fin = date('H:i:s', strtotime($hora_fin > '22:00' ? '22:00' : $hora_fin) + 1800);
|
||||
|
||||
die(json_encode(
|
||||
array_map(fn ($row) => array_merge(
|
||||
$db->where('id', $row['profesor_id'])->getOne('fs_profesor'),
|
||||
$db->where('id', $row['materia_id'])->getOne('fs_materia'),
|
||||
$row
|
||||
),
|
||||
queryAll(
|
||||
"SELECT REPORTE.*
|
||||
FROM fs_asistencia_profesorreporte(null, :periodo, null, :fecha, :fecha) AS REPORTE
|
||||
JOIN PROFESOR P ON P.PROFESOR_ID = REPORTE.PROFESOR_ID
|
||||
WHERE HORA_CHECADO IS NULL
|
||||
AND HORA BETWEEN :inicio AND :fin
|
||||
AND P.PROFESOR_CLAVE ILIKE COALESCE(:clave, P.PROFESOR_CLAVE) and UNACCENT(P.PROFESOR_NOMBRE) ILIKE UNACCENT(COALESCE(:nombre, P.PROFESOR_NOMBRE))
|
||||
AND FECHA = :fecha
|
||||
ORDER BY HORA, MATERIA",
|
||||
[
|
||||
'periodo' => $periodo,
|
||||
'fecha' => $fecha,
|
||||
'inicio' => $hora_inicio,
|
||||
'fin' => $hora_fin,
|
||||
'clave' => empty($clave) ? null : "%$clave%",
|
||||
'nombre' => empty($nombre) ? null : "%$nombre%"
|
||||
]
|
||||
))));
|
||||
|
||||
|
||||
#ECHO "$hora_inicio - $hora_fin";
|
||||
7
action/action_profesores_borra.php
Normal file
7
action/action_profesores_borra.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
$sql = "SELECT fu_estado_facultad_profesor(:idprofesor, :idfacultad, :estado)";
|
||||
$params = [':idprofesor' => $_POST['id_profesor'], ':idfacultad' => $_POST['id_facultad'], ':estado' => $_POST['estado']];
|
||||
echo json_encode(query($sql, $params, false));
|
||||
?>
|
||||
75
action/action_profesores_insert.php
Normal file
75
action/action_profesores_insert.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
$id = trim(filter_input(INPUT_POST, "id", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));
|
||||
if(isset($_POST["dlfacultad"]))
|
||||
$facultad = trim(filter_input(INPUT_POST, "dlfacultad", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));
|
||||
else
|
||||
$facultad = trim(filter_input(INPUT_POST, "mfacultad", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));
|
||||
$clave = trim(filter_input(INPUT_POST, "mclave", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));
|
||||
$grado = trim(filter_input(INPUT_POST, "grado", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));
|
||||
$nombre = trim(filter_input(INPUT_POST, "nombre", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));
|
||||
$grado = mb_strtoupper($grado);
|
||||
if(!empty($grado)){
|
||||
if(!ctype_space($grado)){
|
||||
if($grado[strlen($grado)-1] != '.')
|
||||
$grado.='.';
|
||||
}
|
||||
else{
|
||||
$grado="";
|
||||
}
|
||||
}
|
||||
$fs_profesores = query(//revisar si existe la clave del profesor
|
||||
"SELECT * FROM fs_profesor WHERE clave = :clave",
|
||||
array(":clave" => $_POST["mclave"]),
|
||||
true
|
||||
);
|
||||
if(!$fs_profesores){//hay que crearlo desde 0 (profesor) y agregarlo a su facultad(facultad_profesor)
|
||||
$profesor_id = query(
|
||||
"SELECT public.fi_profesor(
|
||||
:nombre,
|
||||
:clave,
|
||||
:facultad,
|
||||
null,
|
||||
:grado
|
||||
)",
|
||||
array(":nombre" => mb_strtoupper($nombre), ":clave" => $clave, ":facultad" => $facultad, ":grado" => $grado),
|
||||
true
|
||||
);
|
||||
header("Location: ../profesores.php");
|
||||
exit();
|
||||
}
|
||||
else{//el profesor ya existe
|
||||
$profac = query(
|
||||
"SELECT * FROM facultad_profesor WHERE facultad_id = :facultad AND profesor_id = :profesor",
|
||||
array(":facultad" => $facultad, ":profesor" => $fs_profesores["id"]),
|
||||
true
|
||||
);
|
||||
if(!$profac){//agregarlo a la facultad (facultad_profesor)
|
||||
query(
|
||||
"SELECT fi_facultad_profesor(
|
||||
:facultad,
|
||||
:profesor
|
||||
)",
|
||||
array(":facultad" => $facultad, ":profesor" => $fs_profesores["id"]),
|
||||
true
|
||||
);
|
||||
header("Location: ../profesores.php");
|
||||
exit();
|
||||
}
|
||||
else{//regresar error (ya existe este profesor en esta facultad)
|
||||
//print_r($profac);
|
||||
if(!$profac['fp_activo']){
|
||||
query(
|
||||
"SELECT fu_estado_facultad_profesor(:idprofesor, :idfacultad, :estado)",
|
||||
array(":idprofesor" => $fs_profesores["id"], ":idfacultad" => $facultad, ":estado" => true),
|
||||
true
|
||||
);
|
||||
header("Location: ../profesores.php");
|
||||
exit();
|
||||
}
|
||||
header("Location: ../profesores.php?error=1");
|
||||
#exit();
|
||||
}
|
||||
}
|
||||
?>
|
||||
10
action/action_profesores_select.php
Normal file
10
action/action_profesores_select.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
|
||||
global $pdo;
|
||||
|
||||
$sql = "SELECT * FROM profesor WHERE profesor_id = :idProfesor";
|
||||
$params = [':idProfesor' => $_POST['profesor']];
|
||||
|
||||
echo json_encode(query($sql, $params, false));
|
||||
36
action/action_profesores_update.php
Normal file
36
action/action_profesores_update.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
|
||||
$profesor = query(
|
||||
"SELECT * FROM profesor WHERE :clave = profesor_clave",
|
||||
array(":clave" => $_POST["mclave"]),
|
||||
true
|
||||
);
|
||||
if($profesor){
|
||||
if($profesor['profesor_id'] != $_POST['id']){
|
||||
echo "clave en uso";
|
||||
header("Location: ../profesores.php?error=2");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
$grado = $_POST['grado'];
|
||||
$grado = mb_strtoupper($grado);
|
||||
if(!empty($grado)){
|
||||
if(!ctype_space($grado)){
|
||||
if($grado[strlen($grado)-1] != '.')
|
||||
$grado.='.';
|
||||
}
|
||||
else{
|
||||
$grado="";
|
||||
}
|
||||
}
|
||||
print_r($_POST);
|
||||
$sql = "SELECT public.fu_updateprofesor(:id, :clave, :nombre, :grado)";
|
||||
$params = array(':id' => $_POST["id"], ':clave' => $_POST["mclave"], ':nombre' => mb_strtoupper($_POST["nombre"]), ':grado' => $grado);
|
||||
$hecho = query($sql, $params, false);
|
||||
|
||||
header("Location: ../profesores.php", true, 307);
|
||||
exit();
|
||||
?>
|
||||
50
action/action_revisar_excel.php
Normal file
50
action/action_revisar_excel.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
#display PHP errors
|
||||
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
require_once "../include/func_excel.php";
|
||||
require_once "../include/func_string.php";
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
$reader = IOFactory::createReader("Xlsx");
|
||||
$reader->setReadDataOnly(true);
|
||||
|
||||
$file = $_FILES['archivo'];
|
||||
|
||||
|
||||
$spreadsheet = $reader->load($file['tmp_name'][0]);
|
||||
|
||||
$data = [];
|
||||
|
||||
try {
|
||||
|
||||
foreach_sheet(
|
||||
$spreadsheet, // object $spreadsheet
|
||||
function (array $row_data, int $i, string $sheet) {
|
||||
global $horario, $data;
|
||||
|
||||
if (renglón_vacío($row_data)) return;
|
||||
validar_registro($row_data, $i);
|
||||
|
||||
$horario["horario"] = horario($row_data, $i, $sheet);
|
||||
|
||||
foreach (array_filter($row_data) as $key => $value)
|
||||
$horario = array_merge($horario, ($key == 'maestro') ? columna_nombre($value) : [$key => $value]);
|
||||
|
||||
$data[] = $horario;
|
||||
}
|
||||
);
|
||||
|
||||
die(json_encode([
|
||||
"status" => "success",
|
||||
"message" => "Horario revisado con éxito, se leyeron: " . count($data) . " registros",
|
||||
"data" => $data
|
||||
]));
|
||||
} catch (Exception $e) {
|
||||
die(json_encode([
|
||||
"status" => "error",
|
||||
"message" => $e->getMessage(),
|
||||
]));
|
||||
}
|
||||
11
action/action_roles_insert.php
Normal file
11
action/action_roles_insert.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
print_r($_POST);
|
||||
$sql = "INSERT INTO rol (rol_titulo) VALUES (:nombre)";
|
||||
$params = [':nombre' => mb_strtoupper($_POST['mtitulo'])];
|
||||
$hecho = query($sql, $params, true);
|
||||
header("Location: ../roles.php");
|
||||
exit();
|
||||
?>
|
||||
11
action/action_roles_select.php
Normal file
11
action/action_roles_select.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
|
||||
global $pdo;
|
||||
|
||||
$sql = "SELECT * FROM rol WHERE rol_id = :idRol";
|
||||
$params = [':idRol' => $_POST['rol']];
|
||||
|
||||
echo json_encode( query($sql, $params, true));
|
||||
?>
|
||||
11
action/action_roles_update.php
Normal file
11
action/action_roles_update.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
$sql = "UPDATE rol SET rol_titulo = :nombre WHERE rol_id = :id";
|
||||
$params = array(':nombre' => mb_strtoupper($_POST['mtitulo']), ':id' => $_POST['id']);
|
||||
print_r($_POST);
|
||||
$hecho = query($sql, $params, false);
|
||||
header("Location: ../roles.php", true, 307);
|
||||
exit();
|
||||
?>
|
||||
37
action/action_tiempos_update.php
Normal file
37
action/action_tiempos_update.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
print_r($_POST);
|
||||
|
||||
$fs_tiempo = query(
|
||||
"SELECT * FROM fs_tiempo_checado(:facultad, 1)", [':facultad' => $_POST['facultadT']], true
|
||||
);
|
||||
|
||||
if($fs_tiempo){
|
||||
$sql = "SELECT fu_update_tiempo_checado(:idfacultad, :idnivel, :antes, :despues, :retardo)";
|
||||
$params = [':idfacultad' => $_POST['facultadT'], ':idnivel' => 1, ':antes' => -1*$_POST['antesL'], ':despues' => $_POST['despuesL']+1, ':retardo' => $_POST['retardoL']+$_POST['despuesL']+1];
|
||||
}
|
||||
else{
|
||||
$sql = "SELECT fi_tiempo_checado(:idfacultad, :idnivel, :antes, :despues, :retardo)";
|
||||
$params = [':idfacultad' => $_POST['facultadT'], ':idnivel' => 1, ':antes' => -1*$_POST['antesL'], ':despues' => $_POST['despuesL']+1, ':retardo' => $_POST['retardoL']+$_POST['despuesL']+1];
|
||||
}
|
||||
query($sql, $params, false);
|
||||
|
||||
|
||||
$fs_tiempo2 = query(
|
||||
"SELECT * FROM fs_tiempo_checado(:facultad, 2)", [':facultad' => $_POST['facultadT']], true
|
||||
);
|
||||
|
||||
if($fs_tiempo2){
|
||||
$sql = "SELECT fu_update_tiempo_checado(:idfacultad, :idnivel, :antes, :despues, :retardo)";
|
||||
$params = [':idfacultad' => $_POST['facultadT'], ':idnivel' => 2, ':antes' => -1*$_POST['antesP'], ':despues' => $_POST['despuesP']+1, ':retardo' => $_POST['retardoP']+$_POST['despuesP']+1];
|
||||
}
|
||||
else{
|
||||
$sql = "SELECT fi_tiempo_checado(:idfacultad, :idnivel, :antes, :despues, :retardo)";
|
||||
$params = [':idfacultad' => $_POST['facultadT'], ':idnivel' => 2, ':antes' => -1*$_POST['antesP'], ':despues' => $_POST['despuesP']+1, ':retardo' => $_POST['retardoP']+$_POST['despuesP']+1];
|
||||
}
|
||||
query($sql, $params, false);
|
||||
|
||||
header("Location: ../carreras.php?facultad=".$_POST['facultadT']);
|
||||
exit();
|
||||
?>
|
||||
22
action/action_usuario.php
Normal file
22
action/action_usuario.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once '../class/c_login.php';
|
||||
|
||||
// print_r($_POST); exit;
|
||||
|
||||
if (($user = Login::validUser($_POST['username'], $_POST['passwd'])) === false) {
|
||||
echo json_encode("error");
|
||||
exit;
|
||||
}
|
||||
|
||||
$facultades = queryAll("SELECT DISTINCT ID, FACULTAD FROM FS_FACULTAD WHERE ACTIVA");
|
||||
|
||||
for ($i = 0; $i < count($facultades); $i++) {
|
||||
# print_r($facultades[$i]);
|
||||
$facultades[$i]['usuarios'] = queryAll(
|
||||
"SELECT ID, USERNAME FROM FS_USUARIO WHERE facultad = :facultad",
|
||||
array(":facultad" => $facultades[$i]["id"])
|
||||
);
|
||||
}
|
||||
|
||||
echo json_encode($facultades);
|
||||
22
action/action_usuarios_insert.php
Normal file
22
action/action_usuarios_insert.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
if(isset($_POST['dlfacultad']))
|
||||
$facultad=$_POST['dlfacultad'];
|
||||
else
|
||||
$facultad=$_POST['mfacultad'];
|
||||
|
||||
$hecho = query("SELECT * FROM fs_usuario WHERE clave = :clave", [':clave' => $_POST['mclave']], true);
|
||||
if(!$hecho){
|
||||
$sql = "SELECT fi_usuario(:nombre, :correo, :clave, :rol, :facultad)";
|
||||
$params = [':nombre' => mb_strtoupper($_POST['mnombre']), ':correo' => $_POST['mcorreo'], ':clave' => $_POST['mclave'], ':rol' => $_POST['mrol'], ':facultad' => $facultad];
|
||||
$hecho = query($sql, $params, true);
|
||||
header("Location: ../usuarios.php", true, 307);
|
||||
exit();
|
||||
}
|
||||
else{
|
||||
header("Location: ../usuarios.php?error=1");
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
8
action/action_usuarios_select.php
Normal file
8
action/action_usuarios_select.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
$sql = "SELECT * FROM usuario WHERE usuario_id = :idUsuario";
|
||||
$params = [':idUsuario' => $_POST['usuario']];
|
||||
echo json_encode(query($sql, $params, true));
|
||||
?>
|
||||
15
action/action_usuarios_update.php
Normal file
15
action/action_usuarios_update.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
if(isset($_POST['dlfacultad']))
|
||||
$facultad=$_POST['dlfacultad'];
|
||||
else
|
||||
$facultad=$_POST['mfacultad'];
|
||||
$sql = "SELECT fu_update_usuario(:id, :nombre, :correo, :clave, :rol, :facultad)";
|
||||
$params = array(':id' => $_POST['id'], ':nombre' => mb_strtoupper($_POST['mnombre']), ':correo' => $_POST['mcorreo'], ':clave' => $_POST['mclave'], ':rol' => $_POST['mrol'], ':facultad' => $facultad);
|
||||
#print_r($_POST);
|
||||
$hecho = query($sql, $params, false);
|
||||
header("Location: ../usuarios.php", true, 307);
|
||||
exit();
|
||||
?>
|
||||
10
action/carrera_find.php
Normal file
10
action/carrera_find.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
$ruta = '../';
|
||||
require_once '../include/bd_pdo.php';
|
||||
global $pdo;
|
||||
|
||||
$sql = "SELECT * FROM fs_carreras(:fac, null, null)";
|
||||
$params = [':fac' => $_POST['fac_id']];
|
||||
|
||||
echo json_encode(query($sql, $params, false));
|
||||
?>
|
||||
37
action/force_session.php
Normal file
37
action/force_session.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
$ruta = "../";
|
||||
require_once '../class/c_login.php';
|
||||
|
||||
# print_r($_POST); exit;
|
||||
extract($_POST); // $usuario
|
||||
Login::log_out();
|
||||
|
||||
$user = query("SELECT * FROM FS_USUARIO WHERE ID = :id", [":id" => $usuario]);
|
||||
// die(json_encode($user));
|
||||
|
||||
$facultad = [
|
||||
"facultad_id" => $user["facultad"],
|
||||
"facultad" => $user["facultad_nombre"]
|
||||
];
|
||||
|
||||
$rol = [
|
||||
"rol_id" => $user["rol"],
|
||||
"rol" => $user["titulo"]
|
||||
];
|
||||
|
||||
$admin = false;
|
||||
|
||||
$periodo = $user["periodo"];
|
||||
|
||||
$user = [
|
||||
"id" => $user["id"],
|
||||
"nombre" => $user["username"]
|
||||
];
|
||||
|
||||
$user = new Login($user, $facultad, $rol, $admin, $periodo);
|
||||
|
||||
session_start();
|
||||
$_SESSION['user'] = serialize($user);
|
||||
|
||||
header("Location: ../main.php");
|
||||
exit;
|
||||
BIN
action/one_row.xlsx
Normal file
BIN
action/one_row.xlsx
Normal file
Binary file not shown.
26
action/usuario_find.php
Normal file
26
action/usuario_find.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
$ruta = '../';
|
||||
require_once '../include/bd_pdo.php';
|
||||
global $pdo;
|
||||
|
||||
if($_POST['nombre']==""){
|
||||
$nombre = null;
|
||||
}else{
|
||||
$nombre = $_POST['nombre'];
|
||||
}
|
||||
if($_POST['clave']==""){
|
||||
$clave = null;
|
||||
}else{
|
||||
$clave = $_POST['clave'];
|
||||
}
|
||||
if($_POST['facultad']==""){
|
||||
$facultad = null;
|
||||
}else{
|
||||
$facultad = $_POST['facultad'];
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM fs_profesores(:nombre, :clave, :facultad) ORDER BY profesor_nombre";
|
||||
$params = [':nombre' => $nombre, ':clave' => $clave, ':facultad' => $facultad];
|
||||
|
||||
echo json_encode(query($sql, $params, false));
|
||||
?>
|
||||
Reference in New Issue
Block a user