- Implemented OrdersRepository for handling order data with pagination, filtering, and sorting capabilities. - Added methods for retrieving order status options, quick stats, and detailed order information. - Created OrderStatusRepository for managing order status groups and statuses, including CRUD operations and sorting. - Introduced a bootstrap file for test environment setup and autoloading.
108 lines
5.4 KiB
PHP
108 lines
5.4 KiB
PHP
<?php
|
|
$integrationsList = is_array($integrations ?? null) ? $integrations : [];
|
|
$selectedIntegrationId = max(0, (int) ($selectedIntegrationId ?? 0));
|
|
$shopProStatusesList = is_array($shopProStatuses ?? null) ? $shopProStatuses : [];
|
|
$orderProOptions = is_array($orderProStatusOptions ?? null) ? $orderProStatusOptions : [];
|
|
?>
|
|
|
|
<section class="card">
|
|
<h1><?= $e($t('settings.title')) ?></h1>
|
|
<p class="muted"><?= $e($t('settings.description')) ?></p>
|
|
<nav class="settings-nav mt-16" aria-label="<?= $e($t('settings.submenu_label')) ?>">
|
|
<a class="settings-nav__link<?= ($activeSettings ?? '') === 'database' ? ' is-active' : '' ?>" href="/settings/database"><?= $e($t('settings.database.title')) ?></a>
|
|
<a class="settings-nav__link<?= ($activeSettings ?? '') === 'integrations' ? ' is-active' : '' ?>" href="/settings/integrations/shoppro"><?= $e($t('settings.integrations.title')) ?></a>
|
|
<a class="settings-nav__link<?= ($activeSettings ?? '') === 'order_statuses' ? ' is-active' : '' ?>" href="/settings/order-statuses"><?= $e($t('settings.order_statuses.title')) ?></a>
|
|
<a class="settings-nav__link<?= ($activeSettings ?? '') === 'cron' ? ' is-active' : '' ?>" href="/settings/cron"><?= $e($t('settings.cron.title')) ?></a>
|
|
<a class="settings-nav__link<?= ($activeSettings ?? '') === 'gs1' ? ' is-active' : '' ?>" href="/settings/gs1"><?= $e($t('settings.gs1.title')) ?></a>
|
|
<a class="settings-nav__link<?= ($activeSettings ?? '') === 'products' ? ' is-active' : '' ?>" href="/settings/products"><?= $e($t('settings.products.title')) ?></a>
|
|
</nav>
|
|
</section>
|
|
|
|
<section class="card mt-16">
|
|
<h2 class="section-title"><?= $e($t('settings.order_statuses.title')) ?></h2>
|
|
<p class="muted mt-12"><?= $e($t('settings.order_statuses.description')) ?></p>
|
|
|
|
<?php if (!empty($errorMessage)): ?>
|
|
<div class="alert alert--danger mt-12" role="alert"><?= $e((string) $errorMessage) ?></div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($successMessage)): ?>
|
|
<div class="alert alert--success mt-12" role="status"><?= $e((string) $successMessage) ?></div>
|
|
<?php endif; ?>
|
|
|
|
<form method="get" action="/settings/order-statuses" class="mt-16">
|
|
<label class="form-field">
|
|
<span class="field-label"><?= $e($t('settings.order_statuses.integration')) ?></span>
|
|
<select class="form-control" name="integration_id" onchange="this.form.submit()">
|
|
<?php if ($integrationsList === []): ?>
|
|
<option value="0"><?= $e($t('settings.order_statuses.no_integrations')) ?></option>
|
|
<?php else: ?>
|
|
<?php foreach ($integrationsList as $integration): ?>
|
|
<?php $id = max(0, (int) ($integration['id'] ?? 0)); ?>
|
|
<?php if ($id <= 0) continue; ?>
|
|
<option value="<?= $e((string) $id) ?>"<?= $id === $selectedIntegrationId ? ' selected' : '' ?>>
|
|
<?= $e((string) ($integration['name'] ?? ('#' . $id))) ?> (ID: <?= $e((string) $id) ?>)
|
|
</option>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</select>
|
|
</label>
|
|
</form>
|
|
|
|
<?php if ($selectedIntegrationId > 0): ?>
|
|
<form action="/settings/order-statuses/save" method="post" class="mt-16">
|
|
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
|
<input type="hidden" name="integration_id" value="<?= $e((string) $selectedIntegrationId) ?>">
|
|
|
|
<div class="table-wrap">
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th><?= $e($t('settings.order_statuses.fields.shoppro_code')) ?></th>
|
|
<th><?= $e($t('settings.order_statuses.fields.shoppro_name')) ?></th>
|
|
<th><?= $e($t('settings.order_statuses.fields.orderpro_status')) ?></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if ($shopProStatusesList === []): ?>
|
|
<tr>
|
|
<td colspan="3" class="muted"><?= $e($t('settings.order_statuses.empty')) ?></td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($shopProStatusesList as $status): ?>
|
|
<?php
|
|
$shopCode = trim((string) ($status['code'] ?? ''));
|
|
if ($shopCode === '') continue;
|
|
$shopName = trim((string) ($status['name'] ?? $shopCode));
|
|
$selectedOrderPro = trim((string) ($status['mapped_orderpro_status'] ?? ''));
|
|
?>
|
|
<tr>
|
|
<td>
|
|
<?= $e($shopCode) ?>
|
|
<input type="hidden" name="shoppro_names[<?= $e($shopCode) ?>]" value="<?= $e($shopName) ?>">
|
|
</td>
|
|
<td><?= $e($shopName) ?></td>
|
|
<td>
|
|
<select class="form-control" name="mappings[<?= $e($shopCode) ?>]">
|
|
<option value=""><?= $e($t('settings.order_statuses.fields.no_mapping')) ?></option>
|
|
<?php foreach ($orderProOptions as $orderProCode => $orderProLabel): ?>
|
|
<option value="<?= $e((string) $orderProCode) ?>"<?= $selectedOrderPro === (string) $orderProCode ? ' selected' : '' ?>>
|
|
<?= $e((string) $orderProLabel) ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="form-actions mt-16">
|
|
<button type="submit" class="btn btn--primary"><?= $e($t('settings.order_statuses.actions.save')) ?></button>
|
|
</div>
|
|
</form>
|
|
<?php endif; ?>
|
|
</section>
|