diff --git a/action/action_auditoria.php b/action/action_auditoria.php index 4d99192..efac69e 100644 --- a/action/action_auditoria.php +++ b/action/action_auditoria.php @@ -31,7 +31,7 @@ try { "WITH horarios AS ( SELECT horario_id, - facultad.facultad_id, + horario.facultad_id, horario_fecha_inicio, horario_fecha_fin, horario_grupo, @@ -40,20 +40,19 @@ try { PERIODO.periodo_fecha_fin, salon, COALESCE(materia_nombre, materia_asignacion_materia) as materia, - carrera_nombre as carrera, + coalesce(carrera_nombre, materia_asignacion_carrera) as carrera, facultad_nombre as facultad, nivel_nombre as nivel, horario_fin FROM horario left JOIN materia USING (materia_id) - LEFT JOIN carrera USING (carrera_id) + left join carrera using (carrera_id) left join materia_asignacion using (horario_id) - -- JOIN carrera USING (carrera_id) but if carrera_id is null then 0 - JOIN nivel USING (nivel_id) - JOIN facultad ON facultad.facultad_id = COALESCE(carrera.facultad_id, 0) + join facultad on facultad.facultad_id = horario.facultad_id JOIN PERIODO USING (periodo_id) + JOIN nivel on periodo.nivel_id = nivel.nivel_id JOIN SALON USING (salon_id) - WHERE (PERIODO.periodo_id, facultad.facultad_id) = (:periodo_id, COALESCE(:facultad_id, facultad.facultad_id)) + WHERE (PERIODO.periodo_id, horario.facultad_id) = (:periodo_id, COALESCE(:facultad_id, horario.facultad_id)) ), fechas AS ( SELECT fechas_clase(h.horario_id, true) as registro_fecha_ideal, h.horario_id diff --git a/action/action_estado_supervisor.php b/action/action_estado_supervisor.php index 12ffd1f..a64c05a 100644 --- a/action/action_estado_supervisor.php +++ b/action/action_estado_supervisor.php @@ -1,4 +1,4 @@ - [ diff --git a/action/action_grupo.php b/action/action_grupo.php index 4e230ea..3079e11 100644 --- a/action/action_grupo.php +++ b/action/action_grupo.php @@ -23,7 +23,8 @@ if (!isset($_GET['carrera_id'])) { exit(); } -$grupos = $db->query(<<query(<<query(<< $user->periodo_id, - ':facultad_id' => $user->facultad['facultad_id'], - ':carrera_id' => $_GET['carrera_id'] - ] -); + [ + ':periodo_id' => $user->periodo_id, + ':facultad_id' => $user->facultad['facultad_id'], + ':carrera_id' => $_GET['carrera_id'] ?? 0 + ] + ); +} catch (PDOException $ex) { + echo json_encode([]); + exit(); +} echo json_encode(array_map(fn($grupo) => $grupo['horario_grupo'], $grupos)); \ No newline at end of file diff --git a/action/action_usuarios_delete.php b/action/action_usuarios_delete.php new file mode 100644 index 0000000..77e33ba --- /dev/null +++ b/action/action_usuarios_delete.php @@ -0,0 +1,15 @@ +querySingle("UPDATE usuario SET estado_baja = TRUE WHERE usuario_id = ?", [$_GET['id']]); + header("Location: ../usuarios.php", true, 307); +} catch (PDOException $e) { + header("Location: ../usuarios.php?error=2"); + exit; +} diff --git a/action/asignacion_delete.php b/action/asignacion_delete.php new file mode 100644 index 0000000..5605d9d --- /dev/null +++ b/action/asignacion_delete.php @@ -0,0 +1,33 @@ +user["id"]; + + try{ + $db->query('SELECT * from fd_asignacion_solicitud(:id, :creador)', [":id"=> $id, ":creador"=>$creador]); + $return["ok"] = "La solicitud se borró correctamente"; + + }catch(Exception $e){ + $return["error"] = "Ocurrió un error al borrar la solicitud de salón."; + } + + +} +echo json_encode($return); +?> diff --git a/action/asignacion_insert.php b/action/asignacion_insert.php index 0b88848..3a3a593 100644 --- a/action/asignacion_insert.php +++ b/action/asignacion_insert.php @@ -23,6 +23,8 @@ $hora_ini = filter_input(INPUT_POST, "hora_ini", FILTER_SANITIZE_NUMBER_INT);//l $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(isset($_POST["salon"]) && $_POST["salon"] != "") + $salon = filter_input(INPUT_POST, "salon", FILTER_SANITIZE_NUMBER_INT);//limpia texto if(empty($_POST["prof"])) $prof = $user["id"]; @@ -32,7 +34,7 @@ else //$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]); +$aula_rs = $db->querySingle("select tipoaula_nombre, tipoaula_supervisor from tipoaula where tipoaula_id = :id", [":id"=>$aula]); $duracion_rs = $db->querySingle("select * from duracion where duracion_id = :id", [":id"=>$duracion_id]); @@ -45,16 +47,52 @@ $fecha_new = DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')." ".$ $fecha_fin_new = date("Y-m-d", strtotime($fecha_new))." ".$duracion_tiempo; $dia_new = date('w', strtotime($fecha_new)); +//Datos de dependencia de usuario +$fac_rs = $db->querySingle("SELECT facultad_nombre, clave_dependencia from facultad where facultad_id = :id_fac",[':id_fac' => $user->facultad["facultad_id"]] ); - -//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"]; +$salon_desc = "Pendiente"; +if(!empty($salon)){ + $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($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 coor.usuario_correo as coordinador_correo + from reposicion_solicitud rs + inner join profesor p on rs.profesor_id =p.profesor_id + inner join usuario u on u.usuario_id = rs.usuario_id + inner join horario_view hv on hv.horario_id = rs.horario_id + inner join usuario coor on hv.facultad_id = coor.facultad_id and coor.rol_id = :rol_coord + where hv.facultad_id = :id_fac', + [':rol_coord' => COORDINADOR, ':id_fac' => $user->facultad["facultad_id"]] + ); +$coord_correos=[]; +foreach($correos_rs as $correo){ + if( count($coord_correos)==0 && $correo["coordinador_correo"]!=""){ + if(!isset($coord_correos["correo"]) || !in_array($correo["coordinador_correo"], $coord_correos["correo"])){ + array_push($coord_correos, $correo["coordinador_correo"]); + } + } +} + +$correosSup_rs = $db->querySingle("SELECT DISTINCT sup.usuario_correo as coordinador_correo + FROM horario_supervisor hs + inner join usuario sup on sup.usuario_id =hs.usuario_id + where :id_fac = ANY(hs.facultad_id_array) + and sup.usuario_correo is not null and sup.usuario_correo != ''", + [':id_fac' => $user->facultad["facultad_id"]] ); + + // Valida que grupo no tenga clases /*$result = validaConflictoHoras($pdo, $gpo, $dia_new, $hora, $materia, "-", $fecha_new, $fecha_fin_new, $duracion); if($result != ""){//error @@ -77,10 +115,14 @@ if($traslape){ } 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)', + $edo = 1; + if(!$user->jefe_carrera) + $edo = 2; + + //echo "SELECT * from fi_asignacion_solicitud( $fecha_new, $hora, $prof, $edo, $comentario, $alumnos, $aula, $duracion_tiempo, ".$user->user["id"].")"; exit(); + $db->query('SELECT * from fi_asignacion_solicitud(:f_nueva, :hora_nueva, :prof, :edo, :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"] + ':prof' => $prof, ':edo'=>$edo, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"] ] ); }catch(Exception $e){ @@ -88,9 +130,34 @@ try{ //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.

"; + +$asunto = ""; +$texto = ""; +$to = ""; +switch($edo){ + case 1://Correo a coordinador + if( count($coord_correos) > 0 ){ + $to = join(",", $coord_correos); + } + $asunto = "Solicitud de salon nueva"; + $texto = "

Se creó una solicitud de asignación de salón nueva.

"; + $texto .= "

Se solicita un espacio de tipo ".mb_strtoupper($aula_rs["tipoaula_nombre"])." para el día ".$fecha." a las ".$hora." hrs. "; + $texto .= "

Ingresa al sistema PAAD para autorizarla.

"; + break; + case 2://Correo a supervisor + $asunto = "Solicitud de salon nueva - ".$fac_rs["clave_dependencia"]." ".$fac_rs["facultad_nombre"]; + //crear plantilla + $texto = "

Se creó una solicitud de asignación de salón nueva para: ".$fac_rs["clave_dependencia"]." ".$fac_rs["facultad_nombre"].".

"; + $texto .= "

Para el día ".$fecha." a las ".$hora." hrs. "; + if(!$aula_rs["tipoaula_supervisor"]){ + $texto .= " en el salón: ".$salon_desc."

"; + }else{ + $texto .= " en un salón de tipo: ".mb_strtoupper($aula_rs["tipoaula_nombre"])."

"; + } + $texto .= "

Ingresa al sistema PAAD para autorizarla.

"; + $to = join(",", $correosSup_rs); + break; +} /* $log = new LogActividad(); @@ -100,7 +167,6 @@ $log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSI if($to!= "" && ENVIO_CORREOS){ - $asunto = "Reposición nueva - solicitud"; //crear plantilla $texto = ' La Salle diff --git a/action/asignacion_select.php b/action/asignacion_select.php new file mode 100644 index 0000000..f23784a --- /dev/null +++ b/action/asignacion_select.php @@ -0,0 +1,81 @@ +tieneAcceso()){ + $return["error"] = "Error! No tienes permisos para realizar esta acción."; +}else*/ if(!isset($_POST["id"])){ + $return["error"] = "Error! No se recibió la información de la reposición."; +}else{ + $id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto + + + try{ + if($user->rol["rol_id"] == 7){//es supervisor + $rs = $db->querySingle('SELECT * from fs_asignacion_solicitud(:id, NULL, NULL, :sup, NULL)', + [':id' => $id, ':sup'=>$user->user["id"]] + ); + }else{//coordinador + $rs = $db->querySingle('SELECT * from fs_asignacion_solicitud(:id, NULL, NULL, NULL, null)', + [':id' => $id] + ); + } + + }catch(Exception $e){ + $return["error"] = "Ocurrió un error al leer los datos de la reposición."; + echo json_encode($return); + exit(); + } + + $return["fecha_nueva"] = date('d/m/Y', strtotime($rs["fecha_nueva"])); + $hora_nueva = explode(":",$rs["hora_nueva"]); + $return["hora_ini"] = $hora_nueva[0]; + $return["min_ini"] = $hora_nueva[1]; + $hora_nueva_fin = explode(":",$rs["hora_nueva_fin"]); + $return["hora_fin"] = $hora_nueva_fin[0]; + $return["min_fin"] = $hora_nueva_fin[1]; + $return["duracion"] = $rs["duracion_total"]; + +// $return["carrera"] = $rs["PlanEstudio_desc"]; +// $return["materia"] = $rs["materia_id"]; +// $return["materia_desc"] = $rs["materia_nombre"]; + $return["salon"] = $rs["salon_id"]; + if($rs["salon_id"]==""){ + $return["salon_desc"] = "Pendiente"; + }else{ + $salon_json = json_decode($rs["salon_array"], true); + if($salon_json[0]== "UNIVERSIDAD LA SALLE"){ + unset($salon_json[0]); + } + $return["salon_desc"] = join(" / ",$salon_json); + } + + //$return["salon_desc"] = $rs["salon"]=="" ? "-Pendiente-": $rs["salon"]; + + $return["profesor"] = $rs["profesor_id"]; + $return["profesor_nombre"] = $rs["profesor_nombre"]; + $return["comentario"] = $rs["descripcion"]; + $return["alumnos"] = $rs["alumnos"]; + $return["aula"] = $rs["tipoaula_id"]; + $return["aula_desc"] = $rs["tipoaula_nombre"]; + $return["aula_supervisor"] = $rs["tipoaula_supervisor"]; + $return["dia"] = date('w', strtotime($rs["fecha_nueva"])); + $return["motivo_cancelacion"] = $rs["motivo_cancelacion"]; + $return["estado"] = $rs["estado_reposicion_id"]; + $return["facultad"] = $rs["facultad_nombre"]; + $return["supervisor_nombre"] = $rs["supervisor_nombre"]; +} +echo json_encode($return); +?> diff --git a/action/asignacion_update.php b/action/asignacion_update.php new file mode 100644 index 0000000..ca3a686 --- /dev/null +++ b/action/asignacion_update.php @@ -0,0 +1,135 @@ + FILTER_FLAG_STRIP_LOW)));//limpia texto +$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"]; + + + +$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)); + +//echo $fecha_new."
"; +//echo $fecha_fin_new."
"; +$fac_rs = $db->querySingle("SELECT facultad_nombre, clave_dependencia from facultad where facultad_id = :id_fac",[':id_fac' => $user->facultad["facultad_id"]] ); + +$salon_desc = "Pendiente"; +if(!empty($salon)){ + $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($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 coor.usuario_correo as coordinador_correo + from reposicion_solicitud rs + inner join profesor p on rs.profesor_id =p.profesor_id + inner join usuario u on u.usuario_id = rs.usuario_id + inner join horario_view hv on hv.horario_id = rs.horario_id + inner join usuario coor on hv.facultad_id = coor.facultad_id and coor.rol_id = :rol_coord + where hv.facultad_id = :id_fac', + [':rol_coord' => COORDINADOR, ':id_fac' => $user->facultad["facultad_id"]] + ); +$coord_correos=[]; +foreach($correos_rs as $correo){ + if( count($coord_correos)==0 && $correo["coordinador_correo"]!=""){ + if(!isset($coord_correos["correo"]) || !in_array($correo["coordinador_correo"], $coord_correos["correo"])){ + array_push($coord_correos, $correo["coordinador_correo"]); + } + } +} + +$correosSup_rs = $db->querySingle("SELECT DISTINCT sup.usuario_correo as coordinador_correo + FROM horario_supervisor hs + inner join usuario sup on sup.usuario_id =hs.usuario_id + where :id_fac = ANY(hs.facultad_id_array) + and sup.usuario_correo is not null and sup.usuario_correo != ''", + [':id_fac' => $user->facultad["facultad_id"]] ); + + +//Valida que profesor no este en 2 reposiciones al mismo tiempo +$traslape = $db->querySingle('SELECT * from traslape_profesor_reposicion(:prof, :fecha, :hora, :dur, :id)', +[':prof' => $prof, ':fecha'=>DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d'), ':hora'=>$hora, ':dur'=>$duracion_tiempo, ':id'=>$id] +)["traslape_profesor_reposicion"]; +echo "SELECT * from traslape_profesor_reposicion($prof, '".DateTime::createFromFormat('d/m/Y', $fecha)->format('Y-m-d')."', $hora, $duracion_tiempo, $id)"; +if($traslape){ + //header("Location:".$pag."?error=9"); + echo "traslape"; + exit(); +} + + +/* +$log = new LogActividad(); +$desc_log = "Actualiza reposición ID[".$id."] Fechas[".$fecha_ini."][".$fecha_fin."] Periodo[".$_SESSION["periodo_id"]."] Materia[".$materia."] Profesor[".$prof."] Salon[".$salon."] Horario[".$hor."]"; +$log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);*/ + +try{ + $db->query('SELECT * from fu_asignacion_solicitud(:id, :f_nueva, :hora_nueva, NULL, NULL, :desc, :alumnos, :aula, :duracion, NULL)', + [':id'=> $id, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora, + ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo + ] + ); +}catch(Exception $e){ + //header("Location: ".$pag."?error=2"); + print_r($e->getMessage()); + echo "SELECT * from fu_asignacion_solicitud(:id, :f_nueva, :hora_nueva, NULL, NULL, :desc, :alumnos, :aula, :duracion, NULL)'"; + print_r( + [':id'=> $id, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora, + ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo + ]); + exit(); +} +header("Location: ".$pag); +exit(); +?> diff --git a/action/horario_profesor.php b/action/horario_profesor.php new file mode 100644 index 0000000..bea48a6 --- /dev/null +++ b/action/horario_profesor.php @@ -0,0 +1,46 @@ + 'No se ha iniciado sesión']); + exit(); +} +$user = Login::get_user(); + +try { + switch ($_SERVER['REQUEST_METHOD']) { + case 'GET': + $profesor_id = $db + ->where('profesor_clave', $_GET['profesor']) + ->getOne('profesor', 'profesor_id'); + // Fetch all puestos + $horarios = $db->query(<<periodo_id, $profesor_id['profesor_id']] + ); + + echo json_encode($horarios); + break; + default: + header('HTTP/1.1 405 Method Not Allowed'); + echo json_encode(['error' => 'Método no permitido']); + break; + } +} catch (PDOException $e) { + echo json_encode([ + 'error' => $e->getMessage(), + 'query' => $db->getLastQuery(), + 'exception' => $e->getTraceAsString() + ]); +} \ No newline at end of file diff --git a/action/mail_javier.php b/action/mail_javier.php new file mode 100644 index 0000000..bfab2f5 --- /dev/null +++ b/action/mail_javier.php @@ -0,0 +1,7 @@ +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 - where r.reposicion_solicitud_id = :id_repo', - [':id_repo' => $id_repo] - ); - //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($salon_rs["salon_array"], true); - if($salon_json[0]== "UNIVERSIDAD LA SALLE"){ - unset($salon_json[0]); +$salon_desc = "Pendiente"; +if(!empty($salon)){ + $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($salon_rs["salon_array"], true); + if($salon_json[0]== "UNIVERSIDAD LA SALLE"){ + unset($salon_json[0]); + } + $salon_desc = join(" / ",$salon_json); } - $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 - from reposicion_solicitud rs - inner join profesor p on rs.profesor_id =p.profesor_id - inner join usuario u on u.usuario_id = rs.usuario_id - inner join horario_view hv on hv.horario_id = rs.horario_id - inner join usuario coor on hv.facultad_id = coor.facultad_id and coor.rol_id = :rol_coord - where rs.reposicion_solicitud_id = :id_repo', - [':rol_coord' => COORDINADOR, ':id_repo' => $id_repo] - ); -//print_r($correos_rs); exit(); + +if($tipo ==1 || $tipo == 2){ + //-------------- + //Obtiene datos reposición + $reposicion_rs = $db->querySingle('SELECT h.materia, r.fecha_nueva, r.hora_nueva, r.fecha_clase, r.descripcion, 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 + where r.reposicion_solicitud_id = :id_repo', + [':id_repo' => $id_repo] + ); + + //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 + from reposicion_solicitud rs + inner join profesor p on rs.profesor_id =p.profesor_id + inner join usuario u on u.usuario_id = rs.usuario_id + inner join horario_view hv on hv.horario_id = rs.horario_id + inner join usuario coor on hv.facultad_id = coor.facultad_id and coor.rol_id = :rol_coord + where rs.reposicion_solicitud_id = :id_repo', + [':rol_coord' => COORDINADOR, ':id_repo' => $id_repo] + ); + //print_r($correos_rs); exit(); +}else{ + //Obtiene datos asignación + $reposicion_rs = $db->querySingle('SELECT r.fecha_nueva, r.hora_nueva, r.descripcion, f.facultad_id, f.facultad_nombre as facultad, f.clave_dependencia, r.motivo_cancelacion, ta.tipoaula_supervisor , ta.tipoaula_nombre, p.profesor_nombre + from asignacion_solicitud r + inner join usuario u on u.usuario_id = r.usuario_id + inner join facultad f on f.facultad_id = u.facultad_id + inner join tipoaula ta on ta.tipoaula_id = r.tipoaula_id + inner join profesor p on p.profesor_id = r.profesor_id + where r.asignacion_solicitud_id = :id_repo', + [':id_repo' => $id_repo] + ); + + //Obtiene correos + $correos_rs = $db->query('SELECT p.profesor_nombre, p.profesor_correo, NULL as jefe_nombre, NULL as jefe_correo, + coor.usuario_nombre as coordinador_nombre, coor.usuario_correo as coordinador_correo + from asignacion_solicitud rs + inner join profesor p on rs.profesor_id =p.profesor_id + inner join usuario u on u.usuario_id = rs.usuario_id + inner join usuario coor on u.facultad_id = coor.facultad_id and coor.rol_id = :rol_coord + where rs.asignacion_solicitud_id = :id_repo', + [':rol_coord' => COORDINADOR, ':id_repo' => $id_repo] + ); + +} $prof_correos=array(); $jefe_correos=[]; @@ -91,74 +121,150 @@ foreach($correos_rs as $correo){ } } -$correosSup_rs = $db->querySingle("SELECT DISTINCT sup.usuario_correo as coordinador_correo +$correosSup_rs = $db->query("SELECT DISTINCT sup.usuario_correo as supervisor_correo FROM horario_supervisor hs inner join usuario sup on sup.usuario_id =hs.usuario_id - where :facultad = ANY(hs.facultad_id_array) - and hs.turno_inicio <= :hora and hs.turno_fin >= :hora", - [':facultad'=>$reposicion_rs["facultad_id"], ':hora'=>$reposicion_rs["hora_nueva"]] ); + where :facultad = ANY(hs.facultad_id_array)", + [':facultad'=>$reposicion_rs["facultad_id"]] ); + +$sup_correos=[]; +foreach($correosSup_rs as $correo){ + array_push($sup_correos, $correo["supervisor_correo"]); +} -if($edo == 4){//cancelación - $motivo = ""; - if(isset($_POST["motivo"]) && $_POST["motivo"] != "") - $motivo = trim($_POST["motivo"]); - $db->querySingle('SELECT fu_reposicion_cancela(:id, :motivo)', - [':id' => $id_repo, ':motivo' => $motivo] - ); -}else{ - if(!empty($salon)){ - $db->querySingle('SELECT fu_reposicion_solicitud(:id, NULL, NULL, NULL, :sal, :edo, NULL, NULL, NULL, NULL)', - [':id' => $id_repo, ':sal' => $salon, ':edo' => $edo] +if($tipo ==1 || $tipo == 2){ + if($edo == 4){//cancelación + $motivo = ""; + if(isset($_POST["motivo"]) && $_POST["motivo"] != "") + $motivo = trim($_POST["motivo"]); + $db->querySingle('SELECT fu_reposicion_cancela(:id, :motivo)', + [':id' => $id_repo, ':motivo' => $motivo] ); }else{ - $db->querySingle('SELECT fu_reposicion_solicitud(:id, NULL, NULL, NULL, NULL, :edo, NULL, NULL, NULL, NULL)', - [':id' => $id_repo, ':edo' => $edo] + if(!empty($salon)){ + $db->querySingle('SELECT fu_reposicion_solicitud(:id, NULL, NULL, NULL, :sal, :edo, NULL, NULL, NULL, NULL)', + [':id' => $id_repo, ':sal' => $salon, ':edo' => $edo] + ); + }else{ + $db->querySingle('SELECT fu_reposicion_solicitud(:id, NULL, NULL, NULL, NULL, :edo, NULL, NULL, NULL, NULL)', + [':id' => $id_repo, ':edo' => $edo] + ); + } + } + + $fecha_clase = date('d/m/Y', strtotime($reposicion_rs["fecha_clase"])); + $fecha_nueva = date('d/m/Y', strtotime($reposicion_rs["fecha_nueva"])); + $hora_tmp = explode(":",$reposicion_rs["horario_hora"]); + $hora_clase = $hora_tmp[0].":".$hora_tmp[1]; + $hora_tmp = explode(":",$reposicion_rs["hora_nueva"]); + $hora_nueva = $hora_tmp[0].":".$hora_tmp[1]; + + $asunto = ""; + $texto = ""; + $to = ""; + switch($edo){ + case 2://Correo a supervisor + $asunto = "Reposición nueva - ".$reposicion_rs["clave_dependencia"]." ".$reposicion_rs["facultad"]; + //crear plantilla + $texto = "

Se creó una reposición nueva para: ".$reposicion_rs["clave_dependencia"]." ".$reposicion_rs["facultad"].".

"; + $texto .= "

".mb_strtoupper($reposicion_rs["materia"])." del día ".$fecha_clase." a las ".$hora_clase." hrs. se propone reponer el ".$fecha_nueva." a las ".$hora_nueva." hrs."; + if(!$reposicion_rs["tipoaula_supervisor"]){ + $texto .= " en el salón: ".$salon_desc."

"; + }else{ + $texto .= " en un salón de tipo: ".$reposicion_rs["tipoaula_nombre"]."

"; + } + $texto .= "

".$reposicion_rs["descripcion"]."

"; + $texto .= "

Ingresa al sistema PAAD para autorizarla.

"; + $to = join(",", $sup_correos); + $ok = 0; + break; + case 3://Correo a coordinador, profesor y jefe + $asunto = "Reposición autorizada - ".$reposicion_rs["materia"]; + $texto = "

La resposición de la clase de ".$reposicion_rs["materia"]." del día ".$fecha_clase." a las ".$hora_clase." hrs. está autorizada para realizarse el día ".$fecha_nueva." a las ".$hora_nueva." hrs. en: $salon_desc

"; + $to = join(",", $coord_correos).",".join(",", $prof_correos).",".join(",", $jefe_correos); + $ok = 0; + $db->querySingle('SELECT fu_reposicion_solicitud_supervisor(:id, :sup)', + [':id' => $id_repo, ':sup'=>$user->user["id"]] + ); + break; + 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 .= "

".$motivo."

"; + $to = join(",", $coord_correos).",".join(",", $prof_correos).",".join(",", $jefe_correos); + $ok = 1; + $db->querySingle('SELECT fu_reposicion_solicitud_supervisor(:id, :sup)', + [':id' => $id_repo, ':sup'=>$user->user["id"]] + ); + break; + } +}else{ + if($edo == 4){//cancelación + $motivo = ""; + if(isset($_POST["motivo"]) && $_POST["motivo"] != "") + $motivo = trim($_POST["motivo"]); + $db->querySingle('SELECT fu_asignacion_cancela(:id, :motivo)', + [':id' => $id_repo, ':motivo' => $motivo] ); + }else{ + if(!empty($salon)){ + $db->querySingle('SELECT fu_asignacion_solicitud(:id, NULL, NULL, :sal, :edo, NULL, NULL, NULL, NULL, NULL)', + [':id' => $id_repo, ':sal' => $salon, ':edo' => $edo] + ); + }else{ + $db->querySingle('SELECT fu_asignacion_solicitud(:id, NULL, NULL, NULL, :edo, NULL, NULL, NULL, NULL, NULL)', + [':id' => $id_repo, ':edo' => $edo] + ); + } + } + + $fecha_nueva = date('d/m/Y', strtotime($reposicion_rs["fecha_nueva"])); + $hora_tmp = explode(":",$reposicion_rs["hora_nueva"]); + $hora_nueva = $hora_tmp[0].":".$hora_tmp[1]; + + $asunto = ""; + $texto = ""; + $to = ""; + switch($edo){ + case 2://Correo a supervisor + $asunto = "Asignación nueva - ".$reposicion_rs["clave_dependencia"]." ".$reposicion_rs["facultad"]; + //crear plantilla + $texto = "

Se creó una solicitud de asignación nueva para: ".$reposicion_rs["clave_dependencia"]." ".$reposicion_rs["facultad"].".

"; + $texto .= "

Se solicita el día ".$fecha_nueva." a las ".$hora_nueva." hrs. para el profesor: ".$reposicion_rs["profesor_nombre"]."."; + if(!$reposicion_rs["tipoaula_supervisor"]){ + $texto .= " en el salón: ".$salon_desc."

"; + }else{ + $texto .= " en un salón de tipo: ".$reposicion_rs["tipoaula_nombre"]."

"; + } + $texto .= "

".$reposicion_rs["descripcion"]."

"; + $texto .= "

Ingresa al sistema PAAD para autorizarla.

"; + $to = join(",", $sup_correos); + $ok = 0; + break; + case 3://Correo a coordinador, profesor y jefe + $asunto = "Asignación autorizada - ".$reposicion_rs["profesor_nombre"]; + $texto = "

La asignación de espacio para el profesor ".$reposicion_rs["profesor_nombre"]." está autorizada para realizarse el día ".$fecha_nueva." a las ".$hora_nueva." hrs. en: $salon_desc

"; + $to = join(",", $coord_correos).",".join(",", $prof_correos).",".join(",", $jefe_correos); + $ok = 0; + $db->querySingle('SELECT fu_asignacion_solicitud_supervisor(:id, :sup)', + [':id' => $id_repo, ':sup'=>$user->user["id"]] + ); + break; + case 4://Correo a coordinador, profesor y jefe + $asunto = "Asignación declinada - ".$reposicion_rs["profesor_nombre"]; + $texto = "

La asignación de espacio para el profesor ".$reposicion_rs["profesor_nombre"]." planeada para el día ".$fecha_nueva." a las ".$hora_nueva." hrs. ha sido declinada por el siguiente motivo:

"; + $texto .= "

".$motivo."

"; + $to = join(",", $coord_correos).",".join(",", $prof_correos).",".join(",", $jefe_correos); + $ok = 1; + $db->querySingle('SELECT fu_asignacion_solicitud_supervisor(:id, :sup)', + [':id' => $id_repo, ':sup'=>$user->user["id"]] + ); + break; } } -$fecha_clase = date('d/m/Y', strtotime($reposicion_rs["fecha_clase"])); -$fecha_nueva = date('d/m/Y', strtotime($reposicion_rs["fecha_nueva"])); -$hora_tmp = explode(":",$reposicion_rs["horario_hora"]); -$hora_clase = $hora_tmp[0].":".$hora_tmp[1]; -$hora_tmp = explode(":",$reposicion_rs["hora_nueva"]); -$hora_nueva = $hora_tmp[0].":".$hora_tmp[1]; - -$asunto = ""; -$texto = ""; -$to = ""; -switch($edo){ - case 2://Correo a supervisor - $asunto = "Reposición nueva - ".$reposicion_rs["clave_dependencia"]." ".$reposicion_rs["facultad"]; - //crear plantilla - $texto = "

Se creó una reposición nueva para: ".$reposicion_rs["clave_dependencia"]." ".$reposicion_rs["facultad"].".

"; - $texto .= "

".mb_strtoupper($reposicion_rs["materia"])." del día ".$fecha_clase." a las ".$hora_clase." hrs. se propone reponer el ".$fecha_nueva." a las ".$hora_nueva." hrs."; - if(!$reposicion_rs["tipoaula_supervisor"]){ - $texto .= " en el salón: ".$salon_desc."

"; - }else{ - $texto .= " en un salón de tipo: ".$reposicion_rs["tipoaula_nombre"]."

"; - } - $texto .= "

Ingresa al sistema PAAD para autorizarla.

"; - $to = join(",", $correosSup_rs); - $ok = 0; - break; - case 3://Correo a coordinador, profesor y jefe - $asunto = "Reposición autorizada - ".$reposicion_rs["materia"]; - $texto = "

La resposición de la clase de ".$reposicion_rs["materia"]." del día ".$fecha_clase." a las ".$hora_clase." hrs. está autorizada para realizarse el día ".$fecha_nueva." a las ".$hora_nueva." hrs. en: $salon_desc

"; - $to = join(",", $coord_correos).",".join(",", $prof_correos).",".join(",", $jefe_correos); - $ok = 0; - break; - 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 .= "

".$motivo."

"; - $to = join(",", $coord_correos).",".join(",", $prof_correos).",".join(",", $jefe_correos); - $ok = 1; - break; -} - if($to!= "" && ENVIO_CORREOS){ $texto = ' La Salle @@ -166,13 +272,12 @@ if($to!= "" && ENVIO_CORREOS){ '; require_once('../include/phpmailer/PHPMailerAutoload.php'); - /*if($_ENV['DB_NAME'] == "paad_pruebas"){ + 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); - }*/ - Mailer::enviarCorreo("alejandro.rosales@lasalle.mx", $asunto, $texto, true); + } } /* diff --git a/action/reposicion_insert.php b/action/reposicion_insert.php index 6da3b42..895c9ff 100644 --- a/action/reposicion_insert.php +++ b/action/reposicion_insert.php @@ -20,15 +20,16 @@ $user = unserialize($_SESSION['user']); $duracion_id = filter_input(INPUT_POST, "duracion", FILTER_SANITIZE_NUMBER_INT);//Id reposicion $bloque = filter_input(INPUT_POST, "bloque", FILTER_SANITIZE_NUMBER_INT);// $ciclo = filter_input(INPUT_POST, "ciclo", FILTER_SANITIZE_NUMBER_INT);// -$fecha_falta = trim(htmlspecialchars($_POST["fecha_falta"], ENT_QUOTES, "UTF-8"));//limpia texto -$fecha = trim(htmlspecialchars($_POST["fecha_inicial"], ENT_QUOTES, "UTF-8"));//limpia texto fecha de reposicion -$fecha_cambio = trim(htmlspecialchars($_POST["fecha_cambio"], ENT_QUOTES, "UTF-8"));//limpia texto +$fecha_falta = trim(htmlspecialchars($_POST["fecha_falta"], ENT_QUOTES, "UTF-8"));//Reposicion +$fecha = trim(htmlspecialchars($_POST["fecha_inicial"], ENT_QUOTES, "UTF-8"));//Reposicion +$fecha_cambio = trim(htmlspecialchars($_POST["fecha_cambio"], ENT_QUOTES, "UTF-8"));//Cambio salón $hora_ini = filter_input(INPUT_POST, "hora_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto hora reposicion $min_ini = filter_input(INPUT_POST, "min_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto $hor = filter_input(INPUT_POST, "horario", FILTER_SANITIZE_NUMBER_INT);//limpia texto $alumnos = filter_input(INPUT_POST, "alumnos", FILTER_SANITIZE_NUMBER_INT);//limpia texto $tipo = filter_input(INPUT_POST, "tipo", FILTER_SANITIZE_NUMBER_INT);//1 Repo , 0 Cambio $aula = filter_input(INPUT_POST, "aula", FILTER_SANITIZE_NUMBER_INT);//1 regular , 2 sala computo, 3 otro facultad +$salon = NULL; if(!$user->jefe_carrera){//coordinador if(isset($_POST["salon"]) && $_POST["salon"] != "") @@ -36,7 +37,7 @@ if(!$user->jefe_carrera){//coordinador } if(empty($_POST["prof"])) - $prof = $user["id"]; + $prof = $user->user["id"]; else $prof = filter_input(INPUT_POST, "prof", FILTER_SANITIZE_NUMBER_INT);//limpia texto @@ -56,11 +57,13 @@ $materia = $horario_rs["materia_id"]; $dia = $horario_rs["horario_dia"]; $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)); + if($tipo == 1){//Reposición + $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)); + $fecha_falta = DateTime::createFromFormat('d/m/Y', $fecha_falta)->format('Y-m-d'); $dia_falta = date('w', strtotime($fecha_falta)); }else{ @@ -131,7 +134,7 @@ if($tipo == 1){//Reposición } }catch(Exception $e){ - echo $e->getMessage(); + echo "ERROR Reposición
".$e->getMessage(); //header("Location: ".$pag."?error=1"); exit(); } @@ -151,23 +154,23 @@ if($tipo == 1){//Reposición try{ if($user->jefe_carrera){//jefe - $db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 1, :desc, :alumnos, true, :aula, :duracion, :usr, :bloque, :ciclo)', - [':f_falta' => $fecha_falta, ':f_nueva' => $fecha_cambio, ':hora_nueva' => $hora, ':hor' => $hor, + $db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 1, :desc, :alumnos, false, :aula, :duracion, :usr, :bloque, :ciclo)', + [':f_falta' => $fecha_cambio, ':f_nueva' => $fecha_cambio, ':hora_nueva' => $hora, ':hor' => $hor, ':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"], ':bloque' => $bloque, ':ciclo' => $ciclo ] ); }else{//coordinador - $db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 2, :desc, :alumnos, true, :aula, :duracion, :usr, :bloque, :ciclo, :salon)', - [':f_falta' => $fecha_falta, ':f_nueva' => $fecha_cambio, ':hora_nueva' => $hora, ':hor' => $hor, + $db->query('SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 2, :desc, :alumnos, false, :aula, :duracion, :usr, :bloque, :ciclo, :salon)', + [':f_falta' => $fecha_cambio, ':f_nueva' => $fecha_cambio, ':hora_nueva' => $hora, ':hor' => $hor, ':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"], ':bloque' => $bloque, ':ciclo' => $ciclo, ':salon'=>$salon ] ); } }catch(Exception $e){ - - header("Location: ".$pag."?error=1"); + echo "ERROR Cambio
".$e->getMessage(); + //header("Location: ".$pag."?error=1"); exit(); } $texto = "

Se creó un cambio de salón nuevo.

"; @@ -191,13 +194,13 @@ if($to!= "" && ENVIO_CORREOS){ '; require_once('../include/phpmailer/PHPMailerAutoload.php'); - /*if($_ENV['DB_NAME'] == "paad_pruebas"){ + 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); - }*/ - Mailer::enviarCorreo("alejandro.rosales@lasalle.mx", $asunto, $texto, true); + } + } header("Location: ".$pag."?ok=0"); diff --git a/action/reposicion_select.php b/action/reposicion_select.php index 38f13af..6193346 100644 --- a/action/reposicion_select.php +++ b/action/reposicion_select.php @@ -80,6 +80,9 @@ $user = unserialize($_SESSION['user']); $return["motivo_cancelacion"] = $rs["motivo_cancelacion"]; $return["estado"] = $rs["estado_reposicion_id"]; $return["facultad"] = $rs["facultad_nombre"]; + $return["carrera"] = $rs["carrera_nombre"]; + $return["grupo"] = $rs["horario_grupo"]; + $return["supervisor_nombre"] = $rs["supervisor_nombre"]; } echo json_encode($return); ?> diff --git a/action/rutas.php b/action/rutas.php index debe75f..a3289da 100644 --- a/action/rutas.php +++ b/action/rutas.php @@ -5,7 +5,7 @@ require_once "../class/c_login.php"; $universidad_la_salle = $db ->where('salon', 'UNIVERSIDAD LA SALLE', 'ILIKE') - ->getOne('salon_view'); + ->getOne('salon_view_mat'); $rutas = array_map( @@ -14,14 +14,14 @@ $rutas = $db ->where('id_espacio_padre', $ruta['id_espacio_sgu']) ->orderBy('salon') - ->get('salon_view'); + ->get('salon_view_mat'); return $ruta; }, $db ->where('id_espacio_padre', $universidad_la_salle['id_espacio_sgu']) ->orderBy('salon') - ->get('salon_view') + ->get('salon_view_mat') ); // echo json_encode($universidad_la_salle, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); EXIT; diff --git a/action/rutas_salón_horario.php b/action/rutas_salón_horario.php index 5019750..ce34c45 100644 --- a/action/rutas_salón_horario.php +++ b/action/rutas_salón_horario.php @@ -31,7 +31,7 @@ try { $data = $db ->where('tiene_salones') ->where("{$_GET['id_espacio_sgu']} = ANY(id_espacio_sgu_array)") - ->get('salon_view', columns: 'id_espacio_sgu, salon, salon_id, salon_array'); + ->get('salon_view_mat', columns: 'id_espacio_sgu, salon, salon_id, salon_array'); $columns = [ // horario @@ -61,47 +61,51 @@ try { 'reposicion_hora_fin', 'salon_reposicion.salon as reposicion_salon', ]; + $fecha = ($_GET['fecha'] != 'null') ? ("'{$_GET['fecha']}'" ?: 'CURRENT_DATE') : 'CURRENT_DATE'; $data = array_map( fn($ruta) => array_merge( [ - 'horarios' => $db - ->join('periodo', 'periodo.periodo_id = horario_view.periodo_id') - ->join('bloque_horario', '(bloque_horario.hora_inicio, bloque_horario.hora_fin) OVERLAPS (horario_view.horario_hora, horario_view.horario_hora + horario_view.duracion)') - ->join('salon_view', 'salon_view.salon_id = horario_view.salon_id') - ->join('horario_profesor', 'horario_profesor.horario_id = horario_view.horario_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('reposicion', 'reposicion.reposicion_id = registro.reposicion_id', 'LEFT') - ->join('salon as salon_reposicion', 'salon_reposicion.salon_id = reposicion.salon_id', 'LEFT') - ->where('CURRENT_DATE BETWEEN periodo.periodo_fecha_inicio AND periodo.periodo_fecha_fin') - ->where('horario_dia = EXTRACT(DOW FROM CURRENT_DATE)') - ->where('bloque_horario.id', $_GET['bloque_horario_id']) - ->where('salon_view.id_espacio_padre', $ruta['id_espacio_sgu']) - ->orderBy('horario_hora') - ->orderBy('salon_view.salon') - ->get( - 'horario_view', - columns: $columns - ), + 'horarios' => $db->query( + "SELECT " . implode(', ', $columns) . << $_GET['bloque_horario_id'], + 'id_espacio_sgu' => $ruta['id_espacio_sgu'], + ] + ), // 'query' => $db->getLastQuery(), 'reposiciones' => $db->query( 'SELECT ' . implode(', ', $columns) . << $_GET['bloque_horario_id'], 'id_espacio_sgu' => $ruta['id_espacio_sgu'], diff --git a/action/usuario_find.php b/action/usuario_find.php index adcf171..ca70e48 100644 --- a/action/usuario_find.php +++ b/action/usuario_find.php @@ -3,21 +3,9 @@ $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']; -} +$nombre = $_POST['nombre'] ?: null; +$clave = $_POST['clave'] ?: null; +$facultad = $_POST['facultad'] ?: null; echo json_encode($db->query("SELECT * FROM fs_profesores(:nombre, :clave, :facultad) ORDER BY profesor_nombre", [':nombre' => $nombre, ':clave' => $clave, ':facultad' => $facultad])); ?> \ No newline at end of file diff --git a/asignacion_crear.php b/asignacion_crear.php index c7cb752..8648316 100644 --- a/asignacion_crear.php +++ b/asignacion_crear.php @@ -24,11 +24,15 @@ if ($user->acceso === null && !$user->admin){ exit(); } -//if (!$user->admin && in_array($user->acceso, ['n'])) - //die(header('Location: main.php?error=1')); -//$user->print_to_log('Reposiciones'); +$jefatura = false; +$coordinador = false; +if($user->rol["rol_id"]==11){ + $jefatura = true; +} +if($user->rol["rol_id"]==9){ + $coordinador = true; +} -//$write = $user->admin || in_array($user->acceso, ['w']); $write = true; // $en_fecha = $db->querySingle("SELECT ESTA_EN_PERIODO(NOW()::DATE, :periodo_id)", [':periodo_id' => $user->periodo_id])['esta_en_periodo']; @@ -166,14 +170,14 @@ if(!is_null($user->periodo_id)){ query('SELECT * FROM fs_reposiciones_solicitud(:f_ini, :f_fin, :usr ,NULL, NULL)', [':f_ini' => $fecha_ini_db, ':f_fin' => $fecha_fin_db, ':usr' => $user->user["id"]]); + $asignaciones_rs = $db->query('SELECT * FROM fs_asignaciones_solicitud(:f_ini, :f_fin, :usr ,NULL)', [':f_ini' => $fecha_ini_db, ':f_fin' => $fecha_fin_db, ':usr' => $user->user["id"]]); } ?>
0){ ?> -

Reposiciones creadas

+ if(isset($asignaciones_rs) && count($asignaciones_rs)>0){ ?> +

Asignaciones creadas

@@ -188,16 +192,16 @@ if(!is_null($user->periodo_id)){ - " id="id"> - " id="id"> + - + " id="">
" title=""> - -
d-flex mx-auto"> +
" title=""> + +
d-flex mx-auto">
- +
@@ -207,19 +211,19 @@ if(!is_null($user->periodo_id)){
".substr($reposicion["hora_nueva"],0,-3)." a ".substr($reposicion["hora_nueva_fin"],0,-3)." hrs."; + echo date("d/m/Y", strtotime($asignacion["fecha_nueva"])) ."
".substr($asignacion["hora_nueva"],0,-3)." a ".substr($asignacion["hora_nueva_fin"],0,-3)." hrs."; ?>
@@ -228,9 +232,9 @@ if(!is_null($user->periodo_id)){ jefe_carrera) || ($reposicion["estado_reposicion_id"] == 2 && !$user->jefe_carrera)){?> + + if(($asignacion["estado_reposicion_id"] == 1 && $jefatura) || ($asignacion["estado_reposicion_id"] == 2 && $coordinador)){?> @@ -349,9 +353,11 @@ if(!is_null($user->periodo_id)){
Salón
    -
  • Salón
  • -
  • Sala de cómputo
  • -
  • Salón/Taller de la facultad
  • + query('select * from tipoaula t order by t.tipoaula_id '); + foreach($tipoaula_rs as $ta){ ?> +
  • ">
  • +
@@ -367,12 +373,19 @@ if(!is_null($user->periodo_id)){ -
+
+
@@ -507,33 +520,27 @@ if(!is_null($user->periodo_id)){ $("#fecha_inicial").removeClass("is-invalid"); $("#fecha_falta").removeClass("is-invalid"); $("#fecha_cambio").removeClass("is-invalid"); - - if($("#tipo").val() == 1){//reposición - if($("#fecha_falta").val() == ""){ - $("#fecha_falta").addClass("is-invalid"); - error = true; - } - if($("#fecha_inicial").val() == ""){//fecha reposición - $("#fecha_inicial").addClass("is-invalid"); - error = true; - } - }else{ - if($("#fecha_cambio").val() == ""){ - $("#fecha_cambio").addClass("is-invalid"); - error = true; - } - } - if($("#horario").val().trim() == "" || $("#horario").val() === null){ - invalidDatalist("#horario", true); + if($("#fecha_falta").val() == ""){ + $("#fecha_falta").addClass("is-invalid"); error = true; } + if($("#fecha_inicial").val() == ""){//fecha reposición + $("#fecha_inicial").addClass("is-invalid"); + error = true; + } + + console.log(myBtn.data("tipo")); if(myBtn.data("tipo") == 2 ){ $('#formaModal').prop("action", "./action/asignacion_update.php"); }else{ $('#formaModal').prop("action", "./action/asignacion_insert.php"); } + if(!error){ + $("#loadingGroup").show(); + $("#submitGroup").hide(); + } return !error; } @@ -653,6 +660,7 @@ if(!is_null($user->periodo_id)){ var button = $(event.relatedTarget); // Button that triggered the modal var id = button.parents("tr").data("id"); $("#id_borrar").val(id); + }); $(".btn-borrar").click(function(){ @@ -682,9 +690,12 @@ if(!is_null($user->periodo_id)){ var button = $(event.relatedTarget); // Button that triggered the modal var tipo = button.data('tipo'); // 1 alta, 2 edicion var modal = $(this); + $("#loadingGroup").hide(); + $("#submitGroup").show(); $("#modal .is-invalid").removeClass("is-invalid"); //$(this).find(".form-control:first-child").focus(); + $('#submitBtn').attr("disabled", false); $("#errorBox").collapse('hide'); diff --git a/cambio_crear.php b/cambio_crear.php new file mode 100644 index 0000000..ae02933 --- /dev/null +++ b/cambio_crear.php @@ -0,0 +1,927 @@ +access(); +//profesor, admin, rol, facultad +if ($user->acceso === null && !$user->admin){ + die(header('Location: index.php')); + exit(); +} + + +$write = true; // + +$en_fecha = $db->querySingle("SELECT ESTA_EN_PERIODO(NOW()::DATE, :periodo_id)", [':periodo_id' => $user->periodo_id])['esta_en_periodo']; + + +if($user->jefe_carrera){ + //$prof_rs = $db->query('SELECT DISTINCT * FROM fs_profesores(null, null, :fac) ORDER BY PROFESOR_NOMBRE', [':fac' => $user->facultad["facultad_id"]]); + $prof_rs = $db->query('SELECT DISTINCT PROFESOR.* FROM PUESTO_USUARIO + JOIN PUESTO_MATERIA USING (PUESTO_ID) + JOIN HORARIO_VIEW USING (MATERIA_ID) + JOIN HORARIO_PROFESOR USING (HORARIO_ID) + JOIN PROFESOR USING (PROFESOR_ID) + WHERE USUARIO_ID = :usr', [':usr' => $user->user["id"]]); +}else{ + $prof_rs = $db->query('SELECT DISTINCT PROFESOR.* FROM PROFESOR + JOIN horario_profesor USING (profesor_id) + JOIN HORARIO_VIEW USING (horario_id) + WHERE FACULTAD_ID = :fac ORDER BY profesor.profesor_nombre', [':fac' => $user->facultad["facultad_id"]]); +} + +//Duraciones +$duracion_rs = $db->query("select * from duracion order by duracion_interval"); + +if(!is_null($user->periodo_id)){ + //Periodo + $periodo_rs = $db->querySingle('SELECT periodo_fecha_inicio, periodo_fecha_fin FROM periodo WHERE periodo_id = :periodo_id', [':periodo_id' => $user->periodo_id]); + $periodo_fin = $periodo_rs["periodo_fecha_fin"]; + if(strtotime($periodo_rs["periodo_fecha_inicio"])>strtotime(date("Y-m-d")) ) + $fecha_man = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_inicio"])); + else{ + $dia_actual = intval(date("w")); + $dias = 2;//días mínimos Lun a Jue + if($dia_actual ==5 || $dia_actual ==4 )//Vie + $dias=4; + else if( $dia_actual ==6 )//Sab + $dias=3; + else if( $dia_actual ==0 )//Do + $dias=2; + + $fecha_man = date("d/m/Y", strtotime("+".$dias." day")); + } + /* + // Materias + $id_prof = $user->profesor; + //$facultad_id = 28; + $materias_rs = $db->query('SELECT * FROM fs_materiasprofesor(:id)', [':id' => $id_prof]); + */ + if(isset($_POST["fecha_inicial"])) + $fecha_ini = $_POST["fecha_inicial"]; + else + $fecha_ini = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_inicio"])); + + if(isset($_POST["fecha_final"])) + $fecha_fin = $_POST["fecha_final"]; + else + $fecha_fin = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_fin"])); + + $date = DateTime::createFromFormat('d/m/Y', $fecha_ini); + $fecha_ini_db = $date->format('Y-m-d'); + + $date = DateTime::createFromFormat('d/m/Y', $fecha_fin); + $fecha_fin_db = $date->format('Y-m-d'); +} + +?> + + + + + + + Reposiciones crear | + <?= $user->facultad['facultad'] ?? "Administrador"; ?> + + + + + + + + + + + + + + + + + + + +
+ 0) {?> + +
+
+ +
+
+ +
+ + periodo_id)) { ?> +
+
+ + +
+ +
+ +
No es una fecha válida.
+
+
+
+ +
+ +
El rango de fechas no es válido.
+
+
+
+
+ + +
+
+ + query('SELECT * FROM fs_cambios_solicitud(:f_ini, :f_fin, :usr ,NULL)', [':f_ini' => $fecha_ini_db, ':f_fin' => $fecha_fin_db, ':usr' => $user->user["id"]]); + } + ?> + +
+ 0){ ?> +

Reposiciones creadas

+
+ + + + + + + + + + + + + + + " id="id"> + + + + + + + + + + + + + + +
EstadoMateriaProfesorFechaDuraciónSalónAcciones
" title=""> + +
d-flex mx-auto"> +
+
+
+ +
+ +
+ +
+ +
+ +
+ + ".substr($reposicion["horario_hora"],0,-3)." a ".substr($reposicion["horario_hora_fin"],0,-3)." hrs.";; + ?> + ".substr($reposicion["hora_nueva"],0,-3)." a ".substr($reposicion["hora_nueva_fin"],0,-3)." hrs."; + ?> + + + + jefe_carrera) || ($reposicion["estado_reposicion_id"] == 2 && !$user->jefe_carrera)){?> + + + +
+
+ periodo_id)){ ?> +
+

Selecciona un periodo

+
+ +
+

No hay solicitudes de cambio disponibles que cumplan con los filtros

+
+ +
+ + + + + + + +
+ + + + + + + + + \ No newline at end of file diff --git a/consultar_horario.php b/consultar_horario.php index 29ef71b..ff98493 100644 --- a/consultar_horario.php +++ b/consultar_horario.php @@ -181,7 +181,7 @@ $write = $user->admin || in_array($user->acceso, ['r']); :key="`${hour}-${block}-${día}`" :class="horarios.getHorarioData(hour, block, día) ? 'bg-light' : ''" class="align-middle h-100" - :style="`width: ${(100 - 6) / (horarios.structure?.sábado ? 6 : 5)}%;`"> + :style="`width: ${(100 - 6) / (horarios.structure?.sábado ? 6 : 5)}%;`" :data-id="horarios.getHorarioData(hour, block, día)?.horario_id">
+ + + + + + Histórico de horarios + + + + + + + + + + periodo_id) { ?> + + + + + + +
+ + +
+ +
+
+
+
+ + + + + +
+
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+ Carrera + + Materia + + Grupo + + Horario + + Alta + + Baja +
+ + {{horario.facultad_nombre}} + + {{horario.carrera_nombre}} + + {{horario.materia_nombre}} + + {{horario.horario_grupo}} + + {{días[horario.horario_dia]}} - {{horario.horario_hora}} - {{horario.horario_fin}} + + {{horario.horario_fecha_inicio}} + + {{horario.horario_fecha_fin}} +
+
+ + + + +
+ + + + + + + \ No newline at end of file diff --git a/import/periodo.php b/import/periodo.php index 6ff824d..b4a8e3c 100644 --- a/import/periodo.php +++ b/import/periodo.php @@ -7,7 +7,9 @@ $user or die("Error: no se pudo cargar el usuario");
get("nivel"); + $niveles = $db + ->orderBy('nivel_nombre') + ->get("nivel"); // collect facultad_id's with facultad from $periodos ?> @@ -33,7 +35,8 @@ $user or die("Error: no se pudo cargar el usuario"); WHERE nivel_id = :nivel_id AND (facultad_id = :facultad_id OR :facultad_id IS NULL) - GROUP BY periodo_id, periodo_nombre', + GROUP BY periodo_id, periodo_nombre, periodo_fecha_inicio + ORDER BY periodo_fecha_inicio DESC', [ ':nivel_id' => $nivel['nivel_id'], ':facultad_id' => $user->facultad['facultad_id'] diff --git a/include/bd_pdo_rest.php b/include/bd_pdo_rest.php new file mode 100644 index 0000000..9956764 --- /dev/null +++ b/include/bd_pdo_rest.php @@ -0,0 +1,63 @@ +load(); +use \SeinopSys\PostgresDb; + +# Connect to the database +try { + // Postgres + $pdo = new PDO("pgsql:host=" . $_ENV['DB_HOST'] . ";dbname=" . $_ENV['DB_NAME'], $_ENV['DB_USER'], $_ENV['DB_PASS']); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + $db = new PostgresDb(); + $db->setConnection($pdo); +} catch (PDOException $e) { + echo "Error: " . $e->getMessage(); +} + +// check recursivelly if the array has only empty strings +function is_response_empty($array) +{ + foreach ($array as $value) { + if (is_array($value)) { + if (!is_response_empty($value)) { + return false; + } + } else { + if (!empty($value)) { + return false; + } + } + } + return true; +} + +// SQL function +function query(string $sql, array $params = null, bool $single = true) +{ + global $pdo; + try { + $stmt = $pdo->prepare($sql); + $stmt->execute($params); + $response = $single ? $stmt->fetch(PDO::FETCH_ASSOC) : $stmt->fetchAll(PDO::FETCH_ASSOC); + + return $response; + } catch (PDOException $e) { + echo "Error: " . $e->getMessage(); + return false; + } finally { + $stmt->closeCursor(); + $stmt = null; + } +} + +function queryAll(string $sql, array $params = null) +{ + return query($sql, $params, false); +} + +function toSQLArray(array $array): string +{ + return sprintf("{%s}", implode(", ", $array)); +} diff --git a/include/db/postgrest b/include/db/postgrest new file mode 100644 index 0000000..55339e5 Binary files /dev/null and b/include/db/postgrest differ diff --git a/include/db/postgrest.conf b/include/db/postgrest.conf new file mode 100644 index 0000000..80e930d --- /dev/null +++ b/include/db/postgrest.conf @@ -0,0 +1,20 @@ +# postgrest.conf + +# The standard connection URI format, documented at +# https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING +db-uri = "postgres://postgres:4ud1t0rf4lt4$$@localhost:5432/paad_pruebas" + +# The database role to use when no client authentication is provided. +# Should differ from authenticator +db-anon-role = "postgres" + +# The secret to verify the JWT for authenticated requests with. +# Needs to be 32 characters minimum. +jwt-secret = "reallyreallyreallyreallyverysafe" +jwt-secret-is-base64 = false + +# Port the postgrest process is listening on for http requests +server-port = 3000 + +# the location root is /api +server-host = "*" \ No newline at end of file diff --git a/js/puestos.js b/js/puestos.js index 13bcd0d..acc9a9f 100644 --- a/js/puestos.js +++ b/js/puestos.js @@ -1,4 +1,6 @@ import { createApp } from 'https://unpkg.com/petite-vue?module'; + +// añade una ventana de confirmación al intentar cambiar de página const app = createApp({ message: null, puestos: [], @@ -57,6 +59,8 @@ const app = createApp({ }); const data = await res.json(); this.message = data.msg; + + modificado = false; // after 3 seconds, remove the message setTimeout(() => { this.message = null; diff --git a/materias.php b/materias.php index 1976f5b..04b96b5 100644 --- a/materias.php +++ b/materias.php @@ -163,6 +163,7 @@ if ($user->admin) { ?>
+ () diff --git a/profesores.php b/profesores.php index 050f2a2..006b68b 100644 --- a/profesores.php +++ b/profesores.php @@ -68,13 +68,12 @@ if ($user->admin) { //si es admin su facultad es null (todas las facultades) } } $fs_profesores = $db->query( - "SELECT DISTINCT PROFESOR.*, FACULTAD.* FROM profesor + "SELECT DISTINCT PROFESOR.*, horario_view.facultad as facultad_nombre, horario_view.facultad_id FROM profesor JOIN horario_profesor USING (profesor_id) - JOIN horario USING (horario_id) - JOIN facultad ON horario.facultad_id = facultad.facultad_id + JOIN horario_view USING (horario_id) WHERE profesor_nombre ILIKE COALESCE(:nombre, profesor_nombre) AND profesor_clave ILIKE COALESCE(:clave, profesor_clave) - AND facultad.facultad_id = COALESCE(:facultad, facultad.facultad_id) + AND facultad_id = COALESCE(:facultad, facultad_id) LIMIT :maxc", array( ":nombre" => "%$desc%", diff --git a/puestos.php b/puestos.php index 2faadd1..b28fc54 100644 --- a/puestos.php +++ b/puestos.php @@ -34,7 +34,7 @@
- + @@ -55,7 +55,7 @@
@@ -106,7 +106,7 @@
acceso == 'w') { ?> -
-
+
-->
@@ -186,10 +186,9 @@
  • acceso == 'w') { ?> - @click="puesto.materias.splice(puesto.materias.indexOf(materia), 1); materias.push(materia)" + @click="modificado = true; puesto.materias.splice(puesto.materias.indexOf(materia), 1); materias.push(materia)" style="cursor: pointer; transition: background-color 0.3s ease;"> - {{materia.clave_materia}} - {{materia.materia_nombre}} @@ -312,8 +311,16 @@ diff --git a/reposiciones_autorizar.php b/reposiciones_autorizar.php index dd86cb1..38ff5c5 100644 --- a/reposiciones_autorizar.php +++ b/reposiciones_autorizar.php @@ -27,10 +27,10 @@ if ($user->acceso === null && !$user->admin){ $supervisor = false; $coordinador = false; -if($user->rol["rol_id"]==7){ +if($user->rol["rol_id"]==7 || $user->rol["rol_id"]==8){ $supervisor = true; } -if($user->rol["rol_id"]==9){ +if($user->rol["rol_id"]==9 || $user->rol["rol_id"]==8){ $coordinador = true; } @@ -87,7 +87,9 @@ if($user->periodo_id!= ""){ $repEdo_rs = $db->query('SELECT * FROM fs_estado_reposicion' ); $repoParams = array(); + $asigParams = array(); $query = ""; + if($user->rol["rol_id"] == 9){//es coordinador $query .= ":facultad, "; $repoParams[":facultad"] = $user->facultad["facultad_id"]; @@ -101,7 +103,8 @@ if($user->periodo_id!= ""){ }else{ $query .= "NULL,"; } - $query .= ":f_ini, :f_fin, :edo, "; + $query .= ":f_ini, :f_fin, "; + $queryAsig = ":f_ini, :f_fin,"; $date = DateTime::createFromFormat('d/m/Y', $fecha_ini); @@ -112,6 +115,9 @@ if($user->periodo_id!= ""){ $repoParams[":f_ini"] = $fecha_ini_db; $repoParams[":f_fin"] = $fecha_fin_db; $repoParams[":edo"] = 1;//se sobreescribe + + $asigParams[":f_ini"] = $fecha_ini_db; + $asigParams[":f_fin"] = $fecha_fin_db; } ?> @@ -190,8 +196,14 @@ if($user->periodo_id!= ""){
  • + +

    + +

    + +