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,19 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Block\Adminhtml\Agent\Edit;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
class BackButton extends GenericButton implements ButtonProviderInterface
{
public function getButtonData(): array
{
return [
'label' => __('Back'),
'on_click' => sprintf("location.href = '%s';", $this->getUrl('*/*/')),
'class' => 'back',
'sort_order' => 10,
];
}
}
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Block\Adminhtml\Agent\Edit;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
class DeleteButton extends GenericButton implements ButtonProviderInterface
{
public function getButtonData(): array
{
if (!$this->getEntityId()) {
return [];
}
return [
'label' => __('Delete Agent'),
'class' => 'delete',
'on_click' => 'deleteConfirm('
. json_encode(__('Are you sure you want to delete this agent?')) . ', '
. json_encode($this->getUrl('*/*/delete', ['entity_id' => $this->getEntityId()]))
. ')',
'sort_order' => 20,
];
}
}
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Block\Adminhtml\Agent\Edit;
use Magento\Backend\Block\Widget\Context;
class GenericButton
{
public function __construct(protected readonly Context $context)
{
}
public function getEntityId(): int
{
return (int) $this->context->getRequest()->getParam('entity_id');
}
public function getUrl(string $route = '', array $params = []): string
{
return $this->context->getUrlBuilder()->getUrl($route, $params);
}
}
@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Block\Adminhtml\Agent\Edit;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
class SaveAndContinueButton extends GenericButton implements ButtonProviderInterface
{
public function getButtonData(): array
{
return [
'label' => __('Save and Continue Edit'),
'class' => 'save',
'data_attribute' => [
'mage-init' => ['button' => ['event' => 'saveAndContinueEdit']],
'form-role' => 'save',
],
'sort_order' => 80,
];
}
}
@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Block\Adminhtml\Agent\Edit;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
class SaveButton extends GenericButton implements ButtonProviderInterface
{
public function getButtonData(): array
{
return [
'label' => __('Save Agent'),
'class' => 'save primary',
'data_attribute' => [
'mage-init' => ['button' => ['event' => 'save']],
'form-role' => 'save',
],
'sort_order' => 90,
];
}
}
+107
View File
@@ -0,0 +1,107 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Block;
use Esun\Agent\Model\Map\CountryPosition;
use Esun\Agent\Model\ResourceModel\Agent\CollectionFactory;
use Magento\Directory\Model\ResourceModel\Country\CollectionFactory as CountryCollectionFactory;
use Magento\Framework\Filesystem\Driver\File;
use Magento\Framework\Module\Dir\Reader as ModuleDirReader;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\Store\Model\StoreManagerInterface;
use RuntimeException;
class AgentLocator extends Template
{
public function __construct(
Context $context,
private readonly ModuleDirReader $moduleDirReader,
private readonly File $file,
private readonly CollectionFactory $collectionFactory,
private readonly StoreManagerInterface $storeManager,
private readonly CountryPosition $countryPosition,
private readonly CountryCollectionFactory $countryCollectionFactory,
array $data = []
) {
parent::__construct($context, $data);
}
public function getCountryOptions(): array
{
return $this->countryCollectionFactory->create()
->loadByStore()
->toOptionArray(false);
}
public function getContactBackgroundUrl(): string
{
return $this->storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA)
. 'wysiwyg/about/icons/esun-contact-bk.png';
}
public function getConfigJson(): string
{
$moduleDir = $this->moduleDirReader->getModuleDir('', 'Esun_Agent');
$dataFile = $moduleDir . '/view/frontend/web/data/agents.json';
if (!$this->file->isExists($dataFile)) {
throw new RuntimeException('Agent data file does not exist.');
}
$data = json_decode($this->file->fileGetContents($dataFile), true, 512, JSON_THROW_ON_ERROR);
$data['agents'] = [];
$mediaUrl = $this->storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA);
$collection = $this->collectionFactory->create()
->addFieldToFilter('is_active', 1)
->setOrder('sort_order', 'ASC')
->setOrder('entity_id', 'ASC');
foreach ($collection as $agentModel) {
$logo = (string) $agentModel->getData('logo');
$position = $this->countryPosition->get((string) $agentModel->getData('country_code'));
$data['agents'][] = [
'id' => (int) $agentModel->getId(),
'system_name' => (string) $agentModel->getData('system_name'),
'name' => (string) $agentModel->getData('name'),
'continent' => (string) $agentModel->getData('continent'),
'country_code' => (string) $agentModel->getData('country_code'),
'country' => (string) $agentModel->getData('country'),
'website' => (string) $agentModel->getData('website'),
'address' => (string) $agentModel->getData('address'),
'note' => (string) $agentModel->getData('note'),
'map_x' => $position['x'] ?? null,
'map_y' => $position['y'] ?? null,
'sort_order' => (int) $agentModel->getData('sort_order'),
'logo_url' => $logo !== ''
? $mediaUrl . ltrim($logo, '/')
: $this->getViewFileUrl('Esun_Agent::images/agents/placeholder.svg'),
];
}
unset($agent);
$config = [
'data' => $data,
'mapUrl' => $this->getViewFileUrl('Esun_Agent::images/world-map-dots.svg'),
'labels' => [
'agents' => (string) __('Agents'),
'exploreAll' => (string) __('Explore All'),
'noResults' => (string) __('No agents match the selected filters.'),
'website' => (string) __('Website'),
'filteredResults' => (string) __('Filtered Results (%1 matched partners)'),
'previousPage' => (string) __('Previous page'),
'nextPage' => (string) __('Next page'),
'page' => (string) __('Page %1'),
],
];
return (string) json_encode(
$config,
JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT
| JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR
);
}
}
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Controller\Adminhtml\Agent;
use Esun\Agent\Model\AgentFactory;
use Magento\Backend\App\Action;
use Magento\Framework\Controller\Result\Redirect;
class Delete extends Action
{
public const ADMIN_RESOURCE = 'Esun_Agent::delete';
public function __construct(Action\Context $context, private readonly AgentFactory $agentFactory)
{
parent::__construct($context);
}
public function execute(): Redirect
{
$id = (int) $this->getRequest()->getParam('entity_id');
try {
$agent = $this->agentFactory->create()->load($id);
if (!$agent->getId()) {
throw new \RuntimeException('Agent not found.');
}
$agent->delete();
$this->messageManager->addSuccessMessage(__('The agent has been deleted.'));
} catch (\Throwable $exception) {
$this->messageManager->addErrorMessage(__('The agent could not be deleted.'));
}
return $this->resultRedirectFactory->create()->setPath('*/*/');
}
}
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Controller\Adminhtml\Agent;
use Esun\Agent\Model\AgentFactory;
use Magento\Backend\App\Action;
use Magento\Framework\Controller\Result\Redirect;
use Magento\Framework\View\Result\Page;
use Magento\Framework\View\Result\PageFactory;
class Edit extends Action
{
public const ADMIN_RESOURCE = 'Esun_Agent::save';
public function __construct(
Action\Context $context,
private readonly PageFactory $pageFactory,
private readonly AgentFactory $agentFactory
) {
parent::__construct($context);
}
public function execute(): Page|Redirect
{
$id = (int) $this->getRequest()->getParam('entity_id');
$agent = $this->agentFactory->create();
if ($id) {
$agent->load($id);
if (!$agent->getId()) {
$this->messageManager->addErrorMessage(__('This agent no longer exists.'));
return $this->resultRedirectFactory->create()->setPath('*/*/');
}
}
$page = $this->pageFactory->create();
$page->setActiveMenu('Esun_Agent::agents');
$page->getConfig()->getTitle()->prepend($id ? __('Edit Agent: %1', $agent->getData('name')) : __('New Agent'));
return $page;
}
}
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Controller\Adminhtml\Agent;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\Page;
use Magento\Framework\View\Result\PageFactory;
class Index extends Action
{
public const ADMIN_RESOURCE = 'Esun_Agent::agents';
public function __construct(Context $context, private readonly PageFactory $pageFactory)
{
parent::__construct($context);
}
public function execute(): Page
{
$page = $this->pageFactory->create();
$page->setActiveMenu('Esun_Agent::agents');
$page->getConfig()->getTitle()->prepend(__('Agents'));
return $page;
}
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Controller\Adminhtml\Agent;
use Esun\Agent\Model\ResourceModel\Agent\CollectionFactory;
use Magento\Backend\App\Action;
use Magento\Framework\Controller\Result\Redirect;
use Magento\Ui\Component\MassAction\Filter;
class MassDelete extends Action
{
public const ADMIN_RESOURCE = 'Esun_Agent::delete';
public function __construct(
Action\Context $context,
private readonly Filter $filter,
private readonly CollectionFactory $collectionFactory
) {
parent::__construct($context);
}
public function execute(): Redirect
{
$collection = $this->filter->getCollection($this->collectionFactory->create());
$deleted = 0;
foreach ($collection as $agent) {
$agent->delete();
$deleted++;
}
$this->messageManager->addSuccessMessage(__('A total of %1 agent(s) have been deleted.', $deleted));
return $this->resultRedirectFactory->create()->setPath('*/*/');
}
}
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Controller\Adminhtml\Agent;
use Magento\Backend\App\Action;
use Magento\Framework\Controller\Result\Forward;
use Magento\Framework\Controller\Result\ForwardFactory;
class NewAction extends Action
{
public const ADMIN_RESOURCE = 'Esun_Agent::save';
public function __construct(Action\Context $context, private readonly ForwardFactory $forwardFactory)
{
parent::__construct($context);
}
public function execute(): Forward
{
return $this->forwardFactory->create()->forward('edit');
}
}
@@ -0,0 +1,105 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Controller\Adminhtml\Agent;
use Esun\Agent\Model\AgentFactory;
use Esun\Agent\Model\Map\CountryPosition;
use Magento\Backend\App\Action;
use Magento\Catalog\Model\ImageUploader;
use Magento\Directory\Model\CountryFactory;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\Controller\Result\Redirect;
use Magento\Framework\Exception\LocalizedException;
class Save extends Action
{
public const ADMIN_RESOURCE = 'Esun_Agent::save';
public function __construct(
Action\Context $context,
private readonly AgentFactory $agentFactory,
private readonly CountryPosition $countryPosition,
private readonly CountryFactory $countryFactory,
private readonly DataPersistorInterface $dataPersistor,
private readonly ImageUploader $imageUploader
) {
parent::__construct($context);
}
public function execute(): Redirect
{
$resultRedirect = $this->resultRedirectFactory->create();
$data = (array) $this->getRequest()->getPostValue();
if ($data === []) {
return $resultRedirect->setPath('*/*/');
}
$id = (int) ($data['entity_id'] ?? 0);
$agent = $this->agentFactory->create();
if ($id) {
$agent->load($id);
if (!$agent->getId()) {
$this->messageManager->addErrorMessage(__('This agent no longer exists.'));
return $resultRedirect->setPath('*/*/');
}
}
try {
$countryCode = strtoupper(trim((string) ($data['country_code'] ?? '')));
$country = $this->countryFactory->create()->loadByCode($countryCode);
if (!$country->getId()) {
throw new LocalizedException(__('Please select a valid country.'));
}
$data['country_code'] = $countryCode;
$data['country'] = (string) $country->getName();
$position = $this->countryPosition->get($countryCode);
if ($position === null) {
throw new LocalizedException(
__('The selected country is not yet available on the agent map. Please contact the website administrator.')
);
}
$data['map_x'] = $position['x'];
$data['map_y'] = $position['y'];
$data['is_active'] = (int) ($data['is_active'] ?? 0);
$data['sort_order'] = max(0, (int) ($data['sort_order'] ?? 0));
$data['website'] = trim((string) ($data['website'] ?? ''));
$data['address'] = trim((string) ($data['address'] ?? ''));
$data['note'] = trim((string) ($data['note'] ?? ''));
$data['logo'] = $this->resolveLogo($data['logo'] ?? null, (string) $agent->getData('logo'));
$agent->addData($data);
$agent->save();
$this->dataPersistor->clear('esun_agent');
$this->messageManager->addSuccessMessage(__('The agent has been saved.'));
if ($this->getRequest()->getParam('back')) {
return $resultRedirect->setPath('*/*/edit', ['entity_id' => $agent->getId()]);
}
return $resultRedirect->setPath('*/*/');
} catch (LocalizedException $exception) {
$this->messageManager->addErrorMessage($exception->getMessage());
} catch (\Throwable $exception) {
$this->messageManager->addExceptionMessage($exception, __('The agent could not be saved.'));
}
$this->dataPersistor->set('esun_agent', $data);
return $resultRedirect->setPath('*/*/edit', ['entity_id' => $id ?: null]);
}
private function resolveLogo(mixed $logoData, string $currentLogo): string
{
if (!is_array($logoData) || !isset($logoData[0]) || !is_array($logoData[0])) {
return $currentLogo;
}
$file = $logoData[0];
if (!empty($file['tmp_name']) && !empty($file['name'])) {
return $this->imageUploader->moveFileFromTmp((string) $file['name'], true);
}
return $currentLogo;
}
}
@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Controller\Adminhtml\Agent;
use Magento\Backend\App\Action;
use Magento\Catalog\Model\ImageUploader;
use Magento\Framework\Controller\Result\Json;
use Magento\Framework\Controller\Result\JsonFactory;
class Upload extends Action
{
public const ADMIN_RESOURCE = 'Esun_Agent::save';
public function __construct(
Action\Context $context,
private readonly JsonFactory $jsonFactory,
private readonly ImageUploader $imageUploader
) {
parent::__construct($context);
}
public function execute(): Json
{
$result = $this->jsonFactory->create();
try {
return $result->setData($this->imageUploader->saveFileToTmpDir('logo'));
} catch (\Throwable $exception) {
return $result->setData([
'error' => $exception->getMessage(),
'errorcode' => $exception->getCode(),
]);
}
}
}
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Controller\Adminhtml\Application;
use Esun\Agent\Model\ApplicationFactory;
use Magento\Backend\App\Action;
use Magento\Framework\Controller\Result\Redirect;
class Delete extends Action
{
public const ADMIN_RESOURCE = 'Esun_Agent::applications_delete';
public function __construct(Action\Context $context, private readonly ApplicationFactory $applicationFactory)
{
parent::__construct($context);
}
public function execute(): Redirect
{
try {
$application = $this->applicationFactory->create()->load((int)$this->getRequest()->getParam('entity_id'));
if (!$application->getId()) {
throw new \RuntimeException('Application not found.');
}
$application->delete();
$this->messageManager->addSuccessMessage(__('The application has been deleted.'));
} catch (\Throwable $exception) {
$this->messageManager->addErrorMessage(__('The application could not be deleted.'));
}
return $this->resultRedirectFactory->create()->setPath('*/*/');
}
}
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Controller\Adminhtml\Application;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\Page;
use Magento\Framework\View\Result\PageFactory;
class Index extends Action
{
public const ADMIN_RESOURCE = 'Esun_Agent::applications';
public function __construct(Context $context, private readonly PageFactory $pageFactory)
{
parent::__construct($context);
}
public function execute(): Page
{
$page = $this->pageFactory->create();
$page->setActiveMenu('Esun_Agent::applications');
$page->getConfig()->getTitle()->prepend(__('Agent Applications'));
return $page;
}
}
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Controller\Adminhtml\Application;
use Esun\Agent\Model\ResourceModel\Application\CollectionFactory;
use Magento\Backend\App\Action;
use Magento\Framework\Controller\Result\Redirect;
use Magento\Ui\Component\MassAction\Filter;
class MassDelete extends Action
{
public const ADMIN_RESOURCE = 'Esun_Agent::applications_delete';
public function __construct(
Action\Context $context,
private readonly Filter $filter,
private readonly CollectionFactory $collectionFactory
) {
parent::__construct($context);
}
public function execute(): Redirect
{
$collection = $this->filter->getCollection($this->collectionFactory->create());
$deleted = 0;
foreach ($collection as $application) {
$application->delete();
$deleted++;
}
$this->messageManager->addSuccessMessage(
__('A total of %1 application(s) have been deleted.', $deleted)
);
return $this->resultRedirectFactory->create()->setPath('*/*/');
}
}
@@ -0,0 +1,94 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Controller\Index;
use Esun\Agent\Model\ApplicationFactory;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Controller\Result\Json;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\Exception\LocalizedException;
use Psr\Log\LoggerInterface;
class Apply implements HttpPostActionInterface
{
public function __construct(
private readonly RequestInterface $request,
private readonly JsonFactory $jsonFactory,
private readonly ApplicationFactory $applicationFactory,
private readonly LoggerInterface $logger
) {
}
public function execute(): Json
{
$result = $this->jsonFactory->create();
try {
$data = $this->validateRequest();
$this->applicationFactory->create()
->setData($data)
->save();
return $result->setData([
'success' => true,
'message' => (string)__('Thank you. Your application has been submitted successfully.'),
]);
} catch (LocalizedException $exception) {
$result->setHttpResponseCode(422);
return $result->setData([
'success' => false,
'message' => $exception->getMessage(),
]);
} catch (\Throwable $exception) {
$this->logger->critical($exception);
$result->setHttpResponseCode(500);
return $result->setData([
'success' => false,
'message' => (string)__('Unable to submit your application. Please try again later.'),
]);
}
}
private function validateRequest(): array
{
if (trim((string)$this->request->getParam('hideit', '')) !== '') {
throw new LocalizedException(__('Unable to submit your application.'));
}
$data = [
'company_name' => trim((string)$this->request->getParam('company_name', '')),
'contact_person' => trim((string)$this->request->getParam('contact_person', '')),
'country' => trim((string)$this->request->getParam('country', '')),
'email' => trim((string)$this->request->getParam('email', '')),
'message' => trim((string)$this->request->getParam('message', '')),
];
if ($data['company_name'] === '') {
throw new LocalizedException(__('Enter the company name.'));
}
if ($data['contact_person'] === '') {
throw new LocalizedException(__('Enter the contact person.'));
}
if ($data['country'] === '') {
throw new LocalizedException(__('Select a country.'));
}
if (!filter_var($data['email'], FILTER_VALIDATE_EMAIL)) {
throw new LocalizedException(__('Enter a valid email address.'));
}
if (
mb_strlen($data['company_name']) > 255 ||
mb_strlen($data['contact_person']) > 255 ||
mb_strlen($data['country']) > 255 ||
mb_strlen($data['email']) > 255
) {
throw new LocalizedException(__('One or more fields are too long.'));
}
if (mb_strlen($data['message']) > 5000) {
throw new LocalizedException(__('The message must not exceed 5000 characters.'));
}
return $data;
}
}
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Controller\Index;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\View\Result\Page;
use Magento\Framework\View\Result\PageFactory;
class Index implements HttpGetActionInterface
{
public function __construct(
private readonly PageFactory $pageFactory
) {
}
public function execute(): Page
{
return $this->pageFactory->create();
}
}
+15
View File
@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Model;
use Esun\Agent\Model\ResourceModel\Agent as AgentResource;
use Magento\Framework\Model\AbstractModel;
class Agent extends AbstractModel
{
protected function _construct(): void
{
$this->_init(AgentResource::class);
}
}
@@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Model\Agent;
use Esun\Agent\Model\ResourceModel\Agent\CollectionFactory;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\UrlInterface;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Ui\DataProvider\AbstractDataProvider;
class DataProvider extends AbstractDataProvider
{
private array $loadedData = [];
public function __construct(
string $name,
string $primaryFieldName,
string $requestFieldName,
CollectionFactory $collectionFactory,
private readonly DataPersistorInterface $dataPersistor,
private readonly StoreManagerInterface $storeManager,
array $meta = [],
array $data = []
) {
$this->collection = $collectionFactory->create();
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
}
public function getData(): array
{
if ($this->loadedData !== []) {
return $this->loadedData;
}
foreach ($this->collection->getItems() as $agent) {
$data = $agent->getData();
if (!empty($data['logo'])) {
$data['logo'] = [[
'name' => basename((string) $data['logo']),
'url' => $this->storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA)
. ltrim((string) $data['logo'], '/'),
]];
}
$this->loadedData[(int) $agent->getId()] = $data;
}
$persisted = $this->dataPersistor->get('esun_agent');
if (is_array($persisted) && $persisted !== []) {
$id = (int) ($persisted['entity_id'] ?? 0);
$this->loadedData[$id] = $persisted;
$this->dataPersistor->clear('esun_agent');
}
return $this->loadedData;
}
}
+15
View File
@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Model;
use Esun\Agent\Model\ResourceModel\Application as ApplicationResource;
use Magento\Framework\Model\AbstractModel;
class Application extends AbstractModel
{
protected function _construct(): void
{
$this->_init(ApplicationResource::class);
}
}
@@ -0,0 +1,283 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Model\Map;
class CountryPosition
{
/**
* Coordinates are percentages calibrated to Esun_Agent::images/world-map-dots.svg.
* They belong to the country, never to an individual agent record.
* Base label points come from Natural Earth 1:50m Admin 0 map units and are
* projected to this SVG; countries already used by eSUN keep their visual overrides.
*/
private const POSITIONS = [
'AF' => [68.471, 33.867], // Afghanistan
'AL' => [55.587, 30.802], // Albania
'DZ' => [50.780, 37.062], // Algeria
'AS' => [2.570, 57.959], // American Samoa
'AD' => [50.428, 29.908], // Andorra
'AO' => [54.996, 56.768], // Angola
'AI' => [32.493, 41.385], // Anguilla
'AQ' => [59.968, 92.000], // Antarctica
'AG' => [32.831, 41.936], // Antigua & Barbuda
'AR' => [31.900, 81.900], // Argentina
'AM' => [62.445, 30.894], // Armenia
'AN' => [30.855, 44.265], // Netherlands Antilles (legacy Magento country code)
'AW' => [30.563, 44.089], // Aruba
'AU' => [85.400, 77.000], // Australia
'AT' => [53.750, 30.000], // Austria
'AZ' => [63.114, 30.921], // Azerbaijan
'BS' => [28.570, 37.532], // Bahamas
'BH' => [64.043, 37.696], // Bahrain
'BD' => [74.912, 38.565], // Bangladesh
'BB' => [33.453, 43.784], // Barbados
'BY' => [57.894, 24.584], // Belarus
'BE' => [49.300, 26.000], // Belgium
'BZ' => [25.358, 41.877], // Belize
'BJ' => [50.653, 45.124], // Benin
'BM' => [32.010, 34.749], // Bermuda
'BT' => [75.011, 36.997], // Bhutan
'BO' => [32.057, 59.259], // Bolivia
'BA' => [55.273, 29.214], // Bosnia & Herzegovina
'BW' => [56.716, 62.279], // Botswana
'BV' => [50.944, 80.222], // Bouvet Island
'BR' => [34.250, 66.700], // Brazil
'IO' => [69.819, 53.439], // British Indian Ocean Territory
'VG' => [32.045, 41.299], // British Virgin Islands
'BN' => [81.820, 47.899], // Brunei
'BG' => [57.000, 30.000], // Bulgaria
'BF' => [49.621, 44.016], // Burkina Faso
'BI' => [58.310, 51.852], // Burundi
'KH' => [79.029, 44.028], // Cambodia
'CM' => [53.465, 47.835], // Cameroon
'CA' => [20.556, 23.556], // Canada
'CV' => [43.433, 42.881], // Cape Verde
'BQ' => [32.463, 41.715], // Caribbean Netherlands
'KY' => [27.433, 40.877], // Cayman Islands
'CF' => [55.807, 46.699], // Central African Republic
'TD' => [55.179, 42.849], // Chad
'CL' => [29.100, 79.200], // Chile
'CN' => [79.538, 34.654], // China
'CX' => [79.353, 55.828], // Christmas Island
'CC' => [76.897, 56.755], // Cocos (Keeling) Islands
'CO' => [29.674, 48.407], // Colombia
'KM' => [62.033, 56.515], // Comoros
'CG' => [54.417, 49.933], // Congo - Brazzaville
'CD' => [56.516, 51.032], // Congo - Kinshasa
'CK' => [5.615, 61.787], // Cook Islands
'CR' => [26.645, 45.247], // Costa Rica
'HR' => [54.548, 28.369], // Croatia
'CU' => [28.340, 39.926], // Cuba
'CW' => [30.855, 44.265], // Curaçao
'CY' => [59.190, 33.513], // Cyprus
'CZ' => [54.272, 26.444], // Czechia
'CI' => [48.453, 46.462], // Côte d’Ivoire
'DK' => [52.505, 23.571], // Denmark
'DJ' => [61.805, 44.345], // Djibouti
'DM' => [32.960, 42.700], // Dominica
'DO' => [30.374, 40.979], // Dominican Republic
'EC' => [27.200, 60.800], // Ecuador
'EG' => [57.000, 38.500], // Egypt
'SV' => [25.308, 43.537], // El Salvador
'GQ' => [52.497, 48.898], // Equatorial Guinea
'ER' => [60.635, 42.545], // Eritrea
'EE' => [58.000, 22.000], // Estonia
'SZ' => [58.741, 64.741], // Eswatini
'ET' => [60.858, 46.207], // Ethiopia
'FK' => [33.684, 78.672], // Falkland Islands
'FO' => [48.039, 20.635], // Faroe Islands
'FJ' => [98.000, 59.903], // Fiji
'FI' => [54.400, 17.500], // Finland
'FR' => [47.500, 30.000], // France
'GF' => [35.259, 48.111], // French Guiana
'PF' => [8.483, 59.793], // French Polynesia
'TF' => [69.201, 77.391], // French Southern Territories
'GA' => [53.288, 50.243], // Gabon
'GM' => [45.834, 43.558], // Gambia
'GE' => [62.149, 30.228], // Georgia
'DE' => [51.900, 26.400], // Germany
'GH' => [49.712, 46.356], // Ghana
'GI' => [48.514, 32.934], // Gibraltar
'GR' => [55.300, 35.200], // Greece
'GL' => [39.074, 14.905], // Greenland
'GD' => [32.867, 44.280], // Grenada
'GP' => [32.935, 42.303], // Guadeloupe
'GU' => [90.195, 43.694], // Guam
'GT' => [22.000, 50.500], // Guatemala
'GG' => [49.288, 26.642], // Guernsey
'GN' => [47.218, 44.986], // Guinea
'GW' => [45.966, 44.256], // Guinea-Bissau
'GY' => [33.627, 47.580], // Guyana
'HT' => [29.938, 40.903], // Haiti
'HM' => [70.418, 79.502], // Heard & McDonald Islands
'HN' => [25.865, 43.014], // Honduras
'HK' => [81.694, 39.399], // Hong Kong SAR China
'HU' => [55.402, 27.765], // Hungary
'IS' => [44.813, 19.410], // Iceland
'IN' => [67.500, 48.500], // India
'ID' => [74.000, 72.500], // Indonesia
'IR' => [65.259, 34.810], // Iran
'IQ' => [62.017, 34.372], // Iraq
'IE' => [47.834, 24.935], // Ireland
'IM' => [48.742, 24.396], // Isle of Man
'IL' => [62.050, 38.861], // Israel
'IT' => [53.077, 28.876], // Italy
'JM' => [28.523, 41.435], // Jamaica
'JP' => [88.456, 32.933], // Japan
'JE' => [49.419, 26.757], // Jersey
'JO' => [60.104, 35.453], // Jordan
'KZ' => [69.079, 26.836], // Kazakhstan
'KE' => [60.530, 49.741], // Kenya
'KI' => [6.282, 49.140], // Kiribati
'XK' => [55.795, 29.886], // Kosovo
'KW' => [63.143, 36.110], // Kuwait
'KG' => [70.704, 30.323], // Kyrgyzstan
'LA' => [78.482, 40.824], // Laos
'LV' => [57.072, 23.052], // Latvia
'LB' => [59.998, 33.881], // Lebanon
'LS' => [57.846, 66.378], // Lesotho
'LR' => [47.372, 46.955], // Liberia
'LY' => [55.003, 37.420], // Libya
'LI' => [52.655, 27.753], // Liechtenstein
'LT' => [56.692, 23.979], // Lithuania
'LU' => [51.688, 26.515], // Luxembourg
'MO' => [81.543, 39.550], // Macao SAR China
'MG' => [62.973, 60.349], // Madagascar
'MW' => [59.336, 57.437], // Malawi
'MY' => [81.621, 48.806], // Malaysia
'MV' => [70.419, 48.029], // Maldives
'ML' => [49.434, 41.173], // Mali
'MT' => [54.009, 33.051], // Malta
'MH' => [97.554, 46.655], // Marshall Islands
'MQ' => [33.040, 43.053], // Martinique
'MR' => [47.294, 40.751], // Mauritania
'MU' => [65.991, 61.278], // Mauritius
'YT' => [62.542, 57.097], // Mayotte
'MX' => [21.667, 39.139], // Mexico
'FM' => [93.954, 46.748], // Micronesia
'MD' => [57.913, 27.600], // Moldova
'MC' => [52.055, 29.345], // Monaco
'MN' => [78.889, 28.278], // Mongolia
'ME' => [55.318, 29.787], // Montenegro
'MS' => [32.725, 42.096], // Montserrat
'MA' => [48.004, 35.054], // Morocco
'MZ' => [60.511, 57.746], // Mozambique
'MM' => [76.612, 39.812], // Myanmar (Burma)
'NA' => [54.752, 61.431], // Namibia
'NR' => [96.370, 50.289], // Nauru
'NP' => [73.233, 36.637], // Nepal
'NL' => [51.000, 21.000], // Netherlands
'NC' => [95.857, 61.703], // New Caledonia
'NZ' => [95.000, 84.300], // New Zealand
'NI' => [26.370, 44.017], // Nicaragua
'NE' => [52.640, 41.762], // Niger
'NG' => [52.084, 45.542], // Nigeria
'NU' => [2.816, 60.581], // Niue
'NF' => [96.654, 66.129], // Norfolk Island
'KP' => [85.123, 31.165], // North Korea
'MK' => [55.988, 30.375], // North Macedonia
'MP' => [90.482, 42.828], // Northern Mariana Islands
'NO' => [49.400, 14.000], // Norway
'OM' => [65.927, 39.554], // Oman
'PK' => [69.040, 36.150], // Pakistan
'PW' => [87.383, 46.450], // Palau
'PS' => [59.523, 35.217], // Palestinian Territories
'PA' => [27.680, 45.881], // Panama
'PG' => [89.975, 53.164], // Papua New Guinea
'PY' => [33.293, 62.041], // Paraguay
'PE' => [28.250, 68.100], // Peru
'PH' => [77.300, 54.500], // Philippines
'PN' => [14.356, 63.536], // Pitcairn Islands
'PL' => [55.000, 25.000], // Poland
'PT' => [45.293, 34.539], // Portugal
'QA' => [64.207, 38.082], // Qatar
'RO' => [56.937, 28.404], // Romania
'RU' => [72.222, 24.028], // Russia
'RW' => [58.362, 51.054], // Rwanda
'RE' => [65.427, 61.730], // Réunion
'WS' => [2.100, 57.577], // Samoa
'SM' => [53.456, 29.253], // San Marino
'SA' => [62.769, 46.847], // Saudi Arabia
'SN' => [45.895, 42.851], // Senegal
'RS' => [55.950, 29.293], // Serbia
'SC' => [65.411, 52.598], // Seychelles
'SL' => [46.732, 45.931], // Sierra Leone
'SG' => [74.000, 58.500], // Singapore
'SX' => [32.481, 41.481], // Sint Maarten
'SK' => [55.292, 26.987], // Slovakia
'SI' => [54.143, 28.249], // Slovenia
'SB' => [94.214, 54.461], // Solomon Islands
'SO' => [62.553, 48.315], // Somalia
'ZA' => [53.800, 69.500], // South Africa
'GS' => [41.371, 80.935], // South Georgia & South Sandwich Islands
'KR' => [82.175, 37.264], // South Korea
'ES' => [49.038, 31.068], // Spain
'LK' => [72.418, 46.420], // Sri Lanka
'BL' => [32.546, 41.546], // St. Barthélemy
'SH' => [48.413, 58.861], // St. Helena
'KN' => [32.567, 41.813], // St. Kitts & Nevis
'LC' => [33.061, 43.440], // St. Lucia
'MF' => [32.486, 41.462], // St. Martin
'PM' => [34.352, 27.787], // St. Pierre & Miquelon
'VC' => [32.962, 43.820], // St. Vincent & Grenadines
'SD' => [58.128, 42.288], // Sudan
'SR' => [34.469, 48.043], // Suriname
'SJ' => [55.022, 12.799], // Svalbard & Jan Mayen
'SE' => [55.283, 18.900], // Sweden
'CH' => [50.500, 31.000], // Switzerland
'SY' => [60.633, 33.469], // Syria
'ST' => [51.950, 49.542], // São Tomé & Príncipe
'TW' => [81.600, 45.000], // Taiwan
'TJ' => [70.163, 31.961], // Tajikistan
'TZ' => [60.922, 53.405], // Tanzania
'TH' => [72.200, 50.500], // Thailand
'TL' => [84.960, 54.891], // Timor-Leste
'TG' => [50.294, 45.841], // Togo
'TK' => [2.087, 54.757], // Tokelau
'TO' => [2.000, 61.783], // Tonga
'TT' => [33.078, 44.806], // Trinidad & Tobago
'TN' => [52.502, 34.092], // Tunisia
'TM' => [66.299, 31.179], // Turkmenistan
'TC' => [30.069, 39.698], // Turks & Caicos Islands
'TV' => [98.000, 54.730], // Tuvalu
'TR' => [59.700, 30.500], // Türkiye
'UM' => [2.000, 36.683], // U.S. Outlying Islands
'VI' => [32.006, 41.620], // U.S. Virgin Islands
'UG' => [59.152, 49.068], // Uganda
'UA' => [58.928, 26.519], // Ukraine
'AE' => [65.000, 44.000], // United Arab Emirates
'GB' => [43.100, 26.100], // United Kingdom
'US' => [22.778, 31.583], // United States
'UY' => [34.454, 68.312], // Uruguay
'UZ' => [67.778, 30.639], // Uzbekistan
'VU' => [96.364, 58.540], // Vanuatu
'VA' => [53.459, 30.212], // Vatican City
'VE' => [32.056, 46.608], // Venezuela
'VN' => [74.800, 50.800], // Vietnam
'WF' => [2.000, 57.937], // Wallis & Futuna
'EH' => [46.492, 38.682], // Western Sahara
'YE' => [62.743, 42.762], // Yemen
'ZM' => [57.332, 58.145], // Zambia
'ZW' => [58.313, 60.506], // Zimbabwe
'AX' => [55.519, 21.593], // Åland Islands
];
/**
* @return array{x: float, y: float}|null
*/
public function get(string $countryCode): ?array
{
$position = self::POSITIONS[strtoupper(trim($countryCode))] ?? null;
if ($position === null) {
return null;
}
return ['x' => $position[0], 'y' => $position[1]];
}
public function has(string $countryCode): bool
{
return $this->get($countryCode) !== null;
}
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Model\ResourceModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class Agent extends AbstractDb
{
protected function _construct(): void
{
$this->_init('esun_agent', 'entity_id');
}
}
@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Model\ResourceModel\Agent;
use Esun\Agent\Model\Agent as AgentModel;
use Esun\Agent\Model\ResourceModel\Agent as AgentResource;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
class Collection extends AbstractCollection
{
protected $_idFieldName = 'entity_id';
protected function _construct(): void
{
$this->_init(AgentModel::class, AgentResource::class);
}
}
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Model\ResourceModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class Application extends AbstractDb
{
protected function _construct(): void
{
$this->_init('esun_agent_application', 'entity_id');
}
}
@@ -0,0 +1,18 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Model\ResourceModel\Application;
use Esun\Agent\Model\Application as ApplicationModel;
use Esun\Agent\Model\ResourceModel\Application as ApplicationResource;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
class Collection extends AbstractCollection
{
protected $_idFieldName = 'entity_id';
protected function _construct(): void
{
$this->_init(ApplicationModel::class, ApplicationResource::class);
}
}
@@ -0,0 +1,22 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Model\Source;
use Magento\Framework\Data\OptionSourceInterface;
class Continent implements OptionSourceInterface
{
public function toOptionArray(): array
{
return [
['value' => 'africa', 'label' => __('Africa')],
['value' => 'asia', 'label' => __('Asia')],
['value' => 'europe', 'label' => __('Europe')],
['value' => 'north_america', 'label' => __('North America')],
['value' => 'south_america', 'label' => __('South America')],
['value' => 'oceania', 'label' => __('Oceania')],
['value' => 'antarctica', 'label' => __('Antarctica')],
];
}
}
@@ -0,0 +1,26 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Model\Source;
use Esun\Agent\Model\Map\CountryPosition;
use Magento\Directory\Model\Config\Source\Country;
use Magento\Framework\Data\OptionSourceInterface;
class MapCountry implements OptionSourceInterface
{
public function __construct(
private readonly Country $countrySource,
private readonly CountryPosition $countryPosition
) {
}
public function toOptionArray(): array
{
return array_values(array_filter(
$this->countrySource->toOptionArray(),
fn (array $option): bool => (string) ($option['value'] ?? '') === ''
|| $this->countryPosition->has((string) $option['value'])
));
}
}
@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Setup\Patch\Data;
use Esun\Agent\Model\Map\CountryPosition;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class CorrectSoutheastAsiaMapPositions implements DataPatchInterface
{
private const COUNTRY_CODES = ['ID', 'SG', 'TH', 'TW', 'VN'];
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup,
private readonly ResourceConnection $resourceConnection,
private readonly CountryPosition $countryPosition
) {
}
public function apply(): self
{
$connection = $this->moduleDataSetup->getConnection();
$table = $this->resourceConnection->getTableName('esun_agent');
$this->moduleDataSetup->startSetup();
foreach (self::COUNTRY_CODES as $countryCode) {
$position = $this->countryPosition->get($countryCode);
if ($position === null) {
continue;
}
$connection->update(
$table,
['map_x' => $position['x'], 'map_y' => $position['y']],
['country_code = ?' => $countryCode]
);
}
$this->moduleDataSetup->endSetup();
return $this;
}
public static function getDependencies(): array
{
return [ImportAgents::class];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,92 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Setup\Patch\Data;
use Esun\Agent\Model\Map\CountryPosition;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Driver\File;
use Magento\Framework\Module\Dir\Reader as ModuleDirReader;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class ImportAgents implements DataPatchInterface
{
public function __construct(
private readonly ModuleDataSetupInterface $moduleDataSetup,
private readonly ModuleDirReader $moduleDirReader,
private readonly Filesystem $filesystem,
private readonly File $file,
private readonly CountryPosition $countryPosition
) {
}
public function apply(): self
{
$this->moduleDataSetup->startSetup();
$connection = $this->moduleDataSetup->getConnection();
$table = $this->moduleDataSetup->getTable('esun_agent');
if ((int) $connection->fetchOne($connection->select()->from($table, 'COUNT(*)')) > 0) {
$this->moduleDataSetup->endSetup();
return $this;
}
$moduleDir = $this->moduleDirReader->getModuleDir('', 'Esun_Agent');
$data = json_decode(
$this->file->fileGetContents($moduleDir . '/view/frontend/web/data/agents.json'),
true,
512,
JSON_THROW_ON_ERROR
);
$media = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$media->create('agent/logo');
$records = [];
foreach ($data['agents'] as $agent) {
$position = $this->countryPosition->get((string) $agent['country_code']);
$logo = '';
if ($agent['logo'] !== '') {
$source = $moduleDir . '/view/frontend/web/images/agents/' . $agent['logo'];
$logo = 'agent/logo/' . $agent['logo'];
if ($this->file->isExists($source)) {
$media->writeFile($logo, $this->file->fileGetContents($source));
}
}
$records[] = [
'system_name' => $agent['system_name'],
'name' => $agent['name'],
'continent' => $agent['continent'],
'country_code' => $agent['country_code'],
'country' => $agent['country'],
'website' => $agent['website'],
'address' => $agent['address'],
'logo' => $logo,
'note' => $agent['note'],
'map_x' => $position['x'] ?? null,
'map_y' => $position['y'] ?? null,
'sort_order' => $agent['sort_order'],
'is_active' => 1,
];
}
if ($records !== []) {
$connection->insertMultiple($table, $records);
}
$this->moduleDataSetup->endSetup();
return $this;
}
public static function getDependencies(): array
{
return [];
}
public function getAliases(): array
{
return [];
}
}
@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Ui\Component\Listing\Column;
use Magento\Framework\UrlInterface;
use Magento\Ui\Component\Listing\Columns\Column;
class AgentActions extends Column
{
public function __construct(
\Magento\Framework\View\Element\UiComponent\ContextInterface $context,
\Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory,
private readonly UrlInterface $urlBuilder,
array $components = [],
array $data = []
) {
parent::__construct($context, $uiComponentFactory, $components, $data);
}
public function prepareDataSource(array $dataSource): array
{
if (!isset($dataSource['data']['items'])) {
return $dataSource;
}
foreach ($dataSource['data']['items'] as &$item) {
if (!isset($item['entity_id'])) {
continue;
}
$name = $this->getData('name');
$item[$name]['edit'] = [
'href' => $this->urlBuilder->getUrl('esun_agent/agent/edit', ['entity_id' => $item['entity_id']]),
'label' => __('Edit'),
];
$item[$name]['delete'] = [
'href' => $this->urlBuilder->getUrl('esun_agent/agent/delete', ['entity_id' => $item['entity_id']]),
'label' => __('Delete'),
'confirm' => [
'title' => __('Delete %1', $item['name'] ?? __('Agent')),
'message' => __('Are you sure you want to delete this agent?'),
],
'post' => true,
];
}
unset($item);
return $dataSource;
}
}
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace Esun\Agent\Ui\Component\Listing\Column;
use Magento\Framework\UrlInterface;
use Magento\Ui\Component\Listing\Columns\Column;
class ApplicationActions extends Column
{
public function __construct(
\Magento\Framework\View\Element\UiComponent\ContextInterface $context,
\Magento\Framework\View\Element\UiComponentFactory $uiComponentFactory,
private readonly UrlInterface $urlBuilder,
array $components = [],
array $data = []
) {
parent::__construct($context, $uiComponentFactory, $components, $data);
}
public function prepareDataSource(array $dataSource): array
{
foreach ($dataSource['data']['items'] ?? [] as &$item) {
if (!isset($item['entity_id'])) {
continue;
}
$item[$this->getData('name')]['delete'] = [
'href' => $this->urlBuilder->getUrl(
'esun_agent/application/delete',
['entity_id' => $item['entity_id']]
),
'label' => __('Delete'),
'confirm' => [
'title' => __('Delete application'),
'message' => __('Are you sure you want to delete this application?'),
],
'post' => true,
];
}
unset($item);
return $dataSource;
}
}
+14
View File
@@ -0,0 +1,14 @@
{
"name": "esun/module-agent",
"description": "eSUN global agent locator",
"type": "magento2-module",
"version": "1.0.0",
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Esun\\Agent\\": ""
}
}
}
@@ -0,0 +1,315 @@
<?php
declare(strict_types=1);
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing;
$projectRoot = dirname(__DIR__, 6);
require $projectRoot . '/vendor/autoload.php';
$input = $argv[1] ?? '';
if ($input === '' || !is_file($input)) {
fwrite(STDERR, "Usage: php import-agent-xlsx.php /absolute/path/agents.xlsx\n");
exit(1);
}
$moduleRoot = dirname(__DIR__, 2);
$logoDir = $moduleRoot . '/view/frontend/web/images/agents';
$dataFile = $moduleRoot . '/view/frontend/web/data/agents.json';
if (!is_dir($logoDir) && !mkdir($logoDir, 0775, true) && !is_dir($logoDir)) {
throw new RuntimeException('Unable to create logo directory.');
}
if (!is_dir(dirname($dataFile)) && !mkdir(dirname($dataFile), 0775, true) && !is_dir(dirname($dataFile))) {
throw new RuntimeException('Unable to create data directory.');
}
foreach (glob($logoDir . '/*.png') ?: [] as $oldLogo) {
unlink($oldLogo);
}
$spreadsheet = IOFactory::load($input);
$sheet = $spreadsheet->getSheet(0);
$rows = $sheet->toArray(null, true, true, true);
$drawingsByRow = [];
foreach ($sheet->getDrawingCollection() as $drawing) {
$coordinate = $drawing->getCoordinates();
if (!preg_match('/^H(\d+)$/i', $coordinate, $matches)) {
continue;
}
$drawingsByRow[(int) $matches[1]][] = $drawing;
}
// Excel may anchor two logos in one tall H cell for two adjacent records (the
// BRACK/ALLTRON rows in the current source file). Move extra drawings to the
// next logo-less record while keeping their visual order.
foreach ($drawingsByRow as $rowNumber => $rowDrawings) {
if (count($rowDrawings) < 2) {
continue;
}
$drawingsByRow[$rowNumber] = [array_shift($rowDrawings)];
$targetRow = $rowNumber + 1;
foreach ($rowDrawings as $drawing) {
while (isset($drawingsByRow[$targetRow])) {
$targetRow++;
}
$drawingsByRow[$targetRow] = [$drawing];
$targetRow++;
}
}
ksort($drawingsByRow);
$agents = [];
$usedSlugs = [];
$unmappedCountries = [];
foreach ($rows as $rowNumber => $row) {
if ($rowNumber === 1 || trim((string) ($row['B'] ?? '')) === '') {
continue;
}
$countrySource = cleanText((string) ($row['C'] ?? ''));
$country = countryMetadata($countrySource);
if ($country === null) {
$unmappedCountries[$countrySource] = true;
continue;
}
$id = count($agents) + 1;
$mapPosition = mapPosition($country['code']);
$name = cleanText((string) ($row['B'] ?? $row['A'] ?? ''));
$baseSlug = slugify($name) ?: sprintf('agent-%03d', $id);
$slug = $baseSlug;
$suffix = 2;
while (isset($usedSlugs[$slug])) {
$slug = $baseSlug . '-' . $suffix++;
}
$usedSlugs[$slug] = true;
$logo = '';
if (isset($drawingsByRow[$rowNumber][0])) {
$logo = $slug . '.png';
saveDrawingAsPng($drawingsByRow[$rowNumber][0], $logoDir . '/' . $logo);
}
$agents[] = [
'id' => $id,
'slug' => $slug,
'system_name' => cleanText((string) ($row['A'] ?? '')),
'name' => $name,
'continent' => $country['continent'],
'country_code' => $country['code'],
'country' => $country['name'],
'website' => normalizeWebsite((string) ($row['E'] ?? '')),
'address' => cleanText((string) ($row['F'] ?? '')),
'logo' => $logo,
'note' => cleanText((string) ($row['I'] ?? '')),
'map_x' => $mapPosition['x'],
'map_y' => $mapPosition['y'],
'sort_order' => $id,
];
}
if ($unmappedCountries !== []) {
throw new RuntimeException('Unmapped countries: ' . implode(', ', array_keys($unmappedCountries)));
}
$payload = [
'version' => 1,
'source_updated_at' => date('Y-m-d', (int) filemtime($input)),
'continents' => [
['code' => 'north_america', 'label' => 'North America', 'x' => 21.5, 'y' => 34.5],
['code' => 'south_america', 'label' => 'South America', 'x' => 31.5, 'y' => 64.5],
['code' => 'europe', 'label' => 'Europe', 'x' => 49.5, 'y' => 31.5],
['code' => 'africa', 'label' => 'Africa', 'x' => 51.5, 'y' => 55.5],
['code' => 'asia', 'label' => 'Asia', 'x' => 69.0, 'y' => 37.5],
['code' => 'oceania', 'label' => 'Oceania', 'x' => 83.0, 'y' => 68.0],
['code' => 'antarctica', 'label' => 'Antarctica', 'x' => 51.0, 'y' => 91.0],
],
'agents' => $agents,
];
file_put_contents(
$dataFile,
json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR) . "\n"
);
printf("Imported %d agents and %d logos.\n", count($agents), count(array_filter(array_column($agents, 'logo'))));
function cleanText(string $value): string
{
$value = str_replace(["\xc2\xa0", "\r\n", "\r"], [' ', "\n", "\n"], $value);
$value = preg_replace('/[ \t]+/u', ' ', trim($value)) ?? trim($value);
return $value;
}
function normalizeWebsite(string $website): string
{
$website = cleanText($website);
if ($website === '') {
return '';
}
$website = preg_replace('#^http:/([^/])#i', 'http://$1', $website) ?? $website;
if (!preg_match('#^https?://#i', $website)) {
$website = 'https://' . $website;
}
return $website;
}
function slugify(string $value): string
{
$ascii = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $value) ?: $value;
$slug = strtolower((string) preg_replace('/[^a-zA-Z0-9]+/', '-', $ascii));
return trim($slug, '-');
}
function countryMetadata(string $source): ?array
{
$key = mb_strtolower(trim($source));
$key = str_replace(['(', ')'], ['(', ')'], $key);
$key = preg_replace('/\s+/u', ' ', $key) ?? $key;
$countries = [
'argentina' => ['Argentina', 'AR', 'south_america'],
'australia' => ['Australia', 'AU', 'oceania'],
'austria' => ['Austria', 'AT', 'europe'],
'belgium' => ['Belgium', 'BE', 'europe'],
'brazil' => ['Brazil', 'BR', 'south_america'],
'bulgaria' => ['Bulgaria', 'BG', 'europe'],
'canada' => ['Canada', 'CA', 'north_america'],
'chile' => ['Chile', 'CL', 'south_america'],
'china(taiwan)' => ['China (Taiwan)', 'TW', 'asia'],
'china (taiwan)' => ['China (Taiwan)', 'TW', 'asia'],
'ecuador' => ['Ecuador', 'EC', 'south_america'],
'egypt' => ['Egypt', 'EG', 'africa'],
'estonia' => ['Estonia', 'EE', 'europe'],
'finland' => ['Finland', 'FI', 'europe'],
'france' => ['France', 'FR', 'europe'],
'germany' => ['Germany', 'DE', 'europe'],
'greece' => ['Greece', 'GR', 'europe'],
'guatemala' => ['Guatemala', 'GT', 'north_america'],
'india' => ['India', 'IN', 'asia'],
'indonesia' => ['Indonesia', 'ID', 'asia'],
'israel' => ['Israel', 'IL', 'asia'],
'korea' => ['Korea', 'KR', 'asia'],
'mexico' => ['Mexico', 'MX', 'north_america'],
'mongolia' => ['Mongolia', 'MN', 'asia'],
'netherlands' => ['Netherlands', 'NL', 'europe'],
'new zealand' => ['New Zealand', 'NZ', 'oceania'],
'norway' => ['Norway', 'NO', 'europe'],
'peru' => ['Peru', 'PE', 'south_america'],
'philippines' => ['Philippines', 'PH', 'asia'],
'poland' => ['Poland', 'PL', 'europe'],
'russia' => ['Russia', 'RU', 'europe'],
'saudia arabia' => ['Saudi Arabia', 'SA', 'asia'],
'singapore' => ['Singapore', 'SG', 'asia'],
'south africa' => ['South Africa', 'ZA', 'africa'],
'switzerland' => ['Switzerland', 'CH', 'europe'],
'thailand' => ['Thailand', 'TH', 'asia'],
'turkey' => ['Turkey', 'TR', 'asia'],
'uk' => ['United Kingdom', 'GB', 'europe'],
'united arab emirates' => ['United Arab Emirates', 'AE', 'asia'],
'united kingdom' => ['United Kingdom', 'GB', 'europe'],
'united states' => ['United States', 'US', 'north_america'],
'uzbekistan' => ['Uzbekistan', 'UZ', 'asia'],
'vietnam' => ['Vietnam', 'VN', 'asia'],
];
if (!isset($countries[$key])) {
return null;
}
return [
'name' => $countries[$key][0],
'code' => $countries[$key][1],
'continent' => $countries[$key][2],
];
}
function mapPosition(string $countryCode): array
{
// This SVG is an intentionally stylized projection. These positions are
// calibrated against its actual land shapes rather than raw longitude and latitude.
$svgOverrides = [
'ID' => ['x' => 81.5, 'y' => 66.0],
'SG' => ['x' => 77.0, 'y' => 60.5],
'TH' => ['x' => 76.2, 'y' => 52.0],
'TW' => ['x' => 81.6, 'y' => 45.0],
'VN' => ['x' => 77.6, 'y' => 52.5],
];
if (isset($svgOverrides[$countryCode])) {
return $svgOverrides[$countryCode];
}
$centroids = [
'AE' => [54.0, 24.0], 'AR' => [-64.0, -34.0], 'AT' => [14.0, 47.5],
'AU' => [134.0, -25.0], 'BE' => [4.5, 50.5], 'BG' => [25.0, 43.0],
'BR' => [-52.0, -10.0], 'CA' => [-106.0, 56.0], 'CH' => [8.0, 47.0],
'CL' => [-71.0, -33.0], 'DE' => [10.0, 51.0], 'EC' => [-78.0, -1.5],
'EE' => [25.5, 58.5], 'EG' => [30.0, 27.0], 'FI' => [26.0, 64.0],
'FR' => [2.0, 46.0], 'GB' => [-2.0, 54.0], 'GR' => [22.0, 39.0],
'GT' => [-90.2, 15.7], 'ID' => [118.0, -2.0], 'IL' => [35.0, 31.5],
'IN' => [79.0, 22.0], 'KR' => [128.0, 36.0], 'MN' => [104.0, 46.0],
'MX' => [-102.0, 23.0], 'NL' => [5.5, 52.0], 'NO' => [9.0, 61.0],
'NZ' => [172.0, -41.0], 'PE' => [-75.0, -9.0], 'PH' => [122.0, 13.0],
'PL' => [19.0, 52.0], 'RU' => [80.0, 55.0], 'SA' => [45.0, 24.0],
'SG' => [103.8, 1.3], 'TH' => [101.0, 15.0], 'TR' => [35.0, 39.0],
'TW' => [121.0, 24.0], 'US' => [-98.0, 39.0], 'UZ' => [64.0, 41.0],
'VN' => [108.0, 16.0], 'ZA' => [24.0, -30.0],
];
if (!isset($centroids[$countryCode])) {
return ['x' => null, 'y' => null];
}
[$longitude, $latitude] = $centroids[$countryCode];
$x = ($longitude + 180) / 360 * 100;
$y = (90 - $latitude) / 180 * 100 + max(0, $latitude) / 12;
return [
'x' => round(max(2, min(98, $x)), 3),
'y' => round(max(4, min(92, $y)), 3),
];
}
function saveDrawingAsPng(Drawing|MemoryDrawing $drawing, string $destination): void
{
if ($drawing instanceof MemoryDrawing) {
ob_start();
$renderingFunction = $drawing->getRenderingFunction();
$renderingFunction($drawing->getImageResource());
$bytes = (string) ob_get_clean();
} else {
$bytes = file_get_contents($drawing->getPath());
if ($bytes === false) {
throw new RuntimeException('Unable to read drawing: ' . $drawing->getName());
}
}
$source = imagecreatefromstring($bytes);
if ($source === false) {
throw new RuntimeException('Unsupported logo image: ' . $drawing->getName());
}
$width = imagesx($source);
$height = imagesy($source);
$scale = min(1, 560 / max(1, $width), 220 / max(1, $height));
$targetWidth = max(1, (int) round($width * $scale));
$targetHeight = max(1, (int) round($height * $scale));
$target = imagecreatetruecolor($targetWidth, $targetHeight);
imagealphablending($target, false);
imagesavealpha($target, true);
$transparent = imagecolorallocatealpha($target, 255, 255, 255, 127);
imagefill($target, 0, 0, $transparent);
imagecopyresampled($target, $source, 0, 0, 0, 0, $targetWidth, $targetHeight, $width, $height);
imagepng($target, $destination, 8);
imagedestroy($source);
imagedestroy($target);
}
+19
View File
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework/Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
<resource id="Magento_Catalog::catalog">
<resource id="Esun_Agent::agents" title="Agent Management" sortOrder="60">
<resource id="Esun_Agent::save" title="Save Agents" sortOrder="10"/>
<resource id="Esun_Agent::delete" title="Delete Agents" sortOrder="20"/>
<resource id="Esun_Agent::applications" title="Agent Applications" sortOrder="30">
<resource id="Esun_Agent::applications_delete" title="Delete Agent Applications" sortOrder="10"/>
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add id="Esun_Agent::agents"
title="Agents Management"
module="Esun_Agent"
sortOrder="60"
parent="Esun_ImageManager::esun"
action="esun_agent/agent/index"
resource="Esun_Agent::agents"/>
<add id="Esun_Agent::applications"
title="Agent Applications"
module="Esun_Agent"
sortOrder="70"
parent="Esun_ImageManager::esun"
action="esun_agent/application/index"
resource="Esun_Agent::applications"/>
</menu>
</config>
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework/App/etc/routes.xsd">
<router id="admin">
<route id="esun_agent" frontName="esun_agent">
<module name="Esun_Agent" before="Magento_Backend"/>
</route>
</router>
</config>
+53
View File
@@ -0,0 +1,53 @@
<?xml version="1.0"?>
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="esun_agent" resource="default" engine="innodb" comment="eSUN Agents">
<column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
<column xsi:type="varchar" name="system_name" nullable="false" length="255" comment="System Name"/>
<column xsi:type="varchar" name="name" nullable="false" length="255" comment="Company Name"/>
<column xsi:type="varchar" name="continent" nullable="false" length="32" comment="Continent Code"/>
<column xsi:type="varchar" name="country_code" nullable="false" length="2" comment="Country Code"/>
<column xsi:type="varchar" name="country" nullable="false" length="128" comment="Country Name"/>
<column xsi:type="varchar" name="website" nullable="false" length="1024" default="" comment="Website"/>
<column xsi:type="text" name="address" nullable="false" comment="Address"/>
<column xsi:type="varchar" name="logo" nullable="false" length="255" default="" comment="Logo Path"/>
<column xsi:type="varchar" name="note" nullable="false" length="255" default="" comment="Public Note"/>
<column xsi:type="decimal" name="map_x" nullable="true" scale="3" precision="6" comment="Map X Percent"/>
<column xsi:type="decimal" name="map_y" nullable="true" scale="3" precision="6" comment="Map Y Percent"/>
<column xsi:type="smallint" name="sort_order" unsigned="true" nullable="false" default="0" comment="Sort Order"/>
<column xsi:type="smallint" name="is_active" unsigned="true" nullable="false" default="1" comment="Is Active"/>
<column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/>
<column xsi:type="timestamp" name="updated_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP" comment="Updated At"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="entity_id"/>
</constraint>
<index referenceId="ESUN_AGENT_CONTINENT" indexType="btree">
<column name="continent"/>
</index>
<index referenceId="ESUN_AGENT_COUNTRY_CODE" indexType="btree">
<column name="country_code"/>
</index>
<index referenceId="ESUN_AGENT_IS_ACTIVE_SORT_ORDER" indexType="btree">
<column name="is_active"/>
<column name="sort_order"/>
</index>
</table>
<table name="esun_agent_application" resource="default" engine="innodb" comment="eSUN Agent Applications">
<column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
<column xsi:type="varchar" name="company_name" nullable="false" length="255" comment="Company Name"/>
<column xsi:type="varchar" name="contact_person" nullable="false" length="255" comment="Contact Person"/>
<column xsi:type="varchar" name="country" nullable="false" length="255" comment="Country"/>
<column xsi:type="varchar" name="email" nullable="false" length="255" comment="Email"/>
<column xsi:type="text" name="message" nullable="false" comment="Other Message"/>
<column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="entity_id"/>
</constraint>
<index referenceId="ESUN_AGENT_APPLICATION_EMAIL" indexType="btree">
<column name="email"/>
</index>
<index referenceId="ESUN_AGENT_APPLICATION_CREATED_AT" indexType="btree">
<column name="created_at"/>
</index>
</table>
</schema>
@@ -0,0 +1,48 @@
{
"esun_agent": {
"column": {
"entity_id": true,
"system_name": true,
"name": true,
"continent": true,
"country_code": true,
"country": true,
"website": true,
"address": true,
"logo": true,
"note": true,
"map_x": true,
"map_y": true,
"sort_order": true,
"is_active": true,
"created_at": true,
"updated_at": true
},
"index": {
"ESUN_AGENT_CONTINENT": true,
"ESUN_AGENT_COUNTRY_CODE": true,
"ESUN_AGENT_IS_ACTIVE_SORT_ORDER": true
},
"constraint": {
"PRIMARY": true
}
},
"esun_agent_application": {
"column": {
"entity_id": true,
"company_name": true,
"contact_person": true,
"country": true,
"email": true,
"message": true,
"created_at": true
},
"index": {
"ESUN_AGENT_APPLICATION_EMAIL": true,
"ESUN_AGENT_APPLICATION_CREATED_AT": true
},
"constraint": {
"PRIMARY": true
}
}
}
+57
View File
@@ -0,0 +1,57 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<virtualType name="EsunAgentGridCollection"
type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">esun_agent</argument>
<argument name="resourceModel" xsi:type="string">Esun\Agent\Model\ResourceModel\Agent</argument>
</arguments>
</virtualType>
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="esun_agent_listing_data_source" xsi:type="string">EsunAgentGridCollection</item>
<item name="esun_agent_application_listing_data_source" xsi:type="string">EsunAgentApplicationGridCollection</item>
</argument>
</arguments>
</type>
<virtualType name="EsunAgentApplicationGridCollection"
type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">esun_agent_application</argument>
<argument name="resourceModel" xsi:type="string">Esun\Agent\Model\ResourceModel\Application</argument>
</arguments>
</virtualType>
<virtualType name="EsunAgentImageUploader" type="Magento\Catalog\Model\ImageUploader">
<arguments>
<argument name="baseTmpPath" xsi:type="string">agent/tmp/logo</argument>
<argument name="basePath" xsi:type="string">agent/logo</argument>
<argument name="allowedExtensions" xsi:type="array">
<item name="jpg" xsi:type="string">jpg</item>
<item name="jpeg" xsi:type="string">jpeg</item>
<item name="png" xsi:type="string">png</item>
<item name="gif" xsi:type="string">gif</item>
<item name="webp" xsi:type="string">webp</item>
</argument>
<argument name="allowedMimeTypes" xsi:type="array">
<item name="jpg" xsi:type="string">image/jpeg</item>
<item name="png" xsi:type="string">image/png</item>
<item name="gif" xsi:type="string">image/gif</item>
<item name="webp" xsi:type="string">image/webp</item>
</argument>
</arguments>
</virtualType>
<type name="Esun\Agent\Controller\Adminhtml\Agent\Upload">
<arguments>
<argument name="imageUploader" xsi:type="object">EsunAgentImageUploader</argument>
</arguments>
</type>
<type name="Esun\Agent\Controller\Adminhtml\Agent\Save">
<arguments>
<argument name="imageUploader" xsi:type="object">EsunAgentImageUploader</argument>
</arguments>
</type>
</config>
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework/App/etc/routes.xsd">
<router id="standard">
<route id="agent" frontName="agents">
<module name="Esun_Agent"/>
</route>
</router>
</config>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Esun_Agent">
<sequence>
<module name="Magento_Catalog"/>
<module name="Magento_Directory"/>
<module name="Magento_Theme"/>
<module name="Magento_Ui"/>
<module name="Esun_ImageManager"/>
</sequence>
</module>
</config>
+10
View File
@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
use Magento\Framework\Component\ComponentRegistrar;
ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'Esun_Agent',
__DIR__
);
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework/View/Layout/etc/page_configuration.xsd">
<update handle="styles"/>
<body>
<referenceContainer name="content">
<uiComponent name="esun_agent_form"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<uiComponent name="esun_agent_listing"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework/View/Layout/etc/page_configuration.xsd">
<update handle="esun_agent_agent_edit"/>
</page>
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<uiComponent name="esun_agent_application_listing"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,64 @@
<?xml version="1.0"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">esun_agent_application_listing.esun_agent_application_listing_data_source</item>
</item>
</argument>
<settings>
<spinner>esun_agent_application_columns</spinner>
<deps>
<dep>esun_agent_application_listing.esun_agent_application_listing_data_source</dep>
</deps>
</settings>
<dataSource name="esun_agent_application_listing_data_source" component="Magento_Ui/js/grid/provider">
<settings>
<storageConfig><param name="indexField" xsi:type="string">entity_id</param></storageConfig>
<updateUrl path="mui/index/render"/>
</settings>
<aclResource>Esun_Agent::applications</aclResource>
<dataProvider class="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider"
name="esun_agent_application_listing_data_source">
<settings>
<requestFieldName>id</requestFieldName>
<primaryFieldName>entity_id</primaryFieldName>
</settings>
</dataProvider>
</dataSource>
<listingToolbar name="listing_top">
<settings><sticky>true</sticky></settings>
<bookmark name="bookmarks"/>
<columnsControls name="columns_controls"/>
<filters name="listing_filters"/>
<massaction name="listing_massaction">
<action name="delete">
<settings>
<confirm>
<message translate="true">Are you sure you want to delete the selected applications?</message>
<title translate="true">Delete applications</title>
</confirm>
<url path="esun_agent/application/massDelete"/>
<type>delete</type>
<label translate="true">Delete</label>
</settings>
</action>
</massaction>
<paging name="listing_paging"/>
</listingToolbar>
<columns name="esun_agent_application_columns">
<selectionsColumn name="ids"><settings><indexField>entity_id</indexField></settings></selectionsColumn>
<column name="entity_id"><settings><filter>textRange</filter><label translate="true">ID</label><sorting>desc</sorting></settings></column>
<column name="company_name"><settings><filter>text</filter><label translate="true">Company Name</label></settings></column>
<column name="contact_person"><settings><filter>text</filter><label translate="true">Contact Person</label></settings></column>
<column name="country"><settings><filter>text</filter><label translate="true">Country</label></settings></column>
<column name="email"><settings><filter>text</filter><label translate="true">Email</label></settings></column>
<column name="message"><settings><filter>text</filter><label translate="true">Other Message</label></settings></column>
<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date">
<settings><filter>dateRange</filter><dataType>date</dataType><label translate="true">Submitted At</label></settings>
</column>
<actionsColumn name="actions" class="Esun\Agent\Ui\Component\Listing\Column\ApplicationActions">
<settings><indexField>entity_id</indexField><resizeEnabled>false</resizeEnabled><resizeDefaultWidth>90</resizeDefaultWidth></settings>
</actionsColumn>
</columns>
</listing>
@@ -0,0 +1,154 @@
<?xml version="1.0"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">esun_agent_form.esun_agent_form_data_source</item>
</item>
<item name="label" xsi:type="string" translate="true">Agent Information</item>
<item name="template" xsi:type="string">templates/form/collapsible</item>
</argument>
<settings>
<buttons>
<button name="back" class="Esun\Agent\Block\Adminhtml\Agent\Edit\BackButton"/>
<button name="delete" class="Esun\Agent\Block\Adminhtml\Agent\Edit\DeleteButton"/>
<button name="save_and_continue" class="Esun\Agent\Block\Adminhtml\Agent\Edit\SaveAndContinueButton"/>
<button name="save" class="Esun\Agent\Block\Adminhtml\Agent\Edit\SaveButton"/>
</buttons>
<namespace>esun_agent_form</namespace>
<dataScope>data</dataScope>
<deps>
<dep>esun_agent_form.esun_agent_form_data_source</dep>
</deps>
</settings>
<dataSource name="esun_agent_form_data_source">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
</item>
</argument>
<settings>
<submitUrl path="*/*/save"/>
</settings>
<dataProvider class="Esun\Agent\Model\Agent\DataProvider" name="esun_agent_form_data_source">
<settings>
<requestFieldName>entity_id</requestFieldName>
<primaryFieldName>entity_id</primaryFieldName>
</settings>
</dataProvider>
</dataSource>
<fieldset name="agent" sortOrder="10">
<settings>
<label translate="true">Agent Information</label>
<collapsible>false</collapsible>
</settings>
<field name="entity_id" formElement="hidden">
<settings><dataType>number</dataType></settings>
</field>
<field name="is_active" formElement="select" sortOrder="10">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Magento\Config\Model\Config\Source\Yesno</item>
<item name="config" xsi:type="array"><item name="default" xsi:type="number">1</item></item>
</argument>
<settings>
<dataType>number</dataType>
<label translate="true">Active</label>
<dataScope>is_active</dataScope>
</settings>
</field>
<field name="name" formElement="input" sortOrder="20">
<settings>
<dataType>text</dataType>
<label translate="true">Company Name</label>
<dataScope>name</dataScope>
<validation><rule name="required-entry" xsi:type="boolean">true</rule></validation>
</settings>
</field>
<field name="system_name" formElement="input" sortOrder="30">
<settings>
<dataType>text</dataType>
<label translate="true">System Name</label>
<dataScope>system_name</dataScope>
<validation><rule name="required-entry" xsi:type="boolean">true</rule></validation>
</settings>
</field>
<field name="continent" formElement="select" sortOrder="40">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Esun\Agent\Model\Source\Continent</item>
</argument>
<settings>
<dataType>text</dataType>
<label translate="true">Continent</label>
<dataScope>continent</dataScope>
<validation><rule name="required-entry" xsi:type="boolean">true</rule></validation>
</settings>
</field>
<field name="country_code" formElement="select" sortOrder="50">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Esun\Agent\Model\Source\MapCountry</item>
</argument>
<settings>
<dataType>text</dataType>
<label translate="true">Country</label>
<dataScope>country_code</dataScope>
<validation><rule name="required-entry" xsi:type="boolean">true</rule></validation>
</settings>
</field>
<field name="website" formElement="input" sortOrder="60">
<settings>
<dataType>text</dataType>
<label translate="true">Website</label>
<dataScope>website</dataScope>
<validation><rule name="validate-url" xsi:type="boolean">true</rule></validation>
</settings>
</field>
<field name="address" formElement="textarea" sortOrder="70">
<settings>
<dataType>text</dataType>
<label translate="true">Address</label>
<dataScope>address</dataScope>
</settings>
</field>
<field name="logo" formElement="fileUploader" sortOrder="80">
<settings>
<label translate="true">Logo</label>
<componentType>fileUploader</componentType>
<dataScope>logo</dataScope>
<elementTmpl>ui/form/element/uploader/uploader</elementTmpl>
</settings>
<formElements>
<fileUploader>
<settings>
<allowedExtensions>jpg jpeg png gif webp</allowedExtensions>
<maxFileSize>4194304</maxFileSize>
<notice translate="true">Allowed: JPG, PNG, GIF or WebP. Maximum size: 4 MB.</notice>
<uploaderConfig>
<param name="url" xsi:type="url" path="esun_agent/agent/upload"/>
</uploaderConfig>
</settings>
</fileUploader>
</formElements>
</field>
<field name="note" formElement="input" sortOrder="90">
<settings>
<dataType>text</dataType>
<label translate="true">Public Note</label>
<dataScope>note</dataScope>
</settings>
</field>
<field name="sort_order" formElement="input" sortOrder="100">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array"><item name="default" xsi:type="number">0</item></item>
</argument>
<settings>
<dataType>number</dataType>
<label translate="true">Sort Order</label>
<dataScope>sort_order</dataScope>
<validation><rule name="validate-number" xsi:type="boolean">true</rule></validation>
</settings>
</field>
</fieldset>
</form>
@@ -0,0 +1,134 @@
<?xml version="1.0"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">esun_agent_listing.esun_agent_listing_data_source</item>
</item>
</argument>
<settings>
<spinner>esun_agent_columns</spinner>
<deps>
<dep>esun_agent_listing.esun_agent_listing_data_source</dep>
</deps>
<buttons>
<button name="add">
<url path="*/*/new"/>
<class>primary</class>
<label translate="true">Add New Agent</label>
</button>
</buttons>
</settings>
<dataSource name="esun_agent_listing_data_source" component="Magento_Ui/js/grid/provider">
<settings>
<storageConfig>
<param name="indexField" xsi:type="string">entity_id</param>
</storageConfig>
<updateUrl path="mui/index/render"/>
</settings>
<aclResource>Esun_Agent::agents</aclResource>
<dataProvider class="Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider"
name="esun_agent_listing_data_source">
<settings>
<requestFieldName>id</requestFieldName>
<primaryFieldName>entity_id</primaryFieldName>
</settings>
</dataProvider>
</dataSource>
<listingToolbar name="listing_top">
<settings>
<sticky>true</sticky>
</settings>
<bookmark name="bookmarks"/>
<columnsControls name="columns_controls"/>
<filters name="listing_filters"/>
<massaction name="listing_massaction">
<action name="delete">
<settings>
<confirm>
<message translate="true">Are you sure you want to delete the selected agents?</message>
<title translate="true">Delete agents</title>
</confirm>
<url path="esun_agent/agent/massDelete"/>
<type>delete</type>
<label translate="true">Delete</label>
</settings>
</action>
</massaction>
<paging name="listing_paging"/>
</listingToolbar>
<columns name="esun_agent_columns">
<selectionsColumn name="ids">
<settings>
<indexField>entity_id</indexField>
</settings>
</selectionsColumn>
<column name="entity_id">
<settings>
<filter>textRange</filter>
<label translate="true">ID</label>
<sorting>asc</sorting>
</settings>
</column>
<column name="name">
<settings>
<filter>text</filter>
<label translate="true">Company Name</label>
</settings>
</column>
<column name="system_name">
<settings>
<filter>text</filter>
<label translate="true">System Name</label>
</settings>
</column>
<column name="continent" component="Magento_Ui/js/grid/columns/select">
<settings>
<options class="Esun\Agent\Model\Source\Continent"/>
<filter>select</filter>
<dataType>select</dataType>
<label translate="true">Continent</label>
</settings>
</column>
<column name="country">
<settings>
<filter>text</filter>
<label translate="true">Country</label>
</settings>
</column>
<column name="sort_order">
<settings>
<filter>textRange</filter>
<dataType>number</dataType>
<label translate="true">Sort Order</label>
</settings>
</column>
<column name="is_active">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Magento\Config\Model\Config\Source\Yesno</item>
</argument>
<settings>
<filter>select</filter>
<dataType>select</dataType>
<label translate="true">Active</label>
</settings>
</column>
<column name="updated_at" class="Magento\Ui\Component\Listing\Columns\Date">
<settings>
<filter>dateRange</filter>
<dataType>date</dataType>
<label translate="true">Updated At</label>
</settings>
</column>
<actionsColumn name="actions" class="Esun\Agent\Ui\Component\Listing\Column\AgentActions">
<settings>
<indexField>entity_id</indexField>
<resizeEnabled>false</resizeEnabled>
<resizeDefaultWidth>107</resizeDefaultWidth>
</settings>
</actionsColumn>
</columns>
</listing>
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework/View/Layout/etc/page_configuration.xsd"
layout="cms-custom-full-width">
<head>
<title>Global Agents</title>
<css src="Esun_Agent::css/agent-locator.css"/>
</head>
<body>
<referenceBlock name="page.main.title" remove="true"/>
<referenceContainer name="content">
<block class="Esun\Agent\Block\AgentLocator"
name="esun.agent.locator"
template="Esun_Agent::agent-locator.phtml"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,180 @@
<?php
/** @var \Esun\Agent\Block\AgentLocator $block */
/** @var \Magento\Framework\Escaper $escaper */
?>
<div class="agent-locator" id="agent-locator">
<section class="agent-hero" aria-labelledby="agent-hero-title">
<div class="agent-hero__inner">
<div class="agent-hero__copy">
<p class="agent-hero__eyebrow"><?= $escaper->escapeHtml(__('Global Channel Network:')) ?></p>
<h1 class="agent-hero__title" id="agent-hero-title">
<?= $escaper->escapeHtml(__('Partnering For A Shared Future')) ?>
</h1>
<p class="agent-hero__description">
<?= $escaper->escapeHtml(
__('ESUN Cordially Invites Global Partners To Join Us In Tapping Into The Trillion-Dollar Market For 3D Printing And Biomaterials')
) ?>
</p>
</div>
<a class="agent-hero__apply" href="#agent-application"
aria-label="<?= $escaper->escapeHtmlAttr(__('Apply')) ?>">
<span><?= $escaper->escapeHtml(__('Apply')) ?></span>
<span class="agent-hero__apply-arrow" aria-hidden="true">→</span>
</a>
</div>
</section>
<section class="agent-map" aria-labelledby="agent-map-title">
<h2 class="agent-map__title" id="agent-map-title"><?= $escaper->escapeHtml(__('Global Agents')) ?></h2>
<p class="agent-map__intro"><?= $escaper->escapeHtml(__('Select a continent to discover our trusted global partners.')) ?></p>
<div class="agent-map__canvas" data-role="map-canvas">
<img class="agent-map__image" data-role="map-image" alt="" aria-hidden="true"/>
<div class="agent-map__markers" data-role="map-markers"></div>
<aside class="agent-map__popup" data-role="map-popup" aria-live="polite" hidden>
<button class="agent-map__popup-close" data-role="popup-close" type="button"
aria-label="<?= $escaper->escapeHtmlAttr(__('Close')) ?>">&times;</button>
<div class="agent-map__popup-heading">
<h2 data-role="popup-title"></h2>
<span class="agent-map__count" data-role="popup-count"></span>
</div>
<div class="agent-map__featured" data-role="popup-agents"></div>
<button class="agent-map__explore" data-role="explore-all" type="button">
<span><?= $escaper->escapeHtml(__('Explore All')) ?></span>
<span aria-hidden="true">›</span>
</button>
</aside>
</div>
</section>
<section class="agent-directory" id="global-agents" aria-labelledby="agent-directory-title">
<h2 class="agent-directory__title" id="agent-directory-title"><?= $escaper->escapeHtml(__('Global Suppliers')) ?></h2>
<div class="agent-filters">
<label class="agent-filters__field">
<span class="agent-sr-only"><?= $escaper->escapeHtml(__('Continent')) ?></span>
<select data-role="continent-filter" aria-label="<?= $escaper->escapeHtmlAttr(__('Continent')) ?>">
<option value=""><?= $escaper->escapeHtml(__('Continent')) ?></option>
</select>
</label>
<label class="agent-filters__field">
<span class="agent-sr-only"><?= $escaper->escapeHtml(__('Country')) ?></span>
<select data-role="country-filter" aria-label="<?= $escaper->escapeHtmlAttr(__('Country')) ?>">
<option value=""><?= $escaper->escapeHtml(__('Country')) ?></option>
</select>
</label>
<label class="agent-filters__field agent-filters__search">
<span class="agent-sr-only"><?= $escaper->escapeHtml(__('Search agents')) ?></span>
<span class="agent-filters__search-icon" aria-hidden="true"></span>
<input data-role="keyword-filter" type="search"
placeholder="<?= $escaper->escapeHtmlAttr(__('Name, location or keyword...')) ?>"/>
</label>
<p class="agent-filters__result" data-role="result-count" aria-live="polite"></p>
<button class="agent-filters__reset" data-role="reset-filters" type="button">
<span aria-hidden="true">↻</span>
<?= $escaper->escapeHtml(__('Reset')) ?>
</button>
</div>
<div class="agent-directory__grid" data-role="agent-list"></div>
<p class="agent-directory__empty" data-role="empty-state" hidden></p>
<nav class="agent-pagination" data-role="pagination"
aria-label="<?= $escaper->escapeHtmlAttr(__('Agent list pagination')) ?>" hidden></nav>
</section>
<section class="agent-application" id="agent-application"
style="background-image:url('<?= $escaper->escapeUrl($block->getContactBackgroundUrl()) ?>')"
aria-labelledby="agent-application-title">
<div class="agent-application__inner">
<div class="agent-application__contact">
<div class="agent-application__contact-item">
<span class="agent-application__icon agent-application__icon--mail" aria-hidden="true"></span>
<span class="agent-application__contact-label">
<?= $escaper->escapeHtml(__('To become our distributor:')) ?>
</span>
<a href="mailto:partner@esun3d.com">partner@esun3d.com</a>
</div>
<div class="agent-application__contact-item">
<span class="agent-application__icon agent-application__icon--phone" aria-hidden="true"></span>
<span class="agent-application__contact-label"><?= $escaper->escapeHtml(__('Tel:')) ?></span>
<a href="tel:+8675523768972">+86 0755-23768972</a>
</div>
</div>
<form class="agent-application__form" data-role="agent-application-form"
action="<?= $escaper->escapeUrl($block->getUrl('agent/index/apply')) ?>"
method="post" novalidate>
<?= /* @noEscape */ $block->getBlockHtml('formkey') ?>
<h2 class="agent-sr-only" id="agent-application-title">
<?= $escaper->escapeHtml(__('Become Our Distributor')) ?>
</h2>
<div class="agent-application__status" data-role="application-status"
role="status" aria-live="polite"></div>
<div class="agent-application__grid">
<label class="agent-application__field required">
<span><?= $escaper->escapeHtml(__('Company Name')) ?></span>
<input type="text" name="company_name" maxlength="255" required
autocomplete="organization"
placeholder="<?= $escaper->escapeHtmlAttr(__('Company Name')) ?>"
data-validate="{required:true}"/>
</label>
<label class="agent-application__field required">
<span><?= $escaper->escapeHtml(__('Contact Person')) ?></span>
<input type="text" name="contact_person" maxlength="255" required
autocomplete="name"
placeholder="<?= $escaper->escapeHtmlAttr(__('Contact Person')) ?>"
data-validate="{required:true}"/>
</label>
<label class="agent-application__field required">
<span><?= $escaper->escapeHtml(__('Country')) ?></span>
<select name="country" required data-validate="{required:true}">
<option value=""><?= $escaper->escapeHtml(__('Country')) ?></option>
<?php foreach ($block->getCountryOptions() as $country): ?>
<option value="<?= $escaper->escapeHtmlAttr((string)$country['label']) ?>">
<?= $escaper->escapeHtml((string)$country['label']) ?>
</option>
<?php endforeach; ?>
</select>
</label>
<label class="agent-application__field required">
<span><?= $escaper->escapeHtml(__('Email')) ?></span>
<input type="email" name="email" maxlength="255" required
autocomplete="email"
placeholder="<?= $escaper->escapeHtmlAttr(__('Email')) ?>"
data-validate="{required:true, 'validate-email':true}"/>
</label>
</div>
<label class="agent-application__field agent-application__message">
<span><?= $escaper->escapeHtml(__('Other Message')) ?></span>
<textarea name="message" maxlength="5000" rows="3"
placeholder="<?= $escaper->escapeHtmlAttr(__('Other Message')) ?>"></textarea>
</label>
<input class="agent-application__trap" type="text" name="hideit"
tabindex="-1" autocomplete="off"/>
<div class="agent-application__actions">
<button class="agent-application__submit" type="submit">
<span><?= $escaper->escapeHtml(__('Send')) ?></span>
</button>
</div>
</form>
</div>
<p class="agent-application__tagline">
<?= $escaper->escapeHtml(__('Work Together for Mutual Success')) ?>
</p>
</section>
</div>
<script type="text/x-magento-init">
{
"#agent-locator": {
"Esun_Agent/js/agent-locator": <?= /* @noEscape */ $block->getConfigJson() ?>
},
"[data-role=agent-application-form]": {
"Esun_Agent/js/agent-application": {}
}
}
</script>
@@ -0,0 +1,836 @@
.agent-locator {
--agent-green: #16ad5b;
--agent-text: #202421;
--agent-muted: #707774;
--agent-border: #dfe4e1;
color: var(--agent-text);
font-family: Arial, Helvetica, sans-serif;
}
.agent-hero {
background:
radial-gradient(ellipse at 57% -25%, rgba(5, 112, 69, .72) 0, rgba(31, 143, 91, .42) 30%, transparent 58%),
radial-gradient(ellipse at 38% 108%, rgba(24, 135, 80, .34) 0, transparent 54%),
linear-gradient(101deg, #9bdab7 0%, #87d1aa 31%, #72c298 53%, rgba(218, 238, 226, .74) 72%, #fff 90%);
min-height: clamp(310px, 19vw, 390px);
overflow: hidden;
position: relative;
}
.agent-hero::before,
.agent-hero::after {
content: '';
pointer-events: none;
position: absolute;
}
.agent-hero::before {
background: linear-gradient(145deg, rgba(14, 119, 72, .2), rgba(255, 255, 255, .06));
height: 145%;
left: 43%;
top: -88%;
transform: rotate(-8deg);
width: 30%;
}
.agent-hero::after {
background: radial-gradient(ellipse, rgba(255, 255, 255, .25), transparent 68%);
height: 150%;
left: 58%;
top: 1%;
transform: rotate(15deg);
width: 24%;
}
.agent-hero__inner {
align-items: end;
box-sizing: border-box;
display: grid;
gap: clamp(40px, 8vw, 150px);
grid-template-columns: minmax(0, 2.7fr) minmax(210px, .75fr);
margin: 0 auto;
max-width: 1680px;
min-height: inherit;
padding: clamp(42px, 4vw, 68px) clamp(24px, 7vw, 120px);
position: relative;
z-index: 1;
}
.agent-hero__copy {
color: #fff;
max-width: 1080px;
}
.agent-hero__eyebrow {
font-size: clamp(28px, 2.45vw, 47px);
font-weight: 400;
line-height: 1.15;
margin: 0 0 8px;
}
.agent-hero__title {
color: #fff;
font-size: clamp(38px, 3.35vw, 66px);
font-weight: 400;
letter-spacing: .055em;
line-height: 1.13;
margin: 0;
text-transform: none;
}
.agent-hero__description {
font-size: clamp(17px, 1.28vw, 25px);
line-height: 1.22;
margin: clamp(32px, 3vw, 54px) 0 0;
max-width: 1010px;
}
.agent-hero__apply {
align-items: center;
align-self: end;
background: var(--agent-green);
border-radius: 999px;
box-sizing: border-box;
color: #fff;
display: inline-flex;
font-size: clamp(18px, 1.25vw, 25px);
font-weight: 700;
gap: 22px;
justify-content: center;
justify-self: end;
min-height: 78px;
min-width: clamp(220px, 14vw, 270px);
padding: 18px 34px;
user-select: none;
}
.agent-hero__apply-arrow {
font-size: 36px;
font-weight: 300;
line-height: .8;
}
.agent-map,
.agent-directory {
box-sizing: border-box;
margin: 0 auto;
max-width: 1680px;
padding-left: clamp(24px, 7vw, 120px);
padding-right: clamp(24px, 7vw, 120px);
}
.agent-map {
padding-top: clamp(44px, 6vw, 88px);
}
.agent-map__title,
.agent-directory__title {
color: #252927;
font-size: clamp(30px, 3vw, 48px);
font-weight: 700;
letter-spacing: .12em;
margin: 0;
text-transform: uppercase;
}
.agent-map__intro {
color: var(--agent-muted);
font-size: 17px;
margin: 14px 0 24px;
}
.agent-map__canvas {
min-height: 420px;
position: relative;
}
.agent-map__image {
display: block;
height: auto;
pointer-events: none;
width: 100%;
}
.agent-map__markers {
inset: 0;
position: absolute;
}
.agent-map__marker {
appearance: none;
background: rgba(22, 173, 91, .22);
border: 0;
border-radius: 50%;
box-shadow: 0 0 0 1px rgba(22, 173, 91, .12);
cursor: pointer;
height: 22px;
left: var(--marker-x);
padding: 0;
position: absolute;
top: var(--marker-y);
transform: translate(-50%, -50%);
transition: transform .18s ease, background-color .18s ease;
width: 22px;
z-index: 2;
}
.agent-map__marker::before {
animation: agent-marker-pulse 2.2s infinite;
border: 2px solid rgba(22, 173, 91, .46);
border-radius: inherit;
content: '';
inset: -7px;
position: absolute;
}
.agent-map__marker:hover,
.agent-map__marker:focus-visible,
.agent-map__marker[aria-pressed="true"] {
background: rgba(22, 173, 91, .38);
outline: 3px solid rgba(22, 173, 91, .2);
transform: translate(-50%, -50%) scale(1.12);
}
.agent-map__marker-core {
background: var(--agent-green);
border: 3px solid #fff;
border-radius: 50%;
box-shadow: 0 3px 10px rgba(0, 0, 0, .18);
inset: 4px;
position: absolute;
}
@keyframes agent-marker-pulse {
0%, 100% { opacity: .7; transform: scale(.8); }
50% { opacity: 0; transform: scale(1.28); }
}
.agent-map__popup {
background: rgba(255, 255, 255, .98);
border: 1px solid #edf0ee;
border-radius: 26px;
box-shadow: 0 16px 48px rgba(22, 53, 37, .13);
box-sizing: border-box;
max-width: 680px;
padding: clamp(24px, 3vw, 46px);
position: absolute;
right: 2.5%;
top: 13%;
width: 48%;
z-index: 5;
}
.agent-map__popup[hidden] {
display: none;
}
.agent-map__popup-close {
appearance: none;
background: transparent;
border: 0;
color: #6d746f;
cursor: pointer;
font-size: 28px;
line-height: 1;
padding: 8px;
position: absolute;
right: 16px;
top: 12px;
}
.agent-map__popup-heading {
align-items: center;
display: flex;
gap: 12px;
margin: 0 34px 26px 0;
}
.agent-map__popup-heading h2 {
font-size: clamp(22px, 2vw, 30px);
letter-spacing: .06em;
margin: 0;
}
.agent-map__count {
align-items: center;
background: var(--agent-green);
border-radius: 999px;
box-sizing: border-box;
color: #fff;
display: inline-flex;
font-size: 16px;
font-weight: 700;
justify-content: center;
line-height: 1;
min-height: 32px;
min-width: 52px;
padding: 7px 15px;
white-space: nowrap;
}
.agent-map__featured {
display: grid;
gap: 20px 26px;
grid-template-columns: repeat(3, minmax(0, 1fr));
}
.agent-map__featured-item {
align-items: center;
display: grid;
gap: 10px;
grid-template-columns: minmax(66px, 1fr) minmax(70px, 1fr);
min-width: 0;
}
.agent-map__featured-item img {
background: #fff;
border-radius: 7px;
height: 48px;
object-fit: contain;
width: 100%;
}
.agent-map__featured-item span {
font-size: 14px;
line-height: 1.25;
overflow-wrap: anywhere;
white-space: normal;
}
.agent-map__explore {
align-items: center;
appearance: none;
background: transparent;
border: 0;
color: var(--agent-green);
cursor: pointer;
display: flex;
font-size: 17px;
font-weight: 700;
gap: 14px;
margin: 28px 0 0 auto;
padding: 8px 0;
}
.agent-map__explore span:last-child {
font-size: 26px;
font-weight: 400;
}
.agent-directory {
padding-bottom: 90px;
padding-top: clamp(52px, 7vw, 100px);
scroll-margin-top: 90px;
}
.agent-directory__title::after {
background: var(--agent-green);
content: '';
display: block;
height: 3px;
margin-top: 16px;
width: 82px;
}
.agent-filters {
align-items: center;
border-bottom: 1px solid var(--agent-border);
display: grid;
gap: 18px;
grid-template-columns: minmax(180px, .8fr) minmax(180px, .8fr) minmax(280px, 1.7fr) auto auto;
margin-top: 42px;
padding-bottom: 18px;
}
.agent-filters__field select,
.agent-filters__field input {
background: #fff;
border: 1px solid #cdd3d0;
border-radius: 8px;
box-sizing: border-box;
color: #343936;
font-size: 15px;
height: 48px;
padding: 0 16px;
width: 100%;
}
.agent-filters__search {
position: relative;
}
.agent-filters__search input {
padding-left: 45px;
}
.agent-filters__search-icon {
border: 2px solid #70869d;
border-radius: 50%;
height: 11px;
left: 17px;
position: absolute;
top: 16px;
width: 11px;
}
.agent-filters__search-icon::after {
background: #70869d;
content: '';
height: 2px;
position: absolute;
right: -6px;
top: 10px;
transform: rotate(45deg);
width: 7px;
}
.agent-filters__result {
color: var(--agent-green);
font-size: 15px;
margin: 0;
white-space: nowrap;
}
.agent-filters__reset {
align-items: center;
appearance: none;
background: var(--agent-green);
border: 0;
border-radius: 10px;
color: #fff;
cursor: pointer;
display: flex;
font-size: 16px;
gap: 8px;
height: 48px;
justify-content: center;
min-width: 142px;
padding: 0 22px;
}
.agent-filters__reset span {
font-size: 24px;
}
.agent-directory__grid {
display: grid;
gap: 26px;
grid-template-columns: repeat(3, minmax(0, 1fr));
margin-top: 28px;
}
.agent-card {
background: #fff;
border: 1px solid #e7ebe9;
border-radius: 14px;
box-shadow: 0 8px 24px rgba(25, 55, 40, .04);
box-sizing: border-box;
min-width: 0;
padding: 28px 34px;
}
.agent-card__header {
align-items: center;
display: grid;
gap: 24px;
grid-template-columns: minmax(120px, 42%) minmax(0, 1fr);
margin-bottom: 20px;
}
.agent-card__logo {
height: 74px;
object-fit: contain;
width: 100%;
}
.agent-card__name {
font-size: 17px;
line-height: 1.3;
margin: 0;
overflow-wrap: anywhere;
}
.agent-card__body p {
align-items: flex-start;
display: flex;
font-size: 14px;
gap: 10px;
line-height: 1.45;
margin: 12px 0 0;
overflow-wrap: anywhere;
}
.agent-card__flag {
font-size: 19px;
line-height: 1;
}
.agent-card__pin {
border: 2px solid #35bf75;
border-radius: 50% 50% 50% 0;
flex: 0 0 12px;
height: 12px;
margin: 2px 2px 0 1px;
transform: rotate(-45deg);
width: 12px;
}
.agent-card__pin::after {
background: #35bf75;
border-radius: 50%;
content: '';
height: 4px;
left: 4px;
position: absolute;
top: 4px;
width: 4px;
}
.agent-card__website span {
flex: 0 0 auto;
}
.agent-card__website a {
color: #3d4943;
text-decoration: underline;
}
.agent-directory__empty {
color: var(--agent-muted);
font-size: 18px;
margin: 54px 0;
text-align: center;
}
.agent-pagination {
align-items: center;
display: flex;
gap: 18px;
justify-content: center;
margin-top: 34px;
}
.agent-pagination[hidden] {
display: none;
}
.agent-pagination__button {
appearance: none;
background: #cfe9dc;
border: 0;
border-radius: 999px;
cursor: pointer;
height: 10px;
min-width: 10px;
padding: 0;
transition: background-color .18s ease, transform .18s ease, width .18s ease;
width: 10px;
}
.agent-pagination__button--page:hover,
.agent-pagination__button--page:focus-visible {
background: #76cea2;
outline: 3px solid rgba(22, 173, 91, .16);
}
.agent-pagination__button--page[aria-current="page"] {
background: var(--agent-green);
width: 34px;
}
.agent-pagination__button--previous,
.agent-pagination__button--next {
align-items: center;
border: 1px solid var(--agent-green);
display: flex;
font-size: 34px;
height: 54px;
justify-content: center;
line-height: 1;
width: 54px;
}
.agent-pagination__button--previous {
background: #fff;
color: var(--agent-green);
margin-right: 28px;
}
.agent-pagination__button--next {
background: var(--agent-green);
color: #fff;
margin-left: 28px;
}
.agent-pagination__button--previous:disabled,
.agent-pagination__button--next:disabled {
cursor: default;
opacity: .35;
}
.agent-sr-only {
clip: rect(0, 0, 0, 0);
clip-path: inset(50%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
.agent-application {
background-color: #f4f5f1;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
box-sizing: border-box;
min-height: 560px;
padding: 76px clamp(24px, 7vw, 120px) 56px;
scroll-margin-top: 110px;
}
.agent-application__inner {
display: grid;
gap: clamp(54px, 8vw, 145px);
grid-template-columns: minmax(260px, .7fr) minmax(520px, 1.5fr);
margin: 0 auto;
max-width: 1320px;
}
.agent-application__contact {
align-self: center;
display: grid;
gap: 42px;
}
.agent-application__contact-item {
display: grid;
justify-items: start;
}
.agent-application__contact-item a {
color: #111;
font-size: 19px;
font-weight: 700;
text-decoration: none;
}
.agent-application__contact-label {
color: #666;
font-size: 13px;
margin: 10px 0 3px;
text-transform: uppercase;
}
.agent-application__icon {
background-position: center;
background-repeat: no-repeat;
background-size: contain;
display: block;
height: 40px;
width: 40px;
}
.agent-application__icon--mail {
background-image: url('../images/email.svg');
}
.agent-application__icon--phone {
background-image: url('../images/phone-call.svg');
}
.agent-application__form { min-width: 0; }
.agent-application__grid {
display: grid;
gap: 23px 22px;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.agent-application__field {
display: block;
margin: 0;
}
.agent-application__field > span {
color: #303330;
display: block;
font-size: 15px;
font-weight: 400;
margin: 0 0 7px;
}
.agent-application__field.required > span::after {
color: var(--agent-green);
content: ' *';
}
.agent-application__field input,
.agent-application__field select,
.agent-application__field textarea {
background-color: transparent;
border: 0;
border-bottom: 1.5px solid #3f423f;
border-radius: 0;
box-shadow: none;
box-sizing: border-box;
color: #202421;
font-family: inherit;
font-size: 15px;
height: 37px;
margin: 0;
padding: 4px 0 8px;
width: 100%;
}
.agent-application__field textarea {
height: 88px;
min-height: 88px;
resize: vertical;
}
.agent-application__field input:focus,
.agent-application__field select:focus,
.agent-application__field textarea:focus {
border-color: var(--agent-green);
box-shadow: none;
outline: 0;
}
.agent-application__field input::placeholder,
.agent-application__field textarea::placeholder { color: #9b9e9b; opacity: 1; }
.agent-application__field .mage-error {
color: #e02b27;
font-size: 12px;
margin-top: 5px;
}
.agent-application__message { margin-top: 23px; }
.agent-application__actions {
display: flex;
justify-content: flex-end;
margin-top: 28px;
}
.agent-application__submit,
.agent-application__submit.action.primary {
background: var(--agent-green);
border: 1px solid var(--agent-green);
border-radius: 28px;
box-shadow: none;
color: #fff;
font-size: 15px;
font-weight: 600;
letter-spacing: .16em;
min-width: 112px;
padding: 13px 24px;
}
.agent-application__submit:hover,
.agent-application__submit:focus,
.agent-application__submit.action.primary:hover,
.agent-application__submit.action.primary:focus { background: #0d934b; border-color: #0d934b; color: #fff; }
.agent-application__submit:disabled { cursor: wait; opacity: .65; }
.agent-application__trap { display: none !important; }
.agent-application__status {
border-radius: 4px;
display: none;
margin: 0 0 18px;
padding: 10px 14px;
}
.agent-application__status.success { background: #e8f6ed; color: #08753c; display: block; }
.agent-application__status.error { background: #fdecec; color: #b3261e; display: block; }
.agent-application__tagline {
color: #111;
font-size: clamp(30px, 2.5vw, 46px);
font-weight: 400;
letter-spacing: .055em;
margin: 72px auto 0;
max-width: 1320px;
text-align: center;
}
@media (max-width: 1180px) {
.agent-map__canvas { min-height: 360px; }
.agent-map__popup { width: 56%; }
.agent-map__featured { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.agent-filters { grid-template-columns: 1fr 1fr 2fr; }
.agent-filters__result { grid-column: 1 / 3; }
.agent-filters__reset { justify-self: end; }
.agent-directory__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.agent-application__inner { gap: 50px; grid-template-columns: minmax(220px, .6fr) minmax(0, 1.4fr); }
}
@media (max-width: 767px) {
.agent-hero {
background:
radial-gradient(ellipse at 82% 5%, rgba(5, 112, 69, .42), transparent 48%),
linear-gradient(145deg, #92d4ae 0%, #62bd8d 67%, #dcefe5 100%);
min-height: 0;
}
.agent-hero__inner {
display: grid;
gap: 28px;
grid-template-columns: 1fr;
padding: 40px 18px;
}
.agent-hero__eyebrow { font-size: 25px; }
.agent-hero__title { font-size: 35px; letter-spacing: .025em; }
.agent-hero__description { font-size: 16px; margin-top: 26px; }
.agent-hero__apply {
justify-self: start;
min-height: 58px;
min-width: 180px;
padding: 13px 26px;
}
.agent-map,
.agent-directory { padding-left: 18px; padding-right: 18px; }
.agent-map__title,
.agent-directory__title { letter-spacing: .07em; }
.agent-map__intro { font-size: 15px; }
.agent-map__canvas { min-height: 360px; }
.agent-map__image { margin-top: 30px; }
.agent-map__marker { height: 18px; width: 18px; }
.agent-map__popup {
border-radius: 20px;
bottom: 0;
left: 0;
max-width: none;
padding: 24px 20px;
right: 0;
top: auto;
width: 100%;
}
.agent-map__popup-heading { margin-bottom: 18px; }
.agent-map__featured { gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.agent-map__featured-item { grid-template-columns: 70px minmax(0, 1fr); }
.agent-map__explore { margin-top: 18px; }
.agent-filters { display: grid; grid-template-columns: 1fr; }
.agent-filters__result { grid-column: auto; white-space: normal; }
.agent-filters__reset { justify-self: stretch; }
.agent-directory__grid { grid-template-columns: 1fr; }
.agent-card { padding: 24px; }
.agent-pagination { gap: 13px; }
.agent-pagination__button--previous { margin-right: 8px; }
.agent-pagination__button--next { margin-left: 8px; }
.agent-application { min-height: 0; padding: 52px 18px 42px; }
.agent-application__inner { gap: 46px; grid-template-columns: 1fr; }
.agent-application__contact { gap: 28px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.agent-application__grid { grid-template-columns: 1fr; }
.agent-application__tagline { font-size: 28px; margin-top: 52px; }
}
@media (max-width: 480px) {
.agent-application__contact { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
.agent-map__marker::before { animation: none; }
html:focus-within { scroll-behavior: auto; }
}
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Some files were not shown because too many files have changed in this diff Show More