reposiciones.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. //no index
  3. header("X-Robots-Tag: noindex, nofollow", true);
  4. //no caché
  5. header('Expires: Sun, 01 Jan 2014 00:00:00 GMT');
  6. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
  7. header('Cache-Control: no-store, no-cache, must-revalidate');
  8. header('Cache-Control: post-check=0, pre-check=0', false);
  9. header('Pragma: no-cache');
  10. date_default_timezone_set('America/Mexico_City');
  11. //header("Content-Type: text/xml; charset=UTF-8");
  12. require_once("../include/util.php");
  13. require_once("../include/nusoap/nusoap.php");
  14. require_once("../include/bd_pdo.php");
  15. define("PAG", "http://200.13.89.27/webservice/reposiciones_service");//pruebas
  16. $server = new soap_server();
  17. $server->configureWSDL("reposiciones_service", PAG);
  18. //Create a complex types
  19. function reposicion_autoriza($token, $id_repo, $salon){
  20. global $pdo;
  21. //$pass_hash = password_hash("W3bS3rv1c3.R3p0##", PASSWORD_DEFAULT);
  22. $ok = true;
  23. $rep_id = 0;
  24. $resultMsg = "Ocurrió un error al crear la reposición";
  25. if(!password_verify("W3bS3rv1c3.R3p0##", $token)){
  26. $array = array("result"=>false, "result_msg"=>"Token de conexión inválido");
  27. return $array;
  28. }
  29. try{
  30. $stmt = $pdo->prepare('SELECT * from fu_reposicion_autoriza(:id,:salon, 5)');//estado 5 aprobado
  31. $stmt->bindParam(":id", $id_repo);
  32. $stmt->bindParam(":salon", $salon);
  33. if(!$stmt->execute()){
  34. $resultMsg = "Error al autorizar la reposición";
  35. $ok = false;
  36. }else{
  37. $resultMsg = "La reposición se actualizó correctamente";
  38. }
  39. $stmt->closeCursor();
  40. }catch(Exception $e){
  41. $resultMsg = "Ocurrió un error al actualizar la reposición".$e->getMessage();
  42. $ok = false;
  43. }
  44. $array = array("result"=>$ok, "result_msg"=>$resultMsg);
  45. return $array;
  46. }
  47. function reposicion_rechaza($token, $id_repo, $motivo){
  48. global $pdo;
  49. //$pass_hash = password_hash("W3bS3rv1c3.R3p0##", PASSWORD_DEFAULT);
  50. $ok = true;
  51. $rep_id = 0;
  52. $resultMsg = "Ocurrió un error al crear la reposición";
  53. if(!password_verify("W3bS3rv1c3.R3p0##", $token)){
  54. $array = array("result"=>false, "result_msg"=>"Token de conexión inválido");
  55. return $array;
  56. }
  57. try{
  58. $stmt = $pdo->prepare('SELECT * from fu_reposicion_rechaza(:id,:motivo, 4)');//estado 4 rechazado
  59. $stmt->bindParam(":id", $id_repo);
  60. $stmt->bindParam(":motivo", $motivo);
  61. if(!$stmt->execute()){
  62. $resultMsg = "Error al rechazar la reposición";
  63. $ok = false;
  64. }else{
  65. $resultMsg = "La reposición se actualizó correctamente";
  66. }
  67. $stmt->closeCursor();
  68. }catch(Exception $e){
  69. $resultMsg = "Ocurrió un error al actualizar la reposición".$e->getMessage();
  70. $ok = false;
  71. }
  72. $array = array("result"=>$ok, "result_msg"=>$resultMsg);
  73. return $array;
  74. }
  75. // Parametros de salida
  76. $server->register("reposicion_autoriza",
  77. array("token" => "xsd:string", "reposicion" => "xsd:integer", "salon" => "xsd:string"),//recibe id reposicion y salón como texto
  78. array('result' => 'xsd:boolean', 'result_msg' => 'xsd:string'),//regresa
  79. PAG,
  80. PAG."#reposicion_autoriza",
  81. "rpc",
  82. "encoded",
  83. "Actualiza el salón de la resposición");
  84. $server->register("reposicion_rechaza",
  85. array("token" => "xsd:string", "reposicion" => "xsd:integer", "mensaje" => "xsd:string"),//recibe id reposicion y mensaje del motivo
  86. array('result' => 'xsd:boolean', 'result_msg' => 'xsd:string'),//regresa
  87. PAG,
  88. PAG."#checahorarios",
  89. "rpc",
  90. "encoded",
  91. "Rechaza la reposición y escribe el motivo");
  92. @$server->service(file_get_contents("php://input"));
  93. ?>