/**
  * Renders the total view where a SLC can see all of the student's hours.
  * @param  Integer $id Id of the SLC
  * @return Template that contains all student's hours
  */
 public function slcOverzicht($id)
 {
     if (isLogged($id)) {
         $totaaluren = 0;
         $array = null;
         if (!empty($_POST)) {
             $statement = $this->db->prepare("SELECT \n\t\t\t\t\turen_Id, \n\t\t\t\t\tSUM(uren_Studielast) as studielast, \n\t\t\t\t\t(SELECT user_Name FROM User WHERE u.User_user_Id = user_Id) AS user_Name,\n\t\t\t\t\t(SELECT cursus_Name FROM Cursus WHERE cursus_Id IN(SELECT Cursus_cursus_Id FROM Onderdeel WHERE onderdeel_Id = u.Onderdeel_onderdeel_Id)) as cursus, \n\t\t\t\t\t(SELECT cursus_Id FROM Cursus WHERE cursus_Id IN(SELECT Cursus_cursus_Id FROM Onderdeel WHERE onderdeel_Id = u.Onderdeel_onderdeel_Id)) as cursus_Id,\n\t\t\t\t\t(SELECT SUM(onderdeel_Norm) FROM Onderdeel WHERE Cursus_cursus_Id = o.Cursus_cursus_Id) AS totaleNorm\n\t\t\t\t\tFROM \n\t\t\t\t\tUren as u,\n\t\t\t\t\tOnderdeel as o\n\t\t\t\t\tWHERE\n\t\t\t\t\tUser_user_Id = " . $_POST['student_Id'] . " \n\t\t\t\t\tAND\n\t\t\t\t\tu.Onderdeel_onderdeel_Id = o.Onderdeel_Id\n\t\t\t\t\tGROUP BY \n\t\t\t\t\tcursus");
             $statement->execute();
             $urenoverzichtData = $statement->fetchAll(\PDO::FETCH_ASSOC);
             $array = array();
             $count = 0;
             foreach ($urenoverzichtData as $uren) {
                 $onderdeel_norm = $uren['totaleNorm'];
                 $berekening = $uren['studielast'] / $onderdeel_norm * 100;
                 if ($berekening > 100) {
                     $berekening = $berekening - 100;
                     $berekening = "<font color=\"red\">" . $berekening . "%</font> boven";
                 } else {
                     $berekening = 100 - $berekening;
                     $berekening = "<font color=\"green\">" . $berekening . "%</font> onder";
                 }
                 $totaaluren += $uren['studielast'];
                 $studielast_in_uren = min_naar_uren($uren['studielast']);
                 $array[] = array('uren_Id' => $uren['uren_Id'], 'studielast' => $studielast_in_uren, 'cursus_Id' => $uren['cursus_Id'], 'cursus' => $uren['cursus'], 'onderdeel_Norm' => min_naar_uren($uren['totaleNorm']), 'berekening' => $berekening);
                 $count++;
             }
         }
         $urenoverzichtData = null;
         $sql = "SELECT * FROM User WHERE actief <> 0 AND Rol_rol_Id = 1";
         $statement = $this->db->prepare($sql);
         $statement->execute();
         $students = $statement->fetchAll(\PDO::FETCH_ASSOC);
         echo $this->twigRenderer->renderTemplate('urenoverzicht_slc.twig', array('id' => $id, 'students' => $students, 'student_Name' => $urenoverzichtData[0]['user_Name'], 'urenoverzichtarray' => $array));
     } else {
         echo $this->twigRenderer->renderTemplate('noaccess.twig');
     }
 }
 /**
  * Renders a specific part out of the complete display of hours
  * This result is based on the assignment
  * @param  Integer $id       Id of the student
  * @param  Integer $weeknr   Week number to zoom in on
  * @param  Integer $jaar     Year to zoom in on
  * @param  Integer $cursusid Id of the course
  * @return Template that shows a specific part of the complete display of hours based on an assignment
  */
 public function studentOverzichtDetailOnderdeel($id, $weeknr, $jaar, $onderdeelid)
 {
     $result = getUserDetails($id);
     if (isLogged($id) && $result['Rol_rol_Id'] == 1) {
         $startandenddate = getStartAndEndDate($weeknr, $jaar);
         $statement = $this->db->prepare("SELECT\n\t\t\t\t(SELECT onderdeel_Name FROM Onderdeel WHERE onderdeel_Id = Onderdeel_onderdeel_Id) AS onderdeel,\t\t\t\t\t\t\t\t\t\t\n\t\t\t\turen_Studielast as studielast,\n\t\t\t\turen_Date AS datum\n\t\t\t\tFROM\n\t\t\t\tUren\n\t\t\t\tWHERE\n\t\t\t\turen_Date between '" . $startandenddate[0] . "' and '" . $startandenddate[1] . "' \n\t\t\t\tAND \n\t\t\t\tUser_user_Id = " . $id . "\n\t\t\t\tAND\n\t\t\t\tOnderdeel_onderdeel_Id = '" . $onderdeelid . "'\n\t\t\t\tGROUP BY uren_Date");
         $statement->execute();
         $urenoverzichtData = $statement->fetchAll(\PDO::FETCH_ASSOC);
         $array = array();
         $onderdeel = '';
         foreach ($urenoverzichtData as $uren) {
             $studielast_in_uren = min_naar_uren($uren['studielast']);
             $dag_vd_week = date('w', strtotime($uren['datum']));
             $dagen = array('Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag');
             $onderdeel = $uren['onderdeel'];
             $array[] = array('dag' => $dagen[$dag_vd_week], 'datum' => date('d-M-Y', strtotime($uren['datum'])), 'onderdeel' => $uren['onderdeel'], 'studielast' => $studielast_in_uren);
         }
         echo $this->twigRenderer->renderTemplate('urenoverzichtdetailOnderdeel_student.twig', array('id' => $id, 'onderdeeloverzichtarray' => $array, 'onderdeel' => $onderdeel, 'weeknr' => $weeknr));
     } else {
         echo $this->twigRenderer->renderTemplate('noaccess.twig');
     }
 }
 /**
  * Renders the template that shows a specific entry out of the hours page of the teacher
  * @param  Integer $id       Id of the teacher
  * @param  Integer $userid   Id of the user 
  * @param  Integer $weeknr   Week number
  * @param  Integer $jaar     The year
  * @param  Integer $cursusid Id of the course
  * @return Template of the specific entry based on the data provided
  */
 public function docentOverzichtDetail($id, $userid, $weeknr, $jaar, $cursusid)
 {
     $result = getUserDetails($id);
     if (isLogged($id)) {
         $startandenddate = getStartAndEndDate($weeknr, $jaar);
         $statement = $this->db->prepare("SELECT\n\t\t\t\t(SELECT onderdeel_Name FROM Onderdeel WHERE onderdeel_Id = Onderdeel_onderdeel_Id) AS onderdeel,\n\t\t\t\t(SELECT onderdeel_Norm FROM Onderdeel WHERE onderdeel_Id = Onderdeel_onderdeel_Id) AS onderdeel_Norm,\n\t\t\t\t(SELECT user_Name FROM User WHERE user_Id = '" . $userid . "') AS student,\n\t\t\t\t(SELECT cursus_Name FROM Cursus WHERE cursus_Id = '" . $cursusid . "') as cursus,\n\t\t\t\tSUM(uren_Studielast) as studielast\n\t\t\t\tFROM\n\t\t\t\tUren\n\t\t\t\tWHERE\n\t\t\t\tOnderdeel_onderdeel_Id in (SELECT onderdeel_Id FROM Onderdeel WHERE Onderdeel_onderdeel_Id = onderdeel_Id AND Cursus_cursus_Id IN (SELECT cursus_Id FROM Cursus WHERE cursus_Id = Cursus_cursus_Id AND cursus_Id = '" . $cursusid . "'))\n\t\t\t\tAND\n\t\t\t\tUser_user_Id = '" . $userid . "'\n\t\t\t\tAND\n\t\t\t\turen_Date between '" . $startandenddate[0] . "' and '" . $startandenddate[1] . "'\n\t\t\t\tGROUP BY Onderdeel_onderdeel_Id");
         $statement->execute();
         $urenoverzichtData = $statement->fetchAll(\PDO::FETCH_ASSOC);
         $totaalPerOnderdeel = $this->totaalTotDatum($userid, $startandenddate[1], $cursusid);
         $count = 0;
         $student = '';
         $cursus = '';
         foreach ($urenoverzichtData as $uren) {
             $onderdeel_norm = $uren['onderdeel_Norm'];
             $berekening = $totaalPerOnderdeel[$count]['totaalOnderdeel'] / $onderdeel_norm * 100;
             if ($berekening > 100) {
                 $berekening = $berekening - 100;
                 $berekening = "<font color=\"red\">" . $berekening . "%</font> boven";
             } else {
                 $berekening = 100 - $berekening;
                 $berekening = "<font color=\"green\">" . $berekening . "%</font> onder";
             }
             $studielast_in_uren = min_naar_uren($uren['studielast']);
             $student = $uren['student'];
             $cursus = $uren['cursus'];
             $array[] = array('onderdeel' => $uren['onderdeel'], 'studielast' => $studielast_in_uren, 'onderdeel_Norm' => min_naar_uren($uren['onderdeel_Norm']), 'totaalPerOnderdeel' => min_naar_uren($totaalPerOnderdeel[$count]['totaalOnderdeel']), 'berekening' => $berekening);
             $count++;
         }
         echo $this->twigRenderer->renderTemplate('urenoverzichtdetail_docent.twig', array('id' => $id, 'onderdeeloverzichtarray' => $array, 'student' => $student, 'weeknr' => $weeknr, 'cursus_Name' => $cursus));
     } else {
         echo $this->twigRenderer->renderTemplate('noaccess.twig');
     }
 }