From 113ac2aeddc4471a4662c805761cdbc03b88d97c Mon Sep 17 00:00:00 2001 From: Alejandro Rosales Date: Mon, 22 Jan 2024 16:12:37 +0000 Subject: [PATCH] Fixes and improvements to main.php, test.php, c_login.php, reposicion_profesor_materias.php, puesto.php, action_usuarios_insert.php, periodos.php, reposicion_autoriza.php, profesor_faltas.php --- action/action_usuarios_insert.php | 23 +++-- action/asignacion_insert.php | 120 ++++++++++++++++++++++++ action/periodos.php | 6 +- action/profesor_faltas.php | 12 +-- action/puesto.php | 3 +- action/reposicion_autoriza.php | 7 +- action/reposicion_insert.php | 72 +++++++++----- action/reposicion_profesor_materias.php | 6 +- action/reposicion_update.php | 9 +- asignacion_crear.php | 87 +++++------------ class/c_login.php | 2 +- consultar_horario.php | 25 ++++- main.php | 2 +- puestos.php | 41 +++++--- reposiciones_crear.php | 66 +++++++++++-- test.php | 20 +--- usuarios.php | 21 ++++- 17 files changed, 366 insertions(+), 156 deletions(-) create mode 100644 action/asignacion_insert.php 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 = ' + La Salle + '.$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){ '; 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 9b1b940..6da3b42 100644 --- a/action/reposicion_insert.php +++ b/action/reposicion_insert.php @@ -21,21 +21,25 @@ $duracion_id = filter_input(INPUT_POST, "duracion", FILTER_SANITIZE_NUMBER_INT); $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 = 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 -$hora_ini = filter_input(INPUT_POST, "hora_ini", FILTER_SANITIZE_NUMBER_INT);//limpia texto +$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 +if(!$user->jefe_carrera){//coordinador + if(isset($_POST["salon"]) && $_POST["salon"] != "") + $salon = filter_input(INPUT_POST, "dlSalon", 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 @@ -79,7 +83,7 @@ $materia_rs = $db->querySingle('SELECT materia_nombre from materia where materi //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"]] + select coalesce(facultad_id,0) from usuario u where u.usuario_id = :id_usr) and coor.usuario_correo != \'\'',[':rol_coord' => COORDINADOR, ':id_usr' => $user->user["id"]] ); if( count($correos_rs) > 0 ){ $to = $correos_rs["usuario_correo"]; @@ -108,20 +112,33 @@ if($tipo == 1){//Reposición } try{ - $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_new, ':hora_nueva' => $hora, ':hor' => $hor, - ':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"], - ':bloque' => $bloque, ':ciclo' => $ciclo - ] - ); + 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_new, ':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 + echo 'SELECT * from fi_reposicion_solicitud(:f_falta, :f_nueva, :hora_nueva, :hor, :prof, 2, :desc, :alumnos, true, :aula, :duracion, :usr, :bloque, :ciclo, '.$salon.')'; + $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_new, ':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){ echo $e->getMessage(); //header("Location: ".$pag."?error=1"); exit(); } + $fecha_clase = date('d/m/Y', strtotime($fecha_falta)); + $fecha_nueva = date('d/m/Y', strtotime($fecha_new)); $texto = "

Se creó una reposición nueva.

"; - $texto .= "

".mb_strtoupper($materia_rs["materia_nombre"])." del día ".$fecha_falta." a las ".$hor." hrs. se propone reponer el ".$fecha_new." a las ".$hora." hrs."; + $texto .= "

".mb_strtoupper($materia_rs["materia_nombre"])." del día ".$fecha_clase." a las ".$horario_rs["horario_hora"]." hrs. se propone reponer el ".$fecha_nueva." a las ".$hora." hrs."; $texto .= "

Ingresa al sistema PAAD para autorizarla.

"; /* @@ -133,19 +150,28 @@ if($tipo == 1){//Reposición }else{//Cambio salón / hora try{ - $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, - ':prof' => $prof, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo, ':usr'=>$user->user["id"], - ':bloque' => $bloque, ':ciclo' => $ciclo - ] - ); + 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, + ':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, + ':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"); exit(); } $texto = "

Se creó un cambio de salón nuevo.

"; - $texto .= "

".mb_strtoupper($materia_rs["materia_nombre"])." del día ".$fecha_falta." a las ".$hora." hrs. se propone reponer el ".$fecha_nueva." a las ".$hora_nueva." hrs."; + $texto .= "

".mb_strtoupper($materia_rs["materia_nombre"])." del día ".$fecha_falta." a las ".$hora." hrs. se propone reponer el ".$fecha_nueva." a las ".$hora." hrs."; $texto .= "

Ingresa al sistema PAAD para autorizarlo.

"; /* @@ -156,7 +182,6 @@ if($tipo == 1){//Reposición } - if($to!= "" && ENVIO_CORREOS){ $asunto = "Reposición nueva - solicitud"; //crear plantilla @@ -166,14 +191,15 @@ 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); } -exit(); header("Location: ".$pag."?ok=0"); +exit(); ?> diff --git a/action/reposicion_profesor_materias.php b/action/reposicion_profesor_materias.php index d411a7c..12832bf 100644 --- a/action/reposicion_profesor_materias.php +++ b/action/reposicion_profesor_materias.php @@ -22,7 +22,11 @@ $user = unserialize($_SESSION['user']); $id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto try{ - $rs = $db->query('SELECT * FROM fs_materiasprofesor(:id, :jefe)', [':id' => $id, ':jefe'=>$user->user["id"]] ); + if($user->jefe_carrera){ + $rs = $db->query('SELECT * FROM fs_materiasprofesor(:id, :jefe)', [':id' => $id, ':jefe'=>$user->user["id"]] ); + }else{ + $rs = $db->query('SELECT * FROM fs_materiasprofesor(:id, NULL)', [':id' => $id] ); + } }catch(Exception $e){ $return["error"] = "Ocurrió un error al leer los datos de las materias."; diff --git a/action/reposicion_update.php b/action/reposicion_update.php index 741f678..fc11a8e 100644 --- a/action/reposicion_update.php +++ b/action/reposicion_update.php @@ -87,9 +87,10 @@ if($tipo == 1){//Reposición //Valida que profesor no este en 2 reposiciones al mismo tiempo */ - $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 = $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"; @@ -104,7 +105,7 @@ if($tipo == 1){//Reposición } try{ - $db->query('SELECT * from fu_reposicion_solicitud(:id, :f_falta, :f_nueva, :hora_nueva, NULL, 1, :desc, :alumnos, :aula, :duracion, NULL)', + $db->query('SELECT * from fu_reposicion_solicitud(:id, :f_falta, :f_nueva, :hora_nueva, NULL, NULL, :desc, :alumnos, :aula, :duracion, NULL)', [':id'=> $id, ':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo ] @@ -112,7 +113,7 @@ try{ }catch(Exception $e){ //header("Location: ".$pag."?error=2"); print_r($e->getMessage()); - echo "SELECT * from fu_reposicion_solicitud(:id, :f_falta, :f_nueva, :hora_nueva, NULL, 1, :desc, :alumnos, :aula, :duracion, NULL)'"; + echo "SELECT * from fu_reposicion_solicitud(:id, :f_falta, :f_nueva, :hora_nueva, NULL, NULL, :desc, :alumnos, :aula, :duracion, NULL)'"; print_r( [':id'=> $id, ':f_falta' => $fecha_falta, ':f_nueva' => $fecha_new, ':hora_nueva' => $hora, ':desc' => $comentario, ':alumnos' => $alumnos, ':aula' => $aula, ':duracion' => $duracion_tiempo diff --git a/asignacion_crear.php b/asignacion_crear.php index e922dcb..c7cb752 100644 --- a/asignacion_crear.php +++ b/asignacion_crear.php @@ -37,8 +37,9 @@ $en_fecha = $db->querySingle("SELECT ESTA_EN_PERIODO(NOW()::DATE, :periodo_id)", //$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 PROFESOR - JOIN HORARIO_VIEW USING (PROFESOR_ID_ID) - WHERE FACULTAD_ID = :fac', [':fac' => $user->facultad["facultad_id"]]); + 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 @@ -51,13 +52,14 @@ if(!is_null($user->periodo_id)){ 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{ - $dias = 3; - if( intval(date("w")) >=3 && intval(date("w"))<=5 )//Mie a Vie - $dias+=3; - else if( intval(date("w")) ==6 )//Sab - $dias+=2; - else if( intval(date("w")) ==0 )//Do - $dias+=1; + $dia_actual = intval(date("w")); + $dias = 1;//días mínimos Lun a Jue + if($dia_actual ==5 )//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")); } @@ -131,7 +133,7 @@ if(!is_null($user->periodo_id)){
- +
@@ -164,7 +166,6 @@ 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"]]); } ?> @@ -179,8 +180,7 @@ if(!is_null($user->periodo_id)){ Estado Responsable - Fecha falta - Fecha reposición + Fecha solicitada Duración Salón Acciones @@ -207,11 +207,7 @@ if(!is_null($user->periodo_id)){ - - ".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."; @@ -234,7 +230,7 @@ if(!is_null($user->periodo_id)){ + if(($reposicion["estado_reposicion_id"] == 1 && $user->jefe_carrera) || ($reposicion["estado_reposicion_id"] == 2 && !$user->jefe_carrera)){?> @@ -263,7 +259,7 @@ if(!is_null($user->periodo_id)){