public function testParseAISDateTime()
 {
     $this->assertEquals(AIS2Utils::parseAISDateTime("11.01.2010 08:30"), mktime(8, 30, 00, 1, 11, 2010));
     $this->assertEquals(AIS2Utils::parseAISDateTime("31.02.2011 09:35"), mktime(9, 35, 00, 2, 31, 2011));
     // parsovanie bez uvodnych nul zatial nepodporujeme (a ani nemusime)
     // AIS2Utils::parseAISDateTime("31.2.2011 9:35");
     $this->setExpectedException("Exception");
     AIS2Utils::parseAISDateTime("8:30 11.1.2010");
 }
 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;
 }
 /**
  * Akcia pre zobrazenie mojich terminov hodnotenia
  *
  * @param Trace $trace trace object
  * @param Request $request request from browser
  * @param Response $response response information
  */
 public function runMojeTerminyHodnotenia(Trace $trace, Context $context)
 {
     $request = $context->getRequest();
     $response = $context->getResponse();
     $termin = $request->getParameter('termin');
     $this->terminyHodnotenia = $this->terminyHodnoteniaScreen->getTerminyHodnotenia($trace->addChild("get terminy hodnotenia"));
     $hodnotenia = $this->hodnoteniaScreen->getHodnotenia($trace->addChild("get hodnotenia"));
     $hodnoteniePredmetu = array();
     foreach ($hodnotenia->getData() as $row) {
         $hodnoteniePredmetu[$row['nazov']] = $row['znamka'];
     }
     $this->terminyHodnoteniaActive = array();
     $this->terminyHodnoteniaOld = array();
     foreach ($this->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&nbsp;predmetu)";
             }
         }
         if ($datum < time()) {
             if ($row['jePrihlaseny'] == 'A') {
                 $this->terminyHodnoteniaOld[] = $row;
             }
         } else {
             if ($row['mozeOdhlasit'] == 1) {
                 $row['hashNaOdhlasenie'] = $this->hashNaOdhlasenie($row);
             }
             $this->terminyHodnoteniaActive[] = $row;
         }
     }
     $this->prihlaseni = null;
     $response->set('prihlaseni', null);
     if ($request->getParameter('termin') != null) {
         $this->prihlaseni = $this->terminyHodnoteniaScreen->getZoznamPrihlasenychDialog($trace, $termin)->getZoznamPrihlasenych($trace);
         $response->set('prihlaseni', $this->prihlaseni->getData());
     }
     $response->set('terminyActive', $this->terminyHodnoteniaActive);
     $response->set('terminyOld', $this->terminyHodnoteniaOld);
     $response->set('termin', $termin);
     $response->setTemplate('studium/mojeTerminyHodnotenia');
 }
 /**
  * Akcia pre zobrazenie mojich terminov hodnotenia
  *
  * @param Trace $trace trace object
  * @param Request $request request from browser
  * @param Response $response response information
  */
 public function runMojeTerminyHodnotenia(Trace $trace, Context $context)
 {
     $request = $context->getRequest();
     $response = $context->getResponse();
     $termin = $request->getParameter('termin');
     $terminyHodnotenia = $this->terminyHodnoteniaScreen->getTerminyHodnotenia($trace->addChild("get terminy hodnotenia"));
     $hodnotenia = $this->hodnoteniaScreen->getHodnotenia($trace->addChild("get hodnotenia"));
     $hodnoteniePredmetu = array();
     foreach ($hodnotenia->getData() as $hodnoteniaRow) {
         $hodnoteniePredmetu[$hodnoteniaRow[HodnoteniaFields::PREDMET_SKRATKA]] = $hodnoteniaRow[HodnoteniaFields::ZNAMKA];
     }
     $terminyHodnoteniaActive = array();
     $terminyHodnoteniaOld = array();
     foreach ($terminyHodnotenia->getData() as $terminyRow) {
         $mojeTerminyRow = $terminyRow;
         if ($terminyRow[TerminyFields::ZNAMKA] == '') {
             // skusme najst znamku v hodnoteniach
             $predmet = $terminyRow[TerminyFields::PREDMET_SKRATKA];
             if (isset($hodnoteniePredmetu[$predmet]) && $hodnoteniePredmetu[$predmet] != '') {
                 // TODO(ppershing): move this to another field and deal with it in template!
                 $mojeTerminyRow[TerminyFields::ZNAMKA] = $hodnoteniePredmetu[$predmet] . " (nepriradená k termínu)";
             }
         }
         $datum = AIS2Utils::parseAISDateTime($terminyRow[TerminyFields::DATUM] . " " . $terminyRow[TerminyFields::CAS]);
         if ($datum < time()) {
             if ($terminyRow[TerminyFields::JE_PRIHLASENY] == 'TRUE') {
                 $terminyHodnoteniaOld[] = $mojeTerminyRow;
             }
         } else {
             if ($terminyRow[TerminyFields::MOZE_ODHLASIT] == 1) {
                 $mojeTerminyRow[MojeTerminyFields::HASH_ODHLASENIE] = StudiumUtils::hashNaOdhlasenie($terminyRow);
             }
             $terminyHodnoteniaActive[] = $mojeTerminyRow;
         }
     }
     $response->set('prihlaseni', null);
     if ($request->getParameter('termin') !== '') {
         $prihlaseni = $this->terminyHodnoteniaScreen->getZoznamPrihlasenychDialog($trace, $termin)->getZoznamPrihlasenych($trace);
         $response->set('prihlaseni', $prihlaseni->getData());
     }
     $response->set('terminyActive', $terminyHodnoteniaActive);
     $response->set('terminyOld', $terminyHodnoteniaOld);
     $response->set('termin', $termin);
     $response->setTemplate('studium/mojeTerminyHodnotenia');
 }