_prepareListNaicsCodes($list); return parent::_prepareList($list); } private function _prepareListNaicsCodes(array &$list) { if (!($ids = array_column($list, 'id'))) { return $this; } $map = $this->getNaicsCodesMap($ids); foreach ($list as &$row) { $row['naicsCodes'] = Qs_Array::get($map, $row['id'], []); } return $this; } protected function getNaicsCodesMap(array $taxationIds) { $select = $this->_db->select(); $select->from($this->_getPair('Naics', 'n'), ['t.id', '*']); $select->join($this->_getPair('LicenseNaics', 'ln'), '`ln`.`naicsCode` = `n`.`id`', []); $select->join($this->_getPair('License', 'l'), '`l`.`id` = `ln`.`licenseId`', []); $select->join($this->_getPair('Taxation', 't'), '`t`.`vendorId` = `l`.`vendorId`', []); $select->where('`t`.`id` IN (?)', $taxationIds, Qs_Db::INT_TYPE); $select->where('DATE(`l`.`added`) < `t`.`end` AND `l`.`expiredOn` > `t`.`start`'); $select->group(['t.id', 'n.id']); $select->order(['l.id', NaicsModel::getOrderByCodeExpr('n')]); $map = $this->_db->fetchAll($select, [], Qs_Db::FETCH_GROUP | Qs_Db::FETCH_ASSOC); return $map; } /** * @param array $data * @return void */ protected function mapCollections(array &$data) { $dropdownMap = [ 'statusTitle' => ['field' => 'status', 'collection' => 'statuses'], 'paymentMethodTitle' => ['field' => 'paymentMethod', 'collection' => 'paymentMethods'], 'checkTypeTitle' => ['field' => 'checkType', 'collection' => 'checkTypes'], ]; foreach ($dropdownMap as $field => $options) { if (($value = Qs_Array::get($data, $options['field']))) { $data[$field] = $this->getConfigArray($options['collection'])[$value]; } } } }