<?php
	/**
	 * @package     Formea.Plugin
	 * @subpackage  Core.Pdf
	 *
	 * @copyright   Copyright (C) 2010-2024 Feseur Sdn Bhd. All rights reserved.
	 * @license     GNU General Public License version 2 or later; see LICENSE.txt
	 */

  namespace Joomla\Component\Formea\Plugins\Core\Pdf\Field;

  use Joomla\CMS\Factory;
  use Joomla\CMS\Form\FormField;
  use Joomla\CMS\Form\FormHelper;
  use Joomla\Registry\Registry;

  class FormeaCorePdfField extends FormField
  {
    /**
     * The name field type.
     *
     * @var    string
     */
    protected $type = 'FormeaCorePdf';



    public function __construct($form = null)
    {
      parent::__construct($form);

    }

    protected function getLabel()
    {
      return '';
    }

    /**
     * Method to get the field input markup for the file field.
     * Field attributes allow specification of a maximum file size and a string
     * of accepted file extensions.
     *
     * @return  string  The field input markup.
     *
     * @note    The field does not include an upload mechanism.
     * @see     \Joomla\CMS\Form\Field\MediaField
     * @since   1.7.0
     */
    protected function getInput()
    {
      $formId = (int) $this->getAttribute('data-formid');
      $container = Factory::getContainer();
      /** @var \Joomla\Database\DatabaseDriver $db */
      $db = $container->get('DatabaseDriver');
      $query = $db->getQuery(true);
      $query->select('*');
      $query->from($db->quoteName('#__formea_cores'));
      $query->where($db->quoteName('name') . ' = ' . $db->quote('PayPal'));
      $db->setQuery($query);
      $payPalObject = $db->loadObject();
      $payPalParams = new Registry($payPalObject->params);
      $integrationType = (int)$payPalParams->get('integration_type',0);

      return '<input type="hidden" id="'.$this->id.'" name="'.$this->name.'" value="'.$integrationType.'"/>';
    }

    /**
     * Method to get a control group with label and input.
     *
     * @param   array  $options  Options to be passed into the rendering of the field
     *
     * @return  string  A string containing the html for the control group
     *
     * @since   3.2
     */
    public function renderField($options = [])
    {
      return $this->getInput();
    }


  }
