public function getHtml()
 {
     $trace = $this->trace->addChild("ZapisanePredmetyCallback");
     $predmetyZapisnehoListu = $this->skusky->getPredmetyZapisnehoListu($trace);
     $predmetyZapisnehoListuTable = new Table(TableDefinitions::predmetyZapisnehoListu());
     $predmetyZapisnehoListuCollapsible = new Collapsible(new HtmlHeader('Predmety zápisného listu'), $predmetyZapisnehoListuTable);
     $kreditovCelkomLeto = 0;
     $kreditovCelkomZima = 0;
     $pocetPredmetovLeto = 0;
     $pocetPredmetovZima = 0;
     foreach (Sorter::sort($predmetyZapisnehoListu->getData(), array("kodSemester" => -1, "nazov" => 1)) as $row) {
         if ($row['kodSemester'] == 'L') {
             $pocetPredmetovLeto += 1;
             $kreditovCelkomLeto += $row['kredit'];
             $class = 'leto';
         } else {
             $pocetPredmetovZima += 1;
             $kreditovCelkomZima += $row['kredit'];
             $class = 'zima';
         }
         $predmetyZapisnehoListuTable->addRow($row, array('class' => $class));
     }
     $pocetPredmetovText = 'Celkom ';
     $pocetPredmetovText .= FajrUtils::formatPlural($pocetPredmetovLeto + $pocetPredmetovZima, '0 predmetov', '1 predmet', '%d predmety', '%d predmetov');
     if ($pocetPredmetovLeto > 0 && $pocetPredmetovZima > 0) {
         $pocetPredmetovText .= sprintf(' (%d v zime, %d v lete)', $pocetPredmetovZima, $pocetPredmetovLeto);
     }
     $kreditovCelkomText = '' . ($kreditovCelkomLeto + $kreditovCelkomZima);
     if ($kreditovCelkomLeto > 0 && $kreditovCelkomZima > 0) {
         $kreditovCelkomText .= sprintf(' (%d+%d)', $kreditovCelkomZima, $kreditovCelkomLeto);
     }
     $predmetyZapisnehoListuTable->addFooter(array('nazov' => $pocetPredmetovText, 'kredit' => $kreditovCelkomText), array());
     $predmetyZapisnehoListuTable->setUrlParams(array('studium' => Input::get('studium'), 'list' => Input::get('list')));
     return $predmetyZapisnehoListuTable->getHtml();
 }
Пример #2
0
 public function testFormatPlural()
 {
     $this->assertEquals(FajrUtils::formatPlural(0, 'ok %d', 'failed one %d', 'failed 2-4 %d', 'failed other %d'), 'ok 0');
     $this->assertEquals(FajrUtils::formatPlural(1, 'failed zero %d', 'ok %d', 'failed 2-4 %d', 'failed other %d'), 'ok 1');
     $this->assertEquals(FajrUtils::formatPlural(2, 'failed zero %d', 'failed one %d', 'ok %d', 'failed other %d'), 'ok 2');
     $this->assertEquals(FajrUtils::formatPlural(3, 'failed zero %d', 'failed one %d', 'ok %d', 'failed other %d'), 'ok 3');
     $this->assertEquals(FajrUtils::formatPlural(4, 'failed zero %d', 'failed one %d', 'ok %d', 'failed other %d'), 'ok 4');
     $this->assertEquals(FajrUtils::formatPlural(5, 'failed zero %d', 'failed one %d', 'failed 2-4 %d', 'ok %d'), 'ok 5');
     $this->assertEquals(FajrUtils::formatPlural(10, 'failed zero %d', 'failed one %d', 'failed 2-4 %d', 'ok %d'), 'ok 10');
 }