<?php

/**
* Datei kalendar.php
*
* @author Christian Szech
* @version 1.0
*/
session_start();
require_once "dates_coordination_class.php";
require_once "db_connect.php";
$userid = $_SESSION["userid"];
$dbc = new DBConnect();
$datesCoordinationArray = $dbc->loadDatesCoord_db($userid);
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo "<xml>";
foreach ($datesCoordinationArray as $d) {
    $date = DetermineFavouriteDate($d->getResults());
    echo "<dateCoordination>";
    echo "<title>" . htmlspecialchars($d->getTitle()) . "</title>";
    echo "<description>" . htmlspecialchars($d->getDescription()) . "</description>";
    echo "<date>" . htmlspecialchars(date_format($date, 'Y-m-d\\TH:i:00')) . "</date>";
    echo "<frist>" . htmlspecialchars(date_format($d->getDeadline(), 'Y-m-d\\TH:i:00')) . "</frist>";
    echo "</dateCoordination>";
}
echo "</xml>";
function DetermineFavouriteDate($resultArray)
{
    $score = 0;
    $max_score = 0;
    $d_max = "";