asistenciasprofesor_select.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /* AJAX
  3. * Selecciona los datos de la carrera
  4. * Recibe:
  5. * id - ID del admin
  6. * fechaini, fechafin rango de fechas de consulta
  7. * Return:
  8. * resultado o cadena de error
  9. */
  10. require_once("../../include/constantes.php");
  11. require_once("../../include/nocache.php");
  12. require_once("../../include/bd_pdo.php");
  13. require_once("../../classes/ValidaSesion.php");
  14. //--- Objeto para validar usuario. El id de usuario lo lee desde sesión
  15. $objSesion = new ValidaSesion($pdo, 23, APSA);
  16. if(!$objSesion->tieneAcceso()){
  17. $return["error"] = "Error! No tienes permisos para realizar esta acción.";
  18. }else if(!isset($_POST["hor"])){
  19. $return["error"] = "Error! No se recibió la información del usuario.";
  20. }else{
  21. $id = "";
  22. if(!empty($_POST["id"]))
  23. $id = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  24. else
  25. $id = $_SESSION["usuario_id"];
  26. $hor = filter_input(INPUT_POST, "hor", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  27. $stmt = $pdo->prepare('Select * from fs_asistenciaprofesor_horario(:id, :hor)');
  28. $stmt->bindParam(":id", $id);
  29. $stmt->bindParam(":hor", $hor);
  30. if(!$stmt->execute()){
  31. $return["error"] = "Ocurrió un error al leer las asistencias del usuario.";
  32. }else{
  33. $rs = $stmt->fetchAll();
  34. $stmt->closeCursor();
  35. $stmt = null;
  36. $asistArr = array();
  37. foreach($rs as $row){
  38. $asistArr[] = $row["Asistencia_inicial"];
  39. }
  40. $return["asistenciaArr"] = $asistArr;
  41. }
  42. }
  43. $return["json"] = json_encode($return);
  44. echo json_encode($return);
  45. ?>