public function render() { $websites = $this->website_service->getResultsWebsites($this->filter); $template = $this->prepareTemplate(); $template->websites = $websites; $template->count = count($websites); $template->render(); }
protected function createComponentFilterForm() { $websites_arr = array(); foreach ($this->website_service->getAll() as $website) { $websites_arr[$website->id_website] = $website->name; } $pages_arr = array(); foreach ($this->page_service->getBasePageHolders() as $pageHolder) { $pages_arr[$pageHolder->getPage()->id_page] = $pageHolder->getWebsite()->name . " - " . $pageHolder->getPage()->name; } $form = new \Nette\Application\UI\Form(); $form->addGroup('Filtrování'); $form->addText('id', 'Id'); $form->addText('id_question', 'Rodič'); $input_respondent = $form->addText('id_respondent', 'Respondent'); if ($this->id_respondent !== null) { $input_respondent->setDefaultValue($this->id_respondent); } $form->addText('wireframe', 'Wireframe'); $form->addText('datetime', 'Čas'); $form->addCheckboxList('state', 'Stav', array(\App\Model\Subquestion::STATE_CORRECT => "OK", \App\Model\Subquestion::STATE_ALMOST => "téměř", \App\Model\Subquestion::STATE_WRONG => "NE", \App\Model\Subquestion::STATE_DISQUALIFIED => "nepočítat")); $form->addText('answer', 'Odpověď'); $form->addText('reason', 'Důvod'); $form->addText('type', 'Typ'); $form->addText('seconds', 'Sekundy'); $form->addCheckboxList('know', 'Zná?', array("null" => "nevyplněno", RespondentWebsite::PERIOD_DONT_KNOW => 'neznám', RespondentWebsite::PERIOD_KNOW_THAT_EXISTS => 'vím, že existuje', RespondentWebsite::PERIOD_KNOW_AND_VISIT => 'znám a navštěvuji')); $websites = $form->addDynamic("id_website", function (Container $website) use($websites_arr) { $website->addSelect("id_website", "Web", $websites_arr); $website->addSubmit('removeWebsite', 'Odstranit')->setAttribute("class", "ajax btn btn-xs")->setValidationScope(FALSE)->onClick[] = array($this, 'removeItem'); }); $websites->addSubmit('addWebsite', 'Přidat web')->setValidationScope(FALSE)->setAttribute("class", "ajax btn btn-xs")->onClick[] = array($this, 'addItem'); $pages = $form->addDynamic("id_page", function (Container $website) use($pages_arr) { $website->addSelect("id_page", "Stránka", $pages_arr); $website->addSubmit('removePage', 'Odstranit')->setAttribute("class", "ajax btn btn-xs")->setValidationScope(FALSE)->onClick[] = array($this, 'removeItem'); }); $pages->addSubmit('addPage', 'Přidat stránku')->setValidationScope(FALSE)->setAttribute("class", "ajax btn btn-xs")->onClick[] = array($this, 'addItem'); $this->addOrder($form, array('subquestion.id_subquestion' => "id", 'question.id_question' => "rodič", 'subquestion.seconds' => 'sekundy', 'question.id_respondent' => 'respondent', 'subquestion.datetime' => 'čas')); $form->onSuccess[] = $this->filterFormSubmited; $form->addGroup(); $form->addSubmit('filter', 'Filtrovat')->setAttribute("class", "btn btn-primary ajax"); return $form; }