@copyright Copyright (C) 2020 Vast Development Method. All rights reserved. @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html Portal for mobile health clinics /-----------------------------------------------------------------------------------------------------------------------------*/ // No direct access to this file defined('_JEXEC') or die('Restricted access'); // import the list field type jimport('joomla.form.helper'); JFormHelper::loadFieldClass('list'); /** * Vmmcsfilterpatient Form Field class for the Ehealth_portal component */ class JFormFieldVmmcsfilterpatient extends JFormFieldList { /** * The vmmcsfilterpatient field type. * * @var string */ public $type = 'vmmcsfilterpatient'; /** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ protected function getOptions() { // Get a db connection. $db = JFactory::getDbo(); // Create a new query object. $query = $db->getQuery(true); // Select the text. $query->select($db->quoteName('patient')); $query->from($db->quoteName('#__ehealth_portal_vmmc')); $query->order($db->quoteName('patient') . ' ASC'); // Reset the query using our newly populated query object. $db->setQuery($query); $results = $db->loadColumn(); $_filter = array(); $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_EHEALTH_PORTAL_FILTER_SELECT_PATIENT_NAME') . ' -'); if ($results) { $results = array_unique($results); foreach ($results as $patient) { // Now add the patient and its text to the options array $_filter[] = JHtml::_('select.option', $patient, JFactory::getUser($patient)->name); } } return $_filter; } }