123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- /**
- * Adminhtml VAT ID validation block
- *
- * @author Magento Core Team <core@magentocommerce.com>
- */
- namespace Magento\Customer\Block\Adminhtml\System\Config;
- class Validatevat extends \Magento\Config\Block\System\Config\Form\Field
- {
- /**
- * Merchant Country Field Name
- *
- * @var string
- */
- protected $_merchantCountry = 'general_store_information_country_id';
- /**
- * Merchant VAT Number Field
- *
- * @var string
- */
- protected $_merchantVatNumber = 'general_store_information_merchant_vat_number';
- /**
- * Validate VAT Button Label
- *
- * @var string
- */
- protected $_vatButtonLabel = 'Validate VAT Number';
- /**
- * Set Merchant Country Field Name
- *
- * @param string $countryField
- * @return \Magento\Customer\Block\Adminhtml\System\Config\Validatevat
- */
- public function setMerchantCountryField($countryField)
- {
- $this->_merchantCountry = $countryField;
- return $this;
- }
- /**
- * Get Merchant Country Field Name
- *
- * @return string
- */
- public function getMerchantCountryField()
- {
- return $this->_merchantCountry;
- }
- /**
- * Set Merchant VAT Number Field
- *
- * @param string $vatNumberField
- * @return \Magento\Customer\Block\Adminhtml\System\Config\Validatevat
- */
- public function setMerchantVatNumberField($vatNumberField)
- {
- $this->_merchantVatNumber = $vatNumberField;
- return $this;
- }
- /**
- * Get Merchant VAT Number Field
- *
- * @return string
- */
- public function getMerchantVatNumberField()
- {
- return $this->_merchantVatNumber;
- }
- /**
- * Set Validate VAT Button Label
- *
- * @param string $vatButtonLabel
- * @return \Magento\Customer\Block\Adminhtml\System\Config\Validatevat
- */
- public function setVatButtonLabel($vatButtonLabel)
- {
- $this->_vatButtonLabel = $vatButtonLabel;
- return $this;
- }
- /**
- * Set template to itself
- *
- * @return \Magento\Customer\Block\Adminhtml\System\Config\Validatevat
- */
- protected function _prepareLayout()
- {
- parent::_prepareLayout();
- if (!$this->getTemplate()) {
- $this->setTemplate('Magento_Customer::system/config/validatevat.phtml');
- }
- return $this;
- }
- /**
- * Unset some non-related element parameters
- *
- * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
- * @return string
- */
- public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
- {
- $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
- return parent::render($element);
- }
- /**
- * Get the button and scripts contents
- *
- * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
- * @return string
- */
- protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
- {
- $originalData = $element->getOriginalData();
- $buttonLabel = !empty($originalData['button_label']) ? $originalData['button_label'] : $this->_vatButtonLabel;
- $this->addData(
- [
- 'button_label' => __($buttonLabel),
- 'html_id' => $element->getHtmlId(),
- 'ajax_url' => $this->_urlBuilder->getUrl('customer/system_config_validatevat/validate'),
- ]
- );
- return $this->_toHtml();
- }
- }
|