This commit is contained in:
2026-09-15 10:35:56 +08:00
commit 782f8ea7aa
4086 changed files with 631288 additions and 0 deletions
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace Esun\CustomerVat\Controller\Adminhtml\Application;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
class Index extends Action
{
public const ADMIN_RESOURCE = 'Esun_CustomerVat::applications';
public function __construct(Context $context, private readonly PageFactory $pageFactory)
{
parent::__construct($context);
}
public function execute()
{
$page = $this->pageFactory->create();
$page->setActiveMenu('Esun_CustomerVat::applications');
$page->getConfig()->getTitle()->prepend(__('VAT Number Applications'));
return $page;
}
}
@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace Esun\CustomerVat\Controller\Adminhtml\Application;
use Esun\CustomerVat\Model\ResourceModel\VatApplication as VatResource;
use Esun\CustomerVat\Model\VatApplication;
use Esun\CustomerVat\Model\VatApplicationFactory;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Backend\Model\Auth\Session as AuthSession;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Stdlib\DateTime\DateTime;
class Review extends Action implements HttpPostActionInterface
{
public const ADMIN_RESOURCE = 'Esun_CustomerVat::review';
public function __construct(Context $context, private readonly VatApplicationFactory $factory,
private readonly VatResource $resource, private readonly AuthSession $authSession,
private readonly DateTime $dateTime)
{
parent::__construct($context);
}
public function execute()
{
$id = (int)$this->getRequest()->getParam('id');
$status = (string)$this->getRequest()->getParam('status');
$allowed = [VatApplication::STATUS_PENDING, VatApplication::STATUS_APPROVED, VatApplication::STATUS_REJECTED];
$application = $this->factory->create();
$this->resource->load($application, $id);
if (!$application->getId() || !in_array($status, $allowed, true)) {
$this->messageManager->addErrorMessage(__('Unable to review this VAT application.'));
return $this->resultRedirectFactory->create()->setPath('*/*/index');
}
try {
$admin = $this->authSession->getUser();
$application->addData([
'status' => $status,
'review_note' => trim((string)$this->getRequest()->getParam('review_note')) ?: null,
'reviewed_by' => $admin ? (int)$admin->getId() : null,
'reviewed_at' => $this->dateTime->gmtDate(),
]);
$this->resource->save($application);
$this->messageManager->addSuccessMessage(__('The VAT application review has been saved.'));
} catch (\Throwable $exception) {
$this->messageManager->addExceptionMessage($exception, __('Unable to save the VAT application review.'));
}
return $this->resultRedirectFactory->create()->setPath('*/*/view', ['id' => $id]);
}
}
@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Esun\CustomerVat\Controller\Adminhtml\Application;
use Esun\CustomerVat\Model\ResourceModel\VatApplication as VatResource;
use Esun\CustomerVat\Model\VatApplicationFactory;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Registry;
use Magento\Framework\View\Result\PageFactory;
class View extends Action
{
public const ADMIN_RESOURCE = 'Esun_CustomerVat::applications';
public function __construct(Context $context, private readonly PageFactory $pageFactory,
private readonly VatApplicationFactory $factory, private readonly VatResource $resource,
private readonly Registry $registry)
{
parent::__construct($context);
}
public function execute()
{
$application = $this->factory->create();
$this->resource->load($application, (int)$this->getRequest()->getParam('id'));
if (!$application->getId()) {
$this->messageManager->addErrorMessage(__('The VAT application no longer exists.'));
return $this->resultRedirectFactory->create()->setPath('*/*/index');
}
$this->registry->register('current_customer_vat_admin', $application);
$page = $this->pageFactory->create();
$page->setActiveMenu('Esun_CustomerVat::applications');
$page->getConfig()->getTitle()->prepend(__('VAT Application #%1', $application->getId()));
return $page;
}
}