<?php
session_start();
$usuarioSession = $_SESSION['USUARIO'];
$grupo = $_SESSION['GRUPO'];
$contacto = $_SESSION['CONTACTO'];
$awa_session_id = $_SESSION['AWA_SESION_ID'];
include('../includes/conex.php');
include('../includes/eat.php');
include('../includes/historial.php');
include('../includes/functions.php');
include('../includes/esquemas.php');
include('../class/Schema.php');
include('../class/MotherCar.php');
include('../class/Expediente.php');
include('../class/Bibliotecas.php');
include('../class/Tasaciones.php');
include('../class/Static.php');
include('../class/WebServices.php');
include('../lg/config_vo.php');
if(!isset($usuarioSession) OR $awa_session_id != $awa_id) {
    eatCookies();
    header('Location:../index.php');
}
if(isset($_COOKIE['usuario']) AND $_COOKIE['usuario'] != $staticUsu ) {
    eatCookies();
    header('Loction:../index.php');
}
if (isset($_COOKIE['idioma'])) {
    include('../lg/LG_' . $_COOKIE['idioma'] . '.php');
} else {
    include('../lg/LG_SP.php');
}
$Schema = new Schema($con, $database);
$MotherCar = new MotherCar($con);
$Expediente = new Expediente($con);
$Tasaciones = new Tasaciones($con);
$Bibliotecas = new Bibliotecas($con);
$request = Statics::SafeInput($con, $_POST['request']);
$json['status'] = true;
$json['message'] = 'Successful';
switch($request) {
    case 1:
        $save = [];
        $res = $con->query('SELECT COUNT(T.VEHICULO) AS TASADOS, 
        (SELECT COUNT(T2.VEHICULO) FROM VEHICULOS_TASACIONES T2 WHERE T2.ESTADO = 2) AS COMPRADOS,
        (SELECT COUNT(V.CODIGO) FROM VEHICULOS V WHERE V.ESTADO = "VEN") AS VENDIDOS,
        (SELECT COUNT(O.CODIGO) FROM VEHICULOS_OFERTAS O WHERE O.ESTADO = 1) AS OFERTADOS 
        FROM VEHICULOS_TASACIONES T');
        if($res->num_rows) {
            $save = $res->fetch_assoc();
        }
        $json['statistics'] = $save;
    break;
    default:
        $json['status'] = false;
        $json['message'] = 'Invalid request';
}

echo json_encode($json);

?>

