* User: nillernoels
 * Date: 22/12/15
 * Time: 21:25
 */
include_once "../model/ProjectModel.php";
include_once "../model/TeamModel.php";
include_once "../model/WebFunctions.php";
require_once "../model/AuthenticateSession.php";
$projectPerPage = 4;
$content = "";
$isTrainer = $_SESSION['isTrainer'];
if ($isTrainer != 'true') {
    $studentID = $_SESSION['student_id'];
    $studentName = $_SESSION['name'];
    // get name
    $totalNumberOfProjects = count(TeamModel::getStudentTeams($studentID));
    // get total amount
    $totalNumberOfPages = ceil($totalNumberOfProjects / $projectPerPage);
    // calc number of pages
    $currentPage = isset($_GET['current_page']) ? (int) $_GET['current_page'] : 1;
    // if currentPage var isset else default 1
    $startPage = ($currentPage - 1) * $projectPerPage;
    // calc start page ex. 1 = 0 - 4 projects
    // set content:
    $listOfTeams = TeamModel::getStudentTeamsLimit($studentID, $startPage, $projectPerPage);
    // get teams
    $content = "";
    if (count($listOfTeams) == 0) {
        $content .= "   <div class=\"row text-center\">\n                        <div class=\"col-lg-12\">\n                            <p>No teams attended</p>\n                        </div>\n                    </div>";
    } else {
        for ($int = 0; $int < count($listOfTeams); $int++) {
<?php

include_once "../model/StudentModel.php";
include_once "../model/ProjectModel.php";
include_once "../model/TeamModel.php";
include_once "../model/WebFunctions.php";
require_once "../model/AuthenticateSession.php";
// TODO repair pagination
$teamsPerPage = 4;
$content = "";
$student_id = $_GET['student_id'];
$student_name = StudentModel::getStudentById($student_id);
$totalNumberOfTeams = count(TeamModel::getStudentTeams($student_id));
$totalNumberOfPages = ceil($totalNumberOfTeams / $teamsPerPage);
$currentPage = isset($_GET['current_page']) ? (int) $_GET['current_page'] : 1;
$startPage = ($currentPage - 1) * $teamsPerPage;
// set content
$listOfTeams = TeamModel::getStudentTeams($student_id, $startPage, $teamsPerPage);
$content = "";
if (count($listOfTeams) == 0) {
    $content .= "   <div class=\"row text-center\">\r\n                        <div class=\"col-lg-12\">\r\n                            <p>No teams attended</p>\r\n                        </div>\r\n                    </div>";
} else {
    for ($int = 0; $int < count($listOfTeams); $int++) {
        $teamID = $listOfTeams[$int]['team_id'];
        $content .= "<div class=\"col-md-3 portfolio-item\">\r\n                       <a href=\"team-id-{$teamID}\">\r\n                            <img class=\"img-responsive\" src=\"images/team.jpg\" alt=\"\">\r\n                       </a>\r\n                       <p style='text-align: center'>Team {$teamID}</p>\r\n                 </div>";
    }
}
$pagination = WebFunctions::pagination($currentPage, $totalNumberOfPages);
include_once "../view/profile-student.php";