Exemplo n.º 1
0
 /**
  * Create service
  *
  * @param ServiceLocatorInterface $sm
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $sm)
 {
     $dataGrid = new \ZfcDatagrid\Service\DatagridFactory();
     $dataGrid = $dataGrid->createService($sm);
     $dataGrid->setTitle('Seo');
     $dataGrid->setDefaultItemsPerPage(20);
     $em = $sm->get('doctrine.entitymanager.orm_default');
     $qb = $em->createQueryBuilder();
     $qb->select('s');
     $qb->from('Seo\\Entity\\Seo', 's');
     $dataGrid->setDataSource($qb);
     $col = new Column\Select('id', 's');
     $col->setWidth(1);
     $col->setSortDefault(1, 'DESC');
     $col->setIdentity();
     $col->setHidden(false);
     $col->setLabel('Id');
     $dataGrid->addColumn($col);
     $col = new Column\Select('pageId', 's');
     $col->setLabel('PageId');
     $dataGrid->addColumn($col);
     $col = new Column\Select('type', 's');
     $col->setLabel('Type');
     //    $col->setReplaceValues(array(
     //        'BUILDER' => 'Builder',
     //        'JOB' => 'Job',
     //        'HOMEOWNER' => 'Homeowner'
     //    ));
     $dataGrid->addColumn($col);
     $col = new Column\Select('title', 's');
     $col->setLabel('Title');
     $dataGrid->addColumn($col);
     $col = new Column\Select('description', 's');
     $col->setLabel('Description');
     $dataGrid->addColumn($col);
     $col = new Column\Select('keywords', 's');
     $col->setLabel('Keywords');
     $dataGrid->addColumn($col);
     $action2 = new Column\Action\Icon();
     $action2->setIconClass('icon-edit');
     $action2->setAttribute('href', "/seo/update/" . $action2->getRowIdPlaceholder());
     $action2->setAttribute('data-toggle', 'modal');
     $action2->setAttribute('data-target', '#updateModal');
     $action3 = new Column\Action\Icon();
     $action3->setIconClass('icon-remove');
     $action3->setAttribute('href', '/seo/remove/' . $action3->getRowIdPlaceholder());
     $action3->setAttribute('data-toggle', 'modal');
     $action3->setAttribute('data-target', '#removeModal');
     $col = new Column\Action();
     $col->setLabel('Actions');
     $col->setWidth(1);
     $col->addAction($action2);
     $col->addAction($action3);
     $dataGrid->addColumn($col);
     return $dataGrid;
 }
 public function listAction()
 {
     /* @var $grid \ZfcDatagrid\Datagrid */
     /* @var $em EntityManager */
     $serviceLocator = $this->getServiceLocator();
     $config = $serviceLocator->get('config');
     $entityClass = $config['zfcuser']['userEntityClass'];
     $grid = $serviceLocator->get('ZfcDatagrid\\Datagrid');
     $em = $serviceLocator->get(EntityManager::class);
     $userAliasDql = 'u';
     $qb = $em->getRepository($entityClass)->createQueryBuilder($userAliasDql);
     $grid->setTitle('Users');
     $columnCollection = new ColumnCollection();
     $buttonCollection = new ButtonCollection();
     $colId = new Column\Select('id', $userAliasDql);
     $colId->setLabel('User ID');
     $colId->setWidth(1);
     $columnCollection->put(ColumnCollection::$ID_COLUMN_ID, $colId);
     $colUsername = new Column\Select('username', $userAliasDql);
     $colUsername->setLabel('Username');
     $columnCollection->put(ColumnCollection::$ID_COLUMN_USERNAME, $colUsername);
     $colEmail = new Column\Select('email', $userAliasDql);
     $colEmail->setLabel('Email');
     $columnCollection->put(ColumnCollection::$ID_COLUMN_EMAIL, $colEmail);
     $actions = new Column\Action();
     $actions->setLabel('#Action');
     $actions->setWidth(3);
     $columnCollection->put(ColumnCollection::$ID_COLUMN_ACTIONS, $actions, -1000);
     $editBtn = new Column\Action\Button();
     $editBtn->setLabel('Edit');
     $editBtn->setAttribute('class', 'btn btn-primary btn-sm');
     $editBtn->setLink($this->url()->fromRoute('zfcadmin/zfcuseradmin/edit', array('userId' => $editBtn->getColumnValuePlaceholder($colId))));
     $buttonCollection->put(ButtonCollection::$ID_EDIT_BTN, $editBtn);
     $deleteBtn = new Column\Action\Button();
     $deleteBtn->setLabel('Delete');
     $deleteBtn->setAttribute('class', 'btn btn-danger btn-sm delete-btn');
     $deleteBtn->setLink($this->url()->fromRoute('zfcadmin/zfcuseradmin/remove', array('userId' => $deleteBtn->getColumnValuePlaceholder($colId))));
     $buttonCollection->put(ButtonCollection::$ID_DELETE_BTN, $deleteBtn);
     $events = $this->createPrivateEventManager(ListEvent::class);
     $events->trigger(ListEvent::$EVENT_NAME, $this, array('queryBuilder' => $qb, 'buttonCollection' => $buttonCollection, 'columnCollection' => $columnCollection, 'userAliasDql' => $userAliasDql));
     foreach ($buttonCollection->getIterator() as $btn) {
         $actions->addAction($btn);
     }
     foreach ($columnCollection->getIterator() as $column) {
         $grid->addColumn($column);
     }
     //$grid->addColumn($actions);
     $grid->setDataSource($qb);
     // Finalizing
     $grid->setToolbarTemplateVariables(array('addUrl' => $this->url()->fromRoute('zfcadmin/zfcuseradmin/create')));
     return $grid->getResponse();
 }
Exemplo n.º 3
0
 public function listAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $postData = $request->getPost();
         if ($postData->btnAdd === 'add') {
             $this->redirect()->toRoute('backend_user');
         }
     }
     $sl = $this->getServiceLocator();
     $dbAdapter = $sl->get('Zend\\Db\\Adapter\\Adapter');
     $grid = $sl->get('ZfcDatagrid\\Datagrid');
     $grid->setDefaultItemsPerPage(5);
     $grid->setToolbarTemplate('layout/list-toolbar');
     $grid->setDataSource($sl->get('Backend\\Model\\UserTable')->getUsersList(), $dbAdapter);
     $col = new Column\Select('id', 'u');
     $col->setLabel('id');
     $col->setWidth(25);
     $col->setIdentity(true);
     $col->setSortDefault(1, 'ASC');
     $grid->addColumn($col);
     $col = new Column\Select('username', 'u');
     $col->setLabel('Username');
     $col->setWidth(25);
     $grid->addColumn($col);
     $col = new Column\Select('full_name', 'u');
     $col->setLabel('Name');
     $col->setWidth(25);
     $grid->addColumn($col);
     $col = new Column\Select('email', 'u');
     $col->setLabel('Email');
     $col->setWidth(25);
     $grid->addColumn($col);
     $col = new Column\Select('name', 'r');
     $col->setLabel('Rol');
     $col->setWidth(25);
     $grid->addColumn($col);
     $editBtn = new Column\Action\Button();
     $editBtn->setLabel('Edit');
     $editBtn->setAttribute('class', 'btn btn-primary');
     $editBtn->setAttribute('href', '/backend/user/edit/id/' . $editBtn->getRowIdPlaceholder());
     $delBtn = new Column\Action\Button();
     $delBtn->setLabel('Delete');
     $delBtn->setAttribute('class', 'btn btn-danger');
     $delBtn->setAttribute('href', '/backend/user/delete/id/' . $delBtn->getRowIdPlaceholder());
     $col = new Column\Action();
     $col->addAction($editBtn);
     $col->addAction($delBtn);
     $grid->addColumn($col);
     return $grid->getResponse();
 }
 /**
  * @return \Zend\Http\Response\Stream|\Zend\Stdlib\ResponseInterface|\Zend\View\Model\ViewModel
  */
 public function indexAction()
 {
     $this->layout('layout/admin');
     $grid = $this->dataGridService;
     $grid->setTitle('character-panel grid');
     $grid->setDataSource($this->adminCharacterService->getCharacterQueryBuilder());
     $grid->setToolbarTemplate(null);
     $col = new Column\Select('id', 'p');
     $col->setLabel('#');
     $grid->addColumn($col);
     $col = new Column\Select('jid', 'user');
     $col->setLabel('BackendId');
     $col->addFormatter(new Column\Formatter\GenerateLink($this->viewRenderer, 'PServerAdmin/user_detail', 'usrId', ['action' => 'backend']));
     $grid->addColumn($col);
     $col = new Column\Select('charName', 'p');
     $col->setLabel('CharName');
     $grid->addColumn($col);
     $col = new Column\Select('deleted', 'p');
     $col->setReplaceValues([0 => 'no', 1 => 'yes']);
     $col->setLabel('Deleted');
     $grid->addColumn($col);
     $col = new Column\Select('nickName', 'p');
     $col->setLabel('NickName');
     $grid->addColumn($col);
     $col = new Column\Select('name', 'guild');
     $col->setLabel('GuildName');
     $grid->addColumn($col);
     $col = new Column\Select('jobType', 'job');
     $col->setReplaceValues([0 => 'none', 1 => 'Trader', 2 => 'Thief', 3 => 'Hunter']);
     $col->setLabel('JobType');
     $grid->addColumn($col);
     $col = new Column\Select('level', 'job');
     $col->setLabel('JobLevel');
     $grid->addColumn($col);
     $col = new Column\Select('level', 'p');
     $col->setLabel('Level');
     $grid->addColumn($col);
     $col = new Column\Select('lastLogout', 'p');
     $col->setLabel('LastLogout');
     $col->setType(new AdminDateTime());
     $grid->addColumn($col);
     $grid->render();
     return $grid->getResponse();
 }
Exemplo n.º 5
0
 public function testGetFilterSelectExpression()
 {
     $col = new Column\Select('id', 'user');
     $this->assertFalse($col->hasFilterSelectExpression());
     $this->assertNull($col->getFilterSelectExpression());
     $col->setFilterSelectExpression('CONCAT(%s)');
     $this->assertEquals('CONCAT(%s)', $col->getFilterSelectExpression());
     $this->assertTrue($col->hasFilterSelectExpression());
 }
 /**
  * @return \Zend\Http\Response\Stream|\Zend\Stdlib\ResponseInterface|\Zend\View\Model\ViewModel
  */
 public function indexAction()
 {
     $this->layout('layout/admin');
     /* @var $grid \ZfcDatagrid\Datagrid */
     $grid = $this->dataGridService;
     $grid->setTitle('smc-log grid');
     $grid->setDataSource($this->adminSMCLog->getCharacterQueryBuilder());
     $grid->setToolbarTemplate(null);
     $col = new Column\Select('szuserid', 'p');
     $col->setLabel('UserName');
     $grid->addColumn($col);
     $col = new Column\Select('catagory', 'p');
     $col->setLabel('Category');
     $grid->addColumn($col);
     $col = new Column\Select('szlog', 'p');
     $col->setLabel('Log');
     $grid->addColumn($col);
     $col = new Column\Select('dlogdate', 'p');
     $col->setLabel('LogDate');
     $col->setType(new AdminDateTime());
     $grid->addColumn($col);
     $grid->render();
     return $grid->getResponse();
 }
Exemplo n.º 7
0
 /**
  * Consumers list
  *
  * @return \ZfcDatagrid\Datagrid
  */
 public function getDatagrid()
 {
     $grid = $this->getGrid();
     $grid->setId('dummyGrid');
     $dbAdapter = $this->adapter;
     $select = new Select();
     $select->from(array('c' => 'dummy'));
     $RecordsPerPage = $this->settings->getValueByParameter('Dummy', 'recordsperpage');
     $grid->setDefaultItemsPerPage($RecordsPerPage);
     $grid->setDataSource($select, $dbAdapter);
     $colId = new Column\Select('id', 'c');
     $colId->setLabel('Id');
     $colId->setIdentity();
     $grid->addColumn($colId);
     $col = new Column\Select('name', 'c');
     $col->setLabel(_('Name'));
     $col->setWidth(15);
     $grid->addColumn($col);
     $colType = new Type\DateTime('Y-m-d H:i:s', \IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT);
     $colType->setSourceTimezone('Europe/Rome');
     $colType->setOutputTimezone('UTC');
     $colType->setLocale('it_IT');
     $col = new Column\Select('createdat', 'c');
     $col->setType($colType);
     $col->setLabel(_('Created At'));
     $grid->addColumn($col);
     // Add actions to the grid
     $showaction = new Column\Action\Button();
     $showaction->setAttribute('href', "/admin/dummy/edit/" . $showaction->getColumnValuePlaceholder(new Column\Select('id', 'c')));
     $showaction->setAttribute('class', 'btn btn-xs btn-success');
     $showaction->setLabel(_('edit'));
     $delaction = new Column\Action\Button();
     $delaction->setAttribute('href', '/admin/dummy/delete/' . $delaction->getRowIdPlaceholder());
     $delaction->setAttribute('onclick', "return confirm('Are you sure?')");
     $delaction->setAttribute('class', 'btn btn-xs btn-danger');
     $delaction->setLabel(_('delete'));
     $col = new Column\Action();
     $col->addAction($showaction);
     $col->addAction($delaction);
     $grid->addColumn($col);
     $grid->setToolbarTemplate('');
     return $grid;
 }
 /**
  * Consumers list
  *
  * @return \ZfcDatagrid\Datagrid
  */
 public function getDatagrid()
 {
     $grid = $this->getGrid();
     $grid->setId('profileDatagrid');
     $dbAdapter = $this->adapter;
     $select = new Select();
     $select->from(array('p' => 'profile'));
     $RecordsPerEvent = $this->settings->getValueByParameter('profile', 'recordsperevent');
     $grid->setDefaultItemsPerPage($RecordsPerEvent);
     $grid->setDataSource($select, $dbAdapter);
     $colId = new Column\Select('id', 'p');
     $colId->setLabel('Id');
     $colId->setIdentity();
     $grid->addColumn($colId);
     $col = new Column\Select('name', 'p');
     $col->setLabel(_('Name'));
     $col->setWidth(15);
     $grid->addColumn($col);
     $col = new Column\Select('address', 'p');
     $col->setLabel(_('Address'));
     $grid->addColumn($col);
     $colType = new Type\DateTime('Y-m-d H:i:s', \IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT);
     $colType->setSourceTimezone('Europe/Rome');
     $colType->setOutputTimezone('UTC');
     $colType->setLocale('it_IT');
     $col = new Column\Select('createdat', 'p');
     $col->setType($colType);
     $col->setLabel(_('Created At'));
     $grid->addColumn($col);
     $col = new Column\Select('updatedat', 'p');
     $col->setType($colType);
     $col->setLabel(_('Updated At'));
     $grid->addColumn($col);
     $col = new Column\Select('public', 'p');
     $col->setType(new \ZfcDatagrid\Column\Type\PhpString());
     $col->setLabel(_('Public'));
     $col->setTranslationEnabled(true);
     $col->setFilterSelectOptions(array('' => '-', '0' => _('No'), '1' => _('Yes')));
     $col->setReplaceValues(array('' => '-', '0' => _('No'), '1' => _('Yes')));
     $grid->addColumn($col);
     // Add actions to the grid
     $showaction = new Column\Action\Button();
     $showaction->setAttribute('href', "/admin/profile/edit/" . $showaction->getColumnValuePlaceholder(new Column\Select('id', 'p')));
     $showaction->setAttribute('class', 'btn btn-xs btn-success');
     $showaction->setLabel(_('Edit'));
     $delaction = new Column\Action\Button();
     $delaction->setAttribute('href', '/admin/profile/delete/' . $delaction->getRowIdPlaceholder());
     $delaction->setAttribute('onclick', "return confirm('" . _('Are you sure?') . "')");
     $delaction->setAttribute('class', 'btn btn-xs btn-danger');
     $delaction->setLabel(_('Delete'));
     $col = new Column\Action();
     $col->addAction($showaction);
     $col->addAction($delaction);
     $grid->addColumn($col);
     $grid->setToolbarTemplate('');
     return $grid;
 }
 /**
  * Consumers list
  *
  * @return \ZfcDatagrid\Datagrid
  */
 public function getDatagrid()
 {
     $grid = $this->getGrid();
     $grid->setId('cmspagecategoryGrid');
     $dbAdapter = $this->adapter;
     $select = new Select();
     $select->from(array('c' => 'cms_page_category'));
     $grid->setDefaultItemsPerPage(100);
     $grid->setDataSource($select, $dbAdapter);
     $colId = new Column\Select('id', 'c');
     $colId->setLabel('Id');
     $colId->setIdentity();
     $grid->addColumn($colId);
     $col = new Column\Select('category', 'c');
     $col->setLabel(_('Category'));
     $col->setWidth(15);
     $grid->addColumn($col);
     $col = new Column\Select('visible', 'c');
     $col->setType(new \ZfcDatagrid\Column\Type\String());
     $col->setLabel(_('Visible'));
     $col->setTranslationEnabled(true);
     $col->setFilterSelectOptions(array('' => '-', '0' => 'No', '1' => 'Yes'));
     $col->setReplaceValues(array('' => '-', '0' => 'No', '1' => 'Yes'));
     $grid->addColumn($col);
     // Add actions to the grid
     $showaction = new Column\Action\Button();
     $showaction->setAttribute('href', "/admin/cmscategory/edit/" . $showaction->getColumnValuePlaceholder(new Column\Select('id', 'c')));
     $showaction->setAttribute('class', 'btn btn-xs btn-success');
     $showaction->setLabel(_('edit'));
     $delaction = new Column\Action\Button();
     $delaction->setAttribute('href', '/admin/cmscategory/delete/' . $delaction->getRowIdPlaceholder());
     $delaction->setAttribute('onclick', "return confirm('Are you sure?')");
     $delaction->setAttribute('class', 'btn btn-xs btn-danger');
     $delaction->setLabel(_('delete'));
     $col = new Column\Action();
     $col->addAction($showaction);
     $col->addAction($delaction);
     $grid->addColumn($col);
     $grid->setToolbarTemplate('');
     return $grid;
 }
 private function createGrid()
 {
     $dbAdapter = $this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter');
     $select = new Select();
     $select->from(array('l' => 'base_languages'));
     $grid = $this->getServiceLocator()->get('ZfcDatagrid\\Datagrid');
     $grid->setDefaultItemsPerPage(100);
     $grid->setDataSource($select, $dbAdapter);
     $colId = new Column\Select('id', 'l');
     $colId->setLabel('Id');
     $colId->setIdentity();
     $grid->addColumn($colId);
     $col = new Column\Select('language', 'l');
     $col->setLabel(_('Title'));
     $col->setWidth(15);
     $grid->addColumn($col);
     $col = new Column\Select('locale', 'l');
     $col->setLabel(_('Locale'));
     $grid->addColumn($col);
     $col = new Column\Select('base', 'l');
     $col->setType(new \ZfcDatagrid\Column\Type\String());
     $col->setLabel(_('Base'));
     $col->setTranslationEnabled(true);
     $col->setFilterSelectOptions(array('' => '-', '0' => 'No', '1' => 'Yes'));
     $col->setReplaceValues(array('' => '-', '0' => 'No', '1' => 'Yes'));
     $grid->addColumn($col);
     $col = new Column\Select('active', 'l');
     $col->setType(new \ZfcDatagrid\Column\Type\String());
     $col->setLabel(_('Active'));
     $col->setTranslationEnabled(true);
     $col->setFilterSelectOptions(array('' => '-', '0' => 'No', '1' => 'Yes'));
     $col->setReplaceValues(array('' => '-', '0' => 'No', '1' => 'Yes'));
     $grid->addColumn($col);
     // Add actions to the grid
     $showaction = new Column\Action\Button();
     $showaction->setAttribute('href', "/admin/languages/edit/" . $showaction->getColumnValuePlaceholder(new Column\Select('id', 'l')));
     $showaction->setAttribute('class', 'btn btn-xs btn-success');
     $showaction->setLabel($this->translator->translate('edit'));
     $delaction = new Column\Action\Button();
     $delaction->setAttribute('href', '/admin/languages/delete/' . $delaction->getRowIdPlaceholder());
     $delaction->setAttribute('onclick', "return confirm('Are you sure?')");
     $delaction->setAttribute('class', 'btn btn-xs btn-danger');
     $delaction->setLabel($this->translator->translate('delete'));
     $col = new Column\Action();
     $col->addAction($showaction);
     $col->addAction($delaction);
     $grid->addColumn($col);
     $grid->setToolbarTemplate('');
     return $grid;
 }
 /**
  * Product list
  *
  * @return \ZfcDatagrid\Datagrid
  */
 public function getDatagrid()
 {
     $grid = $this->getGrid();
     $grid->setId('productGrid');
     $dbAdapter = $this->adapter;
     $select = new Select();
     $select->from(array('p' => 'product_attributes'));
     $RecordsPerPage = $this->settings->getValueByParameter('product_attributes', 'recordsperpage');
     $grid->setDefaultItemsPerPage($RecordsPerPage);
     $grid->setDataSource($select, $dbAdapter);
     $colId = new Column\Select('id', 'p');
     $colId->setLabel('Id');
     $colId->setIdentity();
     $grid->addColumn($colId);
     $col = new Column\Select('name', 'p');
     $col->setLabel(_('Name'));
     $col->setWidth(15);
     $grid->addColumn($col);
     $col = new Column\Select('type', 'p');
     $col->setLabel(_('Type'));
     $col->setWidth(5);
     $grid->addColumn($col);
     $col = new Column\Select('quick_search', 'p');
     $col->setLabel(_('Search'));
     $col->setWidth(5);
     $col->setFilterSelectOptions(array('' => '-', '0' => _('No'), '1' => _('Yes')));
     $col->setReplaceValues(array('' => '-', '0' => _('No'), '1' => _('Yes')));
     $grid->addColumn($col);
     $col = new Column\Select('label', 'p');
     $col->setLabel(_('Label'));
     $col->setWidth(15);
     $grid->addColumn($col);
     $col = new Column\Select('is_user_defined', 'p');
     $col->setLabel(_('Is User Defined'));
     $col->setWidth(5);
     $col->setFilterSelectOptions(array('' => '-', '0' => _('No'), '1' => _('Yes')));
     $col->setReplaceValues(array('' => '-', '0' => _('No'), '1' => _('Yes')));
     $grid->addColumn($col);
     $col = new Column\Select('is_required', 'p');
     $col->setLabel(_('Is Required'));
     $col->setWidth(5);
     $col->setFilterSelectOptions(array('' => '-', '0' => _('No'), '1' => _('Yes')));
     $col->setReplaceValues(array('' => '-', '0' => _('No'), '1' => _('Yes')));
     $grid->addColumn($col);
     // Add actions to the grid
     $showaction = new Column\Action\Button();
     $showaction->setAttribute('href', "/admin/product/attributes/edit/" . $showaction->getColumnValuePlaceholder(new Column\Select('id', 'p')));
     $showaction->setAttribute('class', 'btn btn-xs btn-success');
     $showaction->setLabel(_('edit'));
     $delaction = new Column\Action\Button();
     $delaction->setAttribute('href', '/admin/product/attributes/delete/' . $delaction->getRowIdPlaceholder());
     $delaction->setAttribute('onclick', "return confirm('Are you sure?')");
     $delaction->setAttribute('class', 'btn btn-xs btn-danger');
     $delaction->setLabel(_('delete'));
     $col = new Column\Action();
     $col->addAction($showaction);
     $col->addAction($delaction);
     $grid->addColumn($col);
     $grid->setToolbarTemplate('');
     return $grid;
 }
 /**
  * Consumers list
  *
  * @return \ZfcDatagrid\Datagrid
  */
 public function getDatagrid()
 {
     $grid = $this->getGrid();
     $grid->setTitle('Customers');
     $grid->setId('customerGrid');
     $grid->setToolbarTemplateVariables(array('globalActions' => array(_('New Customer') => '/admin/customer/add'), array(_('New Customer') => '/admin/customer/add')));
     $dbAdapter = $this->adapter;
     $select = new Select();
     $select->from(array('c' => 'customer'));
     $select->join('user', 'c.user_id = user.user_id', array('email'), 'left');
     $select->join('base_status', 'status_id = base_status.id', array('id'), 'left');
     // Status array
     $arrStatus = array();
     $status = $this->statusservice->findAll('customers');
     foreach ($status as $s) {
         $arrStatus[$s->getId()] = $s->getStatus();
     }
     $grid->setDefaultItemsPerPage($this->settings->getValueByParameter('Customer', 'recordsperpage'));
     $grid->setDataSource($select, $dbAdapter);
     $col = new Column\Select('id', 'c');
     $col->setLabel('Id');
     $col->setIdentity();
     $grid->addColumn($col);
     $col = new Column\Select('company', 'c');
     $col->setLabel(_('Company'));
     $col->setWidth(40);
     $grid->addColumn($col);
     $col = new Column\Select('firstname', 'c');
     $col->setLabel(_('Last name'));
     $col->setWidth(15);
     $grid->addColumn($col);
     $col = new Column\Select('lastname', 'c');
     $col->setLabel(_('First name'));
     $col->setWidth(15);
     $grid->addColumn($col);
     $colType = new Type\DateTime('Y-m-d H:i:s', \IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT);
     $colType->setSourceTimezone('Europe/Rome');
     $colType->setOutputTimezone('UTC');
     $colType->setLocale('it_IT');
     $col = new Column\Select('id', 'base_status');
     $col->setLabel('Status');
     $col->setWidth(10);
     $col->setReplaceValues($arrStatus);
     $col->setFilterSelectOptions($arrStatus);
     $col->setTranslationEnabled(true);
     $grid->addColumn($col);
     $col = new Column\Select('email', 'user');
     $col->setLabel(_('Email'));
     $col->addFormatter(new Formatter\Email());
     $col->addStyle(new Style\Bold());
     $col->setWidth(15);
     $grid->addColumn($col);
     $col = new Column\Select('createdat', 'c');
     $col->setType($colType);
     $col->setLabel(_('Created At'));
     $grid->addColumn($col);
     // Add actions to the grid
     $showaction = new Column\Action\Icon();
     $showaction->setAttribute('href', "/admin/customer/edit/" . $showaction->getColumnValuePlaceholder(new Column\Select('id', 'c')));
     $showaction->setAttribute('class', 'btn btn-xs btn-success');
     $showaction->setIconClass('glyphicon glyphicon-pencil');
     $delaction = new Column\Action\Icon();
     $delaction->setAttribute('href', '/admin/customer/delete/' . $delaction->getRowIdPlaceholder());
     $delaction->setAttribute('onclick', "return confirm('Are you sure?')");
     $delaction->setAttribute('class', 'btn btn-xs btn-danger');
     $delaction->setIconClass('glyphicon glyphicon-remove');
     $col = new Column\Action();
     $col->addAction($showaction);
     $col->addAction($delaction);
     $grid->addColumn($col);
     $grid->addMassAction(new Action\Mass(_('Enable'), '/admin/customer/massaction/enable', true));
     $grid->addMassAction(new Action\Mass(_('Disable'), '/admin/customer/massaction/disable', true));
     $grid->addMassAction(new Action\Mass(_('Delete'), '/admin/customer/massaction/delete', true));
     #$grid->setToolbarTemplateVariables(['myVariable' => 123]);
     #$grid->setToolbarTemplate('zfc-datagrid/toolbar/customer');
     return $grid;
 }
 /**
  * Consumers list
  *
  * @return \ZfcDatagrid\Datagrid
  */
 public function getDatagrid()
 {
     $grid = $this->getGrid();
     $grid->setId('contactGrid');
     $dbAdapter = $this->adapter;
     $select = new Select();
     $select->from(array('c' => 'customer_group'));
     $grid = $this->getGrid();
     $grid->setDefaultItemsPerPage(10);
     $grid->setDataSource($select, $dbAdapter);
     $colId = new Column\Select('id', 'c');
     $colId->setLabel('Id');
     $colId->setIdentity();
     $grid->addColumn($colId);
     $col = new Column\Select('name', 'c');
     $col->setLabel(_('Name'));
     $grid->addColumn($col);
     $col = new Column\Select('enabled', 'c');
     $col->setLabel(_('Enabled'));
     $col->setWidth(15);
     $col->setFilterSelectOptions(array('' => '-', '0' => _('No'), '1' => _('Yes')));
     $col->setReplaceValues(array('' => '-', '0' => _('No'), '1' => _('Yes')));
     $grid->addColumn($col);
     // Add actions to the grid
     $showaction = new Column\Action\Button();
     $showaction->setAttribute('href', "/admin/customer/group/edit/" . $showaction->getColumnValuePlaceholder(new Column\Select('id', 'c')));
     $showaction->setAttribute('class', 'btn btn-xs btn-success');
     $showaction->setLabel(_('edit'));
     $delaction = new Column\Action\Button();
     $delaction->setAttribute('href', '/admin/customer/group/delete/' . $delaction->getRowIdPlaceholder());
     $delaction->setAttribute('onclick', "return confirm('Are you sure?')");
     $delaction->setAttribute('class', 'btn btn-xs btn-danger');
     $delaction->setLabel(_('delete'));
     $col = new Column\Action();
     $col->addAction($showaction);
     $col->addAction($delaction);
     $grid->addColumn($col);
     $grid->setToolbarTemplate('');
     return $grid;
 }
Exemplo n.º 14
0
 /**
  * Consumers list
  *
  * @return \ZfcDatagrid\Datagrid
  */
 public function getDatagrid()
 {
     $grid = $this->getGrid();
     $grid->setId('cmsblockGrid');
     $dbAdapter = $this->adapter;
     $select = new Select();
     $select->from(array('b' => 'cms_block'))->join(array('l' => 'base_languages'), 'b.language_id = l.id', array('language'), 'left');
     $grid->setDefaultItemsPerPage(100);
     $grid->setDataSource($select, $dbAdapter);
     $colId = new Column\Select('id', 'b');
     $colId->setLabel('Id');
     $colId->setIdentity();
     $grid->addColumn($colId);
     $col = new Column\Select('title', 'b');
     $col->setLabel(_('Title'));
     $col->setWidth(15);
     $grid->addColumn($col);
     $col = new Column\Select('placeholder', 'b');
     $col->setLabel(_('Placeholder'));
     $grid->addColumn($col);
     $colType = new Type\DateTime('Y-m-d H:i:s', \IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT);
     $colType->setSourceTimezone('Europe/Rome');
     $colType->setOutputTimezone('UTC');
     $colType->setLocale('it_IT');
     $col = new Column\Select('createdat', 'b');
     $col->setType($colType);
     $col->setLabel(_('Created At'));
     $grid->addColumn($col);
     $col = new Column\Select('updatedat', 'b');
     $col->setType($colType);
     $col->setLabel(_('Updated At'));
     $grid->addColumn($col);
     $col = new Column\Select('language', 'l');
     $col->setLabel(_('Language'));
     $col->addStyle(new Style\Bold());
     $grid->addColumn($col);
     $col = new Column\Select('visible', 'b');
     $col->setType(new \ZfcDatagrid\Column\Type\String());
     $col->setLabel(_('Visible'));
     $col->setTranslationEnabled(true);
     $col->setFilterSelectOptions(array('' => '-', '0' => 'No', '1' => 'Yes'));
     $col->setReplaceValues(array('' => '-', '0' => 'No', '1' => 'Yes'));
     $grid->addColumn($col);
     // Add actions to the grid
     $showaction = new Column\Action\Button();
     $showaction->setAttribute('href', "/admin/cmsblocks/edit/" . $showaction->getColumnValuePlaceholder(new Column\Select('id', 'b')));
     $showaction->setAttribute('class', 'btn btn-xs btn-success');
     $showaction->setLabel(_('edit'));
     $delaction = new Column\Action\Button();
     $delaction->setAttribute('href', '/admin/cmsblocks/delete/' . $delaction->getRowIdPlaceholder());
     $delaction->setAttribute('onclick', "return confirm('Are you sure?')");
     $delaction->setAttribute('class', 'btn btn-xs btn-danger');
     $delaction->setLabel(_('delete'));
     $col = new Column\Action();
     $col->addAction($showaction);
     $col->addAction($delaction);
     $grid->addColumn($col);
     $grid->setToolbarTemplate('');
     return $grid;
 }
Exemplo n.º 15
0
 /**
  * Product list
  *
  * @return \ZfcDatagrid\Datagrid
  */
 public function getDatagrid()
 {
     $eavProduct = new \Product\Model\EavProduct($this->tableGateway);
     $records = array();
     $result = array();
     $customAttributes = array();
     $grid = $this->getGrid();
     $grid->setId('productGrid');
     $dbAdapter = $this->adapter;
     $select = new Select();
     $select->from(array('p' => 'product'));
     // execute the query
     $sql = new \Zend\Db\Sql\Sql($this->adapter);
     $stmt = $sql->prepareStatementForSqlObject($select);
     $results = $stmt->execute();
     // execute the main query
     $records = $this->tableGateway->select($select);
     // load the attributes from the preferences
     $columnsAttributesIdx = $this->settings->getValueByParameter('product', 'attributes');
     if (!empty($columnsAttributesIdx)) {
         // get from the database the custom attributes set as product preferences ($columnsAttributesIdx)
         $selectedAttributes = $this->attributes->findbyIdx(json_decode($columnsAttributesIdx, true));
         $selectedAttributes->buffer();
         // Get the selected product attribute values ONLY
         $attributes = $eavProduct->loadAttributes($results, $selectedAttributes);
         $attributesValues = $attributes->toArray();
         // loop the selected product attribute records
         foreach ($attributesValues as $recordId => $attributeValue) {
             // loop the record selected values
             foreach ($attributeValue as $id => $value) {
                 // get the attribute information
                 $theAttribute = $eavProduct->getAttribute($id);
                 // create a temporary array of data to merge with the main datagrid array
                 $customAttributes[$recordId][$theAttribute->getName()] = $value;
                 // Create a custom column on the grid
                 $col = new Column\Select($theAttribute->getName());
                 $col->setLabel(_($theAttribute->getLabel()));
                 $grid->addColumn($col);
             }
         }
         // Merge the temporary array with the main datagrid array
         foreach ($records as $record) {
             $result[] = array_merge($record->getArrayCopy(), $customAttributes[$record->getId()]);
         }
     }
     $RecordsPerPage = $this->settings->getValueByParameter('product', 'recordsperpage');
     $grid->setDefaultItemsPerPage($RecordsPerPage);
     $grid->setDataSource($result);
     $colId = new Column\Select('id');
     $colId->setLabel('Id');
     $colId->setIdentity();
     $grid->addColumn($colId);
     $colType = new Type\DateTime('Y-m-d H:i:s', \IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT);
     $colType->setSourceTimezone('Europe/Rome');
     $colType->setOutputTimezone('UTC');
     $colType->setLocale('it_IT');
     $col = new Column\Select('createdat');
     $col->setType($colType);
     $col->setLabel(_('Created At'));
     $col->setWidth(15);
     $grid->addColumn($col);
     // Add actions to the grid
     $showaction = new Column\Action\Button();
     $showaction->setAttribute('href', "/admin/product/edit/" . $showaction->getColumnValuePlaceholder(new Column\Select('id')));
     $showaction->setAttribute('class', 'btn btn-xs btn-success');
     $showaction->setLabel(_('edit'));
     $delaction = new Column\Action\Button();
     $delaction->setAttribute('href', '/admin/product/delete/' . $delaction->getRowIdPlaceholder());
     $delaction->setAttribute('onclick', "return confirm('Are you sure?')");
     $delaction->setAttribute('class', 'btn btn-xs btn-danger');
     $delaction->setLabel(_('delete'));
     $col = new Column\Action();
     $col->addAction($showaction);
     $col->addAction($delaction);
     $grid->addColumn($col);
     $grid->setToolbarTemplate('');
     return $grid;
 }