<?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 JFormFieldMatchlist extends JFormField {

    protected $type = 'matchlist';

    protected function getInput(){
        // Get Matches
        $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_match_id', 'title' )));
        $query->from($db->quoteName('#__spsoccer_matches'));
        $query->where($db->quoteName('enabled')." = 1");
        $query->order('ordering ASC');

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


        foreach($match_list as $match){
            $options[] = JHTML::_( 'select.option', $match->spsoccer_match_id, $match->title );

            //print_r($tournament);
        }

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