function _getTicket() { $cid = JRequest::getInt('cid', 0); $row =& JTable::getInstance('RSTicketsPro_Tickets', 'Table'); $row->load($cid); $this->_db->setQuery("SELECT name FROM #__rsticketspro_departments WHERE id='" . (int) $row->department_id . "'"); $row->department = $this->_db->loadResult(); $this->_db->setQuery("SELECT name FROM #__rsticketspro_statuses WHERE id='" . (int) $row->status_id . "'"); $row->status = JText::_($this->_db->loadResult()); $this->_db->setQuery("SELECT name FROM #__rsticketspro_priorities WHERE id='" . (int) $row->priority_id . "'"); $row->priority = JText::_($this->_db->loadResult()); $row->staff = JFactory::getUser($row->staff_id); $row->customer = JFactory::getUser($row->customer_id); $what = RSTicketsProHelper::getConfig('show_user_info'); $what = $this->_db->getEscaped($what); $what_sql = "u." . $what . " AS user, u.email AS email"; $messages_direction = RSTicketsProHelper::getConfig('messages_direction'); $messages_direction = $messages_direction == 'ASC' ? 'ASC' : 'DESC'; $row->messages = $this->_getList("SELECT m.*, {$what_sql} FROM #__rsticketspro_ticket_messages m LEFT JOIN #__users u ON (m.user_id=u.id) WHERE `ticket_id`='" . (int) $row->id . "' ORDER BY `date` " . $messages_direction); $row->files = array(); $files = $this->_getList("SELECT * FROM #__rsticketspro_ticket_files WHERE ticket_id='" . $cid . "'"); foreach ($files as $file) { $row->files[$file->ticket_message_id][] = $file; } $row->custom_field_values = array(); $row->custom_fields = array(); $this->_db->setQuery("SELECT v.custom_field_id, v.value, cf.type, cf.name FROM #__rsticketspro_custom_fields_values v LEFT JOIN #__rsticketspro_custom_fields cf ON (cf.id = v.custom_field_id) WHERE v.ticket_id='" . $row->id . "'"); $custom_field_values = $this->_db->loadObjectList(); foreach ($custom_field_values as $custom_field_value) { if (in_array($custom_field_value->type, array('select', 'multipleselect', 'checkbox'))) { $custom_field_value->value = explode("\n", $custom_field_value->value); } $row->custom_field_values[$custom_field_value->name] = $custom_field_value->value; } $do_print = JRequest::getInt('print', 0); $editable = false; if ($this->is_staff && $this->_permissions->update_ticket_custom_fields && !$do_print) { $editable = true; } if (JRequest::getVar('task') == 'kbconvert') { $editable = false; } $this->_db->setQuery("SELECT * FROM #__rsticketspro_custom_fields WHERE `published`='1' AND department_id='" . (int) $row->department_id . "' ORDER BY `ordering`"); $custom_fields = $this->_db->loadObjectList(); foreach ($custom_fields as $field) { $row->custom_fields[] = RSTicketsProHelper::showCustomField($field, $row->custom_field_values, $editable); } $this->_db->setQuery("SELECT COUNT(id) FROM #__rsticketspro_ticket_notes WHERE ticket_id='" . $row->id . "'"); $row->notes = $this->_db->loadResult(); $this->_ticket = $row; unset($row); }
function getCustomFields() { $return = array(); $post = JRequest::getVar('rst_custom_fields', array(), 'post'); if (!empty($this->_data['department_id'])) { $post = @$post['department_' . $this->_data['department_id']]; } $fields = $this->_getList("SELECT * FROM #__rsticketspro_custom_fields WHERE published='1' ORDER BY department_id, ordering"); foreach ($fields as $field) { $return[$field->department_id][] = RSTicketsProHelper::showCustomField($field, isset($this->_data['department_id']) && $this->_data['department_id'] == $field->department_id ? $post : array(), true, $field->department_id); } return $return; }