<?php
session_start();
if( $_SESSION["user"] == "" || $_SESSION["passwd"] == "" ) {
//   header("Location: index.php");
}

$Cliente = isset($_POST['key']) ? $_POST["key"]  : ""; 
if( $Cliente == "" ) $Cliente = "8";

include_once('db_config.php');
ini_set('max_execution_time', 120);

   if( strlen($Cliente) > 0 ) {

      $first = true;
      $sql = "select sql_no_cache *, date(FechaInicio) as inicio, date(FechaFin) as fin from ejercicios where id = '" . $Cliente . "' limit 1";
      $result = $conn->query($sql);
      if ($result->num_rows > 0) {
         if( $row = $result->fetch_assoc() ) {
            echo "{\"id\":\"" . $row["ID"] . "\",";
            echo  "\"nombre\":\"" . $row["Nombre_Empresa"] . "\",";
            echo  "\"descripcion\":\"" . $row["DescripcionEjercicio"] . "\",";
            echo  "\"desde\":\"" . $row["inicio"] . "\",";
            echo  "\"hasta\":\"" . $row["fin"] . "\",";
            echo  "\"observaciones\":\"" . $row["Observaciones"] . "\"}";
         }
      }
      else echo "[]";
      mysql_free_result( $result ); 
   }
   mysqli_close($conn);
?>

