Ejemplo n.º 1
0
 protected function createGrid()
 {
     $grid = $this->createPreparedGrid();
     $grid->setModel($this->getModel());
     $grid->addColumnNumber('id', 'ID')->setSortable()->setFilterNumber();
     $grid->addColumnText('username', 'Přihlašovací jméno')->setSortable()->setDefaultSort('asc')->setFilterText();
     $grid->addColumnText('name', 'Jméno')->setSortable()->setFilterText();
     $grid->addColumnText('surname', 'Příjmení')->setSortable()->setFilterText();
     $grid->addColumnText('email', 'Email')->setCustomRender(function ($row) {
         if (Strings::length($row->email) <= 0) {
             return '';
         }
         return Html::el('a')->setText($row->email)->href('mailto:' . $row->email);
     })->setSortable()->setFilterText()->setColumn('user.email');
     $section = $grid->addColumnText('section', 'Sekce');
     $this->helpers->setupAsMultirecord($section, function ($row) {
         $selection = $this->sectionFacade->all();
         $this->userFilter->filterId($selection, $row->id, ':user_has_section');
         $selection->select("section.id,section.name");
         return $selection->fetchPairs('id', 'name');
     });
     $role = $grid->addColumnText('role', 'Role');
     $this->helpers->setupAsMultirecord($role, function ($row) {
         $selection = $this->roleFacade->all();
         $this->userFilter->filterId($selection, $row->id, ':user_has_role');
         $selection->select("role.code,role.name");
         return $selection->fetchPairs('code', 'name');
     });
     $this->helpers->addEditAction($grid);
     $this->helpers->addDeleteEvent($grid, $this->deleteRow, function ($row) {
         return $row->surname . ' ' . $row->name;
     });
     return $grid;
 }
Ejemplo n.º 2
0
 /**
  * @return \Nette\Database\Table\Selection
  */
 public function getUserSection()
 {
     $selection = $this->sectionFacade->all();
     if (!$this->user->getIdentity()->super) {
         $this->sectionFilter->filterId($selection, $this->user->getIdentity()->sections);
     }
     return $selection;
 }
 /**
  * @return array
  */
 protected function getSectionOptions()
 {
     $options = [];
     foreach ($this->sectionFacade->all() as $section) {
         $options[$section['name']] = $this->getOptions($section['id']);
     }
     return $options;
 }
 public function getData()
 {
     $selection = $this->sectionFacade->all();
     if (!$this->user->getIdentity()->super) {
         $this->sectionFilter->filterId($selection, $this->user->getIdentity()->sections);
     }
     return $selection->fetchPairs('id', 'id');
 }
 private function loadFrontSection()
 {
     $selection = $this->moduleFilter->filterCode($this->sectionFacade->all(), ModuleConst::FRONT);
     $record = $selection->fetch();
     if (!$record) {
         return;
     }
     $this->frontSectionId = (int) $record->id;
 }
Ejemplo n.º 6
0
 /**
  * @return array
  */
 protected function getSections()
 {
     if (!$this->sections) {
         $selection = $this->filterSections($this->sectionFacade->all());
         if (!$this->user->getIdentity()->super) {
             $this->sectionFilter->filterId($selection, $this->user->getIdentity()->sections);
         }
         $this->sectionOrderer->order($selection, 'section');
         if ($this->moduleGroup) {
             $selection->select('section.id, module.name');
             $selection->group('section.module');
         } else {
             $selection->select('section.id,section.name');
         }
         $this->sections = $selection->fetchPairs('id', 'name');
     }
     return $this->sections;
 }
 /**
  * @return array
  */
 public function getOptionsWithoutHome()
 {
     $context = $this->moduleFilter->filterNotModule($this->sectionFacade->all(), ModuleConst::FRONT);
     return $this->orderAndFetch($context);
 }
 /**
  * @param int $id
  * @return array
  */
 public function getOptionsBySection($id)
 {
     return $this->sectionFacade->getMenuType($id)->select('menu_type.name, menu_type.code')->order('name')->fetchPairs('code', 'name');
 }
Ejemplo n.º 9
0
 /**
  * @param int $id
  * @param Form $form
  */
 protected function saveData($id, Form $form)
 {
     $this->sectionFacade->setMenuType($id, $form['type']['menu_type_code']->getValue());
 }
 /**
  * @return \Nette\Database\Table\Selection
  */
 protected function allSections()
 {
     return $this->sectionOrderer->order($this->sectionFacade->all());
 }
Ejemplo n.º 11
0
 /**
  * @param int $pageId
  * @return array
  */
 function getPageSection($pageId)
 {
     $context = $this->sectionFacade->all();
     $this->pageFilter->filterId($context, $pageId, ':page_has_section');
     return $context->fetchPairs('id', 'id');
 }
Ejemplo n.º 12
0
 /**
  * @param $id
  */
 public function delete($id)
 {
     $this->sectionFacade->delete($id);
 }
 /**
  * @return \Nette\Database\Table\Selection
  */
 public function all()
 {
     return $this->sectionFilter->filterNotHomeSection($this->sectionFacade->all(), ModuleConst::FRONT);
 }