<?php
|
|
|
|
if($_SERVER["SERVER_NAME"] != "trainersapp.localhost") {
|
|
require("Conn.php");
|
|
} else {
|
|
require("ConnLocal.php");
|
|
}
|
|
|
|
require("MySQLDao.php");
|
|
|
|
//let postString = "nombre=\(nombreMacrociclo!)&desde=\(fechaDesde)&hasta=\(fechaHasta)&tipo=\(tipoEntrenamiento)";
|
|
|
|
$nombre = htmlentities($_POST["nombre"]);
|
|
$desde = htmlentities($_POST["desde"]);
|
|
$hasta = htmlentities($_POST["hasta"]);
|
|
$tipo = htmlentities($_POST["tipo"]);
|
|
$deportista = htmlentities($_POST["deportista"]);
|
|
$entrenador = htmlentities($_POST["entrenador"]);
|
|
|
|
$returnValue = array();
|
|
|
|
if(empty($nombre) || empty($desde) || empty($hasta) || empty($tipo) || empty($deportista) || empty($entrenador))
|
|
{
|
|
$returnValue["status"] = "error";
|
|
$returnValue["message"] = "Hay que rellenar todos los campos";
|
|
echo json_encode($returnValue);
|
|
return;
|
|
}
|
|
|
|
$dao = new MySQLDao();
|
|
$dao->openConnection();
|
|
$result = $dao->insertaMacrociclo($nombre,$desde,$hasta,$tipo,$deportista,$entrenador);
|
|
|
|
if($result)
|
|
{
|
|
$returnValue["status"] = "correcto";
|
|
$returnValue["message"] = "Macrociclo añadido a usuario";
|
|
echo json_encode($returnValue);
|
|
return;
|
|
} else {
|
|
$returnValue["status"] = "error";
|
|
$returnValue["message"] = "Error al insertar macrociclo";
|
|
echo json_encode($returnValue);
|
|
return;
|
|
}
|
|
|
|
$dao->closeConnection();
|
|
|
|
?>
|