Ejemplo n.º 1
0
    $response["Training"]["Attendees"] = $attendees;
    echoRespnse(200, $response);
});
/**
 * Gets the details of a particular training
 * method GET
 * url /trainings
 */
$app->get('/trainings/:trainingID', function ($trainingID) {
    global $user_id;
    $response = array();
    $db = new DbHandler();
    // fetch training details
    $trainingResult = $db->getTraining($user_id, $trainingID);
    // fetch all training attendees
    $attendeesResult = $db->getTrainingAttendees($trainingID);
    $response["Error"] = false;
    $response["Training"] = array();
    $training = $trainingResult->fetch_assoc();
    $attendees = array();
    while ($attendee = $attendeesResult->fetch_assoc()) {
        $attendee["HasAttended"] = (bool) $attendee["HasAttended"];
        array_push($attendees, $attendee);
    }
    $response["Training"]["TrainingID"] = $training["TrainingID"];
    $response["Training"]["TrainingDate"] = $training["TrainingDate"];
    $response["Training"]["IsBonus"] = (bool) $training["IsBonus"];
    $response["Training"]["TeamID"] = $training["TeamID"];
    $response["Training"]["Attendees"] = $attendees;
    echoRespnse(200, $response);
});