diff --git a/action/action_usuarios_insert.php b/action/action_usuarios_insert.php index d34ea1e..7565f32 100644 --- a/action/action_usuarios_insert.php +++ b/action/action_usuarios_insert.php @@ -14,13 +14,16 @@ if ($db->where('usuario_clave', $_POST['mclave'])->has('usuario')) { header("Location: ../usuarios.php?error=1"); exit; } - -$db->insert('usuario', [ - 'usuario_nombre' => mb_strtoupper($_POST['mnombre']), - 'usuario_correo' => $_POST['mcorreo'], - 'usuario_clave' => $_POST['mclave'], - 'rol_id' => $_POST['mrol'] ?? null, - 'facultad_id' => empty($facultad) ? null : $facultad, -]); - -header("Location: ../usuarios.php", true, 307); \ No newline at end of file +try { + $db->insert('usuario', [ + 'usuario_nombre' => mb_strtoupper($_POST['mnombre']), + 'usuario_correo' => $_POST['mcorreo'], + 'usuario_clave' => $_POST['mclave'], + 'rol_id' => $_POST['mrol'] ?? null, + 'facultad_id' => empty($facultad) ? null : $facultad, + ]); + header("Location: ../usuarios.php", true, 307); +} catch (PDOException $e) { + header("Location: ../usuarios.php?error=2"); + exit; +} diff --git a/action/asignacion_insert.php b/action/asignacion_insert.php new file mode 100644 index 0000000..0b88848 --- /dev/null +++ b/action/asignacion_insert.php @@ -0,0 +1,120 @@ +access(); + +$duracion_id = filter_input(INPUT_POST, "duracion", FILTER_SANITIZE_NUMBER_INT);//Id reposicion +$fecha = trim(htmlspecialchars($_POST["fecha_inicial"], ENT_QUOTES, "UTF-8"));//limpia texto +$hora_ini = filter_input(INPUT_POST, "hora_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto +$min_ini = filter_input(INPUT_POST, "min_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto +$alumnos = filter_input(INPUT_POST, "alumnos", FILTER_SANITIZE_NUMBER_INT);//limpia texto +$aula = filter_input(INPUT_POST, "aula", FILTER_SANITIZE_NUMBER_INT);//1 regular , 2 sala computo, 3 otro facultad + +if(empty($_POST["prof"])) + $prof = $user["id"]; +else + $prof = filter_input(INPUT_POST, "prof", FILTER_SANITIZE_NUMBER_INT);//limpia texto +//if(isset($_POST["salon"]) && $_POST["salon"] != "") +//$salon = trim(filter_input(INPUT_POST, "salon", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto +$comentario = trim(htmlspecialchars($_POST["comentario"], ENT_QUOTES, "UTF-8"));//limpia texto + +$aula_rs = $db->querySingle("select tipoaula_nombre from tipoaula where tipoaula_id = :id", [":id"=>$aula]); + + +$duracion_rs = $db->querySingle("select * from duracion where duracion_id = :id", [":id"=>$duracion_id]); +$duracion_tiempo = $duracion_rs["duracion_interval"]; + +//-- Obtiene datos de horario regular de clase + +$hora = $hora_ini.":".$min_ini.":00"; +$fecha_new = DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')." ".$hora; +$fecha_fin_new = date("Y-m-d", strtotime($fecha_new))." ".$duracion_tiempo; +$dia_new = date('w', strtotime($fecha_new)); + + + +//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"]] +); +if( count($correos_rs) > 0 ){ + $to = $correos_rs["usuario_correo"]; +} + +// Valida que grupo no tenga clases +/*$result = validaConflictoHoras($pdo, $gpo, $dia_new, $hora, $materia, "-", $fecha_new, $fecha_fin_new, $duracion); +if($result != ""){//error + //echo $result; + header("Location:".$pag."?error=7"); + exit(); +} +*/ +//Valida que profesor no este en 2 reposiciones al mismo tiempo en la fecha nueva + +$traslape = $db->querySingle('SELECT * from traslape_profesor_reposicion(:prof, :fecha, :hora, :dur)', + [':prof' => $prof, ':fecha'=>DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d'), ':hora'=>$hora, ':dur'=>$duracion_tiempo] +)["traslape_profesor_reposicion"]; +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(); +} + +try{ + //echo "SELECT * from fi_asignacion_solicitud( $fecha_new, $hora, $prof, 1, $comentario, $alumnos, $aula, $duracion_tiempo, ".$user->user["id"].")"; + $db->query('SELECT * from fi_asignacion_solicitud(:f_nueva, :hora_nueva, :prof, 1, :desc, :alumnos, :aula, :duracion, :usr)', + [':f_nueva' => $fecha_new, ':hora_nueva' => $hora, + ':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"] + ] + ); +}catch(Exception $e){ + echo $e->getMessage(); + //header("Location: ".$pag."?error=1"); + exit(); +} +$texto = "
Se creó una asignación nueva.
"; +$texto .= "Se solicita un espacio de tipo ".mb_strtoupper($aula_rs["tipoaula_nombre"])." del día ".$fecha_new." hrs. "; +$texto .= "
Ingresa al sistema PAAD para autorizarla.
"; + +/* +$log = new LogActividad(); +$desc_log = "Inserta reposición nueva ID[".$rs["fi_reposicion"]."] Fechas[".$fecha_falta.">".$fecha_new."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$hor."] Alumnos[".$alumnos."]"; +$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);*/ + + + +if($to!= "" && ENVIO_CORREOS){ + $asunto = "Reposición nueva - solicitud"; + //crear plantilla + $texto = ' +
+ '.$texto.'
+ ';
+
+ require_once('../include/phpmailer/PHPMailerAutoload.php');
+ if($_ENV['DB_NAME'] == "paad_pruebas"){
+ $asunto = "PRUEBAS-".$asunto;
+ Mailer::enviarCorreo("alejandro.lara@lasalle.mx", $asunto, $texto, true);
+ }else{
+ Mailer::enviarCorreo($to, $asunto, $texto, true);
+ }
+}
+
+header("Location: ".$pag."?ok=0");
+?>
diff --git a/action/periodos.php b/action/periodos.php
index 618e1d1..bc1d98f 100644
--- a/action/periodos.php
+++ b/action/periodos.php
@@ -16,7 +16,7 @@ try {
$periodo_id = $user->periodo_id;
if (is_null($user->facultad['facultad_id'])) {
$periodos = $db
- ->where('CURRENT_DATE BETWEEN periodo_fecha_inicio AND periodo_fecha_fin')
+ //->where('CURRENT_DATE BETWEEN periodo_fecha_inicio AND periodo_fecha_fin')
->join('nivel', 'nivel.nivel_id = periodo.nivel_id')
->orderBy('periodo_id')
->get('periodo', null, 'periodo.*, nivel_nombre as nivel');
@@ -25,8 +25,8 @@ try {
"SELECT DISTINCT periodo.*, nivel_nombre as nivel FROM periodo
JOIN horario_view USING (periodo_id)
JOIN nivel ON nivel.nivel_id = periodo.nivel_id
- WHERE CURRENT_DATE BETWEEN periodo.periodo_fecha_inicio AND periodo.periodo_fecha_fin
- AND facultad_id = :facultad_id
+ WHERE /*CURRENT_DATE BETWEEN periodo.periodo_fecha_inicio AND periodo.periodo_fecha_fin
+ AND */facultad_id = :facultad_id
ORDER BY periodo_id
",
['facultad_id' => $user->facultad['facultad_id']]
diff --git a/action/profesor_faltas.php b/action/profesor_faltas.php
index 500dcdc..0e9e896 100644
--- a/action/profesor_faltas.php
+++ b/action/profesor_faltas.php
@@ -53,13 +53,12 @@ try {
$data = array_column($db->query(
"WITH fechas AS (
SELECT
- fcc.registro_fecha_ideal,
- fcc.horario_id,
+ h.horario_id,
+ fechas_clase(h.horario_id, true) AS registro_fecha_ideal,
hp.profesor_id
- FROM fechas_clase_cache fcc
+ FROM horario h
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
+ WHERE (h.PERIODO_ID, h.FACULTAD_ID) = (:periodo_id, :facultad_id) AND hp.profesor_id <> 0
),
asistencia_faltas AS (
SELECT
@@ -97,7 +96,8 @@ try {
FROM asistencia_faltas_con_porcentaje afcp
JOIN profesor p USING (profesor_id)
WHERE $filter
- ORDER BY afcp.porcentaje DESC",
+ ORDER BY afcp.porcentaje DESC;
+ ",
[
'periodo_id' => $user->periodo_id,
'facultad_id' => $facultad,
diff --git a/action/puesto.php b/action/puesto.php
index bbdffb1..0eb4fe2 100644
--- a/action/puesto.php
+++ b/action/puesto.php
@@ -15,7 +15,6 @@ try {
case 'GET':
// Fetch all puestos
$facultad_id = $user->facultad['facultad_id'] ?? -1;
- $carreras = array_map(fn($c) => $c['carrera_id'], $db->where('facultad_id', $facultad_id)->get(tableName: 'carrera', columns: 'carrera_id'));
$puestos = array_map(
fn($p) => array(
...$p,
@@ -28,7 +27,7 @@ try {
),
$db->orderBy('puesto.nombre', 'desc')
->where('facultad_id', $facultad_id)
- ->get(tableName: 'puesto', numRows: count($carreras), columns: 'puesto_id, nombre'),
+ ->get(tableName: 'puesto', columns: 'puesto_id, nombre'),
);
echo json_encode($puestos);
break;
diff --git a/action/reposicion_autoriza.php b/action/reposicion_autoriza.php
index 2c91177..beb1c04 100644
--- a/action/reposicion_autoriza.php
+++ b/action/reposicion_autoriza.php
@@ -153,7 +153,7 @@ switch($edo){
case 4://Correo a coordinador, profesor y jefe
$asunto = "Reposición declinada - ".$reposicion_rs["materia"];
$texto = "La resposición de la clase de ".$reposicion_rs["materia"]." planeada para el día ".$fecha_nueva." a las ".$hora_nueva." hrs. ha sido declinada por el siguiente motivo:
"; - $texto .= "".$reposicion_rs["motivo_cancelacion"]."
"; + $texto .= "".$motivo."
"; $to = join(",", $coord_correos).",".join(",", $prof_correos).",".join(",", $jefe_correos); $ok = 1; break; @@ -166,12 +166,13 @@ if($to!= "" && ENVIO_CORREOS){