New things
This commit is contained in:
@@ -12,11 +12,10 @@ require_once "../include/bd_pdo.php";
|
||||
global $pdo;
|
||||
//print_r($_POST);
|
||||
if (!isset($_POST['periodo']) || count($_POST["periodo"])==0) {
|
||||
//header("Location: ../días_festivos.php?error=1");
|
||||
echo "Error no hay periodo";
|
||||
header("Location: ../días_festivos.php?error=0");
|
||||
exit();
|
||||
}
|
||||
$periodo = $_POST['periodo'];
|
||||
$periodoArr = $_POST['periodo'];
|
||||
|
||||
if (isset($_POST['rango'])) {
|
||||
$diaInicio = new DateTime(date("Y-m-d", strtotime(str_replace("/", "-", $_POST['diaFestivo']))));
|
||||
@@ -24,27 +23,35 @@ if (isset($_POST['rango'])) {
|
||||
$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);
|
||||
|
||||
$db->querySingle('SELECT fi_diasfestivos({'.implode(",",$fieldName).'}, :dia)', [':dia' => $date]);
|
||||
/*$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)";
|
||||
/*$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);
|
||||
$dia = query($sql, $params, false);*/
|
||||
//if (!$dia && !$dia_general) { //no hay repetidos
|
||||
foreach($periodoArr as $periodo){
|
||||
$db->querySingle('SELECT fi_diasfestivos({'.implode(",",$fieldName).'}, :dia)', [':dia' => $_POST['diaFestivo']]);
|
||||
/*$sql = "SELECT fi_diasfestivos(:periodo, :dia)";
|
||||
$params = [':periodo' => $periodo, ":dia" => $_POST['diaFestivo']];
|
||||
$id = query($sql, $params, false);*/
|
||||
}
|
||||
header("Location: ../días_festivos.php");
|
||||
exit();
|
||||
} else {
|
||||
|
||||
/*} else {
|
||||
header("Location: ../días_festivos.php?error=1");
|
||||
exit();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
135
action/profesor_faltas.php
Normal file
135
action/profesor_faltas.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?
|
||||
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':
|
||||
$facultad = $_GET['facultad'] ?? $user->facultad['facultad_id'] ?? null;
|
||||
$porcentaje = $_GET['porcentaje'] ?? null;
|
||||
$faltas = $_GET['faltas'] ?? null;
|
||||
|
||||
if (!isset($facultad) || !is_numeric($facultad)) {
|
||||
$error = 'No se ha seleccionado una facultad';
|
||||
} else if ((!isset($faltas) || !is_numeric($faltas)) && (!isset($porcentaje) || !is_numeric($porcentaje))) {
|
||||
$error = 'Debe especificar las faltas o el porcentaje';
|
||||
} else if (isset($faltas) && (!is_numeric($faltas) || $faltas <= 0)) {
|
||||
$error = 'Las faltas deben ser un número mayor a 0';
|
||||
} else if (isset($porcentaje) && (!is_numeric($porcentaje) || $porcentaje <= 0)) {
|
||||
$error = 'El porcentaje debe ser un número mayor a 0';
|
||||
} else if (isset($faltas) && isset($porcentaje)) {
|
||||
$error = 'No se puede especificar las faltas y el porcentaje al mismo tiempo';
|
||||
} else if (!isset($facultad) || !is_numeric($facultad)) {
|
||||
$error = 'Debe especificar una facultad';
|
||||
}
|
||||
|
||||
if (isset($error)) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => $error]);
|
||||
exit();
|
||||
}
|
||||
// Initialize the data array
|
||||
$data = array();
|
||||
|
||||
// Check if 'profesor' or 'supervisor' is set and prepare the specific part of the SQL query accordingly.
|
||||
if (isset($_GET['profesor']) || isset($_GET['supervisor'])) {
|
||||
|
||||
$condition = isset($_GET['profesor'])
|
||||
? "r.registro_fecha IS NULL AND NOT COALESCE(r.registro_justificada, FALSE)"
|
||||
: "estado_supervisor_id = 2";
|
||||
|
||||
$filter = isset($faltas)
|
||||
? "afcp.faltas >= :faltas"
|
||||
: "afcp.porcentaje >= :porcentaje";
|
||||
|
||||
// Prepare the SQL query with placeholders for parameters
|
||||
$data = array_column($db->query(
|
||||
"WITH fechas AS (
|
||||
SELECT
|
||||
fcc.registro_fecha_ideal,
|
||||
fcc.horario_id,
|
||||
hp.profesor_id
|
||||
FROM fechas_clase_cache fcc
|
||||
JOIN horario_profesor hp USING (horario_id)
|
||||
JOIN horario h USING (horario_id)
|
||||
WHERE (h.PERIODO_ID, h.FACULTAD_ID) = (:periodo_id, :facultad_id) and profesor_id <> 0
|
||||
),
|
||||
asistencia_faltas AS (
|
||||
SELECT
|
||||
f.profesor_id,
|
||||
COUNT(1) AS total,
|
||||
COUNT(1) FILTER (WHERE $condition AND f.registro_fecha_ideal <= current_date) AS faltas
|
||||
FROM fechas f
|
||||
LEFT JOIN registro r USING (registro_fecha_ideal, horario_id, profesor_id)
|
||||
GROUP BY f.profesor_id
|
||||
),
|
||||
asistencia_faltas_con_porcentaje AS (
|
||||
SELECT
|
||||
af.profesor_id,
|
||||
af.faltas,
|
||||
af.total,
|
||||
CASE
|
||||
WHEN af.total > 0 THEN ROUND((af.faltas::NUMERIC / af.total) * 100, 2)
|
||||
ELSE NULL
|
||||
END AS porcentaje
|
||||
FROM asistencia_faltas af
|
||||
WHERE af.faltas > 0
|
||||
)
|
||||
SELECT
|
||||
json_build_object(
|
||||
'profesor', json_build_object(
|
||||
'profesor_nombre', p.profesor_nombre,
|
||||
'profesor_clave', p.profesor_clave,
|
||||
'profesor_correo', p.profesor_correo
|
||||
),
|
||||
'profesor_id', afcp.profesor_id,
|
||||
'faltas', afcp.faltas,
|
||||
'total', afcp.total,
|
||||
'porcentaje', afcp.porcentaje
|
||||
) AS result_json
|
||||
FROM asistencia_faltas_con_porcentaje afcp
|
||||
JOIN profesor p USING (profesor_id)
|
||||
WHERE $filter
|
||||
ORDER BY afcp.porcentaje DESC",
|
||||
[
|
||||
'periodo_id' => $user->periodo_id,
|
||||
'facultad_id' => $facultad,
|
||||
] + (isset($faltas)
|
||||
? ['faltas' => $faltas]
|
||||
: ['porcentaje' => $porcentaje])
|
||||
), 'result_json');
|
||||
} else {
|
||||
// Send a 400 Bad Request header and an error message in JSON format
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
echo json_encode(['error' => 'Especifique si las faltas son de profesor o supervisor']);
|
||||
exit();
|
||||
}
|
||||
if (empty($data)) {
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
echo json_encode(['error' => 'No se encontraron faltas']);
|
||||
} else {
|
||||
echo json_encode(
|
||||
array_map(fn($item) => json_decode($item), $data)
|
||||
);
|
||||
}
|
||||
|
||||
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(),
|
||||
]);
|
||||
}
|
||||
@@ -33,26 +33,29 @@ if(isset($_POST["salon"]) && $_POST["salon"] != "")
|
||||
|
||||
//--------------
|
||||
//Obtiene datos reposición
|
||||
//TODO , SALÓN SALIÓ PENDIENTE Y FALTA REVISAR LISTA DE CORREOS TO
|
||||
$reposicion_rs = $db->querySingle('SELECT h.materia, r.fecha_nueva, r.hora_nueva, r.fecha_clase, h.horario_hora, h.facultad_id, h.facultad, f.clave_dependencia, s.salon_id, s.salon_array, r.motivo_cancelacion, ta.tipoaula_supervisor , ta.tipoaula_nombre
|
||||
$reposicion_rs = $db->querySingle('SELECT h.materia, r.fecha_nueva, r.hora_nueva, r.fecha_clase, h.horario_hora, h.facultad_id, h.facultad, f.clave_dependencia, r.motivo_cancelacion, ta.tipoaula_supervisor , ta.tipoaula_nombre
|
||||
from reposicion_solicitud r
|
||||
inner join horario_view h on h.horario_id = r.horario_id
|
||||
inner join facultad f on f.facultad_id = h.facultad_id
|
||||
inner join tipoaula ta on ta.tipoaula_id = r.tipoaula_id
|
||||
left join salon_view s on r.salon_id = s.salon_id
|
||||
where r.reposicion_solicitud_id = :id_repo',
|
||||
[':id_repo' => $id_repo]
|
||||
);
|
||||
|
||||
if($reposicion_rs["salon_id"] == "" || $reposicion_rs["salon_id"] == NULL){
|
||||
//Obtiene datos de salón asignado
|
||||
$salon_rs = $db->querySingle('SELECT s.salon_id, s.salon_array FROM salon_view s where s.salon_id = :id_salon',
|
||||
[':id_salon' => $salon]
|
||||
);
|
||||
if($salon_rs["salon_id"] == "" || $salon_rs["salon_id"] == NULL){
|
||||
$salon_desc = "Pendiente";
|
||||
}else{
|
||||
$salon_json = json_decode($reposicion_rs["salon_array"], true);
|
||||
$salon_json = json_decode($salon_rs["salon_array"], true);
|
||||
if($salon_json[0]== "UNIVERSIDAD LA SALLE"){
|
||||
unset($salon_json[0]);
|
||||
}
|
||||
$salon_desc = join(" / ",$salon_json);
|
||||
}
|
||||
|
||||
//Obtiene correos
|
||||
$correos_rs = $db->query('SELECT p.profesor_nombre, p.profesor_correo, u.usuario_nombre as jefe_nombre, u.usuario_correo as jefe_correo,
|
||||
coor.usuario_nombre as coordinador_nombre, coor.usuario_correo as coordinador_correo
|
||||
@@ -163,12 +166,12 @@ if($to!= "" && ENVIO_CORREOS){
|
||||
</body>';
|
||||
|
||||
require_once('../include/phpmailer/PHPMailerAutoload.php');
|
||||
/*if(DB_NAME == "poad_pruebas"){
|
||||
if($_ENV['DB_NAME'] == "paad_pruebas"){
|
||||
$asunto = "PRUEBAS-".$asunto;
|
||||
Mailer::enviarCorreo("alejandro.lara@lasalle.mx", $asunto, $texto, true);
|
||||
}else{*/
|
||||
}else{
|
||||
Mailer::enviarCorreo($to, $asunto, $texto, true);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -39,6 +39,7 @@ else
|
||||
$comentario = trim(htmlspecialchars($_POST["comentario"], ENT_QUOTES, "UTF-8"));//limpia texto
|
||||
|
||||
|
||||
|
||||
$duracion_rs = $db->querySingle("select * from duracion where duracion_id = :id", [":id"=>$duracion_id]);
|
||||
$duracion_tiempo = $duracion_rs["duracion_interval"];
|
||||
|
||||
@@ -73,6 +74,9 @@ if(intval($dia) != intval($dia_falta)){
|
||||
exit();
|
||||
}
|
||||
|
||||
//Obtiene materia
|
||||
$materia_rs = $db->querySingle('SELECT materia_nombre from materia where materia_id = :mat',[':mat' => $materia]);
|
||||
|
||||
//Obtiene correo
|
||||
$correos_rs = $db->querySingle('SELECT coor.usuario_correo, coor.usuario_nombre from usuario coor where rol_id = :rol_coord and facultad_id = (
|
||||
select coalesce(facultad_id,0) from usuario u where u.usuario_id = :id_usr)',[':rol_coord' => COORDINADOR, ':id_usr' => $user->user["id"]]
|
||||
@@ -98,6 +102,7 @@ if($tipo == 1){//Reposición
|
||||
if($traslape){
|
||||
//print_r($_POST);
|
||||
//echo "SELECT * from traslape_profesor_reposicion($prof,'".DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')."' , '$hora', $duracion)";
|
||||
|
||||
header("Location:".$pag."?error=9");
|
||||
exit();
|
||||
}
|
||||
@@ -110,12 +115,13 @@ if($tipo == 1){//Reposición
|
||||
]
|
||||
);
|
||||
}catch(Exception $e){
|
||||
|
||||
echo $e->getMessage();
|
||||
//header("Location: ".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
$texto = "<p>Se creó una reposición nueva.</p>";
|
||||
$texto .= "<p><b>".mb_strtoupper($reposicion_rs["materia"])."</b> del día <b>".$fecha_falta." a las ".$hor." hrs. </b> se propone reponer el <b>".$fecha_new." a las ".$hora." hrs.</b>";
|
||||
$texto .= "<p><b>".mb_strtoupper($materia_rs["materia_nombre"])."</b> del día <b>".$fecha_falta." a las ".$hor." hrs. </b> se propone reponer el <b>".$fecha_new." a las ".$hora." hrs.</b>";
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarla.</p>";
|
||||
|
||||
/*
|
||||
@@ -134,11 +140,12 @@ if($tipo == 1){//Reposición
|
||||
]
|
||||
);
|
||||
}catch(Exception $e){
|
||||
|
||||
header("Location: ".$pag."?error=1");
|
||||
exit();
|
||||
}
|
||||
$texto = "<p>Se creó un cambio de salón nuevo.</p>";
|
||||
$texto .= "<p><b>".mb_strtoupper($reposicion_rs["materia"])."</b> del día <b>".$fecha_falta." a las ".$hora." hrs. </b> se propone reponer el <b>".$fecha_nueva." a las ".$hora_nueva." hrs.</b>";
|
||||
$texto .= "<p><b>".mb_strtoupper($materia_rs["materia_nombre"])."</b> del día <b>".$fecha_falta." a las ".$hora." hrs. </b> se propone reponer el <b>".$fecha_nueva." a las ".$hora_nueva." hrs.</b>";
|
||||
$texto .= "<p>Ingresa al <a href='https://paad.lci.ulsa.mx'>sistema PAAD</a> para autorizarlo.</p>";
|
||||
|
||||
/*
|
||||
@@ -159,14 +166,14 @@ if($to!= "" && ENVIO_CORREOS){
|
||||
</body>';
|
||||
|
||||
require_once('../include/phpmailer/PHPMailerAutoload.php');
|
||||
/*if(DB_NAME == "poad_pruebas"){
|
||||
if($_ENV['DB_NAME'] == "paad_pruebas"){
|
||||
$asunto = "PRUEBAS-".$asunto;
|
||||
Mailer::enviarCorreo("alejandro.lara@lasalle.mx", $asunto, $texto, true);
|
||||
}else{*/
|
||||
}else{
|
||||
Mailer::enviarCorreo($to, $asunto, $texto, true);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
header("Location: ".$pag."?ok=0");
|
||||
exit();
|
||||
header("Location: ".$pag."?ok=0");
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user