public function render()
 {
     $template = $this->template;
     $breadcrumb = new \App\Model\Category($this->database);
     $template->breadcrumbs = $breadcrumb->getPageBreadcrumb($this->presenter->getParameter("page_id"));
     $template->setFile(__DIR__ . '/PageBreadcrumbsControl.latte');
     $template->render();
 }
 public function insertCategoryFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     if (is_numeric($form->values->type)) {
         $slugName = new \App\Model\Slug($this->database);
         $slugId = $slugName->insert($form->values->title, $form->values->type);
     }
     $category = new \App\Model\Category($this->database);
     $category->setCategory($form->values->title, $form->values->parent_id, $slugId);
     $redirectTo = $this->presenter->getName();
     $this->presenter->redirect(":" . $redirectTo . ":default", array("id" => $form->values->parent_id));
 }
 /**
  * Edit contact
  */
 function createComponentEditForm()
 {
     $this->template->id = $this->presenter->getParameter('id');
     $categories = new \App\Model\Category($this->database);
     $cats = $categories->getSubIds(2);
     $groups = $this->database->table("categories")->where("id", $cats)->fetchPairs("id", "title");
     $form = new \Nette\Forms\BootstrapUIForm();
     $form->setTranslator($this->presenter->translator);
     $form->getElementPrototype()->class = "form-horizontal";
     $form->getElementPrototype()->role = 'form';
     $form->getElementPrototype()->autocomplete = 'off';
     $form->addGroup('');
     $form->addHidden('contact_id');
     $form->addHidden('pages_id');
     $form->addText("name", "dictionary.main.Name")->setAttribute("placeholder", "dictionary.main.Name");
     $form->addText("company", "dictionary.main.Company")->setAttribute("placeholder", "dictionary.main.Company");
     $form->addRadioList("type", "Osoba nebo organizace", array(0 => " osoby", 1 => " organizace"));
     $form->addText("post", "dictionary.main.Post")->setAttribute("placeholder", "dictionary.main.Post")->setOption("description", 1);
     $form->addText("email", "E-mail")->setAttribute("placeholder", "dictionary.main.Email")->setAttribute("class", "form-control");
     $form->addText("phone", "dictionary.main.Phone")->setAttribute("placeholder", "dictionary.main.Phone")->setAttribute("class", "form-control");
     $form->addSelect("categories_id", "dictionary.main.Category", $groups)->setAttribute("class", "form-control");
     $form->addGroup('dictionary.main.Address');
     $form->addText("street", "Ulice")->setAttribute("placeholder", "dictionary.main.Street")->setOption("description", 1);
     $form->addText("zip", "dictionary.main.ZIP")->setAttribute("placeholder", "dictionary.main.ZIP")->setOption("description", 1);
     $form->addText("city", "Město")->setAttribute("placeholder", "Město")->setOption("description", 1);
     $form->addGroup('Firemní údaje');
     $form->addText("vatin", "IČ")->setAttribute("placeholder", "dictionary.main.VatIn")->setOption("description", 1);
     $form->addText("vatid", "DIČ")->setAttribute("placeholder", "dictionary.main.VatId")->setHtmlId("kurzy_ico")->setOption("description", 1);
     $form->addText("banking_account", "Bankovní účet")->setAttribute("placeholder", "Bankovní účet")->setOption("description", 1);
     $form->addText("dateofbirth", "Datum narození")->setAttribute("placeholder", "Datum narození");
     $form->addGroup('Ostatní');
     $form->addTextArea("notes", "dictionary.main.Notes")->setAttribute("class", "form-control");
     $page = $this->database->table("pages")->get($this->presenter->getParameter("id"));
     $contact = $this->database->table("contacts")->where("pages_id", $this->presenter->getParameter("id"))->fetch();
     $arr = array("contact_id" => $contact->id, "pages_id" => $page->id, "name" => $contact->name, "company" => $contact->company, "post" => $contact->post, "type" => $contact->type, "email" => $contact->email, "phone" => $contact->phone, "categories_id" => $contact->categories_id, "street" => $contact->street, "zip" => $contact->zip, "city" => $contact->city, "banking_account" => $contact->banking_account, "vatin" => $contact->vatin, "vatid" => $contact->vatid, "notes" => $contact->notes, "dateofbirth" => $contact->date_of_birth);
     $form->setDefaults($arr);
     $form->addSubmit("submitm", "dictionary.main.Save")->setAttribute("class", "btn btn-success");
     $form->onSuccess[] = $this->editFormSucceeded;
     $form->onValidate[] = $this->editFormValidated;
     return $form;
 }
 protected function createComponentEditForm()
 {
     $categoryAll = new \App\Model\Category($this->database);
     $category = $this->database->table("categories")->get($this->presenter->getParameter("id"));
     $categories = $categoryAll->getAll();
     unset($categories[$category->id]);
     $form = new \Nette\Forms\BootstrapUIForm();
     $form->setTranslator($this->presenter->translator);
     $form->getElementPrototype()->class = "form-horizontal";
     $form->getElementPrototype()->role = 'form';
     $form->getElementPrototype()->autocomplete = 'off';
     $form->addHidden('id');
     $form->addText('title', 'dictionary.main.Title');
     $form->addSelect('parent', 'Nadřazená kategorie', $categories)->setPrompt('admin.categories.NothingRelated')->setAttribute("class", "form-control");
     $form->addText('url', 'dictionary.main.URL');
     $form->addSubmit('submitm', 'dictionary.main.Save');
     $arr = array("id" => $category->id, "title" => $category->title, "parent" => $category->parent_id);
     $form->setDefaults(array_filter($arr));
     $form->onSuccess[] = $this->editFormSucceeded;
     return $form;
 }
 public function insertFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $category = new \App\Model\Category($this->database);
     $category->setCategory($form->values->title, $form->values->parent);
     $this->presenter->redirect(this, array("id" => null));
 }