<?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\CMS\Language\Text;
  use Joomla\Registry\Registry;

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



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

    }


    /**
     * 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()
    {
      $leftName = $this->name.'[left]';
      $leftId = $this->id.'_left';
      $leftValue = 15;
      if(isset($this->value->left)){
        $leftValue = $this->value->left;
      }

      $rightName = $this->name.'[right]';
      $rightId = $this->id.'_right';
      $rightValue = 15;
      if(isset($this->value->right)){
        $rightValue = $this->value->right;
      }

      $topName = $this->name.'[top]';
      $topId = $this->id.'_top';
      $topValue = 27;
      if(isset($this->value->top)){
        $topValue = $this->value->top;
      }

      $bottomName = $this->name.'[bottom]';
      $bottomId = $this->id.'_bottom';
      $bottomValue = 25;
      if(isset($this->value->bottom)){
        $bottomValue = $this->value->bottom;
      }

      $html ='<div class="row">';

      $html .='<div class="col-md-3">';
      $html .='<div class="input-group">';
      $html .='<input type="number" class="form-control" name="'.$leftName.'" id='.$leftId.' step="any" value="'.$leftValue.'" placeholder="'.Text::_('FORMEA_PDF_LEFT_MARGIN_PLACEHOLDER').'">';
      $html .='<span class="input-group-text">mm</span>';
      $html .='</div>';//.input-group
      $html .='<div class="form-text text-muted">'.Text::_('FORMEA_PDF_LEFT').'</div>';
      $html .='</div>';//.col-md-3

      $html .='<div class="col-md-3">';
      $html .='<div class="input-group">';
      $html .='<input type="number" class="form-control" name="'.$topName.'" id='.$topId.' step="any" value="'.$topValue.'" placeholder="'.Text::_('FORMEA_PDF_TOP_MARGIN_PLACEHOLDER').'">';
      $html .='<span class="input-group-text">mm</span>';
      $html .='</div>';//.input-group
      $html .='<div class="form-text text-muted">'.Text::_('FORMEA_PDF_TOP').'</div>';
      $html .='</div>';//.col-md-3

      $html .='<div class="col-md-3">';
      $html .='<div class="input-group">';
      $html .='<input type="number" class="form-control" name="'.$rightName.'" id='.$rightId.' step="any" value="'.$rightValue.'" placeholder="'.Text::_('FORMEA_PDF_RIGHT_MARGIN_PLACEHOLDER').'">';
      $html .='<span class="input-group-text">mm</span>';
      $html .='</div>';//.input-group
      $html .='<div class="form-text text-muted">'.Text::_('FORMEA_PDF_RIGHT').'</div>';
      $html .='</div>';//.col-md-3

      $html .='<div class="col-md-3">';
      $html .='<div class="input-group">';
      $html .='<input type="number" class="form-control" name="'.$bottomName.'" id='.$bottomId.' step="any" value="'.$bottomValue.'" placeholder="'.Text::_('FORMEA_PDF_BOTTOM_MARGIN_PLACEHOLDER').'">';
      $html .='<span class="input-group-text">mm</span>';
      $html .='</div>';//.input-group
      $html .='<div class="form-text text-muted">'.Text::_('FORMEA_PDF_BOTTOM').'</div>';
      $html .='</div>';//.col-md-3

      $html .='</div>';//.row
      return $html;
    }



  }
