[ AdminAcl::ACL_VENDOR_SERVICES_ID => [ 'list', 'cancel', 'new', 'insert', 'edit', 'update', 'delete', 'changeOption', 'back', 'exportToCsv', 'exportToPdf', 'downloadPdfExport' ] ], AdminObj::TYPE_TRIBAL_ACCOUNT => [ TribalAccountAcl::ACL_VENDOR_SERVICES_READ_ID => [ 'list', 'cancel', 'back', 'exportToCsv', 'exportToPdf', 'downloadPdfExport' ], ] ]; protected function _initAction() { $this->_initPermittedActions(); return parent::_initAction(); } protected function _initPermittedActions() { $aclIds = AclPermission::getAllowedResources(); if (AclPermission::isTribalAccount()) { if (in_array(TribalAccountAcl::ACL_VENDOR_SERVICES_READ_ID, $aclIds)) { $this->_actions = array_merge( $this->_actions, $this->_allowedActions[AdminObj::TYPE_TRIBAL_ACCOUNT][TribalAccountAcl::ACL_VENDOR_SERVICES_READ_ID] ); } } else { if (in_array(AdminAcl::ACL_VENDOR_SERVICES_ID, $aclIds)) { $this->_actions = array_merge( $this->_actions, $this->_allowedActions[AdminObj::TYPE_ADMIN][AdminAcl::ACL_VENDOR_SERVICES_ID] ); } } return $this; } protected function _getDefaultLinks() { $links = parent::_getDefaultLinks(); $query = $this->getFilter(); $query['orderBy'] = $this->_getList()->getOrderBy(); $query = array_filter($query); $links['exportToCsv'] = [ 'title' => 'Export to .csv', 'url' => $this->url(array_merge(['action' => 'exportToCsv'], $query)), ]; $this->injectPdfExportLinks($links, $query); return $links; } protected function _doExportToCsv() { if ($this->_getDataObj()->hasFilter()) { $form = $this->_getFilterForm(); if ($form->validate()) { $this->_getDataObj()->addFilter($form->getValues()); } } $options = ['order' => $this->_getList()->getOrderBy()]; $this->_dataObj->setSelectOptions($options); $stmt = $this->_getDataObj()->getListStatement(); $rowCallback = function () use ($stmt) { $row = $stmt->fetch(); if ($row) { $row = $this->_getRow4ExportCsv($row); } return $row; }; $helper = new ExportCsv([ 'fileName' => $this->getConfig('itemsName') . ' {date}.csv', 'columns' => $this->getConfigArray('csvExportColumns'), 'rowCallback' => $rowCallback, ]); $helper->export(); $this->_postExportCsv(); exit; } protected function _postExportCsv() { $this->_log(); return $this; } protected function _getRow4ExportCsv(&$data) { $row = str_replace(["\n", "\r"], ' ', $data); return $row; } protected function _getListOptions() { $options = parent::_getListOptions(); $options['vendorUrl'] = VendorView::getPage('url'); return $options; } }