<?php
/**
 * @package Sj Jobs Categories For Js Jobs
 * @version 1.0.0
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @copyright (c) 2015 YouTech Company. All Rights Reserved.
 * @author YouTech Company http://www.smartaddons.com
 *
 */

defined('_JEXEC') or die;
 
JFormHelper::loadFieldClass('list');

if (!class_exists('JFormFieldSjJobsCategories')) {
	class JFormFieldSjJobsCategories extends JFormFieldList
	{
		protected function getOptions()
		{			
			$db = JFactory::getDBO();
			$query = "SELECT id,cat_title FROM `#__js_job_categories` WHERE isactive = 1";
			$query.=" ORDER BY ordering ";
			try {
				$db->setQuery($query);
				$rows = $db->loadObjectList();
			}
			catch (Exception $e){
				echo $e->getMessage();
			}

			foreach($rows as $row){
				$options[] = JHtml::_('select.option', $row->id, $row->cat_title);
			}
			
			return $options;
		}

	}
}