feat(117): smsplanet integration settings

This commit is contained in:
2026-05-12 13:18:41 +02:00
parent 09f9ca798d
commit bcbb35bc6b
22 changed files with 1392 additions and 22 deletions

View File

@@ -562,6 +562,7 @@ return [
'inpost' => 'InPost',
'shoppro' => 'shopPRO',
'hostedsms' => 'HostedSMS',
'smsplanet' => 'SMSPLANET',
'shoppro_instances' => ':count instancji',
],
'status' => [
@@ -762,6 +763,68 @@ return [
'test_failed' => 'Nie udalo sie wyslac testowego SMS.',
],
],
'smsplanet' => [
'title' => 'Integracja SMSPLANET',
'description' => 'Konfiguracja konta SMSPLANET do wysylki SMS z orderPRO.',
'config' => [
'title' => 'Konfiguracja API',
],
'test' => [
'title' => 'Test wysylki SMS',
'description' => 'Test realnie wysyla SMS przez API SMSPLANET.',
],
'auth' => [
'token' => 'Bearer token',
'key_password' => 'Klucz API + haslo API',
],
'fields' => [
'auth_method' => 'Metoda autoryzacji',
'api_token' => 'Token Bearer',
'api_key' => 'Klucz API',
'api_password' => 'Haslo API',
'sender' => 'Pole nadawcy / from',
'options' => 'Opcje wysylki',
'clear_polish' => 'Zamien polskie znaki na odpowiedniki GSM',
'transactional' => 'Wysylka kanalem transakcyjnym',
'is_active' => 'Integracja aktywna',
'test_phone' => 'Numer testowy',
'test_message' => 'Tresc testowego SMS',
],
'token' => [
'saved' => 'Token jest zapisany. Pozostaw pole puste, aby nie zmieniac.',
'missing' => 'Brak zapisanego tokenu Bearer.',
],
'key' => [
'saved' => 'Klucz API jest zapisany. Pozostaw pole puste, aby nie zmieniac.',
'missing' => 'Brak zapisanego klucza API.',
],
'password' => [
'saved' => 'Haslo API jest zapisane. Pozostaw pole puste, aby nie zmieniac.',
'missing' => 'Brak zapisanego hasla API.',
],
'hints' => [
'auth_method' => 'SMSPLANET zaleca token Bearer, ale API obsluguje tez klucz i haslo.',
'sender' => 'Pole nadawcy musi byc dostepne na koncie SMSPLANET albo miec wartosc testowa dopuszczona przez provider.',
],
'status' => [
'secret' => 'Sekret API',
'active' => 'Aktywna',
'saved' => 'zapisany',
'missing' => 'brak',
'last_test' => 'Ostatni test',
'message_id' => 'Identyfikator wiadomości',
],
'actions' => [
'save' => 'Zapisz ustawienia SMSPLANET',
'send_test' => 'Wyslij testowy SMS',
],
'flash' => [
'saved' => 'Ustawienia SMSPLANET zostaly zapisane.',
'save_failed' => 'Nie udalo sie zapisac ustawien SMSPLANET.',
'test_success' => 'Testowy SMS zostal przyjety przez SMSPLANET. messageId: :message_id.',
'test_failed' => 'Nie udalo sie wyslac testowego SMS.',
],
],
'inpost' => [
'title' => 'Integracja InPost',
'description' => 'Konfiguracja polaczenia z API InPost ShipX do obslugi przesylek.',

View File

@@ -2717,6 +2717,7 @@ details[open] > .order-statuses-side__title .order-statuses-side__arrow {
}
.integration-settings-checkboxes {
grid-column: 1 / -1;
border: 0;
padding: 0;
margin: 0;
@@ -2737,10 +2738,21 @@ details[open] > .order-statuses-side__title .order-statuses-side__arrow {
display: inline-flex;
align-items: center;
gap: 6px;
min-height: 24px;
font-size: 13px;
line-height: 1.3;
color: #334155;
}
.integration-settings-checkboxes__item input[type='checkbox'],
.integration-settings-checkboxes__item input[type='radio'] {
flex: 0 0 auto;
width: 16px;
height: 16px;
margin: 0;
accent-color: var(--c-action-primary);
}
// Hamburger button (hidden on desktop)
.topbar__hamburger {
display: none;

View File

@@ -0,0 +1,159 @@
<?php
$settings = is_array($settings ?? null) ? $settings : [];
$authMethod = (string) ($settings['auth_method'] ?? 'token');
$sender = trim((string) ($settings['sender'] ?? ''));
$hasApiToken = (bool) ($settings['has_api_token'] ?? false);
$hasApiKey = (bool) ($settings['has_api_key'] ?? false);
$hasApiPassword = (bool) ($settings['has_api_password'] ?? false);
$isActive = (bool) ($settings['is_active'] ?? true);
$clearPolish = (bool) ($settings['clear_polish'] ?? false);
$transactional = (bool) ($settings['transactional'] ?? false);
$lastTestAt = trim((string) ($settings['last_test_at'] ?? ''));
$lastTestStatus = trim((string) ($settings['last_test_status'] ?? ''));
$lastTestMessage = trim((string) ($settings['last_test_message'] ?? ''));
$lastTestHttpCode = $settings['last_test_http_code'] ?? null;
$lastMessageId = '';
if (str_starts_with($lastTestMessage, 'messageId:')) {
$lastMessageId = trim(substr($lastTestMessage, strlen('messageId:')));
}
?>
<section class="card">
<h2 class="section-title"><?= $e($t('settings.smsplanet.title')) ?></h2>
<p class="muted mt-12"><?= $e($t('settings.smsplanet.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; ?>
<?php if (!empty($testMessage)): ?>
<div class="alert alert--info mt-12" role="status"><?= $e((string) $testMessage) ?></div>
<?php endif; ?>
</section>
<section class="card mt-16">
<h3 class="section-title"><?= $e($t('settings.smsplanet.config.title')) ?></h3>
<div class="muted mt-12">
<?= $e($t('settings.smsplanet.status.secret')) ?>:
<strong><?= $e(($hasApiToken || $hasApiPassword) ? $t('settings.smsplanet.status.saved') : $t('settings.smsplanet.status.missing')) ?></strong>
|
<?= $e($t('settings.smsplanet.status.active')) ?>:
<strong><?= $e($isActive ? $t('settings.integrations_hub.active.yes') : $t('settings.integrations_hub.active.no')) ?></strong>
</div>
<form class="statuses-form mt-16" action="/settings/integrations/smsplanet/save" method="post" novalidate>
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
<fieldset class="integration-settings-checkboxes">
<legend class="field-label"><?= $e($t('settings.smsplanet.fields.auth_method')) ?></legend>
<div class="integration-settings-checkboxes__list">
<label class="integration-settings-checkboxes__item">
<input type="radio" name="auth_method" value="token"<?= $authMethod === 'token' ? ' checked' : '' ?>>
<span><?= $e($t('settings.smsplanet.auth.token')) ?></span>
</label>
<label class="integration-settings-checkboxes__item">
<input type="radio" name="auth_method" value="key_password"<?= $authMethod === 'key_password' ? ' checked' : '' ?>>
<span><?= $e($t('settings.smsplanet.auth.key_password')) ?></span>
</label>
</div>
<span class="muted"><?= $e($t('settings.smsplanet.hints.auth_method')) ?></span>
</fieldset>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.smsplanet.fields.api_token')) ?></span>
<input class="form-control" type="password" name="api_token" autocomplete="new-password" placeholder="<?= $hasApiToken ? '********' : '' ?>">
<span class="muted"><?= $e($hasApiToken ? $t('settings.smsplanet.token.saved') : $t('settings.smsplanet.token.missing')) ?></span>
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.smsplanet.fields.api_key')) ?></span>
<input class="form-control" type="password" name="api_key" autocomplete="new-password" placeholder="<?= $hasApiKey ? '********' : '' ?>">
<span class="muted"><?= $e($hasApiKey ? $t('settings.smsplanet.key.saved') : $t('settings.smsplanet.key.missing')) ?></span>
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.smsplanet.fields.api_password')) ?></span>
<input class="form-control" type="password" name="api_password" autocomplete="new-password" placeholder="<?= $hasApiPassword ? '********' : '' ?>">
<span class="muted"><?= $e($hasApiPassword ? $t('settings.smsplanet.password.saved') : $t('settings.smsplanet.password.missing')) ?></span>
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.smsplanet.fields.sender')) ?></span>
<input class="form-control" type="text" name="sender" maxlength="32" value="<?= $e($sender) ?>" required>
<span class="muted"><?= $e($t('settings.smsplanet.hints.sender')) ?></span>
</label>
<fieldset class="integration-settings-checkboxes">
<legend class="field-label"><?= $e($t('settings.smsplanet.fields.options')) ?></legend>
<div class="integration-settings-checkboxes__list">
<label class="integration-settings-checkboxes__item">
<input type="checkbox" name="clear_polish" value="1"<?= $clearPolish ? ' checked' : '' ?>>
<span><?= $e($t('settings.smsplanet.fields.clear_polish')) ?></span>
</label>
<label class="integration-settings-checkboxes__item">
<input type="checkbox" name="transactional" value="1"<?= $transactional ? ' checked' : '' ?>>
<span><?= $e($t('settings.smsplanet.fields.transactional')) ?></span>
</label>
<label class="integration-settings-checkboxes__item">
<input type="checkbox" name="is_active" value="1"<?= $isActive ? ' checked' : '' ?>>
<span><?= $e($t('settings.smsplanet.fields.is_active')) ?></span>
</label>
</div>
</fieldset>
<div class="form-actions mt-16">
<button type="submit" class="btn btn--primary"><?= $e($t('settings.smsplanet.actions.save')) ?></button>
</div>
</form>
</section>
<section class="card mt-16">
<h3 class="section-title"><?= $e($t('settings.smsplanet.test.title')) ?></h3>
<p class="muted mt-12"><?= $e($t('settings.smsplanet.test.description')) ?></p>
<form class="statuses-form mt-16" action="/settings/integrations/smsplanet/test" method="post" novalidate>
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
<label class="form-field">
<span class="field-label"><?= $e($t('settings.smsplanet.fields.test_phone')) ?></span>
<input class="form-control" type="tel" name="phone" inputmode="tel" placeholder="48600111222" required>
</label>
<label class="form-field">
<span class="field-label"><?= $e($t('settings.smsplanet.fields.test_message')) ?></span>
<textarea class="form-control" name="message" rows="4" maxlength="918" required>Test orderPRO SMSPLANET</textarea>
</label>
<div class="form-actions mt-16">
<button type="submit" class="btn btn--secondary"><?= $e($t('settings.smsplanet.actions.send_test')) ?></button>
</div>
</form>
<?php if ($lastTestAt !== ''): ?>
<div class="alert <?= $lastTestStatus === 'ok' ? 'alert--success' : 'alert--danger' ?> mt-16" role="status">
<div>
<strong><?= $e($t('settings.smsplanet.status.last_test')) ?>:</strong>
<?= $e($lastTestAt) ?>
<?php if ($lastTestStatus !== ''): ?>
<span class="badge badge--<?= $lastTestStatus === 'ok' ? 'success' : 'muted' ?>"><?= $e(strtoupper($lastTestStatus)) ?></span>
<?php endif; ?>
<?php if ($lastTestHttpCode !== null): ?>
<span class="badge badge--muted">HTTP <?= $e((string) $lastTestHttpCode) ?></span>
<?php endif; ?>
</div>
<?php if ($lastMessageId !== ''): ?>
<div class="mt-12">
<?= $e($t('settings.smsplanet.status.message_id')) ?>:
<code><?= $e($lastMessageId) ?></code>
</div>
<?php elseif ($lastTestMessage !== ''): ?>
<div class="mt-12"><?= $e($lastTestMessage) ?></div>
<?php endif; ?>
</div>
<?php endif; ?>
</section>