<?php
require_once '../../classes/dao.php';


if (isset($_GET['function'])) {
    if ($_GET['function'] == "get_scores")
        get_scores();
    elseif ($_GET['function'] == "get_map_info")
        get_map_info();
    elseif ($_GET['function'] == "get_activities_of_day")
        get_activities_of_day();
} else
    show_error();

function get_scores() {
    if (isset($_GET['team'])) {
        header('Content-Type: application/json');
        $dao = new Dao();
        echo json_encode($dao->get_score_team($_GET['team']));
    } else {
        show_error();
    }
}

function get_map_info() {
    if (isset($_GET['selector'])) {
        header('Content-Type: application/json');
        $dao = new Dao();
        echo json_encode($dao->get_map_info($_GET['selector']));
    } else {
        show_error();
    }
}


function get_activities_of_day() {
    if (isset($_GET['day'])) {
        header('Content-Type: application/json');
        $dao = new Dao();
        echo json_encode($dao->get_activities_of_day($_GET['day']));
    } else {
        show_error();
    }
}



function show_error() {
    echo "Échec : ";
    var_dump($_GET);
}
