<?php

$uid = TaskerMAN\Core\IO::GET('id');
$user = new TaskerMAN\Application\User($uid);
// User does not exist, throw 404
if (!$user->exists) {
    throw new TaskMAN\Core\FatalException('404 - Page Not Found', new \Exception('Requested user (' . $uid . ') was not found'));
}
TaskerMAN\WebInterface\WebInterface::setTitle($user->name);
$stats = TaskerMAN\Application\DashboardStats::getStats($user->id);
if (isset($_POST['delete'])) {
    try {
        TaskerMAN\Application\UserManagement::delete($uid);
        if ($uid == TaskerMAN\WebInterface\WebInterface::$user->getID()) {
            // User deleted themselves, log them out
            TaskerMAN\WebInterface\Session::destroy();
            header('Location: index.php?p=login');
            exit;
        }
        header('Location: index.php?p=list_users');
        exit;
    } catch (TaskerMAN\Application\UserManagementException $e) {
        $alert = '<div class="alert alert-danger" role="alert">' . $e->getMessage() . '</div>';
    }
} elseif (isset($_POST['submit'])) {
    // Form submitted
    if (isset($_POST['admin'])) {
        $is_admin = true;
    } else {
        $is_admin = false;
    }
<?php

// Return dashboard stats
echo TaskerMAN\Application\API::response(TaskerMAN\Application\DashboardStats::getStats(TaskerMAN\Application\API::$uid));
<?php

TaskerMAN\WebInterface\WebInterface::setTitle('Dashboard');
$stats = TaskerMAN\Application\DashboardStats::getStats();
?>

<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
	<div class="row placeholders">
		<div class="col-xs-6 col-sm-3 placeholder">
			<br />
			<br />
			<span class="large-dashboard-number"><?php 
echo $stats['outstanding'];
?>
</span>
		</div>

		<div class="col-xs-6 col-sm-3 placeholder">
			<br />
			<br />
			<?php 
echo '<span class="large-dashboard-number"';
if ($stats['overdue'] > 0) {
    echo ' style="color: #F7464A"';
} else {
    echo ' style="color: #66CD00"';
}
echo '>' . $stats['overdue'] . '</span>';
?>
		</div>