_addResources(); return parent::exec(); } protected function _addResources() { $this->_doc->addStylesheet('css/modules/employee-admin.css'); return $this; } protected function _getFormOptions($type = null) { $options = parent::_getFormOptions($type); if ($type == 'new') { $options['questions'] = $this->getModel()->getQuestions(['enabled' => 'y']); } elseif ($type == 'edit') { $options['questions'] = $this->getModel()->getUsedQuestions(['employeeId' => $this->getData()['id']]); } return $options; } protected function _prepareViewItem(array &$item) { parent::_prepareViewItem($item); $item['questionnaire'] = $this->getModel()->getFullQuestionnaire(['employeeId' => $item['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)), ]; return $links; } protected function _doExportToCsv() { $dataObj = $this->_getDataObj(); if ($dataObj->hasFilter()) { $form = $this->_getFilterForm(); if ($form->validate()) { $dataObj->addFilter($form->getValues()); } } $options = ['order' => $this->_getList()->getOrderBy()]; $dataObj->setSelectOptions($options); $stmt = $dataObj->getList4ExportStatement(); $rowCallback = function () use ($stmt, $dataObj) { $row = $stmt->fetch(); if ($row) { $dataObj->prepareExportRow($row); } return $row; }; $helper = new ExportCsv([ 'fileName' => $this->getConfig('itemsName') . ' {date}.csv', 'columns' => $dataObj->getExportCsvColumns(), 'rowCallback' => $rowCallback, ]); $helper->export(); exit; } }