123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
- /*
- Cambia de estado la reposición
- */
- require_once("../../include/constantes.php");
- require_once("../../include/bd_pdo.php");
- require_once("../../classes/ValidaSesion.php");
- require_once("../classes/LogActividad.php");//die on error
- require_once("../../include/util.php");
- require_once("../include/validacionesHorario.php");
- require_once('../../include/phpmailer/PHPMailerAutoload.php');
- require_once ("../../classes/Mailer.php");
- require_once("../../include/nusoap/nusoap.php");
- $pag = "../reposicion.php";
- //--- Objeto para validar usuario. El id de usuario lo lee desde sesión
- $objSesion = new ValidaSesion($pdo, 52, APSA);
- if(!$objSesion->tieneAcceso()){
- $objSesion->terminaSesion();
- //print_r($objSesion->getError());
- }
- if(!$objSesion->puedeEditar()){
- header("Location: ".$pag);
- exit();
- }
- unset($objValida);
- if(!isset($_POST["id"]) || !isset($_POST["edo"]) ){
- header("Location: ".$pag."?error=0");
- exit();
- }
- $id_repo = filter_input(INPUT_POST, "id", FILTER_SANITIZE_NUMBER_INT);//limpia texto
- $id_cronos = filter_input(INPUT_POST, "id_cronos", FILTER_SANITIZE_NUMBER_INT);//limpia texto
- $edo = filter_input(INPUT_POST, "edo", 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
- $salon_desc = trim(filter_input(INPUT_POST, "salon_desc", FILTER_SANITIZE_STRING,array('flags' => FILTER_FLAG_STRIP_LOW)));//limpia texto
- if(!empty($id_cronos) && $edo>=3){//sincronoza reposiciones
- $client = new nusoap_client('http://200.13.89.27/checador_otros/admin_checador/webservice/reposiciones_service.php?wsdl', 'wsdl');
- $error = $client->getError();
- if ($error) {
- header("Location:".$pag."?error=12");
- exit();
- }
- $token = password_hash("W3bS3rv1c3.R3p0##", PASSWORD_DEFAULT);
- if(isset($salon)) $result = $client->call("reposicion_actualiza_estado", array($token, $id_cronos, $edo, $salon_desc, ""));
- else $result = $client->call("reposicion_actualiza_estado", array($token, $id_cronos, $edo, "", ""));
- //print_r($result);
- //exit();
- if ($client->fault) {
- header("Location:".$pag."?error=12");
- exit();
- } else {
- $error = $client->getError();
- if ($error) {
- header("Location:".$pag."?error=12");
- exit();
- } else {
- $ok = $result["result"];
- if(!$ok){
- header("Location:".$pag."?error=12");
- exit();
- }
- }
- }
- }
- //Valida que tenga clase en la fecha de falta
- if(!empty($salon)) $stmt = $pdo->prepare('SELECT fu_reposicion(:id, NULL, NULL, :sal, :edo, NULL, NULL, NULL, NULL, NULL)');
- else $stmt = $pdo->prepare('SELECT fu_reposicion(:id, NULL, NULL, NULL, :edo, NULL, NULL, NULL, NULL, NULL)');
- $stmt->bindParam(":id", $id_repo);
- $stmt->bindParam(":edo", $edo);
- if(!empty($salon)) $stmt->bindParam(":sal", $salon);
- if(!$stmt->execute()){
- //print_r($stmt->errorInfo());
- header("Location:".$pag."?error=1");
- exit();
- }
- $stmt->closeCursor();
- $stmt = null;
- $stmt = $pdo->prepare('Select * from fs_reposicion(:id, :periodo, NULL, NULL, NULL, NULL, NULL, 0, 1)');
- $stmt->bindParam(":id", $id_repo);
- $stmt->bindParam(":periodo", $_SESSION["periodo_id"]);
- if(!$stmt->execute()){
- header("Location:".$pag."?error=1");
- exit();
- }
- $rs = $stmt->fetch();
- $stmt->closeCursor();
- $stmt = null;
- $stmt = $pdo->prepare('Select * from fs_contacto(:usr, 3, NULL)');//3 = correo
- $stmt->bindParam(":usr", $rs["Usuario_id"]);
- if(!$stmt->execute()){
- header("Location:".$pag."?error=1");
- exit();
- }
- $correos_rs = $stmt->fetchAll();
- $stmt->closeCursor();
- $stmt = null;
- $correoList = "";
- foreach($correos_rs as $c){
- if($c.substr("lasallistas.org,mx",0) || $c.substr("lasalle.mx",0)){
- $correoList .= $c.";";
- }
- }
- //$correoHTML = "<p>Se aprobó la reposición para el <b> a las </b> en el salón <b></b>.</p>";
- $log = new LogActividad();
- if($edo == 4){
- $desc_log = "Cancela reposición ID[".$id_repo."] edo[".$edo."]";
- $ok = 2;
- }else{
- $desc_log = "Autoriza reposición ID[".$id_repo."] edo[".$edo."] Salon[".(empty($salon)?"":$salon)."]";
- $ok = 0;
- if($edo == 5){
- $ok = 1;
- /*if($correoList!= "")
- Mailer::enviarCorreo($correoList , "Reposición autorizada", $correoHTML);*/
- }
- if($edo == 3){
- $ok = 3;
- /*if($correoList!= "")
- Mailer::enviarCorreo($correoList , "Reposición autorizada", $correoHTML);*/
- }
- }
- $log->appendLog($_SESSION["usuario_id"], $_SESSION["usuario_nombre"]." ".$_SESSION["usuario_apellidos"], $desc_log);
- header("Location: ".$pag."?ok=".$ok);
- exit();
- ?>
|