getTable('Event')->find($id_event, array('id', 'id_type', 'name')); } public function setEvent(array $event) { $this->_event = $event; return $this; } public function getEvent($field = false, $default = null) { return Qs_Array::get($this->_event, $field, $default); } function _getWhat4Grid($opt = array()) { return parent::_getWhat4Grid($opt) . ', IF(' . $this->quoteField('teamname') . ' = "", "No Name", ' . $this->quoteField('teamname') . ') AS `teamname` '; } function getList4Grid($opt = array()) { unset($opt['ipp']); $list = parent::getList4Grid($opt); return $list; } function _getRegistrationList() { $sql = 'SELECT ' . ' `efr`.`id_team`, ' . ' `efr`.`id` AS `id_request`, ' . ' CONCAT(`m`.`last_name`, ", ", `m`.`first_name`, " ", `m`.`middle_initial`, ' . ' IF(`m`.`middle_initial` <> "",". ", ""), IF(`c`.`name` <> "", "- ", ""), IFNULL(`c`.`name`,"")) ' . ' AS `name`, ' . ' `m`.`id` AS `id_member`'; $sql .= 'FROM `' . $this->db->tblEventFormReq . '` AS `efr` '; $sql .= 'LEFT ' . $this->_getJoinMember() . ' '; $sql .= 'LEFT ' . $this->_getJoinLocation() . ' '; $sql .= 'LEFT ' . $this->_getJoinCompany() . ' '; $sql .= 'WHERE 1' . ' AND `efr`.`id_event` = ' . $this->getEvent('id') . ' ' . ' AND `efr`.`deleted` = "n" '; $_list = $this->db->queryAll($sql); $list = array(); $this->isDBError($_list); foreach ($_list as $row) { $list[$row['id_team']][] = $row; } return $list; } protected function _prepareList4GridResult(&$listItem) { $registrations = $this->_getRegistrationList(); foreach ($listItem['list'] as &$row) { $row['members'] = Qs_Array::get($registrations, $row['id'], array()); } if (isset($registrations[0])) { $listItem['noTeamList'] = $registrations[0]; } return $this; } protected function _getJoinMember() { $sql = 'JOIN `' . $this->db->tblMember . '` AS `m` ' . ' ON `m`.`id` = `efr`.`id_member`'; return $sql; } protected function _getJoinLocation() { $sql = 'JOIN `' . $this->db->tblLocation . '` AS `l` ' . ' ON `l`.`id` = `m`.`id_location`'; return $sql; } protected function _getJoinCompany() { $sql = 'JOIN `' . $this->db->tblCompany . '` AS `c` ' . ' ON `c`.`id` = `l`.`id_company`'; return $sql; } function _getWhere4Grid($opt = array()) { $sql = parent::_getWhere4Grid($opt); $sql .= 'AND ' . $this->quoteField('id_event') . ' = ' . $this->db->quote($this->getEvent('id'), 'integer') . ' '; return $sql; } function delete() { $sql = 'SELECT `id` ' . 'FROM `' . $this->db->tblEventFormReq . '` ' . 'WHERE 1 ' . 'AND `deleted` = "n" ' . 'AND `id_event` = ' . $this->db->quote($this->getEvent('id'), 'integer') . ' ' . 'AND `id_team` = ' . $this->db->quote($this->id, 'integer'); $ids = $this->db->queryCol($sql); Qs_Db::isError($ids); require_once('app/Event/Form/Req/Req.php'); $requestObj = new EventForm_Req(null); foreach ($ids as $id) { $requestObj->id = $id; $requestObj->delete(); } return parent::delete(); } function initFromForm(Form $form) { $files = array(); $data = $form->exportValues(); $data['id_event'] = $this->getEvent('id'); $this->arrayParseUrl2Tag($data); $this->initFromArray($data, $files); return true; } }