/** * Create grid UI component Grido\Grid * * @param array|IRepository|Selection $data * @param string $primaryKey * @param integer $perPage * @param array $permanentlyFilter * * @return Grid */ public function createGrido($data = null, $primaryKey = null, $perPage = null, $permanentlyFilter = []) { $grid = new Grid(); // set data model if ($data) { if ($data instanceof IRepository) { $dataModel = new Mepatek\Components\Grido\DataSources\RepositorySource($data); $dataModel->setPermanentlyFilter($permanentlyFilter); } elseif ($data instanceof Selection) { $dataModel = new Grido\DataSources\NetteDatabase($data); } else { $dataModel = new Grido\DataSources\ArraySource($data); } $grid->setModel($dataModel); } else { $dataModel = new Grido\DataSources\ArraySource([]); $grid->setModel($dataModel); } // set primary key if ($primaryKey) { $grid->setPrimaryKey($primaryKey); } // set properties of grido $grid->filterRenderType = \Grido\Components\Filters\Filter::RENDER_INNER; if ($this->translator) { $grid->setTranslator($this->translator); } $grid->getTablePrototype()->class("table table-striped table-hover table-bordered dataTable"); // set item per page if ($perPage) { $grid->setDefaultPerPage($perPage); } return $grid; }
public function createComponentUserMotivationGrid($name) { try { $seasons = [null => null] + $this->seasonService->getSelectSeasons(); //$users = [null=>null]+$this->userService->getSelectUsers(); } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad(null, self::LAST_CHANCE_REDIRECT, $ex); } $grid = new Grid($this, $name); $grid->setModel($this->entryService->getEntriesDataSource($this->getUser()->getIdentity())); $grid->setPrimaryKey("id"); // $grid->addColumnNumber('id', '#') // ->cellPrototype->class[] = 'center'; // $headerId = $grid->getColumn('id')->headerPrototype; // $headerId->class[] = 'center'; // $headerId->rowspan = "2"; // $headerId->style['width'] = '0.1%'; $grid->addColumnText('season', $this->tt("motivationModule.protected.grid.season"))->setSortable()->setFilterSelect($seasons); $headerSeas = $grid->getColumn('season')->headerPrototype; $headerSeas->class[] = 'center'; $grid->addColumnText('amount', $this->tt("motivationModule.protected.grid.amount"))->setSortable()->setFilterText(); $headerAmnt = $grid->getColumn('amount')->headerPrototype; $headerAmnt->class[] = 'center'; $grid->addColumnDate("updated", $this->tt("motivationModule.protected.grid.updated"), self::DATE_FORMAT)->setSortable(); $headerOd = $grid->getColumn('updated')->headerPrototype; $headerOd->class[] = 'center'; $grid->addColumnText('type', $this->tt("motivationModule.protected.grid.type"))->setSortable()->setReplacement(MotivationEntryType::getOptions())->setFilterSelect([null => null] + MotivationEntryType::getOptions()); $headerT = $grid->getColumn('type')->headerPrototype; $headerT->class[] = 'center'; $grid->addColumnText('subject', $this->tt("motivationModule.protected.grid.subject"))->setSortable()->setFilterText(); $headerSubj = $grid->getColumn('subject')->headerPrototype; $headerSubj->class[] = 'center'; $grid->setFilterRenderType($this->filterRenderType); $grid->setExport("protected-motivation" . date("Y-m-d H:i:s", time())); }
public function createComponentUserEventsGrid($name) { $eventTypes = [null => null] + EventType::getOptions(); $partyTypes = [null => null] + EventParticipationType::getOptions(); $grid = new Grid($this, $name); $grid->setModel($this->eventService->getUserEventsDataSource($this->getUser()->getIdentity())); $grid->setPrimaryKey("id"); $grid->setTranslator($this->getTranslator()); $grid->addColumnText('title', 'eventsModule.grid.title')->setCustomRender($this->titleRender)->setTruncate(20)->setSortable()->setFilterText(); $headerTitle = $grid->getColumn('title')->headerPrototype; $headerTitle->class[] = 'center'; $headerTitle->style["width"] = "20%"; $grid->addColumnText('eventType', "eventsModule.grid.type")->setCustomRender($this->typeRender)->setSortable()->setFilterSelect($eventTypes); $headerType = $grid->getColumn('eventType')->headerPrototype; $headerType->class[] = 'center'; $grid->addColumnDate('takePlaceSince', 'eventsModule.grid.takeSince', self::DATETIME_FORMAT)->setCustomRender($this->sinceRender)->setSortable(); $headerSince = $grid->getColumn('takePlaceSince')->headerPrototype; $headerSince->class[] = 'center'; $grid->addColumnDate('takePlaceTill', 'eventsModule.grid.takeTill', self::DATETIME_FORMAT)->setCustomRender($this->tillRender)->setSortable(); $headerTill = $grid->getColumn('takePlaceTill')->headerPrototype; $headerTill->class[] = 'center'; $grid->addColumnText("type", "eventsModule.participation.type")->setCustomRender($this->partyTypeRender)->setSortable()->setFilterSelect($partyTypes); $headerPart = $grid->getColumn('type')->headerPrototype; $headerPart->class[] = 'center'; $grid->addActionHref("goto", "", "goToEvent")->setIcon("eye-open")->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("eventsModule.grid.view")])); $grid->setFilterRenderType($this->filterRenderType); return $grid; }
protected function createComponentGrid($name) { $grid = new Grid(); $grid->setModel($this->userModel->findAll()); $grid->setPrimaryKey('id'); $grid->addColumnText('username', 'Používateľ')->setSortable()->setFilterText(); $grid->addColumnText('email', 'E-mail')->setSortable()->setFilterText(); $grid->addColumnDate('last_login', 'Posledné prihlásenie')->setSortable()->setFilterDate(); $grid->filterRenderType = $this->filterRenderType; $grid->addActionHref('remove', 'Odstrániť užívateľa')->setIcon('minus')->setConfirm(function ($item) { return "Ste si istý, že chcete odstrániť užívateľa {$item->username}"; }); return $grid; }
protected function createComponentSearchGrid($name) { if ($this->groupsOutput) { $grid = new Grid($this, $name); $grid->setModel($this->groupsOutput); $grid->setPrimaryKey('id'); $grid->addColumnText('name', 'Názov')->setSortable(); $grid->addColumnText('desc', 'Popis')->setSortable(); $grid->addColumnNumber('pocet', 'Počet ľudí')->setSortable(); // $operation = array('join' => 'Pripojiť sa', 'leave' => 'Odísť'); // $grid->setOperation($operation, $this->handleOperations) // ->setConfirm('delete', 'Are you sure you want to delete %i items?'); $grid->filterRenderType = $this->filterRenderType; } }
/** * Admin payments grid control factory * @param string $name */ public function createComponentPaymentsGrid($name) { try { $seasons = [null => null] + $this->seasonService->getSelectSeasons(); $users = [null => null] + $this->getUsersService()->getSelectUsers(); } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad(null, "default", $ex); } $grid = new Grid($this, $name); $grid->setModel($this->getPaymentService()->getPaymentsDataSource()); $grid->setPrimaryKey("id"); $grid->addColumnNumber('id', '#')->cellPrototype->class[] = 'center'; $headerId = $grid->getColumn('id')->headerPrototype; $headerId->class[] = 'center'; $headerId->rowspan = "2"; $headerId->style['width'] = '0.1%'; $grid->addColumnText('owner', $this->tt('paymentsModule.admin.grid.user'))->setSortable()->setFilterSelect($users); $headerLabel = $grid->getColumn('owner')->headerPrototype; $headerLabel->class[] = 'center'; $grid->addColumnText('season', $this->tt('paymentsModule.admin.grid.season'))->setSortable()->setFilterSelect($seasons); $headerSeas = $grid->getColumn('season')->headerPrototype; $headerSeas->class[] = 'center'; $grid->addColumnDate('dueDate', $this->tt('paymentsModule.admin.grid.dueDate'), self::DATE_FORMAT)->setSortable()->setFilterDateRange(); $headerOrdered = $grid->getColumn('dueDate')->headerPrototype; $headerOrdered->class[] = 'center'; $grid->addColumnNumber('amount', $this->tt('paymentsModule.admin.grid.amount'))->setSortable()->setFilterNumber(); $headerAm = $grid->getColumn('amount')->headerPrototype; $headerAm->class[] = 'center'; $states = [null => null] + PaymentStatus::getOptions(); $grid->addColumnText('status', $this->tt('paymentsModule.admin.grid.status'))->setTruncate(9)->setSortable()->setCustomRender($this->statusRender)->setFilterSelect($states); $headerSta = $grid->getColumn('status')->headerPrototype; $headerSta->class[] = 'center'; $grid->addActionHref('delete', '', 'deletePayment!')->setIcon('trash')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("paymentsModule.admin.grid.delete")]))->setConfirm(function ($u) { return $this->tt("paymentsModule.admin.grid.messages.rlyDelPayment", null, ["id" => $u->getId()]); }); $grid->addActionHref('edit', '', 'updatePayment')->setIcon('pencil')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("paymentsModule.admin.grid.update")])); $grid->setOperation(["delete" => $this->tt("system.common.delete"), "markCash" => $this->tt("paymentsModule.admin.grid.markDoneCash"), "markAcc" => $this->tt("paymentsModule.admin.grid.markDoneAcc"), "markSent" => $this->tt("paymentsModule.admin.grid.markSent")], $this->paymentsGridOpsHandler)->setConfirm("delete", $this->tt("paymentsModule.admin.grid.messages.rlyDelPaymentItems")); $grid->setFilterRenderType($this->filterRenderType); $grid->setExport("admin-payments " . date("Y-m-d H:i:s", time())); }
/** * Partners grid factory * @param string $name */ public function createComponentPartnersGrid($name) { try { $users = [null => null] + $this->getUsersService()->getSelectUsers(); } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad(null, "default", $ex); } $grid = new Grid($this, $name); $grid->setTranslator($this->getTranslator()); $grid->setModel($this->getPartnerService()->getPartnersDataSource()); $grid->setPrimaryKey("id"); $grid->addColumnNumber('id', '#')->cellPrototype->class[] = 'center'; $headerId = $grid->getColumn('id')->headerPrototype; $headerId->class[] = 'center'; $headerId->rowspan = "2"; $headerId->style['width'] = '0.1%'; $grid->addColumnText('name', 'partnersModule.admin.grid.name')->setSortable()->setCustomRender($this->nameRender); $headerName = $grid->getColumn('name')->headerPrototype; $headerName->class[] = 'center'; // $grid->addColumnText('referrer','partnersModule.admin.grid.referrer') // ->setSortable() // ->setFilterSelect($users); // $headerRef = $grid->getColumn('referrer')->headerPrototype; // $headerRef->class[] = 'center'; $grid->addColumnDate('updated', 'partnersModule.admin.grid.updated', self::DATE_FORMAT)->setSortable()->setFilterDateRange(); $headerUpdated = $grid->getColumn('updated')->headerPrototype; $headerUpdated->class[] = 'center'; $y = $this->tt("system.common.yes"); $n = $this->tt("system.common.no"); $activeList = [null => null, true => $y, false => $n]; $grid->addColumnNumber('active', 'partnersModule.admin.grid.active')->setReplacement([true => $y, null => $n])->setSortable()->setFilterSelect($activeList); $headerActive = $grid->getColumn('active')->headerPrototype; $headerActive->class[] = 'center'; $grid->addColumnText('note', 'partnersModule.admin.grid.note')->setTruncate(30)->setSortable(); $headerNote = $grid->getColumn('note')->headerPrototype; $headerNote->class[] = 'center'; // actions $grid->addActionHref('delete', '', 'deletePartner!')->setIcon('trash')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("partnersModule.admin.grid.delete")]))->setConfirm(function ($u) { return $this->tt("partnersModule.admin.grid.messages.rlyDelPartner", null, ["id" => $u->getId()]); }); $grid->addActionHref('edit', '', 'updatePartner')->setIcon('pencil')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("partnersModule.admin.grid.update")])); $grid->setOperation(["delete" => $this->tt("system.common.delete")], $this->partnersGridOpsHandler)->setConfirm("delete", $this->tt("partnersModule.admin.grid.messages.rlyDelPartnerItems")); $grid->setFilterRenderType($this->filterRenderType); $grid->setExport("admin-partners " . date("Y-m-d H:i:s", time())); }
public function createComponentStaticPagesGrid($name) { try { // $users = [null=>null] + $this->userService->getSelectUsers(); // $pages = [null=>null] + $this->staticPageService->getSelectStaticPages(); $states = [null => null] + StaticPageStatus::getOptions(); $commModes = [null => null] + CommentMode::getOptions(); } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad(null, ":System:Default:adminRoot", $ex); } $grid = new Grid($this, $name); $grid->setTranslator($this->getTranslator()); $grid->setModel($this->staticPageService->getPagesDataSource()); $grid->setPrimaryKey('id'); $grid->addColumnNumber('id', '#')->cellPrototype->class[] = 'center'; $headerId = $grid->getColumn('id')->headerPrototype; $headerId->class[] = 'center'; $headerId->rowspan = "2"; $headerId->style['width'] = '0.1%'; $grid->addColumnText('title', $this->tt("systemModule.admin.grid.title"))->setSortable(); $headerTt = $grid->getColumn('title')->headerPrototype; $headerTt->class[] = 'center'; $grid->addColumnText('abbr', $this->tt("systemModule.admin.grid.abbr"))->setSortable()->setFilterText(); $headerAb = $grid->getColumn('abbr')->headerPrototype; $headerAb->class[] = 'center'; // $grid->addColumnText('parent', $this->tt("systemModule.admin.grid.parent")) // ->setSortable() // ->setFilterSelect($pages); // $headerParent = $grid->getColumn('parent')->headerPrototype; // $headerParent->class[] = 'center'; $grid->addColumnText('group', $this->tt("systemModule.admin.grid.group"))->setSortable()->setFilterSelect([null => null] + $this->getSelectSportGroups()); $headerParent = $grid->getColumn('group')->headerPrototype; $headerParent->class[] = 'center'; $grid->addColumnText('commentMode', $this->tt("systemModule.admin.grid.commMode"))->setSortable()->setCustomRender($this->spCommModeRender)->setFilterSelect($commModes); $headerCm = $grid->getColumn('commentMode')->headerPrototype; $headerCm->class[] = 'center'; $grid->addColumnText('status', $this->tt("systemModule.admin.grid.status"))->setSortable()->setCustomRender($this->spStatusRender)->setFilterSelect($states); $headerSt = $grid->getColumn('status')->headerPrototype; $headerSt->class[] = 'center'; $grid->addActionHref('delete', '', 'deleteStaticPage!')->setIcon('trash')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("systemModule.admin.grid.delete")]))->setConfirm(function ($u) { return $this->tt("systemModule.admin.grid.messages.rlyDelPage", null, ["id" => $u->getId()]); }); $grid->addActionHref('edit', '', 'updateStaticPage')->setIcon('pencil')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("systemModule.admin.grid.update")])); $grid->setOperation(["delete" => $this->tt("systemModule.admin.grid.delete")], $this->staticPagesOpHandler)->setConfirm("delete", $this->tt("systemModule.admin.grid.messages.rlyDelPageItems")); $grid->setFilterRenderType($this->filterRenderType); $grid->setExport("admin-types " . date("Y-m-d H:i:s", time())); }
public function createComponentEntriesGrid($name) { $seasons = [null => null] + $this->getSelectSeasons(); $users = [null => null] + $this->getSelectUsers(); $grid = new Grid($this, $name); $grid->setModel($this->entryService->getEntriesDataSource()); $grid->setPrimaryKey("id"); $grid->addColumnNumber('id', '#')->cellPrototype->class[] = 'center'; $headerId = $grid->getColumn('id')->headerPrototype; $headerId->class[] = 'center'; $headerId->rowspan = "2"; $headerId->style['width'] = '0.1%'; $grid->addColumnText('season', $this->tt("motivationModule.admin.grid.season"))->setSortable()->setFilterSelect($seasons); $headerSeas = $grid->getColumn('season')->headerPrototype; $headerSeas->class[] = 'center'; $grid->addColumnText('owner', $this->tt("motivationModule.admin.grid.owner"))->setSortable()->setFilterSelect($users); $headerOwn = $grid->getColumn('owner')->headerPrototype; $headerOwn->class[] = 'center'; $grid->addColumnText('amount', $this->tt("motivationModule.admin.grid.amount"))->setSortable()->setFilterText(); $headerAmnt = $grid->getColumn('amount')->headerPrototype; $headerAmnt->class[] = 'center'; $types = MotivationEntryType::getOptions(); $grid->addColumnText('type', $this->tt("motivationModule.admin.grid.type"))->setSortable()->setReplacement($types)->setFilterSelect([null => null] + $types); $headerT = $grid->getColumn('type')->headerPrototype; $headerT->class[] = 'center'; $grid->addColumnText('subject', $this->tt("motivationModule.protected.grid.subject"))->setSortable()->setFilterText(); $headerSubj = $grid->getColumn('subject')->headerPrototype; $headerSubj->class[] = 'center'; $grid->addActionHref('delete', '', "deleteEntry!")->setIcon('trash')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("motivationModule.admin.grid.delete")]))->setConfirm(function ($u) { return $this->tt("motivationModule.admin.grid.rlyDeleteEntryId", null, ["id" => $u->getId()]); }); $grid->addActionHref("update", "", "updateEntry")->setIcon("pencil")->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("motivationModule.admin.grid.update")])); $operation = ['delete' => $this->tt("system.common.delete")]; $grid->setOperation($operation, $this->entryGridOpsHandler)->setConfirm('delete', $this->tt("motivationModule.admin.grid.reallyDeleteItems")); $grid->setFilterRenderType($this->filterRenderType); $grid->setExport("admin-motivation-entries" . date("Y-m-d H:i:s", time())); }
public function createComponentSeasonTaxGrid($name) { $grid = new Grid($this, $name); $grid->setModel($this->getSeasonTaxService()->getSeasonTaxesDataSource()); $grid->setPrimaryKey('id'); $grid->addColumnNumber('id', '#')->cellPrototype->class[] = 'center'; $headerId = $grid->getColumn('id')->headerPrototype; $headerId->class[] = 'center'; $headerId->rowspan = "2"; $headerId->style['width'] = '0.1%'; $grid->addColumnText('season', 'Sezóna')->setSortable(); $headerLabel = $grid->getColumn('season')->headerPrototype; $headerLabel->class[] = 'center'; $grid->addColumnText('sportGroup', 'Skupina')->setSortable(); $headerSince = $grid->getColumn('sportGroup')->headerPrototype; $headerSince->class[] = 'center'; $grid->addColumnDate('changed', 'Změněno')->setSortable(); $headerTill = $grid->getColumn('changed')->headerPrototype; $headerTill->class[] = 'center'; if ($this->isMemberShip()) { $grid->addColumnText('memberShip', 'Člp')->setSortable(); $headerMship = $grid->getColumn('memberShip')->headerPrototype; $headerMship->class[] = 'center'; } $grid->addColumnText('comment', 'Poznámka')->setSortable()->setTruncate(15); $headerNote = $grid->getColumn('comment')->headerPrototype; $headerNote->class[] = 'center'; $grid->addActionHref('delete', '', 'deleteSeasonTax!')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("seasonsModule.admin.grid.delete")]))->setIcon('trash')->setConfirm(function ($u) { return $this->tt("seasonsModule.admin.grid.reallyDeleteTaxId", null, ["id" => $u->getId()]); }); $grid->addActionHref('edit', '', 'updateSeasonTax')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("seasonsModule.admin.grid.update")]))->setIcon('pencil'); $grid->setOperation(["delete" => $this->tt("seasonsModule.admin.grid.delete")], $this->taxOperationsGridHandle); $grid->setFilterRenderType($this->filterRenderType); $grid->setExport("admin-seasons " . date("Y-m-d H:i:s", time())); return $grid; }
public function createComponentWebProfilesPermitGrid($name) { $grid = new Grid($this, $name); $grid->setModel($this->userService->getWebProfilesToPermitDatasource()); $grid->setTranslator($this->getTranslator()); $grid->setDefaultPerPage(30); $grid->setPrimaryKey('id'); $grid->addColumnNumber('id', '#')->cellPrototype->class[] = 'center'; $headerId = $grid->getColumn('id')->headerPrototype; $headerId->class[] = 'center'; $headerId->rowspan = "2"; $headerId->style['width'] = '0.1%'; $grid->addColumnText("personalLikes", "usersModule.admin.wpGrid.content.label")->setTruncate(100)->setCustomRender($this->wpDataRender)->cellPrototype->class[] = 'center'; $headerData = $grid->getColumn('personalLikes')->headerPrototype; $headerData->class[] = 'center'; $headerData->style['width'] = '70%'; $grid->addColumnText("personalDisLikes", "usersModule.admin.wpGrid.photo.label")->setCustomRender($this->wpPhotoRender)->cellPrototype->class[] = 'center'; $headerPhoto = $grid->getColumn('personalDisLikes')->headerPrototype; $headerPhoto->class[] = 'center'; $headerPhoto->style['width'] = '8%'; $y = $this->tt("system.common.yes"); $n = $this->tt("system.common.no"); $activeList = [null => null] + [true => $y, false => $n]; $grid->addColumnText('publish', $this->tt("systemModule.admin.grid.active"))->setSortable()->setReplacement([true => $y, null => $n])->setFilterSelect($activeList); $headerAct = $grid->getColumn('publish')->headerPrototype; $headerAct->class[] = 'center'; $headerAct->style['width'] = '0.1%'; $grid->addActionHref('yes', '', "permitProfile!")->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("usersModule.admin.grid.permitProfile")]))->setIcon('ok')->setConfirm(function ($u) { return $this->tt("usersModule.admin.wpGrid.reallyPermitItem", null, ["id" => $u->getId()]); }); $grid->addActionHref('no', '', "denyProfile!")->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("usersModule.admin.grid.denyProfile")]))->setIcon('remove')->setConfirm(function ($u) { return $this->tt("usersModule.admin.wpGrid.reallyDenyItem", null, ["id" => $u->getId()]); }); $operation = array('yes' => 'Permit', 'no' => 'Deny'); $grid->setOperation($operation, $this->wppGridOperationsHandler)->setConfirm("yes", $this->tt("usersModule.admin.wpGrid.reallyPermitItems"))->setConfirm("no", $this->tt("usersModule.admin.wpGrid.reallyDenyItems")); $grid->setFilterRenderType($this->filterRenderType); $grid->setExport("admin-users " . date("Y-m-d H:i:s", time())); return $grid; }
/** * Admin articles grid factory. * @param string $name * @return Grid */ public function createComponentArticlesGrid($name) { $articleStates = [null => null] + ArticleStatus::getOptions(); $commentModes = [null => null] + CommentMode::getOptions(); try { $users = [null => null] + $this->usersService->getSelectUsers(); } catch (Exceptions\DataErrorException $ex) { $this->handleException($ex); } $grid = new Grid($this, $name); $grid->setModel($this->articleService->getArticlesDataSource()); $grid->setTranslator($this->getTranslator()); $grid->setPrimaryKey("id"); $grid->addColumnNumber("id", "#")->cellPrototype->class[] = "center"; $headerId = $grid->getColumn("id")->headerPrototype; $headerId->class[] = "center"; $headerId->rowspan = "2"; $headerId->style["width"] = '0.1%'; $grid->addColumnText('title', $this->tt("articlesModule.admin.grid.title"))->setSortable()->setCustomRender($this->titleRender)->setFilterText(); $headerTitle = $grid->getColumn('title')->headerPrototype; $headerTitle->class[] = 'center'; $grid->addColumnText('status', $this->tt("articlesModule.admin.grid.state"))->setSortable()->setCustomRender($this->statusRender)->setFilterSelect($articleStates); $headerStatus = $grid->getColumn('status')->headerPrototype; $headerStatus->class[] = 'center'; $grid->addColumnText('commentMode', $this->tt("articlesModule.admin.grid.comments"))->setSortable()->setCustomRender($this->commentModeRender)->setFilterSelect($commentModes); $headerStatus = $grid->getColumn('commentMode')->headerPrototype; $headerStatus->class[] = 'center'; $grid->addColumnText('author', $this->tt("articlesModule.admin.grid.author"))->setSortable()->setFilterSelect($users); $headerAuthor = $grid->getColumn('author')->headerPrototype; $headerAuthor->class[] = 'center'; $grid->addColumnDate('updated', $this->tt("articlesModule.admin.grid.change"), self::DATETIME_FORMAT)->setSortable()->setFilterDateRange(); $headerAuthor = $grid->getColumn('updated')->headerPrototype; $headerAuthor->class[] = 'center'; $grid->addActionHref('delete', '', 'deleteArticle!')->setIcon('trash')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("articlesModule.admin.grid.delete")]))->setConfirm(function ($u) { return $this->tt("articlesModule.admin.grid.rlyDelArticle", null, ["id" => $u->getId()]); }); $grid->addActionHref('edit', '', 'updateArticle')->setIcon('pencil')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("articlesModule.admin.grid.update")])); $grid->addActionHref("goto", "", "goToArticle")->setIcon('eye-open')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("articlesModule.admin.grid.view")])); $grid->setOperation(["delete" => $this->tt("system.common.delete")], $this->articlesGridOperationHandler); $grid->setFilterRenderType($this->filterRenderType); $grid->setExport("admin-articles" . date("Y-m-d H:i:s", time())); return $grid; }
/** * @param $name * @return Grid */ protected function createComponentGrid($name) { $grid = new Grid($this, $name); $grid->translator->lang = 'cs'; $fluent = $this->pagesRepository->getAll(); $pages = []; foreach ($fluent as $pageRow) { $pages[$pageRow->id] = $pageRow; } if (isset($grid->model)) { $grid->model = $fluent; } $grid->addColumnNumber('id', 'ID'); $header = $grid->getColumn('id')->headerPrototype; $header->style['width'] = '0.5%'; $grid->addColumnText('name', 'Název')->setFilterText()->setSuggestion(); $grid->getColumn('name')->headerPrototype->style['width'] = '80%'; $grid->addColumnText('active', 'Aktivní')->setCustomRender(function ($item) { if ($item->active == 0) { $i = Html::el('i', ['class' => 'glyphicon glyphicon-thumbs-down']); $el = Html::el('a', ['class' => 'btn btn-danger btn-xs btn-mini ajax'])->href($this->presenter->link("active!", $item->id))->setHtml($i); } else { $i = Html::el('i', ['class' => 'glyphicon glyphicon-thumbs-up']); $el = Html::el('a', ['class' => 'btn btn-success btn-xs btn-mini ajax'])->href($this->presenter->link("active!", $item->id))->setHtml($i); } return $el; })->cellPrototype->class[] = 'center'; $grid->addColumnText('inMenu', 'Top menu')->setCustomRender(function ($item) { $menuItems = (array) json_decode($item->inMenu); if (!in_array('topMenu', $menuItems)) { $i = Html::el('i', ['class' => 'glyphicon glyphicon-thumbs-down']); $el = Html::el('a', ['class' => 'btn btn-danger btn-xs btn-mini ajax'])->href($this->presenter->link("inTopMenu!", $item->id))->setHtml($i); } else { $i = Html::el('i', ['class' => 'glyphicon glyphicon-thumbs-up']); $el = Html::el('a', ['class' => 'btn btn-success btn-xs btn-mini ajax'])->href($this->presenter->link("inTopMenu!", $item->id))->setHtml($i); } return $el; })->cellPrototype->class[] = 'center'; $grid->addActionHref('edit', '')->setIcon('pencil'); $grid->addActionEvent('delete', '')->setCustomRender(function ($item) { if ($item->parent === 0 || $item->rgt - $item->lft > 1) { $i = Html::el('i', ['class' => 'fa']); $el = Html::el('span', ['class' => 'btn btn-xs btn-mini'])->setHtml($i); } else { $i = Html::el('i', ['class' => 'fa fa-trash']); $el = Html::el('a', ['class' => 'btn btn-default btn-xs btn-mini ajax', 'data-grido-confirm' => "Opravdu chcete tuto položku odstranit?"])->href($this->presenter->link("delete!", $item->id))->setHtml($i); } return $el; }); $grid->addActionEvent('moveup', '')->setCustomRender(function ($item) use($pages) { $first = $item->parent == 0 || $item->lft - 1 == $pages[$item->parent]['lft']; if ($first) { $i = Html::el('i', ['class' => 'fa']); $el = Html::el('span', ['class' => 'btn btn-xs btn-mini'])->setHtml($i); } else { $i = Html::el('i', ['class' => 'fa fa-arrow-up']); $el = Html::el('a', ['class' => 'btn btn-default btn-xs btn-mini ajax'])->href($this->presenter->link("move!", $item->id, self::UP))->setHtml($i); } return $el; }); $grid->addActionEvent('movedn', '')->setCustomRender(function ($item) use($pages) { $last = $item->parent == 0 || $item->rgt + 1 == $pages[$item->parent]['rgt']; if ($last) { $i = Html::el('i', ['class' => 'fa']); $el = Html::el('span', ['class' => 'btn btn-xs btn-mini'])->setHtml($i); } else { $i = Html::el('i', ['class' => 'fa fa-arrow-down']); $el = Html::el('a', ['class' => 'btn btn-default btn-xs btn-mini ajax'])->href($this->presenter->link("move!", $item->id, self::DN))->setHtml($i); } return $el; }); $grid->addActionHref('add', '')->setIcon('plus'); $grid->setDefaultSort(['lft' => 'ASC']); $grid->setRememberState(TRUE); $grid->setPrimaryKey('id'); $grid->setDefaultPerPage(50); $grid->setRowCallback(function ($item, $tr) { $tr->class[] = "level_{$item->level}"; return $tr; }); $grid->filterRenderType = $this->filterRenderType; $grid->setExport(); return $grid; }
/** * User's payments grid factory * @param string $name * @return Grid */ public function createComponentUserPaymentsGrid($name) { try { $seasons = $this->seasonService->getSelectSeasons(); } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad(null, ":System:Default:userRoot", $ex); } $grid = new Grid($this, $name); $grid->setModel($this->paymentService->getPaymentsDataSource($this->getUser()->getIdentity())); $grid->setTranslator($this->getTranslator()); $grid->setPrimaryKey("id"); $grid->addColumnNumber('id', '#')->cellPrototype->class[] = 'center'; $headerId = $grid->getColumn('id')->headerPrototype; $headerId->class[] = 'center'; $headerId->rowspan = "2"; $headerId->style['width'] = '0.1%'; $grid->addColumnNumber('amount', $this->tt('paymentsModule.admin.grid.amount'))->setSortable()->setFilterNumber(); $headerAm = $grid->getColumn('amount')->headerPrototype; $headerAm->class[] = 'center'; $grid->addColumnText('subject', $this->tt('paymentsModule.admin.grid.subject'))->setCustomRender($this->subjectRender)->setSortable()->setFilterText(); $headerSeas = $grid->getColumn('subject')->headerPrototype; $headerSeas->class[] = 'center'; $grid->addColumnDate('dueDate', $this->tt('paymentsModule.admin.grid.dueDate'), self::DATE_FORMAT)->setSortable()->setFilterDateRange(); $headerOrdered = $grid->getColumn('dueDate')->headerPrototype; $headerOrdered->class[] = 'center'; $states = [null => null] + PaymentStatus::getOptions(); $grid->addColumnText('status', $this->tt('paymentsModule.admin.grid.status'))->setTruncate(9)->setSortable()->setCustomRender($this->statusRender)->setFilterSelect($states); $grid->addColumnText('season', $this->tt('paymentsModule.admin.grid.season'))->setSortable()->setFilterSelect($seasons); $headerSeas = $grid->getColumn('season')->headerPrototype; $headerSeas->class[] = 'center'; $headerSta = $grid->getColumn('status')->headerPrototype; $headerSta->class[] = 'center'; $grid->addActionHref("show", "", "paymentDetails")->setIcon("eye-open"); $grid->addActionHref("markAsSent", "", "markAsSent!")->setIcon("check")->setConfirm(function ($u) { return $this->tt("paymentsModule.protected.grid.messages.rlyMarkAsSent", null, ["id" => $u->getId()]); }); $grid->setFilterRenderType($this->filterRenderType); return $grid; }
public function createComponentForumThreadsGrid($name) { $commentModes = [null => null] + CommentMode::getOptions(); $users = [null => null] + $this->getSelectUsers(); $forums = [null => null] + (array) $this->getSelectForums(); $grid = new Grid($this, $name); $grid->setModel($this->forumService->getForumThreadsDataSource()); $grid->setTranslator($this->getTranslator()); $grid->setPrimaryKey("id"); $grid->addColumnNumber("id", "#")->cellPrototype->class[] = "center"; $headerId = $grid->getColumn("id")->headerPrototype; $headerId->class[] = "center"; $headerId->rowspan = "2"; $headerId->style["width"] = '0.1%'; $grid->addColumnText('title', "communicationModule.admin.grid.title")->setTruncate(20)->setSortable()->setFilterText(); $headerTitle = $grid->getColumn('title')->headerPrototype; $headerTitle->class[] = 'center'; $grid->addColumnText('forum', "communicationModule.admin.grid.forum")->setSortable()->setFilterSelect($forums); $headerPar = $grid->getColumn('forum')->headerPrototype; $headerPar->class[] = 'center'; $grid->addColumnText('commentMode', "communicationModule.admin.grid.comments")->setCustomRender($this->commentModeRender)->setSortable()->setFilterSelect($commentModes); $headerStatus = $grid->getColumn('commentMode')->headerPrototype; $headerStatus->class[] = 'center'; $grid->addColumnText('author', "communicationModule.admin.grid.author")->setSortable()->setFilterSelect($users); $headerAuthor = $grid->getColumn('author')->headerPrototype; $headerAuthor->class[] = 'center'; $grid->addActionHref('delete', '', 'deleteForumThread!')->setIcon('trash')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("communicationModule.admin.grid.delete")]))->setConfirm(function ($u) { return $this->tt("communicationModule.admin.grid.messages.rlyDelForumThr", null, ["id" => $u->getId()]); }); $grid->addActionHref('edit', '', 'updateForumThread')->setIcon('pencil')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("communicationModule.admin.grid.update")])); $grid->setOperation(["delete" => "communicationModule.admin.grid.delete"], $this->forumGridOpsHandler)->setConfirm("delete", "communicationModule.admin.grid.messages.rlyDelForumThrItems"); $grid->setFilterRenderType($this->filterRenderType); $grid->setExport("admin-forum" . date("Y-m-d H:i:s", time())); return $grid; }
/** * @param $name * @return Grid */ protected function createComponentGrid($name) { $grid = new Grid($this, $name); $grid->translator->lang = 'cs'; $fluent = $this->articlesRepository->getAll(); $articles = []; foreach ($fluent as $articleRow) { $articles[$articleRow->id] = $articleRow; } if (isset($grid->model)) { $grid->model = $fluent; } $grid->addColumnNumber('id', 'ID'); $header = $grid->getColumn('id')->headerPrototype; $header->style['width'] = '0.5%'; $grid->addColumnText('name', 'Název')->setFilterText()->setSuggestion(); $grid->getColumn('name')->headerPrototype->style['width'] = '40%'; $grid->addColumnText('active', 'Aktivní')->setCustomRender(function ($item) { if ($item->active == 0) { $i = Html::el('i', ['class' => 'glyphicon glyphicon-thumbs-down']); $el = Html::el('a', ['class' => 'btn btn-danger btn-xs btn-mini ajax'])->href($this->presenter->link("active!", $item->id))->setHtml($i); } else { $i = Html::el('i', ['class' => 'glyphicon glyphicon-thumbs-up']); $el = Html::el('a', ['class' => 'btn btn-success btn-xs btn-mini ajax'])->href($this->presenter->link("active!", $item->id))->setHtml($i); } return $el; })->cellPrototype->class[] = 'center'; $grid->addActionHref('edit', '')->setIcon('pencil'); $grid->addActionEvent('delete', '')->setCustomRender(function ($item) { $i = Html::el('i', ['class' => 'fa fa-trash']); $el = Html::el('a', ['class' => 'btn btn-default btn-xs btn-mini ajax', 'data-grido-confirm' => "Opravdu chcete tuto položku odstranit?"])->href($this->presenter->link("delete!", $item->id))->setHtml($i); return $el; }); $grid->setDefaultSort(['date' => 'DESC']); $grid->setRememberState(true); $grid->setPrimaryKey('id'); $grid->setDefaultPerPage(50); $grid->filterRenderType = $this->filterRenderType; $grid->setExport(); return $grid; }