'`m`.`email`', 'ce_credits' => '`ech`.`credits`', 'event_date' => '`e`.`eventdate`', 'queue_id' => '`ecsq`.`id`', 'registration_id' => $this->quoteField('id'), $this->quoteField('certificate') ); return $columns; } function _getJoin4Grid() { $sql = parent::_getJoin4Grid(); $sql .= $this->_joinMember(); $sql .= $this->_joinEvent(); $sql .= $this->_joinQueue(); $sql .= $this->_joinCECreditHistory(); return $sql; } protected function _joinMember($alias = null) { return 'JOIN ' . $this->_getPair('Member', 'm') . ' ' . ' ON `m`.`id` = ' . $this->quoteField('id_member', $alias); } protected function _joinEvent($alias = null) { return 'JOIN ' . $this->_getPair('Event', 'e') . ' ' . ' ON `e`.`id` = ' . $this->quoteField('id_event', $alias) . ' '; } protected function _joinQueue() { return 'JOIN ' . $this->_getPair('EventCertificateSendQueue', 'ecsq') . ' ' . 'ON `ecsq`.`id_event` = `e`.`id` ' . 'AND `ecsq`.`id_member` = `m`.`id` '; } protected function _joinCECreditHistory() { return 'JOIN ' . $this->_getPair('EventCECreditHistory', 'ech') . ' ' . 'ON `ech`.`id_event` = `e`.`id` ' . 'AND `ech`.`id_individual` = `m`.`id` '; } public function isProcessing() { $sql = 'SELECT 1 ' . 'FROM ' . $this->_getPair() . ' ' . $this->_getJoin4Grid() . ' ' . 'WHERE ' . $this->quoteField('status', 'ecsq') . ' = ' . $this->db->quote(self::STATUS_PROCESSING) . 'LIMIT 1'; $res = $this->db->queryOne($sql); Qs_Db::isError($res); return '1' === $res; } public function setQueueStatus($queue_id, $status) { $this->getTable('EventCertificateSendQueue')->update( compact('status'), 'id=' . $this->db->quote($queue_id, 'integer') ); } function _filterSql() { return parent::_filterSql() . $this->_filterWhere(); } protected function _filterWhere() { $parts = array(); foreach ($this->_filter as $field => $value) { switch ($field) { case 'status': $parts[] = '`ecsq`.`status` = ' . $this->db->quote($value, 'text'); break; default: break; } } return empty($parts) ? '' : ' AND ' . implode(' AND ', $parts); } }