reposicion_autoriza.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. /*
  3. Cambia de estado la reposición
  4. */
  5. require_once("../../include/constantes.php");
  6. require_once("../../include/bd_pdo.php");
  7. require_once("../../classes/ValidaSesion.php");
  8. require_once("../classes/LogActividad.php");//die on error
  9. require_once("../../include/util.php");
  10. require_once("../include/validacionesHorario.php");
  11. require_once('../../include/phpmailer/PHPMailerAutoload.php');
  12. require_once ("../../classes/Mailer.php");
  13. require_once("../../include/nusoap/nusoap.php");
  14. $pag = "../reposicion.php";
  15. //--- Objeto para validar usuario. El id de usuario lo lee desde sesión
  16. $objSesion = new ValidaSesion($pdo, 52, APSA);
  17. if(!$objSesion->tieneAcceso()){
  18. $objSesion->terminaSesion();
  19. //print_r($objSesion->getError());
  20. }
  21. if(!$objSesion->puedeEditar()){
  22. header("Location: ".$pag);
  23. exit();
  24. }
  25. unset($objValida);
  26. if(!isset($_POST["id"]) || !isset($_POST["edo"]) ){
  27. header("Location: ".$pag."?error=0");
  28. exit();
  29. }
  30. $id_repo = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  31. $id_cronos = filter_input(INPUT_POST, "id_cronos", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  32. $edo = filter_input(INPUT_POST, "edo", FILTER_SANITIZE_NUMBER_INT);//limpia texto
  33. if(isset($_POST["salon"]) && $_POST["salon"] != "")
  34. $salon = trim(filter_input(INPUT_POST, "salon", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  35. $salon_desc = trim(filter_input(INPUT_POST, "salon_desc", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
  36. if(!empty($id_cronos) && $edo>=3){//sincronoza reposiciones
  37. $client = new nusoap_client('http://200.13.89.27/checador_otros/admin_checador/webservice/reposiciones_service.php?wsdl', 'wsdl');
  38. $error = $client->getError();
  39. if ($error) {
  40. header("Location:".$pag."?error=12");
  41. exit();
  42. }
  43. $token = password_hash("W3bS3rv1c3.R3p0##", PASSWORD_DEFAULT);
  44. if(isset($salon)) $result = $client->call("reposicion_actualiza_estado", array($token, $id_cronos, $edo, $salon_desc, ""));
  45. else $result = $client->call("reposicion_actualiza_estado", array($token, $id_cronos, $edo, "", ""));
  46. //print_r($result);
  47. //exit();
  48. if ($client->fault) {
  49. header("Location:".$pag."?error=12");
  50. exit();
  51. } else {
  52. $error = $client->getError();
  53. if ($error) {
  54. header("Location:".$pag."?error=12");
  55. exit();
  56. } else {
  57. $ok = $result["result"];
  58. if(!$ok){
  59. header("Location:".$pag."?error=12");
  60. exit();
  61. }
  62. }
  63. }
  64. }
  65. //Valida que tenga clase en la fecha de falta
  66. if(!empty($salon)) $stmt = $pdo->prepare('SELECT fu_reposicion(:id, NULL, NULL, :sal, :edo, NULL, NULL, NULL, NULL, NULL)');
  67. else $stmt = $pdo->prepare('SELECT fu_reposicion(:id, NULL, NULL, NULL, :edo, NULL, NULL, NULL, NULL, NULL)');
  68. $stmt->bindParam(":id", $id_repo);
  69. $stmt->bindParam(":edo", $edo);
  70. if(!empty($salon)) $stmt->bindParam(":sal", $salon);
  71. if(!$stmt->execute()){
  72. //print_r($stmt->errorInfo());
  73. header("Location:".$pag."?error=1");
  74. exit();
  75. }
  76. $stmt->closeCursor();
  77. $stmt = null;
  78. $stmt = $pdo->prepare('Select * from fs_reposicion(:id, :periodo, NULL, NULL, NULL, NULL, NULL, 0, 1)');
  79. $stmt->bindParam(":id", $id_repo);
  80. $stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
  81. if(!$stmt->execute()){
  82. header("Location:".$pag."?error=1");
  83. exit();
  84. }
  85. $rs = $stmt->fetch();
  86. $stmt->closeCursor();
  87. $stmt = null;
  88. $stmt = $pdo->prepare('Select * from fs_contacto(:usr, 3, NULL)');//3 = correo
  89. $stmt->bindParam(":usr", $rs["Usuario_id"]);
  90. if(!$stmt->execute()){
  91. header("Location:".$pag."?error=1");
  92. exit();
  93. }
  94. $correos_rs = $stmt->fetchAll();
  95. $stmt->closeCursor();
  96. $stmt = null;
  97. $correoList = "";
  98. foreach($correos_rs as $c){
  99. if($c.substr("lasallistas.org,mx",0) || $c.substr("lasalle.mx",0)){
  100. $correoList .= $c.";";
  101. }
  102. }
  103. //$correoHTML = "<p>Se aprobó la reposición para el <b> a las </b> en el salón <b></b>.</p>";
  104. $log = new LogActividad();
  105. if($edo == 4){
  106. $desc_log = "Cancela reposición ID[".$id_repo."] edo[".$edo."]";
  107. $ok = 2;
  108. }else{
  109. $desc_log = "Autoriza reposición ID[".$id_repo."] edo[".$edo."] Salon[".(empty($salon)?"":$salon)."]";
  110. $ok = 0;
  111. if($edo == 5){
  112. $ok = 1;
  113. /*if($correoList!= "")
  114. Mailer::enviarCorreo($correoList , "Reposición autorizada", $correoHTML);*/
  115. }
  116. if($edo == 3){
  117. $ok = 3;
  118. /*if($correoList!= "")
  119. Mailer::enviarCorreo($correoList , "Reposición autorizada", $correoHTML);*/
  120. }
  121. }
  122. $log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);
  123. header("Location: ".$pag."?ok=".$ok);
  124. exit();
  125. ?>