Files
orderPRO/resources/views/settings/smsplanet.php
Jacek Pyziak 933dfcc67b feat(120): alert component unification
Phase 120 - Plan 01:
- Reusable PHP alert component (resources/views/components/alert.php)
  with inline SVG icon per type, optional dismiss button.
- Missing .alert--info SCSS variant added (#eff6ff/#bfdbfe/#1e3a8a) -
  fixes black-on-white alert after Fakturownia test connection.
- Flash::push(type, message) + Flash::all() with BC for set/get;
  legacy key heuristic (error/.save/warning -> typed entries).
- Central flash renderer in 3 layouts (app/auth/public) iterating
  Flash::all() through component (.alerts-stack wrap).
- Vanilla JS alert-dismiss.js with idempotent guard and delegated
  click handler on [data-alert-dismiss].
- 36 views migrated off inline <div class="alert alert--TYPE">;
  .flash--error/success removed from views (orders/show, shipments/prepare).
- SCSS rebuilt: public/assets/css/{app,login}.css.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 18:47:41 +02:00

160 lines
8.1 KiB
PHP

<?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="mt-12"><?php $type='danger'; $message=(string) $errorMessage; $dismissible=true; include dirname(__DIR__) . '/components/alert.php'; ?></div>
<?php endif; ?>
<?php if (!empty($successMessage)): ?>
<div class="mt-12"><?php $type='success'; $message=(string) $successMessage; $dismissible=true; include dirname(__DIR__) . '/components/alert.php'; ?></div>
<?php endif; ?>
<?php if (!empty($testMessage)): ?>
<div class="mt-12"><?php $type='info'; $message=(string) $testMessage; $dismissible=true; include dirname(__DIR__) . '/components/alert.php'; ?></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>