|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / a / home / dev2.destoffenstraat.com / app / code / Geissweb / Euvat / Ui / Component / Form / |
Filename | /home/a/home/dev2.destoffenstraat.com/app/code/Geissweb/Euvat/Ui/Component/Form/SetupFieldset.php |
Size | 6.78 kb |
Permission | rwxrwxrwx |
Owner | root : root |
Create time | 21-Aug-2025 12:26 |
Last modified | 09-Jul-2024 08:42 |
Last accessed | 22-Aug-2025 22:08 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
/**
* ||GEISSWEB| EU VAT Enhanced
*
* NOTICE OF LICENSE
*
* This source file is subject to the GEISSWEB End User License Agreement
* that is available through the world-wide-web at this URL: https://www.geissweb.de/legal-information/eula
*
* DISCLAIMER
*
* Do not edit this file if you wish to update the extension in the future. If you wish to customize the extension
* for your needs please refer to our support for more information.
*
* @copyright Copyright (c) 2015 GEISS Weblösungen (https://www.geissweb.de)
* @license https://www.geissweb.de/legal-information/eula GEISSWEB End User License Agreement
*/
declare(strict_types=1);
namespace Geissweb\Euvat\Ui\Component\Form;
use Geissweb\Euvat\Helper\Configuration;
use Geissweb\Euvat\Helper\Setup;
use Geissweb\Euvat\Logger\Logger;
use Magento\Framework\Exception\StateException;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentInterface;
use Magento\Tax\Model\TaxClass\Source\Customer;
use Magento\Tax\Model\TaxClass\Source\Product;
use Magento\Ui\Component\Form\FieldFactory;
use Magento\Ui\Component\Form\Fieldset;
/**
* Class SetupFieldset provides the fields for the setup form
*/
class SetupFieldset extends Fieldset
{
/**
* @var \Geissweb\Euvat\Helper\Setup
*/
public Setup $setupHelper;
/**
* @var \Magento\Tax\Model\TaxClass\Source\Customer
*/
public Customer $customerTaxClasses;
/**
* @var \Magento\Tax\Model\TaxClass\Source\Product
*/
public Product $productTaxClasses;
/**
* @var \Geissweb\Euvat\Logger\Logger
*/
public Logger $logger;
/**
* @var array[]
*/
public array $existingComponents;
/**
* @var \Geissweb\Euvat\Helper\Configuration
*/
public Configuration $configHelper;
/**
* @var \Magento\Ui\Component\Form\FieldFactory
*/
private FieldFactory $fieldFactory;
/**
* SetupFieldset constructor.
*
* @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
* @param \Magento\Ui\Component\Form\FieldFactory $fieldFactory
* @param \Geissweb\Euvat\Helper\Setup $setupHelper
* @param \Geissweb\Euvat\Helper\Configuration $configHelper
* @param \Geissweb\Euvat\Logger\Logger $logger
* @param \Magento\Tax\Model\TaxClass\Source\Customer $customerTaxClasses
* @param \Magento\Tax\Model\TaxClass\Source\Product $productTaxClasses
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
FieldFactory $fieldFactory,
Setup $setupHelper,
Configuration $configHelper,
Logger $logger,
Customer $customerTaxClasses,
Product $productTaxClasses,
array $components = [],
array $data = []
) {
parent::__construct($context, $components, $data);
$this->fieldFactory = $fieldFactory;
$this->setupHelper = $setupHelper;
$this->configHelper = $configHelper;
$this->logger = $logger;
$this->customerTaxClasses = $customerTaxClasses;
$this->productTaxClasses = $productTaxClasses;
$this->existingComponents = $components;
}
/**
* Get components
*
* @return UiComponentInterface[]
* @throws \Magento\Framework\Exception\NoSuchEntityException|\Magento\Framework\Exception\LocalizedException
*/
public function getChildComponents(): array
{
foreach ($this->existingComponents as $child) {
/** @var \Magento\Ui\Component\Form\Field $child */
if ($child->getName() === 'vat_number') {
$existingConfig = $child->getData('config');
$additionalConfig = $this->configHelper->getAdminVatFieldConfig();
// phpcs:ignore
$newConfig = array_merge($existingConfig, $additionalConfig);
$child->setData('config', $newConfig);
}
}
$i = 0;
$tcFields = [];
try {
foreach ($this->customerTaxClasses->getAllOptions() as $existingCustomerTaxClass) {
$tcFields[ $existingCustomerTaxClass['value'] ] =
[
'label' => ($i == 0) ? __('New customer tax classes') : ' ',
'value' => $existingCustomerTaxClass['value'],
'formElement' => 'select',
'options' => $this->setupHelper->getNewCustomerTaxClassesAsOptionArray(),
'visible' => true,
'required' => true,
'notice' => __('Select the new customer tax class as replacement for: ')
.$existingCustomerTaxClass['label'],
'imports' => [
'visible' => '${$.provider}:data.vatsetup_form_data_source.is_create_tax_rules:checkstate'
],
'_classType' => 'c'
];
$i ++;
}
} catch (StateException $e) {
$this->logger->critical($e);
}
$i = 0;
foreach ($this->productTaxClasses->getAllOptions() as $existingProductTaxClass) {
$tcFields[$existingProductTaxClass['value']] =
[
'label' => ($i==0) ? __('New product tax classes') : ' ',
'value' => $existingProductTaxClass['value'],
'formElement' => 'select',
'options' => $this->setupHelper->getNewProductTaxClassesAsOptionArray(),
'visible' => true,
'required' => true,
'notice' => __('Select the new product tax class as replacement for: ')
.$existingProductTaxClass['label'],
'imports' => [
'visible'=>'${$.provider}:data.vatsetup_form_data_source.is_create_tax_rules:checkstate'
],
'_classType' => 'p'
];
$i++;
}
foreach ($tcFields as $key => $fieldConfig) {
$fieldInstance = $this->fieldFactory->create();
$name = $fieldConfig['_classType'].'_'.$key;
$fieldInstance->setData([
'config' => $fieldConfig,
'name' => $name
]);
$fieldInstance->prepare();
$this->addComponent($name, $fieldInstance);
}
return parent::getChildComponents();
}
}
/**
* ||GEISSWEB| EU VAT Enhanced
*
* NOTICE OF LICENSE
*
* This source file is subject to the GEISSWEB End User License Agreement
* that is available through the world-wide-web at this URL: https://www.geissweb.de/legal-information/eula
*
* DISCLAIMER
*
* Do not edit this file if you wish to update the extension in the future. If you wish to customize the extension
* for your needs please refer to our support for more information.
*
* @copyright Copyright (c) 2015 GEISS Weblösungen (https://www.geissweb.de)
* @license https://www.geissweb.de/legal-information/eula GEISSWEB End User License Agreement
*/
declare(strict_types=1);
namespace Geissweb\Euvat\Ui\Component\Form;
use Geissweb\Euvat\Helper\Configuration;
use Geissweb\Euvat\Helper\Setup;
use Geissweb\Euvat\Logger\Logger;
use Magento\Framework\Exception\StateException;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentInterface;
use Magento\Tax\Model\TaxClass\Source\Customer;
use Magento\Tax\Model\TaxClass\Source\Product;
use Magento\Ui\Component\Form\FieldFactory;
use Magento\Ui\Component\Form\Fieldset;
/**
* Class SetupFieldset provides the fields for the setup form
*/
class SetupFieldset extends Fieldset
{
/**
* @var \Geissweb\Euvat\Helper\Setup
*/
public Setup $setupHelper;
/**
* @var \Magento\Tax\Model\TaxClass\Source\Customer
*/
public Customer $customerTaxClasses;
/**
* @var \Magento\Tax\Model\TaxClass\Source\Product
*/
public Product $productTaxClasses;
/**
* @var \Geissweb\Euvat\Logger\Logger
*/
public Logger $logger;
/**
* @var array[]
*/
public array $existingComponents;
/**
* @var \Geissweb\Euvat\Helper\Configuration
*/
public Configuration $configHelper;
/**
* @var \Magento\Ui\Component\Form\FieldFactory
*/
private FieldFactory $fieldFactory;
/**
* SetupFieldset constructor.
*
* @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
* @param \Magento\Ui\Component\Form\FieldFactory $fieldFactory
* @param \Geissweb\Euvat\Helper\Setup $setupHelper
* @param \Geissweb\Euvat\Helper\Configuration $configHelper
* @param \Geissweb\Euvat\Logger\Logger $logger
* @param \Magento\Tax\Model\TaxClass\Source\Customer $customerTaxClasses
* @param \Magento\Tax\Model\TaxClass\Source\Product $productTaxClasses
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
FieldFactory $fieldFactory,
Setup $setupHelper,
Configuration $configHelper,
Logger $logger,
Customer $customerTaxClasses,
Product $productTaxClasses,
array $components = [],
array $data = []
) {
parent::__construct($context, $components, $data);
$this->fieldFactory = $fieldFactory;
$this->setupHelper = $setupHelper;
$this->configHelper = $configHelper;
$this->logger = $logger;
$this->customerTaxClasses = $customerTaxClasses;
$this->productTaxClasses = $productTaxClasses;
$this->existingComponents = $components;
}
/**
* Get components
*
* @return UiComponentInterface[]
* @throws \Magento\Framework\Exception\NoSuchEntityException|\Magento\Framework\Exception\LocalizedException
*/
public function getChildComponents(): array
{
foreach ($this->existingComponents as $child) {
/** @var \Magento\Ui\Component\Form\Field $child */
if ($child->getName() === 'vat_number') {
$existingConfig = $child->getData('config');
$additionalConfig = $this->configHelper->getAdminVatFieldConfig();
// phpcs:ignore
$newConfig = array_merge($existingConfig, $additionalConfig);
$child->setData('config', $newConfig);
}
}
$i = 0;
$tcFields = [];
try {
foreach ($this->customerTaxClasses->getAllOptions() as $existingCustomerTaxClass) {
$tcFields[ $existingCustomerTaxClass['value'] ] =
[
'label' => ($i == 0) ? __('New customer tax classes') : ' ',
'value' => $existingCustomerTaxClass['value'],
'formElement' => 'select',
'options' => $this->setupHelper->getNewCustomerTaxClassesAsOptionArray(),
'visible' => true,
'required' => true,
'notice' => __('Select the new customer tax class as replacement for: ')
.$existingCustomerTaxClass['label'],
'imports' => [
'visible' => '${$.provider}:data.vatsetup_form_data_source.is_create_tax_rules:checkstate'
],
'_classType' => 'c'
];
$i ++;
}
} catch (StateException $e) {
$this->logger->critical($e);
}
$i = 0;
foreach ($this->productTaxClasses->getAllOptions() as $existingProductTaxClass) {
$tcFields[$existingProductTaxClass['value']] =
[
'label' => ($i==0) ? __('New product tax classes') : ' ',
'value' => $existingProductTaxClass['value'],
'formElement' => 'select',
'options' => $this->setupHelper->getNewProductTaxClassesAsOptionArray(),
'visible' => true,
'required' => true,
'notice' => __('Select the new product tax class as replacement for: ')
.$existingProductTaxClass['label'],
'imports' => [
'visible'=>'${$.provider}:data.vatsetup_form_data_source.is_create_tax_rules:checkstate'
],
'_classType' => 'p'
];
$i++;
}
foreach ($tcFields as $key => $fieldConfig) {
$fieldInstance = $this->fieldFactory->create();
$name = $fieldConfig['_classType'].'_'.$key;
$fieldInstance->setData([
'config' => $fieldConfig,
'name' => $name
]);
$fieldInstance->prepare();
$this->addComponent($name, $fieldInstance);
}
return parent::getChildComponents();
}
}