protected function createComponentTable()
 {
     $repository = $this->getRepository();
     $formFactory = $this->getFormFactory();
     $adminControl = new AdminGrid($repository);
     // columns
     $table = $adminControl->getTable();
     $table->addColumnText('email', 'Name')->setSortable()->getCellPrototype()->width = '100%';
     $table->getColumn('email')->setFilterText()->setSuggestion();
     $form = $adminControl->createForm($formFactory, 'Uživatel', NULL, \CmsModule\Components\Table\Form::TYPE_LARGE);
     $import = $adminControl->createForm($this->importFormFactory, 'Import');
     // Toolbar
     $toolbar = $adminControl->getNavbar();
     $toolbar->addSection('new', 'Create', 'file');
     $adminControl->connectFormWithNavbar($form, $toolbar->getSection('new'));
     $toolbar->addSection('export', 'Export', 'floppy-save')->onClick[] = $this->exportClick;
     $toolbar->addSection('import', 'Import', 'floppy-open');
     $adminControl->connectFormWithNavbar($import, $toolbar->getSection('import'));
     // actions
     $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax';
     $adminControl->connectFormWithAction($form, $table->getAction('edit'));
     $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax';
     $adminControl->connectActionAsDelete($table->getAction('delete'));
     return $adminControl;
 }
 public function invoke()
 {
     $admin = new AdminGrid($this->paymentRepository);
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $table->setDefaultSort(array('date' => 'DESC'));
     $table->addColumnDate('date', 'Date');
     $table->addColumnText('offset', 'Offset');
     $table->addColumnText('amount', 'Amount');
     $table->addColumnText('constantSymbol', 'CS');
     $table->addColumnText('variableSymbol', 'VS');
     $table->addColumnText('specificSymbol', 'SS');
     $table->addColumnText('userIdentification', 'User identification');
     $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax';
     $form = $admin->createForm($this->paymentFormFactory, 'Payment', NULL, \CmsModule\Components\Table\Form::TYPE_FULL);
     $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE);
     // Toolbar
     $toolbar = $admin->getNavbar();
     $toolbar->addSection('new', 'Create', 'file');
     $admin->connectFormWithNavbar($form, $toolbar->getSection('new'), $admin::MODE_PLACE);
     $toolbar->addSection('synchronize', 'Synchronize')->setIcon('refresh');
     $toolbar->getSection('synchronize')->onClick[] = $this->synchronizeClick;
     $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax';
     $admin->connectActionAsDelete($table->getAction('delete'));
     return $admin;
 }
 public function invoke()
 {
     $admin = new AdminGrid($this->currencyRepository);
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $table->addColumnText('name', 'Name');
     $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax';
     $form = $admin->createForm($this->currencyFormFactory, 'Payment', NULL, \CmsModule\Components\Table\Form::TYPE_FULL);
     $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE);
     // Toolbar
     $toolbar = $admin->getNavbar();
     $toolbar->addSection('new', 'Create', 'file');
     $admin->connectFormWithNavbar($form, $toolbar->getSection('new'), $admin::MODE_PLACE);
     $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax';
     $admin->connectActionAsDelete($table->getAction('delete'));
     return $admin;
 }
Exemple #4
0
 protected function createComponentTable()
 {
     $admin = new AdminGrid($this->villageRepository);
     // columns
     $table = $admin->getTable();
     $table->addColumnText('name', 'Name')->setSortable()->getCellPrototype()->width = '50%';
     $table->getColumn('name')->setFilterText()->setSuggestion();
     $table->addColumnText('latitude', 'Latitude');
     $table->addColumnText('longitude', 'Longitude');
     $formFactory = $this->formFactory;
     $form = $admin->createForm($formFactory, '', NULL, \CmsModule\Components\Table\Form::TYPE_FULL);
     $section = $admin->getNavbar()->addSection('new', 'New', 'item');
     $table->addAction('edit', 'Edit');
     $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE);
     $admin->connectFormWithNavbar($form, $section, $admin::MODE_PLACE);
     return $admin;
 }
 public function invoke()
 {
     $admin = new AdminGrid($this->revisionRepository);
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $table->setDefaultSort(array('date' => 'DESC'));
     $table->addColumnText('revision', 'Revision');
     $table->addColumnDate('date', 'Date');
     $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax';
     $form = $admin->createForm($this->revisionFormFactory, 'Revision');
     $admin->connectFormWithAction($form, $table->getAction('edit'));
     // Toolbar
     $toolbar = $admin->getNavbar();
     $toolbar->addSection('new', 'Create', 'file');
     $admin->connectFormWithNavbar($form, $toolbar->getSection('new'));
     $table->addAction('delete', 'Delete');
     $admin->connectActionAsDelete($table->getAction('delete'));
     return $admin;
 }
 protected function createComponentTable()
 {
     $admin = new AdminGrid($this->typeRepository);
     // columns
     $table = $admin->getTable();
     $table->setModel(new Doctrine($this->typeRepository->createQueryBuilder('a')));
     $table->addColumnText('name', 'Name')->setSortable()->getCellPrototype()->width = '100%';
     $table->getColumn('name')->setFilterText()->setSuggestion();
     $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax';
     $form = $admin->createForm($this->typeFormFactory, 'Type');
     $admin->connectFormWithAction($form, $table->getAction('edit'));
     // Toolbar
     $toolbar = $admin->getNavbar();
     $toolbar->addSection('new', 'Create', 'file');
     $admin->connectFormWithNavbar($form, $toolbar->getSection('new'));
     $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax';
     $admin->connectActionAsDelete($table->getAction('delete'));
     return $admin;
 }
Exemple #7
0
 protected function createComponentTable()
 {
     $_this = $this;
     $repository = $this->languageRepository;
     $admin = new AdminGrid($this->languageRepository);
     // columns
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $table->addColumnText('name', 'Name')->setSortable()->getCellPrototype()->width = '50%';
     $table->addColumnText('alias', 'Alias')->setSortable()->getCellPrototype()->width = '20%';
     $table->addColumnText('short', 'Short')->setSortable()->getCellPrototype()->width = '30%';
     // actions
     if ($this->isAuthorized('edit')) {
         $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax';
         $form = $admin->createForm($this->form, 'Language', NULL, \CmsModule\Components\Table\Form::TYPE_LARGE);
         $admin->connectFormWithAction($form, $table->getAction('edit'));
         // Toolbar
         $toolbar = $admin->getNavbar();
         $toolbar->addSection('new', 'Create', 'file');
         $admin->connectFormWithNavbar($form, $toolbar->getSection('new'));
         $admin->onAttached[] = function (AdminGrid $admin) use($table, $_this, $repository) {
             if ($admin->formName && !$admin->id) {
                 $admin['navbarForm']->onSuccess[] = function () use($_this, $repository) {
                     if ($repository->createQueryBuilder('a')->select('count(a.id)')->getQuery()->getSingleScalarResult() <= 1) {
                         $_this->redirect('this');
                     }
                 };
             }
         };
     }
     if ($this->isAuthorized('remove')) {
         $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax';
         $admin->connectActionAsDelete($table->getAction('delete'));
         $table->getAction('delete')->onClick[] = function () use($_this, $repository) {
             if ($repository->createQueryBuilder('a')->select('count(a.id)')->getQuery()->getSingleScalarResult() == 0) {
                 $_this->redirect('this');
             }
         };
     }
     return $admin;
 }
Exemple #8
0
 public function invoke()
 {
     $translator = $this->translator;
     $admin = new AdminGrid($this->personRepository);
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $table->addColumnText('name', 'Name')->getCellPrototype()->style[] = 'width: 70%;';
     $table->addColumnText('type', 'Person')->setCustomRender(function (PersonEntity $personEntity) use($translator) {
         $types = PersonEntity::getTypes();
         return $translator->translate($types[$personEntity->getType()]);
     })->getCellPrototype()->style[] = 'width: 30%;';
     $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax';
     $form = $admin->createForm($this->personFormFactory, 'Payment', NULL, \CmsModule\Components\Table\Form::TYPE_FULL);
     $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE);
     // Toolbar
     $toolbar = $admin->getNavbar();
     $toolbar->addSection('new', 'Create', 'file');
     $admin->connectFormWithNavbar($form, $toolbar->getSection('new'), $admin::MODE_PLACE);
     $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax';
     $admin->connectActionAsDelete($table->getAction('delete'));
     return $admin;
 }
 public function invoke()
 {
     $admin = new AdminGrid($this->accountRepository);
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $table->addColumnText('name', 'Account number')->getCellPrototype()->width = '40%';
     $table->addColumnText('bank', 'Bank')->setCustomRender(function (AccountEntity $account) {
         return (string) $account->bank;
     })->getCellPrototype()->width = '30%';
     $table->addColumnText('person', 'Person')->setCustomRender(function (AccountEntity $account) {
         return $account->getPerson() ? $account->getPerson() : '';
     })->getCellPrototype()->width = '30%';
     $table->addAction('synchronize', 'Synchronize')->onClick[] = $this->synchronizeClick;
     $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax';
     $form = $admin->createForm($this->accountFormFactory, 'Account', NULL, \CmsModule\Components\Table\Form::TYPE_FULL);
     $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE);
     // Toolbar
     $toolbar = $admin->getNavbar();
     $toolbar->addSection('new', 'Create', 'file');
     $admin->connectFormWithNavbar($form, $toolbar->getSection('new'), $admin::MODE_PLACE);
     $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax';
     $admin->connectActionAsDelete($table->getAction('delete'));
     return $admin;
 }
 public function invoke()
 {
     $translator = $this->translator;
     $admin = new AdminGrid($this->invoiceRepository);
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $table->setDefaultSort(array('date' => 'DESC'));
     $table->addColumnText('identification', 'ID');
     $table->addColumnText('revisionCounter', 'Revision');
     $table->addColumnDate('date', 'Date');
     $table->addColumnText('supplier', 'Supplier')->setCustomRender(function (InvoiceEntity $invoiceEntity) {
         return $invoiceEntity->getSupplier()->getAccount()->getPerson();
     });
     $table->addColumnText('customer', 'Customer')->setCustomRender(function (InvoiceEntity $invoiceEntity) {
         return $invoiceEntity->getCustomer();
     });
     $table->addColumnText('amount', 'Amount');
     $table->addColumnText('state', 'State')->setCustomRender(function (InvoiceEntity $invoiceEntity) use($translator) {
         $states = InvoiceEntity::getStates();
         return $translator->translate($states[$invoiceEntity->getState()]);
     });
     $table->addAction('generate', 'Generate ID')->setCustomRender(function (InvoiceEntity $invoiceEntity, $element) {
         if ($invoiceEntity->getIdentification()) {
             $element->class[] = 'disabled';
         }
         return $element;
     })->onClick[] = $this->generateClick;
     $table->addAction('generatePdf', 'Generate PDF')->onClick[] = $this->generatePdfClick;
     $table->addAction('downloadPdf', 'Download PDF')->setCustomRender(function (InvoiceEntity $invoiceEntity, $element) {
         if (!count($invoiceEntity->revisions)) {
             $element->class[] = 'disabled';
         }
         return $element;
     })->onClick[] = $this->downloadPdfClick;
     $table->addAction('show', 'Preview')->onClick[] = $this->showClick;
     $table->addAction('pdf', 'PDF')->onClick[] = $this->pdfClick;
     $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax';
     $form = $admin->createForm($this->invoiceFormFactory, 'Payment', NULL, \CmsModule\Components\Table\Form::TYPE_FULL);
     $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE);
     // Toolbar
     $toolbar = $admin->getNavbar();
     $toolbar->addSection('new', 'Create', 'file');
     $admin->connectFormWithNavbar($form, $toolbar->getSection('new'), $admin::MODE_PLACE);
     $table->addAction('delete', 'Delete')->setCustomRender(function (InvoiceEntity $invoiceEntity, $element) {
         $element->class[] = 'ajax';
         if ($invoiceEntity->getState() !== InvoiceEntity::STATE_NEW) {
             $element->class[] = 'disabled';
         }
         return $element;
     });
     $admin->connectActionAsDelete($table->getAction('delete'));
     return $admin;
 }
Exemple #11
0
 protected function createComponentTable()
 {
     $repository = $this->entityManager->getRepository($this->type);
     $admin = new AdminGrid($repository);
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $table->setModel(new Doctrine($repository->createQueryBuilder('a')->addSelect('u')->innerJoin('a.user', 'u'), array('email' => 'u.email')));
     // columns
     $table->addColumnText('email', 'E-mail')->setCustomRender(function ($entity) {
         return $entity->user->email;
     })->setSortable()->getCellPrototype()->width = '60%';
     $table->getColumn('email')->setFilterText()->setSuggestion();
     $table->addColumnText('roles', 'Roles')->getCellPrototype()->width = '40%';
     $table->getColumn('roles')->setCustomRender(function ($entity) {
         return implode(", ", $entity->user->roles);
     });
     // actions
     if ($this->isAuthorized('edit')) {
         $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax';
         $table->addAction('loginProviders', 'Login providers')->getElementPrototype()->class[] = 'ajax';
         $extendedPage = $this->extendedPage;
         $type = $this->type;
         $form = $admin->createForm($this->getUserType()->getFormFactory(), 'User', function () use($extendedPage, $type) {
             return new $type($extendedPage);
         }, Form::TYPE_LARGE);
         $socialForm = $admin->createForm($this->socialForm, 'Login providers', NULL, Form::TYPE_LARGE);
         $admin->connectFormWithAction($form, $table->getAction('edit'), $admin::MODE_PLACE);
         $admin->connectFormWithAction($socialForm, $table->getAction('loginProviders'));
         // Toolbar
         $toolbar = $admin->getNavbar();
         $toolbar->addSection('new', 'Create', 'file');
         $admin->connectFormWithNavbar($form, $toolbar->getSection('new'), $admin::MODE_PLACE);
     }
     if ($this->isAuthorized('remove')) {
         $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax';
         $admin->connectActionAsDelete($table->getAction('delete'));
     }
     return $admin;
 }
Exemple #12
0
 protected function createComponentTable()
 {
     $admin = new AdminGrid($this->tagRepository);
     // columns
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $table->addColumnText('name', 'Name')->setSortable()->getCellPrototype()->width = '100%';
     // actions
     if ($this->isAuthorized('edit')) {
         $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax';
         $repository = $this->tagRepository;
         $form = $admin->createForm($this->formFactory, 'Tag', function () use($repository) {
             return $repository->createNew();
         }, \CmsModule\Components\Table\Form::TYPE_LARGE);
         $admin->connectFormWithAction($form, $table->getAction('edit'));
         // Toolbar
         $toolbar = $admin->getNavbar();
         $toolbar->addSection('new', 'Create', 'file');
         $admin->connectFormWithNavbar($form, $toolbar->getSection('new'));
     }
     if ($this->isAuthorized('remove')) {
         $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax';
         $admin->connectActionAsDelete($table->getAction('delete'));
     }
     return $admin;
 }
Exemple #13
0
 protected function createComponentTable()
 {
     $admin = new AdminGrid($this->roleRepository);
     // columns
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $table->addColumnText('name', 'Name')->setSortable()->getCellPrototype()->width = '40%';
     $table->getColumn('name')->setFilterText()->setSuggestion();
     $table->addColumnText('parent', 'Parent')->setSortable()->getCellPrototype()->width = '60%';
     $table->getColumn('parent')->setCustomRender(function (RoleEntity $entity) {
         $entities = array();
         $en = $entity;
         while ($en = $en->getParent()) {
             $entities[] = $en->getName();
         }
         return implode(', ', $entities);
     });
     // actions
     if ($this->isAuthorized('edit')) {
         $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax';
         $table->addAction('permissions', 'Permissions')->getElementPrototype()->class[] = 'ajax';
         $form = $admin->createForm($this->roleForm, 'Role');
         $permissionsForm = $admin->createForm($this->permissionsForm, 'Permissions', NULL, Form::TYPE_LARGE);
         $admin->connectFormWithAction($form, $table->getAction('edit'));
         $admin->connectFormWithAction($permissionsForm, $table->getAction('permissions'), $admin::MODE_PLACE);
         // Toolbar
         $toolbar = $admin->getNavbar();
         $toolbar->addSection('new', 'Create', 'file');
         $admin->connectFormWithNavbar($form, $toolbar->getSection('new'));
     }
     if ($this->isAuthorized('remove')) {
         $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax';
         $admin->connectActionAsDelete($table->getAction('delete'));
     }
     return $admin;
 }
Exemple #14
0
 protected function createComponentTable()
 {
     $admin = new AdminGrid($this->layoutRepository);
     // columns
     $table = $admin->getTable();
     $table->setTranslator($this->translator);
     $table->addColumnText('name', 'Name')->setSortable()->setFilterText()->setSuggestion();
     $table->getColumn('name')->getCellPrototype()->width = '60%';
     $table->addColumnText('file', 'File')->setSortable()->setFilterText()->setSuggestion();
     $table->getColumn('file')->getCellPrototype()->width = '40%';
     // actions
     if ($this->isAuthorized('edit')) {
         $table->addAction('edit', 'Edit')->getElementPrototype()->class[] = 'ajax';
         $table->addAction('elements', 'Elements')->getElementPrototype()->class[] = 'ajax';
         $form = $admin->createForm($this->layoutFormFactory, 'Layout');
         $admin->connectFormWithAction($form, $table->getAction('edit'));
         // Toolbar
         $toolbar = $admin->getNavbar();
         $toolbar->addSection('new', 'Create', 'file');
         $admin->connectFormWithNavbar($form, $toolbar->getSection('new'));
         $admin->connectActionWithFloor($table->getAction('elements'), $this['elementTable'], 'Borec');
     }
     if ($this->isAuthorized('remove')) {
         $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax';
         $admin->connectActionAsDelete($table->getAction('delete'));
     }
     return $admin;
 }
Exemple #15
0
 protected function createComponentTable()
 {
     $_this = $this;
     $admin = new AdminGrid();
     $deploymentManager = $this->deploymentManager;
     // columns
     $table = $admin->getTable();
     $table->setModel(new ArraySource($this->getBackups()));
     $table->setTranslator($this->translator);
     $table->addColumnText('name', 'Name')->setCustomRender(function ($items) use($_this) {
         return $items['name'] ?: $_this->translator->translate('untitled');
     })->setSortable()->getCellPrototype()->width = '80%';
     $table->addColumnDate('date', 'Date', 'd.m.Y - H:i:s')->setSortable()->getCellPrototype()->width = '20%';
     // actions
     if ($this->isAuthorized('edit')) {
         // Toolbar
         $toolbar = $admin->getNavbar();
         $toolbar->addSection('new', 'Create backup', 'file')->onClick[] = function () use($_this, $deploymentManager, $admin, $table) {
             $deploymentManager->createBackup($_this->getBackupName());
             $admin->invalidateControl('table');
             $_this->payload->url = $_this->link('this');
             $table->setModel(new ArraySource($_this->getBackups()));
         };
         $table->addAction('load', 'Load')->getElementPrototype()->class[] = 'ajax';
         $table->getAction('load')->onClick[] = function ($button, $id) use($_this, $deploymentManager, $admin, $table) {
             $deploymentManager->loadBackup($id);
             $_this->redirect('this');
         };
     }
     if ($this->isAuthorized('remove')) {
         $table->addAction('delete', 'Delete')->getElementPrototype()->class[] = 'ajax';
         $table->getAction('delete')->onClick[] = function ($button, $id) use($_this, $deploymentManager, $admin, $table) {
             $deploymentManager->removeBackup($id);
             $admin->invalidateControl('table');
             $_this->payload->url = $_this->link('this');
             $table->setModel(new ArraySource($_this->getBackups()));
         };
     }
     return $admin;
 }