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,17 @@
<?php
declare(strict_types=1);
namespace Esun\LingxingErp\Model\Source;
use Magento\Framework\Data\OptionSourceInterface;
class Direction implements OptionSourceInterface
{
public function toOptionArray(): array
{
return [
['value' => 'push', 'label' => __('Push to Lingxing')],
['value' => 'pull', 'label' => __('Pull from Lingxing')],
];
}
}
@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace Esun\LingxingErp\Model\Source;
use Esun\LingxingErp\Model\Store\StoreRepository;
use Magento\Framework\Data\OptionSourceInterface;
class LingxingStore implements OptionSourceInterface
{
public function __construct(
private readonly StoreRepository $repository
) {
}
public function toOptionArray(): array
{
$options = [['value' => '', 'label' => __('-- Select a Lingxing store --')]];
$stores = $this->repository->getAll();
if ($stores === []) {
$options[] = [
'value' => '',
'label' => __('No local stores. Use Esun > Lingxing ERP > Stores > Sync Stores.'),
'disabled' => true,
];
return $options;
}
foreach ($stores as $store) {
$platformCode = (int)$store['platform_code'];
$storeId = (string)$store['store_id'];
$active = (int)$store['is_sync'] === 1 && (int)$store['status'] === 1;
$options[] = [
'value' => $platformCode . '|' . $storeId,
'disabled' => !$active,
'label' => sprintf(
'%s[%s / %d] %s (%s)',
$active ? '' : (string)__('Inactive: '),
(string)($store['platform_name'] ?? 'Platform'),
$platformCode,
(string)($store['store_name'] ?? $storeId),
$storeId
),
];
}
return $options;
}
}
@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace Esun\LingxingErp\Model\Source;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Data\OptionSourceInterface;
class LingxingWarehouse implements OptionSourceInterface
{
public function __construct(private readonly ResourceConnection $resource)
{
}
public function toOptionArray(): array
{
$options = [['value' => '', 'label' => __('Not mapped')]];
$connection = $this->resource->getConnection();
$table = $this->resource->getTableName('esun_lingxing_warehouse');
if (!$connection->isTableExists($table)) {
return $options;
}
$rows = $connection->fetchAll($connection->select()
->from($table, ['wid', 'warehouse_name', 'source_code'])
->where('warehouse_type = ?', 3)
->where('is_deleted = ?', 0)
->where('lingxing_status = ?', 1)
->order(['warehouse_type ASC', 'warehouse_name ASC']));
foreach ($rows as $row) {
$options[] = [
'value' => (string)$row['wid'],
'label' => sprintf(
'%s (WID %s%s)',
$row['warehouse_name'],
$row['wid'],
$row['source_code'] ? ' / mapped to ' . $row['source_code'] : ''
),
];
}
return $options;
}
}
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace Esun\LingxingErp\Model\Source;
use Magento\Framework\Data\OptionSourceInterface;
class SyncStatus implements OptionSourceInterface
{
public function toOptionArray(): array
{
return [
['value' => 'pending', 'label' => __('Pending')],
['value' => 'processing', 'label' => __('Processing')],
['value' => 'retrying', 'label' => __('Retrying')],
['value' => 'success', 'label' => __('Success')],
['value' => 'failed', 'label' => __('Failed')],
['value' => 'ignored', 'label' => __('Ignored')],
['value' => 'canceled', 'label' => __('Canceled')],
['value' => 'not_required', 'label' => __('Not Required')],
];
}
}
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace Esun\LingxingErp\Model\Source;
use Magento\Framework\Data\OptionSourceInterface;
class WarehouseType implements OptionSourceInterface
{
public function toOptionArray(): array
{
return [
['value' => 1, 'label' => __('Local Warehouse')],
['value' => 3, 'label' => __('Overseas Warehouse')],
['value' => 4, 'label' => __('Platform Warehouse')],
['value' => 6, 'label' => __('AWD Warehouse')],
];
}
}