feat(121+122): smsplanet conversation, notifications, default footer
Phase 121 — SMSPLANET Conversation + Notifications:
- migration 20260512_000110 adds smsplanet conversation + notifications tables
- src/Modules/Sms (SmsConversationService, SmsMessageRepository, SmsplanetWebhookController)
- src/Modules/Notifications (Repository, Controller, ApiController)
- order SMS tab, notification center, sender mode, inbound webhook
- public notifications.js + layouts/app.php integration
Phase 122 — SMSPLANET Default SMS Footer:
- migration 20260512_000111 adds smsplanet_integration_settings.default_footer
- footer appended to test SMS and order SMS, validated against 918 char limit
- settings textarea + compact order SMS note when footer configured
Bundled (could not split per-phase without hunk staging):
- routes/web.php (also carries Phase 118 fakturownia redirects)
- DOCS/{ARCHITECTURE,DB_SCHEMA,TECH_CHANGELOG}.md (118 + 121 + 122 entries)
- .paul/codebase/{architecture,db_schema,tech_changelog}.md (118 + 121 + 122)
- .paul/STATE.md, ROADMAP.md, changelog/2026-05-12.md (UNIFY closure)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -177,6 +177,13 @@
|
||||
<div>
|
||||
<strong><?= $e((string) (($user['name'] ?? '') !== '' ? $user['name'] : ($user['email'] ?? ''))) ?></strong>
|
||||
</div>
|
||||
<a class="topbar-notifications" href="/notifications" id="js-notification-button" title="<?= $e($t('notifications.title')) ?>" aria-label="<?= $e($t('notifications.title')) ?>">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<path d="M18 8a6 6 0 10-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9"/>
|
||||
<path d="M13.73 21a2 2 0 01-3.46 0"/>
|
||||
</svg>
|
||||
<span class="topbar-notifications__badge" id="js-notification-badge" hidden>0</span>
|
||||
</a>
|
||||
<form action="/logout" method="post">
|
||||
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
|
||||
<button type="submit" class="btn btn--secondary"><?= $e($t('actions.logout')) ?></button>
|
||||
@@ -206,6 +213,7 @@
|
||||
<script src="/assets/js/modules/invoice-requested-toggle.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/invoice-requested-toggle.js') ?: 0 ?>"></script>
|
||||
<script src="/assets/js/modules/confirm-delete.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/confirm-delete.js') ?: 0 ?>"></script>
|
||||
<script src="/assets/js/modules/alert-dismiss.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/alert-dismiss.js') ?: 0 ?>"></script>
|
||||
<script src="/assets/js/modules/notifications.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/notifications.js') ?: 0 ?>"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.8/dist/chart.umd.min.js"></script>
|
||||
<script src="/assets/js/modules/statistics-summary-charts.js?ver=<?= filemtime(dirname(__DIR__, 3) . '/public/assets/js/modules/statistics-summary-charts.js') ?: 0 ?>"></script>
|
||||
<script>
|
||||
|
||||
67
resources/views/notifications/index.php
Normal file
67
resources/views/notifications/index.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
$items = is_array($notifications ?? null) ? $notifications : [];
|
||||
$pageData = is_array($pagination ?? null) ? $pagination : ['page' => 1, 'per_page' => 30, 'total' => 0];
|
||||
$page = max(1, (int) ($pageData['page'] ?? 1));
|
||||
$perPage = max(1, (int) ($pageData['per_page'] ?? 30));
|
||||
$total = max(0, (int) ($pageData['total'] ?? 0));
|
||||
$totalPages = max(1, (int) ceil($total / $perPage));
|
||||
?>
|
||||
|
||||
<section class="card notifications-page">
|
||||
<div class="notifications-page__head">
|
||||
<div>
|
||||
<h2 class="section-title"><?= $e($t('notifications.title')) ?></h2>
|
||||
<p class="muted mt-8"><?= $e($t('notifications.description')) ?></p>
|
||||
</div>
|
||||
<?php if ((int) ($unreadCount ?? 0) > 0): ?>
|
||||
<form method="post" action="/notifications/mark-read">
|
||||
<input type="hidden" name="_token" value="<?= $e((string) ($csrfToken ?? '')) ?>">
|
||||
<button class="btn btn--secondary btn--sm" type="submit"><?= $e($t('notifications.actions.mark_all_read')) ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="notifications-list mt-16">
|
||||
<?php if ($items === []): ?>
|
||||
<div class="muted"><?= $e($t('notifications.empty')) ?></div>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($items as $notification): ?>
|
||||
<?php
|
||||
$id = (int) ($notification['id'] ?? 0);
|
||||
$targetUrl = trim((string) ($notification['target_url'] ?? ''));
|
||||
$isUnread = trim((string) ($notification['read_at'] ?? '')) === '';
|
||||
?>
|
||||
<article class="notification-row<?= $isUnread ? ' notification-row--unread' : '' ?>">
|
||||
<div class="notification-row__main">
|
||||
<div class="notification-row__title"><?= $e((string) ($notification['title'] ?? '')) ?></div>
|
||||
<div class="notification-row__body"><?= $e((string) ($notification['body'] ?? '')) ?></div>
|
||||
<div class="notification-row__meta"><?= $e((string) ($notification['created_at'] ?? '')) ?></div>
|
||||
</div>
|
||||
<div class="notification-row__actions">
|
||||
<?php if ($targetUrl !== ''): ?>
|
||||
<a class="btn btn--secondary btn--sm" href="<?= $e($targetUrl) ?>"><?= $e($t('notifications.actions.open')) ?></a>
|
||||
<?php endif; ?>
|
||||
<?php if ($isUnread): ?>
|
||||
<form method="post" action="/notifications/mark-read">
|
||||
<input type="hidden" name="_token" value="<?= $e((string) ($csrfToken ?? '')) ?>">
|
||||
<input type="hidden" name="id" value="<?= $e((string) $id) ?>">
|
||||
<button class="btn btn--secondary btn--sm" type="submit"><?= $e($t('notifications.actions.mark_read')) ?></button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($totalPages > 1): ?>
|
||||
<div class="pagination mt-16">
|
||||
<?php if ($page > 1): ?>
|
||||
<a class="btn btn--secondary btn--sm" href="/notifications?page=<?= $page - 1 ?>">←</a>
|
||||
<?php endif; ?>
|
||||
<span class="muted"><?= $e((string) $page) ?>/<?= $e((string) $totalPages) ?></span>
|
||||
<?php if ($page < $totalPages): ?>
|
||||
<a class="btn btn--secondary btn--sm" href="/notifications?page=<?= $page + 1 ?>">→</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
@@ -14,6 +14,9 @@ $invoiceConfigsList = is_array($invoiceConfigs ?? null) ? $invoiceConfigs : [];
|
||||
$invoiceRequestedFlag = (int) ($orderRow['invoice_requested'] ?? 0) === 1;
|
||||
$emailTemplatesList = is_array($emailTemplates ?? null) ? $emailTemplates : [];
|
||||
$emailMailboxesList = is_array($emailMailboxes ?? null) ? $emailMailboxes : [];
|
||||
$smsMessagesList = is_array($smsMessages ?? null) ? $smsMessages : [];
|
||||
$smsPhoneValue = trim((string) ($smsPhone ?? ''));
|
||||
$smsDefaultFooterConfigured = (bool) ($smsDefaultFooterConfigured ?? false);
|
||||
$historyList = is_array($history ?? null) ? $history : [];
|
||||
$activityLogList = is_array($activityLog ?? null) ? $activityLog : [];
|
||||
$statusPanelList = is_array($statusPanel ?? null) ? $statusPanel : [];
|
||||
@@ -181,6 +184,7 @@ foreach ($addressesList as $address) {
|
||||
<button type="button" class="order-details-tab" data-order-tab-target="shipments"><?= $e($t('orders.details.tabs.shipments')) ?> (<?= $e((string) (count($shipmentsList) + count($packagesList))) ?>)</button>
|
||||
<button type="button" class="order-details-tab" data-order-tab-target="payments"><?= $e($t('orders.details.tabs.payments')) ?> (<?= $e((string) count($paymentsList)) ?>)</button>
|
||||
<button type="button" class="order-details-tab" data-order-tab-target="documents"><?= $e($t('orders.details.tabs.documents')) ?> (<?= $e((string) (count($documentsList) + count($receiptsList))) ?>)</button>
|
||||
<button type="button" class="order-details-tab" data-order-tab-target="sms"><?= $e($t('orders.details.tabs.sms')) ?> (<?= $e((string) count($smsMessagesList)) ?>)</button>
|
||||
</section>
|
||||
|
||||
<div class="order-tab-panel is-active" data-order-tab-panel="details">
|
||||
@@ -973,6 +977,62 @@ foreach ($addressesList as $address) {
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div class="order-tab-panel" data-order-tab-panel="sms">
|
||||
<section class="card mt-16">
|
||||
<div class="order-sms-head">
|
||||
<h3 class="section-title"><?= $e($t('orders.details.sms.title')) ?></h3>
|
||||
<?php if ($smsPhoneValue !== ''): ?>
|
||||
<span class="badge badge--muted"><?= $e($smsPhoneValue) ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="order-sms-thread mt-12">
|
||||
<?php if ($smsMessagesList === []): ?>
|
||||
<div class="muted"><?= $e($t('orders.details.sms.empty')) ?></div>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($smsMessagesList as $smsMessage): ?>
|
||||
<?php
|
||||
$direction = (string) ($smsMessage['direction'] ?? '');
|
||||
$isOutbound = $direction === 'outbound';
|
||||
$messageId = trim((string) ($smsMessage['message_id'] ?? ''));
|
||||
$status = trim((string) ($smsMessage['status'] ?? ''));
|
||||
?>
|
||||
<article class="order-sms-bubble<?= $isOutbound ? ' order-sms-bubble--outbound' : ' order-sms-bubble--inbound' ?>">
|
||||
<div class="order-sms-bubble__meta">
|
||||
<span><?= $e($isOutbound ? $t('orders.details.sms.outbound') : $t('orders.details.sms.inbound')) ?></span>
|
||||
<span><?= $e((string) ($smsMessage['created_at'] ?? '')) ?></span>
|
||||
</div>
|
||||
<div class="order-sms-bubble__body"><?= nl2br($e((string) ($smsMessage['body'] ?? ''))) ?></div>
|
||||
<?php if ($isOutbound && ($status !== '' || $messageId !== '')): ?>
|
||||
<div class="order-sms-bubble__meta">
|
||||
<?php if ($status !== ''): ?><span><?= $e($status) ?></span><?php endif; ?>
|
||||
<?php if ($messageId !== ''): ?><span>ID: <?= $e($messageId) ?></span><?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<form class="order-sms-form mt-16" method="post" action="/orders/<?= $e((string) ($orderId ?? 0)) ?>/sms/send">
|
||||
<input type="hidden" name="_token" value="<?= $e((string) ($csrfToken ?? '')) ?>">
|
||||
<label class="form-field">
|
||||
<span class="field-label"><?= $e($t('orders.details.sms.phone')) ?></span>
|
||||
<input class="form-control" type="tel" name="phone" inputmode="tel" value="<?= $e($smsPhoneValue) ?>" required>
|
||||
</label>
|
||||
<label class="form-field">
|
||||
<span class="field-label"><?= $e($t('orders.details.sms.message')) ?></span>
|
||||
<textarea class="form-control" name="message" rows="3" maxlength="918" required></textarea>
|
||||
<?php if ($smsDefaultFooterConfigured): ?>
|
||||
<span class="order-sms-footer-note"><?= $e($t('orders.details.sms.footer_note')) ?></span>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn--primary"><?= $e($t('orders.details.sms.send')) ?></button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -1002,7 +1062,9 @@ foreach ($addressesList as $address) {
|
||||
});
|
||||
});
|
||||
|
||||
var forceTab = <?= json_encode($flashSuccessMsg !== '' && strpos($flashSuccessMsg, 'Przesylka') !== false ? 'shipments' : '') ?>;
|
||||
var queryTab = '';
|
||||
try { queryTab = new URLSearchParams(window.location.search).get('tab') || ''; } catch (e) {}
|
||||
var forceTab = queryTab || <?= json_encode($flashSuccessMsg !== '' && strpos($flashSuccessMsg, 'Przesylka') !== false ? 'shipments' : '') ?>;
|
||||
var savedTab = null;
|
||||
try { savedTab = localStorage.getItem(storageKey); } catch (e) {}
|
||||
setActiveTab(forceTab || savedTab || 'details');
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
$settings = is_array($settings ?? null) ? $settings : [];
|
||||
$authMethod = (string) ($settings['auth_method'] ?? 'token');
|
||||
$sender = trim((string) ($settings['sender'] ?? ''));
|
||||
$senderMode = (string) ($settings['sender_mode'] ?? 'text');
|
||||
$senderPhone = trim((string) ($settings['sender_phone'] ?? ''));
|
||||
$defaultFooter = trim((string) ($settings['default_footer'] ?? ''));
|
||||
$hasApiToken = (bool) ($settings['has_api_token'] ?? false);
|
||||
$hasApiKey = (bool) ($settings['has_api_key'] ?? false);
|
||||
$hasApiPassword = (bool) ($settings['has_api_password'] ?? false);
|
||||
@@ -88,6 +91,33 @@ if (str_starts_with($lastTestMessage, 'messageId:')) {
|
||||
<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.sender_mode')) ?></legend>
|
||||
<div class="integration-settings-checkboxes__list">
|
||||
<label class="integration-settings-checkboxes__item">
|
||||
<input type="radio" name="sender_mode" value="text"<?= $senderMode !== 'phone' ? ' checked' : '' ?>>
|
||||
<span><?= $e($t('settings.smsplanet.sender_modes.text')) ?></span>
|
||||
</label>
|
||||
<label class="integration-settings-checkboxes__item">
|
||||
<input type="radio" name="sender_mode" value="phone"<?= $senderMode === 'phone' ? ' checked' : '' ?>>
|
||||
<span><?= $e($t('settings.smsplanet.sender_modes.phone')) ?></span>
|
||||
</label>
|
||||
</div>
|
||||
<span class="muted"><?= $e($t('settings.smsplanet.hints.sender_mode')) ?></span>
|
||||
</fieldset>
|
||||
|
||||
<label class="form-field smsplanet-sender-phone-field">
|
||||
<span class="field-label"><?= $e($t('settings.smsplanet.fields.sender_phone')) ?></span>
|
||||
<input class="form-control" type="tel" name="sender_phone" inputmode="tel" maxlength="32" value="<?= $e($senderPhone) ?>" placeholder="48600111222">
|
||||
<span class="muted"><?= $e($t('settings.smsplanet.hints.sender_phone')) ?></span>
|
||||
</label>
|
||||
|
||||
<label class="form-field smsplanet-default-footer-field">
|
||||
<span class="field-label"><?= $e($t('settings.smsplanet.fields.default_footer')) ?></span>
|
||||
<textarea class="form-control" name="default_footer" rows="3" maxlength="300"><?= $e($defaultFooter) ?></textarea>
|
||||
<span class="muted"><?= $e($t('settings.smsplanet.hints.default_footer')) ?></span>
|
||||
</label>
|
||||
|
||||
<fieldset class="integration-settings-checkboxes">
|
||||
<legend class="field-label"><?= $e($t('settings.smsplanet.fields.options')) ?></legend>
|
||||
<div class="integration-settings-checkboxes__list">
|
||||
@@ -127,6 +157,9 @@ if (str_starts_with($lastTestMessage, 'messageId:')) {
|
||||
<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>
|
||||
<?php if ($defaultFooter !== ''): ?>
|
||||
<span class="muted"><?= $e($t('settings.smsplanet.hints.test_footer')) ?></span>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
|
||||
<div class="form-actions mt-16">
|
||||
|
||||
Reference in New Issue
Block a user