<?php
/*----------------------------------------------------------------------------------|  www.vdm.io  |----/
				Nampharm 
/-------------------------------------------------------------------------------------------------------/

	@version		1.0.1
	@build			20th August, 2024
	@created		24th May, 2024
	@package		Subform Power
	@subpackage		CurrenciesfiltersymbolField.php
	@author			Oh Martin <https://nampharm.com.na>	
	@copyright		Copyright (C) 2015. All Rights Reserved
	@license		GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
  ____  _____  _____  __  __  __      __       ___  _____  __  __  ____  _____  _  _  ____  _  _  ____ 
 (_  _)(  _  )(  _  )(  \/  )(  )    /__\     / __)(  _  )(  \/  )(  _ \(  _  )( \( )( ___)( \( )(_  _)
.-_)(   )(_)(  )(_)(  )    (  )(__  /(__)\   ( (__  )(_)(  )    (  )___/ )(_)(  )  (  )__)  )  (   )(  
\____) (_____)(_____)(_/\/\_)(____)(__)(__)   \___)(_____)(_/\/\_)(__)  (_____)(_)\_)(____)(_)\_) (__) 

/------------------------------------------------------------------------------------------------------*/
namespace JCB\Component\Subformpower\Administrator\Field;

use Joomla\CMS\Factory;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper as Html;
use Joomla\CMS\Component\ComponentHelper;
use JCB\Component\Subformpower\Administrator\Helper\SubformpowerHelper;

// No direct access to this file
\defined('_JEXEC') or die;

/**
 * Currenciesfiltersymbol Form Field class for the Subformpower component
 *
 * @since  1.6
 */
class CurrenciesfiltersymbolField extends ListField
{
	/**
	 * The currenciesfiltersymbol field type.
	 *
	 * @var        string
	 */
	public $type = 'Currenciesfiltersymbol';

	/**
	 * Method to get a list of options for a list input.
	 *
	 * @return  array    An array of Html options.
	 * @since   1.6
	 */
	protected function getOptions()
	{
		// Get a db connection.
		$db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class);

		// Create a new query object.
		$query = $db->getQuery(true);

		// Select the text.
		$query->select($db->quoteName('symbol'));
		$query->from($db->quoteName('#__subformpower_currency'));
		$query->order($db->quoteName('symbol') . ' ASC');

		// Reset the query using our newly populated query object.
		$db->setQuery($query);

		$_results = $db->loadColumn();
		$_filter = [];
		$_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_SUBFORMPOWER_FILTER_SELECT_SYMBOL') . ' -');

		if ($_results)
		{
			$_results = array_unique($_results);
			foreach ($_results as $symbol)
			{
				// Now add the symbol and its text to the options array
				$_filter[] = Html::_('select.option', $symbol, $symbol);
			}
		}
		return $_filter;
	}
}
