public function getHtml()
 {
     $trace = $this->trace->addChild("MojeTerminyHodnoteniaCallback");
     $trace->tlog("Executing callback");
     $terminyHodnotenia = $this->terminyHodnoteniaApp->getTerminyHodnotenia($trace->addChild("get terminy hodnotenia"));
     $hodnotenia = $this->hodnoteniaApp->getHodnotenia($trace->addChild("get hodnotenia"));
     if (Input::get('action') !== null) {
         $trace->tlog("odhlasujem zo skusky");
         assert(Input::get("action") == "odhlasZoSkusky");
         if ($this->odhlasZoSkusky(Input::get("odhlasIndex"))) {
             FajrUtils::redirect();
         } else {
             throw new Exception('Z termínu sa nepodarilo odhlásiť.');
         }
     }
     $baseUrlParams = array("studium" => Input::get("studium"), "list" => Input::get("list"), "tab" => Input::get("tab"));
     $terminyHodnoteniaTableActive = new Table(TableDefinitions::mojeTerminyHodnotenia(), 'termin', $baseUrlParams);
     $terminyHodnoteniaCollapsibleActive = new Collapsible(new HtmlHeader('Aktuálne termíny hodnotenia'), $terminyHodnoteniaTableActive);
     $terminyHodnoteniaTableOld = new Table(TableDefinitions::mojeTerminyHodnotenia(), 'termin', $baseUrlParams);
     $terminyHodnoteniaCollapsibleOld = new Collapsible(new HtmlHeader('Staré termíny hodnotenia'), $terminyHodnoteniaTableOld);
     if (Input::get('termin') != null) {
         $terminyHodnoteniaTableActive->setOption('selected_key', Input::get('termin'));
         $terminyHodnoteniaTableOld->setOption('selected_key', Input::get('termin'));
     }
     $actionUrl = FajrUtils::linkUrl($baseUrlParams);
     $hodnoteniePredmetu = array();
     foreach ($hodnotenia->getData() as $row) {
         $hodnoteniePredmetu[$row['nazov']] = $row['znamka'];
     }
     foreach ($terminyHodnotenia->getData() as $row) {
         $datum = AIS2Utils::parseAISDateTime($row['dat'] . " " . $row['cas']);
         if ($row['znamka'] == "") {
             // skusme najst znamku v hodnoteniach
             if (isset($hodnoteniePredmetu[$row['predmet']]) && $hodnoteniePredmetu[$row['predmet']] != "") {
                 $row['znamka'] = $hodnoteniePredmetu[$row['predmet']] . " (z predmetu)";
             }
         }
         if ($datum < time()) {
             $row['odhlas'] = "Skúška už bola.";
             if ($row['jePrihlaseny'] == 'A') {
                 $terminyHodnoteniaTableOld->addRow($row, null);
             }
         } else {
             if ($row['mozeOdhlasit'] == 1) {
                 $class = 'terminmozeodhlasit';
                 $hash = $this->hashNaOdhlasenie($row);
                 $row['odhlas'] = "<form method='post' action='{$actionUrl}'>\n              <div>\n              <input type='hidden' name='action' value='odhlasZoSkusky'/>\n              <input type='hidden' name='odhlasIndex'\n              value='" . $row['index'] . "'/>\n              <input type='hidden' name='hash' value='{$hash}'/>\n              <button name='submit' type='submit' class='tableButton negative'>\n                <img src='images/cross.png' alt=''>Odhlás\n              </button></div></form>";
             } else {
                 $row['odhlas'] = "nedá sa";
                 $class = 'terminnemozeodhlasit';
             }
             if ($row['prihlaseny'] != 'A') {
                 $row['odhlas'] = 'Si odhlásený. Ak chceš, opäť sa prihlás.';
                 $class = 'terminodhlaseny';
             }
             $terminyHodnoteniaTableActive->addRow($row, array('class' => $class));
         }
     }
     $html = $terminyHodnoteniaCollapsibleActive->getHtml();
     $html .= $terminyHodnoteniaCollapsibleOld->getHtml();
     if (Input::get('termin') != null) {
         $prihlaseni = $this->terminyHodnoteniaApp->getZoznamPrihlasenychDialog($trace, Input::get('termin'))->getZoznamPrihlasenych($trace);
         $zoznamPrihlasenychTable = new Table(TableDefinitions::zoznamPrihlasenych(), null, array('studium', 'list'));
         $zoznamPrihlasenychTable->addRows($prihlaseni->getData());
         $zoznamPrihlasenychCollapsible = new Collapsible(new HtmlHeader('Zoznam prihlásených
       na vybratý termín'), $zoznamPrihlasenychTable);
         $html .= $zoznamPrihlasenychCollapsible->getHtml();
     }
     return $html;
 }
 public function getHtml()
 {
     $predmetyZapisnehoListu = $this->skusky->getPredmetyZapisnehoListu($this->trace);
     $hodnoteniaData = array();
     foreach ($this->hodnotenia->getHodnotenia($this->trace)->getData() as $row) {
         $hodnoteniaData[$row['nazov']] = $row;
     }
     $this->hodnoteniaData = $hodnoteniaData;
     if (Input::get('action') !== null) {
         assert(Input::get("action") == "prihlasNaSkusku");
         if ($this->prihlasNaSkusku(Input::get("prihlasPredmetIndex"), Input::get("prihlasTerminIndex"))) {
             FajrUtils::redirect(array('tab' => 'TerminyHodnotenia'));
         } else {
             throw new Exception('Na skúšku sa nepodarilo prihlásiť.');
         }
     }
     $baseUrlParams = array("studium" => Input::get("studium"), "list" => Input::get("list"), "tab" => Input::get("tab"));
     $terminyTable = new Table(TableDefinitions::vyberTerminuHodnoteniaJoined(), array('termin' => 'index', 'predmet' => 'predmetIndex'), $baseUrlParams);
     $terminyCollapsible = new Collapsible(new HtmlHeader('Termíny, na ktoré sa môžem prihlásiť'), $terminyTable);
     $actionUrl = FajrUtils::linkUrl($baseUrlParams);
     foreach ($predmetyZapisnehoListu->getData() as $predmetRow) {
         $dialog = $this->skusky->getZoznamTerminovDialog($this->trace->addChild('Get zoznam terminov'), $predmetRow['index']);
         $terminy = $dialog->getZoznamTerminov($this->trace->addChild('Get zoznam terminov'));
         unset($dialog);
         foreach ($terminy->getData() as $row) {
             $row['predmet'] = $predmetRow['nazov'];
             $row['predmetIndex'] = $predmetRow['index'];
             $hash = $this->hashNaPrihlasenie($predmetRow['nazov'], $row);
             $mozeSaPrihlasit = $this->mozeSaPrihlasit($row);
             if ($mozeSaPrihlasit == self::PRIHLASIT_MOZE || $mozeSaPrihlasit == self::PRIHLASIT_MOZE_ZNAMKA) {
                 $row['prihlas'] = "<form method='post' action='{$actionUrl}'><div>\n                           <input type='hidden' name='action' value='prihlasNaSkusku'/>\n                           <input type='hidden' name='prihlasPredmetIndex'\n                           value='" . $row['predmetIndex'] . "'/>\n                           <input type='hidden' name='prihlasTerminIndex'\n                           value='" . $row['index'] . "'/>\n                           <input type='hidden' name='hash' value='{$hash}'/>\n                           <button name='submit' type='submit' class='tableButton positive'>\n                             <img src='images/add.png' alt=''>Prihlás ma!\n                           </button></div></form>";
                 if ($mozeSaPrihlasit == self::PRIHLASIT_MOZE_ZNAMKA) {
                     $row['prihlas'] = 'Už máš zápísané"' . $hodnoteniaData[$row['predmet']]['znamka'] . '"' . $row['prihlas'];
                 }
             } else {
                 if ($mozeSaPrihlasit == self::PRIHLASIT_NEMOZE_CAS) {
                     $row['prihlas'] = 'Nedá sa (neskoro)';
                 } else {
                     if ($mozeSaPrihlasit == self::PRIHLASIT_NEMOZE_POCET) {
                         $row['prihlas'] = 'Termín je plný!';
                     } else {
                         if ($mozeSaPrihlasit == self::PRIHLASIT_NEMOZE_ZNAMKA) {
                             $row['prihlas'] = 'Už máš zápísané"' . $hodnoteniaData[$row['predmet']]['znamka'] . '"';
                         } else {
                             if ($mozeSaPrihlasit == self::PRIHLASIT_NEMOZE_INE) {
                                 $row['prihlas'] = 'Nedá sa, dôvod neznámy';
                             }
                         }
                     }
                 }
             }
             $terminyTable->addRow($row, null);
         }
     }
     if (Input::get('termin') != null && Input::get('predmet') != null) {
         $terminyTable->setOption('selected_key', array('index' => Input::get('termin'), 'predmetIndex' => Input::get('predmet')));
     }
     $html = $terminyCollapsible->getHtml();
     if (Input::get('termin') != null && Input::get('predmet') != null) {
         $prihlaseni = $this->skusky->getZoznamTerminovDialog($this->trace, Input::get('predmet'))->getZoznamPrihlasenychDialog($this->trace, Input::get('termin'))->getZoznamPrihlasenych($this->trace);
         $zoznamPrihlasenychTable = new Table(TableDefinitions::zoznamPrihlasenych(), null, array('studium', 'list'));
         $zoznamPrihlasenychCollapsible = new Collapsible(new HtmlHeader('Zoznam prihlásených na vybratý termín'), $zoznamPrihlasenychTable);
         $zoznamPrihlasenychTable->addRows($prihlaseni->getData());
         $html .= $zoznamPrihlasenychCollapsible->getHtml();
     }
     return $html;
 }