diff --git a/class/manda_correo.php b/class/manda_correo.php index a02c165..c4e33b5 100644 --- a/class/manda_correo.php +++ b/class/manda_correo.php @@ -1,90 +1,90 @@ -query("SELECT DISTINCT coor.usuario_correo FROM usuario coor - where rol_id = 9 and facultad_id = :fac - and coor.usuario_correo is not null and coor.usuario_correo != ''", - [':fac' => $facultad] - ); - //print_r($correos_rs); - foreach($correos_rs as $correo){ - array_push($correos, $correo["usuario_correo"]); - } - unset($correos_rs); - } - if($tipo & self::SUPERVISOR){ - /*$correosSup_rs = $db->querySingle("SELECT DISTINCT sup.usuario_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' => $facultad] );*/ - $correosSup_rs = $db->querySingle("SELECT DISTINCT usuario_correo as supervisor_correo - FROM usuario where rol_id = 7 and not estado_baja"); - foreach($correosSup_rs as $correo){ - if (!empty($correo["usuario_correo"])) - array_push($correos, $correo["usuario_correo"]); - } - unset($correosSup_rs); - } - if($tipo & self::JEFE){ - $correosJefe_rs = $db->querySingle("SELECT DISTINCT jefe.usuario_correo - FROM usuario jefe - where :id_fac = ANY(jefe.facultad_id_array) AND rol_id = 11 - and jefe.usuario_correo is not null and jefe.usuario_correo != ''", - [':id_fac' => $facultad] ); - foreach($correosJefe_rs as $correo){ - if(!empty($correo["usuario_correo"])) - array_push($correos, $correo["usuario_correo"]); - } - unset($correosJefe_rs); - } - if($tipo & self::PROFESOR && $prof_id != NULL){ - $correosProf_rs = $db->querySingle("SELECT DISTINCT prof.usuario_correo - FROM horario_profesor hs - inner join usuario prof on prof.usuario_id =hs.usuario_id - where :id_fac = ANY(hs.facultad_id_array) and prof.usuario_id = :id_prof - and prof.usuario_correo is not null and prof.usuario_correo != ''", - [':id_prof'=>$prof_id, ':id_fac' => $facultad] ); - foreach($correosProf_rs as $correo){ - if(!empty($correo["usuario_correo"])) - array_push($correos, $correo["usuario_correo"]); - } - unset($correosProf_rs); - } - $to .= join(",", $correos); - } - - if($to!= "" && self::ENVIO_CORREOS){ - //crear plantilla - $texto = ' - La Salle - '.$texto.' - '; - - if($_ENV['DB_NAME'] == "paad_pruebas" || self::PRUEBAS){ - $asunto = "PRUEBAS-".$asunto; - } - return Mailer::enviarCorreo($to, $asunto, $texto, true); - - } - return true; - } -} +query("SELECT DISTINCT coor.usuario_correo FROM usuario coor + where rol_id = 9 and facultad_id = :fac + and coor.usuario_correo is not null and coor.usuario_correo != ''", + [':fac' => $facultad] + ); + //print_r($correos_rs); + foreach($correos_rs as $correo){ + array_push($correos, $correo["usuario_correo"]); + } + unset($correos_rs); + } + if($tipo & self::SUPERVISOR){ + /*$correosSup_rs = $db->querySingle("SELECT DISTINCT sup.usuario_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' => $facultad] );*/ + $correosSup_rs = $db->querySingle("SELECT DISTINCT usuario_correo as supervisor_correo + FROM usuario where rol_id = 7 and not estado_baja"); + foreach($correosSup_rs as $correo){ + if (!empty($correo["usuario_correo"])) + array_push($correos, $correo["usuario_correo"]); + } + unset($correosSup_rs); + } + if($tipo & self::JEFE){ + $correosJefe_rs = $db->querySingle("SELECT DISTINCT jefe.usuario_correo + FROM usuario jefe + where :id_fac = facultad_id AND rol_id = 11 + and jefe.usuario_correo is not null and jefe.usuario_correo != ''", + [':id_fac' => $facultad] ); + foreach($correosJefe_rs as $correo){ + if(!empty($correo["usuario_correo"])) + array_push($correos, $correo["usuario_correo"]); + } + unset($correosJefe_rs); + } + if($tipo & self::PROFESOR && $prof_id != NULL){ + $correosProf_rs = $db->querySingle("SELECT DISTINCT prof.usuario_correo + FROM horario_profesor hs + inner join usuario prof on prof.usuario_id =hs.usuario_id + where :id_fac = hs.facultad_id and prof.usuario_id = :id_prof + and prof.usuario_correo is not null and prof.usuario_correo != ''", + [':id_prof'=>$prof_id, ':id_fac' => $facultad] ); + foreach($correosProf_rs as $correo){ + if(!empty($correo["usuario_correo"])) + array_push($correos, $correo["usuario_correo"]); + } + unset($correosProf_rs); + } + $to .= join(",", $correos); + } + + if($to!= "" && self::ENVIO_CORREOS){ + //crear plantilla + $texto = ' + La Salle + '.$texto.' + '; + + if($_ENV['DB_NAME'] == "paad_pruebas" || self::PRUEBAS){ + $asunto = "PRUEBAS-".$asunto; + } + return Mailer::enviarCorreo($to, $asunto, $texto, true); + + } + return true; + } +} ?> \ No newline at end of file diff --git a/rest/horarios.php b/rest/horarios.php index 6679565..a3d7235 100644 --- a/rest/horarios.php +++ b/rest/horarios.php @@ -182,7 +182,7 @@ try{ //claves de carreras en el periodo $arreglo_claves = array_map(function ($item) { - return $item['clave_carrera']; + return intval($item['clave_carrera']); }, $carreras_rs); //print_r($selectedData); exit(); @@ -191,6 +191,9 @@ try{ //Recorre SGU y genera hash foreach( $selectedData as $row ){ + //if ($debug) + // echo trim($row["HoraInicio"]."|".($row["NombreMateria"])."|".(trim($row["ClaveProfesor"])==""?"000000":trim($row["ClaveProfesor"]))."|".$row["IdEspacio"]."|".$per["periodo_id"]."|".$row["Carrera"])."[{$row["ClaveCarrera"]}]|{$row["EsMateriaPorReposicion"]}*"; + if(!$row["EsMateriaPorReposicion"]){ $carrera = $row["ClaveCarrera"]; if(is_null($carrera) || empty($carrera)) @@ -245,12 +248,15 @@ try{ //$areacomun = array(); foreach($sguHash as $sgu){ - if(in_array($sgu["data"]["ClaveCarrera"] , $arreglo_claves) /*&& !in_array($sgu["data"]["ClaveMateria"], $areacomun)*/){ + //print_r($sgu["data"]); + //echo $sgu["data"]["NombreMateria"]. "[".intval($sgu["data"]["ClaveCarrera"])."] =".in_array( intval($sgu["data"]["ClaveCarrera"]) , $arreglo_claves)."     "; + if(in_array( intval($sgu["data"]["ClaveCarrera"]) , $arreglo_claves) /*&& !in_array($sgu["data"]["ClaveMateria"], $areacomun)*/){ $horarios_sgu[] = $sgu; } } + //echo "


"; - //print_r($horarios_sgu);exit(); + //print_r($horarios_sgu["hash"]); unset($sguHash); $elementos_sgu_total = array_merge($elementos_sgu_total, $horarios_sgu); diff --git a/solicitudes_autorizar.php b/solicitudes_autorizar.php index 18ebe1f..3361c95 100644 --- a/solicitudes_autorizar.php +++ b/solicitudes_autorizar.php @@ -1,1068 +1,1070 @@ -access(); -//echo $user; -/*print_r($user); -print_r($user->user["id"]); -echo "****|"; -print_r($user->acceso);//null sin permisos, w o r -echo "|****|"; -print_r($user->profesor); -echo "|****|"; -print_r($user->facultad["facultad_id"]); -exit();*/ -//profesor, admin, rol, facultad -if ($user->acceso === null && !$user->admin){ - die(header('Location: index.php')); - exit(); -} - -$supervisor = false; -$coordinador = false; -if($user->rol["rol_id"]==7 || $user->rol["rol_id"]==8){ - $supervisor = true; -} -if($user->rol["rol_id"]==9 || $user->rol["rol_id"]==8){ - $coordinador = true; -} - -//$user->print_to_log('Reposiciones'); -//$write = $user->admin || in_array($user->acceso, ['w']); -$write = true; // - -function duracionMinutos($fechahora_i, $fechahora_f){ - return round((strtotime($fechahora_f) - strtotime($fechahora_i)) / 60,2); -} -//if($user->periodo_id!= ""){ - //$en_fecha = $db->querySingle("SELECT ESTA_EN_PERIODO(NOW()::DATE, :periodo_id)", [':periodo_id' => $user->periodo_id])['esta_en_periodo']; - - $profesores_rs = array(); - $tab_inicial = 1; - /*if(!$supervisor){ - $fac_id = $user->facultad["facultad_id"]; - $carrera_rs = $db->query('SELECT * FROM fs_profesor_facultad(:fac, :periodo)', [':fac'=>$fac_id, ':periodo' => $user->periodo_id]); - }else{ - $carrera_rs = $db->query('SELECT * FROM fs_profesor_facultad(NULL, :periodo)', [ ':periodo' => $user->periodo_id]); - }*/ - - $salones_rs = $db->query('SELECT * from salon_view where es_salon is true'); - - //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{ - $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; - - $fecha_man = date("d/m/Y", strtotime("+".$dias." day")); - }*/ - - // Fechas filtro - if(isset($_POST["fecha_inicial"])) - $fecha_ini = $_POST["fecha_inicial"]; - else - $fecha_ini = date("d/m/Y", strtotime("-30 day")); - //$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("30 day")); - //$fecha_fin = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_fin"])); - - //Reposiciones - $repEdo_rs = $db->query('SELECT * FROM fs_estado_reposicion' ); - - $repoParams = array(); - - $query = ""; - - if($user->rol["rol_id"] == 9){//es coordinador - $query .= ":facultad, "; - $repoParams[":facultad"] = $user->facultad["facultad_id"]; - }else{//supervisor - $query .= "NULL, "; - } - if(isset($_POST["prof"]) ){ - $query .= ":prof,"; - $profesor = trim($_POST["prof"]);//limpia texto - $repoParams[":prof"] = $profesor; - }else{ - $query .= "NULL,"; - } - $query .= ":f_ini, :f_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'); - $repoParams[":f_ini"] = $fecha_ini_db; - $repoParams[":f_fin"] = $fecha_fin_db; - $repoParams[":edo"] = 1;//se sobreescribe -//} -?> - - - - - Reposiciones autorizar | <?= $user->facultad['facultad'] ?? 'General' ?> - - - - - - - - - - - - - - - - - - - - - - - " ?> -
- -
- - - periodo_id!= ""){ ?> -
-
- - -
- -
- -
No es una fecha válida.
-
-
-
- -
- -
El rango de fechas no es válido.
-
-
-
- -
- -
-
-
-
- - -
- -
- -
- - -

- -

-
- - - - -
- -
- rol["rol_id"] == 7){//es supervisor - $repoParams[":sup"] = $user->user["id"]; - $solicitudes_rs = $db->query('SELECT * FROM fs_solicitud(NULL, '.$query.':edo, NULL, :sup) ', $repoParams ); - }else{ - $solicitudes_rs = $db->query('SELECT * FROM fs_solicitud(NULL, '.$query.':edo, NULL, NULL) ', $repoParams ); - } - - - if(count($solicitudes_rs)==0){ - echo "

No hay reposiciones en este estado

"; - }else{ - ?> - -

>

- - - - - - - - - - - - - - - - " data-edo="" id="id"> - - - - - - - - - - - - - -
EstadoTipoProfesor/MateriaFecha faltaFecha reposiciónSalónAcciones
- -
d-flex mx-auto"> -
-
-
- -
- -
- -
- -
- -
- - -
- - - - -
".substr($reposicion["horario_hora"],0, 5); - }else{ - echo " - "; - } - ?> - ".substr($reposicion["hora_nueva"],0, 5)." a ".substr($reposicion["hora_nueva_fin"],0, 5); - ?> - - - - jefe_carrera || $user->admin || !$coordinador) && $reposicion["estado_reposicion_id"] == 1){?> - " title="Aprobar"> - admin) && $reposicion["estado_reposicion_id"] == 2){?> - " title="Autorizar" > - - " title="Ver detalle"> - - - " title="Ver detalle"> - - - jefe_carrera || $user->admin || $coordinador) && $reposicion["estado_reposicion_id"] == 1)/* nueva */ - || (($user->admin || $coordinador || $supervisor) && $reposicion["estado_reposicion_id"] == 2)/* aprobado facultad */ - ){ - ?> - - -
- -
- -
- - - - - - - -
- - - - - +access(); +//echo $user; +/*print_r($user); +print_r($user->user["id"]); +echo "****|"; +print_r($user->acceso);//null sin permisos, w o r +echo "|****|"; +print_r($user->profesor); +echo "|****|"; +print_r($user->facultad["facultad_id"]); +exit();*/ +//profesor, admin, rol, facultad +if ($user->acceso === null && !$user->admin){ + die(header('Location: index.php')); + exit(); +} + +$supervisor = false; +$coordinador = false; +if($user->rol["rol_id"]==7 || $user->rol["rol_id"]==8){ + $supervisor = true; +} +if($user->rol["rol_id"]==9 || $user->rol["rol_id"]==8){ + $coordinador = true; +} + +//$user->print_to_log('Reposiciones'); +//$write = $user->admin || in_array($user->acceso, ['w']); +$write = true; // + +function duracionMinutos($fechahora_i, $fechahora_f){ + return round((strtotime($fechahora_f) - strtotime($fechahora_i)) / 60,2); +} +//if($user->periodo_id!= ""){ + //$en_fecha = $db->querySingle("SELECT ESTA_EN_PERIODO(NOW()::DATE, :periodo_id)", [':periodo_id' => $user->periodo_id])['esta_en_periodo']; + + $profesores_rs = array(); + $tab_inicial = 1; + /*if(!$supervisor){ + $fac_id = $user->facultad["facultad_id"]; + $carrera_rs = $db->query('SELECT * FROM fs_profesor_facultad(:fac, :periodo)', [':fac'=>$fac_id, ':periodo' => $user->periodo_id]); + }else{ + $carrera_rs = $db->query('SELECT * FROM fs_profesor_facultad(NULL, :periodo)', [ ':periodo' => $user->periodo_id]); + }*/ + + $salones_rs = $db->query('SELECT * from salon_view where es_salon is true'); + + //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{ + $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; + + $fecha_man = date("d/m/Y", strtotime("+".$dias." day")); + }*/ + + // Fechas filtro + if(isset($_POST["fecha_inicial"])) + $fecha_ini = $_POST["fecha_inicial"]; + else + $fecha_ini = date("d/m/Y", strtotime("-30 day")); + //$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("30 day")); + //$fecha_fin = date("d/m/Y", strtotime($periodo_rs["periodo_fecha_fin"])); + + //Reposiciones + $repEdo_rs = $db->query('SELECT * FROM fs_estado_reposicion' ); + + $repoParams = array(); + + $query = ""; + + if($user->rol["rol_id"] == 7){//es coordinador + $query .= "NULL, "; + }else{//supervisor + $query .= ":facultad, "; + $repoParams[":facultad"] = $user->facultad["facultad_id"]; + } + if(isset($_POST["prof"]) ){ + $query .= ":prof,"; + $profesor = trim($_POST["prof"]);//limpia texto + $repoParams[":prof"] = $profesor; + }else{ + $query .= "NULL,"; + } + $query .= ":f_ini, :f_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'); + $repoParams[":f_ini"] = $fecha_ini_db; + $repoParams[":f_fin"] = $fecha_fin_db; + $repoParams[":edo"] = 1;//se sobreescribe +//} +?> + + + + + Reposiciones autorizar | <?= $user->facultad['facultad'] ?? 'General' ?> + + + + + + + + + + + + + + + + + + + + + + + " ?> +
+ +
+ + + periodo_id!= ""){ */ ?> +
+
+ + +
+ +
+ +
No es una fecha válida.
+
+
+
+ +
+ +
El rango de fechas no es válido.
+
+
+
+ +
+ +
+
+
+
+ + +
+ +
+ +
+ + +

+ +

+
+ + + + +
+ +
+ rol["rol_id"] == 7){//es supervisor + $repoParams[":sup"] = $user->user["id"]; + $solicitudes_rs = $db->query('SELECT * FROM fs_solicitud(NULL, '.$query.':edo, NULL, :sup) ', $repoParams ); + }else{ + $solicitudes_rs = $db->query('SELECT * FROM fs_solicitud(NULL, '.$query.':edo, NULL, NULL) ', $repoParams ); + } + + + if(count($solicitudes_rs)==0){ + echo "

No hay reposiciones en este estado

"; + }else{ + ?> + +

>

+ + + + + + + + + + + + + + + + " data-edo="" id="id"> + + + + + + + + + + + + + +
EstadoTipoProfesor/MateriaFecha faltaFecha reposiciónSalónAcciones
+ +
d-flex mx-auto"> +
+
+
+ +
+ +
+ +
+ +
+ +
+ + +
+ + + + +
".substr($reposicion["horario_hora"],0, 5); + }else{ + echo " - "; + } + ?> + ".substr($reposicion["hora_nueva"],0, 5)." a ".substr($reposicion["hora_nueva_fin"],0, 5); + ?> + + + + jefe_carrera || $user->admin || !$coordinador) && $reposicion["estado_reposicion_id"] == 1){?> + " title="Aprobar"> + admin) && $reposicion["estado_reposicion_id"] == 2){?> + " title="Autorizar" > + + " title="Ver detalle"> + + + " title="Ver detalle"> + + + jefe_carrera || $user->admin || $coordinador) && $reposicion["estado_reposicion_id"] == 1)/* nueva */ + || (($user->admin || $coordinador || $supervisor) && $reposicion["estado_reposicion_id"] == 2)/* aprobado facultad */ + ){ + ?> + + +
+ +
+ +
+ + + + + + + +
+ + + + + \ No newline at end of file