<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/

class Authorizepmnt_Form_Admin_Global extends Engine_Form {

  public function init() {

    $this->setTitle('Global Settings')
				->setDescription('These settings affect all members in your community.');

		$supportTicket = '<a href="https://socialengine.com/store/clientarea.php?action=products&module=licensing" target="_blank">click here</a>';
		$descriptionLicense = sprintf('Enter your license key that is provided to you when you purchased this plugin. If you do not know your license key, please %s. (Key Format: SEPHP-XXXXXXXXXXXXXXXX)',$supportTicket);

		$this->addElement('Text', 'authorizepmnt_licensekey', array(
			'label' => 'License Key',
			'description' => $descriptionLicense,
			'required' => true,
			'allowEmpty' => false,
			'validators' => array(
				array('NotEmpty', true),
			),
			'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('authorizepmnt.licensekey'),
		));
		$this->getElement('authorizepmnt_licensekey')->getDecorator('Description')->setOptions(array('placement' => 'PREPEND', 'escape' => false));

		if (engine_in_array($_SERVER['SERVER_NAME'], ['localhost', '127.0.0.1'])) {
			$this->addElement('Text', 'domain_name', array(
				'label' => 'Domain Name',
				'required' => true,
				'allowEmpty' => false,
				'validators' => array(
					array('NotEmpty', true),
				),
				'value' => Engine_Api::_()->getApi('settings', 'core')->getSetting('domain.name'),
			));
		}

		if (Engine_Api::_()->getApi('settings', 'core')->getSetting('authorizepmnt.pluginactivated')) {	

			$gatewayLink = '<a href="admin/payment/gateway" target="_blank">Click here</a>';
			$description = sprintf('%s to enable gateway.',$gatewayLink);
			
			$this->addElement('Dummy', 'authorizepmnt_paymentlink', array(
					'content' => $description,
			));

			// Add submit button
			$this->addElement('Button', 'submit', array(
					'label' => 'Save Changes',
					'type' => 'submit',
					'ignore' => true
			));
		} else {
			//Add submit button
			$this->addElement('Button', 'submit', array(
					'label' => 'Activate your plugin',
					'type' => 'submit',
					'ignore' => true
			));
		}
  }
}
