<?php
    include '../clases/db.php';
    include '../clases/db2.php';

$json = file_get_contents('php://input');   
$obj = json_decode($json);
$id = $obj->flag;

// Returns a Json
header('Content-Type: application/json');

switch($id){
    case '0':
        $conn = new conexion();
        $query = "SELECT * FROM gimnasios WHERE clave_clientes != '' ORDER BY NombreGimnasio ASC";
        echo $conn->jsonQuery($query);
        break;
    
    case '1':
        $conn = new conexion_sec("directoriofitness.com.mx","direct18","L4LL4v3M@3str@",$obj->bd);
        $query = "SELECT * FROM sucursal";
        echo $conn->jsonQuery($query,"directoriofitness.com.mx","direct18","L4LL4v3M@3str@",$obj->bd);
    break;
    
    case '2':
        $conn = new conexion_sec("directoriofitness.com.mx","direct18","L4LL4v3M@3str@",$obj->bd);
        $query = "SELECT * FROM servicios WHERE Borrado = 0 AND Sucursal = $obj->sucursal GROUP BY NombreServicio ORDER BY NombreServicio ASC";
        echo $conn->jsonQuery($query,"directoriofitness.com.mx","direct18","L4LL4v3M@3str@",$obj->bd);
    break;
}

$conn->disconnect();
?>