<?php
/**
 * @package     JGive
 * @subpackage  com_jgive
 *
 * @author      Techjoomla <extensions@techjoomla.com>
 * @copyright   Copyright (C) 2009 - 2019 Techjoomla. All rights reserved.
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 */

defined('JPATH_BASE') or die();

use Joomla\CMS\Form\FormField;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;


/**
 * Custom Cron field for component params.
 *
 * @package  JGive
 *
 * @since    2.2
 */
class JFormFieldCron extends JFormField
{
	public $type = 'Cron';

	/**
	 * Method to get the field input markup.
	 *
	 * TODO: Add access check.
	 *
	 * @return   string  The field input markup.
	 *
	 * @since  1.6
	 */
	protected function getInput()
	{
		$params = ComponentHelper::getParams('com_jgive');
		$this->private_key_cronjob = $params->get('private_key_cronjob');
		$cron_masspayment = '';
		$cron_masspayment = Route::_(
			Uri::root() . 'index.php?option=com_jgive&controller=masspayment&task=performmasspay&pkey=' . $this->private_key_cronjob
		);

		$inputClass   = (JVERSION > '4.0.0') ? 'form-control' : '';

		$return = '<input type="text" class="' . $inputClass . '" name="cronjoburl" disabled="disabled" value="' . $cron_masspayment . '" size="100">';

		return $return;
	}
}
