<?php

/**
 * @package     SP Soccer
 * @author      JoomShaper http://www.joomshaper.com
 * @copyright   Copyright (C) 2010 - 2016 JoomShaper. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die('Restricted access');

// Requred Componenet and module helper
//require_once JPATH_ROOT . '/modules/mod_sp_soccer_recent_results/helper.php';

jimport('joomla.form.formfield');

class JFormFieldPositionlist extends JFormField {

    protected $type = 'positionlist';


    protected function getInput(){

        // Get Tournaments
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);

        // Select all records from the user profile table where key begins with "custom.".
        $query->select($db->quoteName(array('spsoccer_possition_id', 'title' )));
        $query->from($db->quoteName('#__spsoccer_possitions'));
        $query->where($db->quoteName('enabled')." = 1");
        $query->order('ordering DESC');

        $db->setQuery($query);
        $results = $db->loadObjectList();
        $team_list = $results;

        $options = array(''=> JText::_('COM_SOCCER_FIELD_NO_ITEM_SELECTED'));

        foreach($team_list as $team){
            $options[] = JHTML::_( 'select.option', $team->spsoccer_possition_id, $team->title );
        }

        return JHTML::_('select.genericlist', $options, $this->name, '', 'value', 'text', $this->value);
    }
}
