<?php
session_start();
include "Connection.php";
include "Animal.php"; 

$db = new Database(); 
$con =  $db->connect();
$animal = new Animal($con); 

$id_user = $_SESSION["id_user"];
$lang = $_SESSION["lang"];

if(isset($_POST["learn_list"])){
    $data = $animal->readNames($id_user, $lang);
    echo json_encode($data);
}else if (isset($_POST["id_animal"])){
    $id = $_POST["id_animal"];
    $data = $animal->readAnimal($id, $lang);
    echo json_encode($data);
}else if (isset($_POST["id_model"])){
    $id = $_POST["id_model"];
    $data = $animal->readAnimalModel($id);
    echo $data;
}else if (isset($_POST["id_area"])){
    $id_area = $_POST["id_area"];
    $data = $animal->readAreaAnimals(array("id_area"=>$id_area, "id_user"=>$id_user, "lang"=>$lang));
    echo json_encode($data);
}
$db->close($con);
?>
