_dataObj->getFilter(); foreach ($filter as $field => $value) { if ($value) { $params[$field] = $value; } } $params['action'] = 'exportCsv'; $links['exportCsv'] = ['title' => 'Export to CSV', 'url' => $this->url($params)]; return $links; } protected function _doExportCsv() { $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->_getExportFileName(), 'columns' => $dataObj->getExportColumns(), 'rowCallback' => $rowCallback, ]); $helper->export(); $this->_postExportCsv(); exit; } protected function _postExportCsv() { $this->_log(); return $this; } protected function _getExportFileName() { if (null == $this->_exportFileName) { $this->_exportFileName = $this->getConfig('itemsName') . ' {date}.csv'; } return $this->_exportFileName; } protected function _doNew() { $data = []; if ($userId = Qs_Request::getRequestValue('userId')) { $table = new Qs_Db_Table('UserRegistrationCompany'); $data = (array) $table->search($userId); } $form = $this->_getNewForm(['defaults' => $data]); $form->setDefaults(); $this->_addFormItem($form); $this->_postNew(); return $this; } protected function _doAutocompleteDistrict() { exit; } protected function _doAutocompleteDistrictAjax() { $request = Qs_Request::getGet(); $data = $this->_getDataObj()->getAutocompleteDistrictOptions($request); $this->_displayJson($data); } protected function _doAutocompleteUser() { exit; } protected function _doAutocompleteUserAjax() { $request = Qs_Request::getGet(); $data = $this->_getDataObj()->getAutocompleteUserOptions($request); $this->_displayJson($data); } protected function _doRenderPositionRow() { exit; } protected function _doRenderPositionRowAjax() { $itemIndex = (string) Qs_Request::getPostValue('itemIndex'); $this->_doc->clearInitFunctions()->clearInlineScripts()->clearScripts()->clearStylesheets(); $form = $this->_getEditForm(); $form->getSubForm('position')->clearSubForms(); $form->getSubForm('position')->addSubForm( new PositionItemSubForm(['companyId' => $this->_primaryKey['id']]), $itemIndex ); $form->getSubForm('position')->initRender(); $response = [ 'status' => 'success', 'html' => $form->getSubForm('position')->getSubForm($itemIndex)->render(), 'scripts' => $this->_doc->renderInitFunctions(), ]; $this->_displayJson($response); } protected function _initFromForm(Qs_Form $form) { $data = $form->getValues(); $form->dfClearUnusedValues($data); $this->_getDataObj()->initFromForm($data); return $this; } protected function _prepareViewItem(array &$item) { $item['associateCategories'] = $this->_getDataObj()->getAssociateCategories($item['id']); $item['safetyGroups'] = $this->_getDataObj()->getSafetyGroups($item['id']); $item['utilityCategories'] = $this->_getDataObj()->getUtilityCategories($item['id']); $item['personnelPositions'] = $this->_getDataObj()->getPersonnelPositions($item['id']); $item['managementPrivileges'] = $this->_getDataObj()->getManagementPrivileges($item['id']); $item['counties'] = $this->_getDataObj()->getCounties(['id', 'title']); $item['legislativeInfo'] = $item['personnelInfo'] = true; $form = $this->_getEditForm(['defaults' => $item]); $form->setDefaults(); $map = [ 'associateCategory' => 'associateCategories', 'safetyGroupId' => 'safetyGroups', 'utilityCategoryId' => 'utilityCategories', 'position' => 'personnelPositions', 'permission' => 'managementPrivileges', '_legislativeInfo' => 'legislativeInfo', '_personnelInfo' => 'personnelInfo', ]; foreach ($form->getHiddenElements() as $name) { $name = Qs_Array::get($map, $name, $name); unset($item[$name]); } return parent::_prepareViewItem($item); } }