added new email tab to display notification log

This commit is contained in:
Luca Haid
2025-05-27 16:08:37 +02:00
parent 83097953c4
commit acf88406a9

View File

@@ -13,7 +13,8 @@
<li class="nav-item"><a class="nav-link" href="#preorder-detail-<?=$preorder->id?>-map" data-toggle="tab" aria-expanded="false" onclick="loadBorderpointMap(<?=$preorder->id?>)">Übergabepunkt</a></li>
<?php endif; ?>
<li class="nav-item"><a class="nav-link" href="#preorder-detail-<?=$preorder->id?>-history" data-toggle="tab" aria-expanded="false">History</a></li>
<li class="nav-item"><a class="nav-link" href="#preorder-detail-<?=$preorder->id?>-history" data-toggle="tab" aria-expanded="false">History</a></li>
<li class="nav-item"><a class="nav-link" href="#preorder-detail-<?=$preorder->id?>-emails" data-toggle="tab" aria-expanded="false">E-Mails</a></li>
</ul>
</div>
@@ -695,6 +696,219 @@
</div>
</div>
<div id="preorder-detail-<?=$preorder->id?>-emails" class="tab-pane preorder-emails-view">
<?php
$allPreorderEmails = PreordernotificationLogModel::search(["preorder_id" => $preorder->id]);
$allStatusFlagEmails = PreorderStatusnotificationLog::search(["preorder_id" => $preorder->id]);
?>
<div class="container-fluid">
<div class="row">
<div class="col-12">
<h5 class="mb-3">
<i class="fas fa-envelope mr-2 text-muted"></i>
E-Mail Benachrichtigungen
</h5>
<!-- Preorder Notification Emails -->
<?php if (!empty($allPreorderEmails)): ?>
<div class="card mb-3">
<div class="card-header bg-light border-bottom">
<h6 class="mb-0 text-secondary">
<i class="fas fa-bell mr-2"></i>
Vorbestellungs-Benachrichtigungen
<span class="badge badge-secondary ml-2"><?= count($allPreorderEmails) ?></span>
</h6>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-sm table-hover mb-0">
<thead class="thead-light">
<tr>
<th class="border-0 py-2">
<i class="fas fa-envelope-open mr-1 text-muted"></i>
Betreff
</th>
<th class="border-0 py-2">
<i class="fas fa-at mr-1 text-muted"></i>
E-Mail
</th>
<th class="border-0 py-2">
<i class="fas fa-clock mr-1 text-muted"></i>
Gesendet
</th>
<th class="border-0 py-2">
<i class="fas fa-hashtag mr-1 text-muted"></i>
ID
</th>
</tr>
</thead>
<tbody>
<?php foreach ($allPreorderEmails as $emailLog): ?>
<?php
$notification = PreordernotificationModel::getOne($emailLog->data->preordernotification_id);
$sentDate = date('Y-m-d H:i:s', $emailLog->data->sent);
$sentDateFormatted = date('M j, Y \a\t g:i A', $emailLog->data->sent);
?>
<tr>
<td class="py-2">
<div class="font-weight-medium text-dark small">
<?= htmlspecialchars($notification->subject ?? 'Kein Betreff') ?>
</div>
</td>
<td class="py-2">
<span class="badge badge-light text-muted px-2 py-1">
<?= htmlspecialchars($emailLog->data->email) ?>
</span>
</td>
<td class="py-2">
<div class="text-muted small">
<?= $sentDateFormatted ?>
</div>
</td>
<td class="py-2">
<span class="badge badge-secondary">
#<?= $emailLog->data->preordernotification_id ?>
</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<?php endif; ?>
<!-- Status Notification Emails -->
<?php if (!empty($allStatusFlagEmails)): ?>
<div class="card mb-3">
<div class="card-header bg-light border-bottom">
<h6 class="mb-0 text-secondary">
<i class="fas fa-flag mr-2"></i>
Status-Benachrichtigungen
<span class="badge badge-secondary ml-2"><?= count($allStatusFlagEmails) ?></span>
</h6>
</div>
<div class="card-body p-0">
<div class="table-responsive">
<table class="table table-sm table-hover mb-0">
<thead class="thead-light">
<tr>
<th class="border-0 py-2">
<i class="fas fa-flag mr-1 text-muted"></i>
Status
</th>
<th class="border-0 py-2">
<i class="fas fa-at mr-1 text-muted"></i>
E-Mail
</th>
<th class="border-0 py-2">
<i class="fas fa-clock mr-1 text-muted"></i>
Erstellt
</th>
<th class="border-0 py-2">
<i class="fas fa-user mr-1 text-muted"></i>
Benutzer
</th>
</tr>
</thead>
<tbody>
<?php foreach ($allStatusFlagEmails as $statusLog): ?>
<?php
$createdDate = date('Y-m-d H:i:s', $statusLog->create);
$createdDateFormatted = date('M j, Y \a\t g:i A', $statusLog->create);
// Status code color mapping - muted colors
$statusBadgeClass = 'badge-light text-muted';
switch($statusLog->data->status_code) {
case '100': $statusBadgeClass = 'badge-light text-info'; break;
case '110': $statusBadgeClass = 'badge-light text-warning'; break;
case '120': $statusBadgeClass = 'badge-light text-secondary'; break;
case '130': $statusBadgeClass = 'badge-light text-success'; break;
case '140': $statusBadgeClass = 'badge-light text-danger'; break;
}
?>
<tr>
<td class="py-2">
<span class="badge <?= $statusBadgeClass ?> px-2 py-1">
<?= htmlspecialchars($statusLog->data->status_code) ?>
</span>
</td>
<td class="py-2">
<span class="badge badge-light text-muted px-2 py-1">
<?= htmlspecialchars($statusLog->data->email) ?>
</span>
</td>
<td class="py-2">
<div class="text-muted small">
<?= $createdDateFormatted ?>
</div>
</td>
<td class="py-2">
<span class="badge badge-light text-muted">
#<?= $statusLog->data->create_by ?>
</span>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
</div>
<?php endif; ?>
<!-- Empty State -->
<?php if (empty($allPreorderEmails) && empty($allStatusFlagEmails)): ?>
<div class="card border-0">
<div class="card-body text-center py-4">
<div class="mb-3">
<i class="fas fa-envelope-open-text fa-3x text-muted"></i>
</div>
<h6 class="text-muted mb-2">Keine E-Mail-Benachrichtigungen</h6>
<p class="text-muted small mb-0">
Für diese Vorbestellung wurden noch keine E-Mail-Benachrichtigungen versendet.
</p>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
<style>
.preorder-emails-view .badge-light {
background-color: #f8f9fa;
border: 1px solid #e9ecef;
}
.preorder-emails-view .table td {
vertical-align: middle;
border-top: 1px solid #e9ecef;
}
.preorder-emails-view .table tbody tr:hover {
background-color: #f8f9fa;
}
.preorder-emails-view .card {
border: 1px solid #e9ecef;
border-radius: 0.375rem;
}
.preorder-emails-view .card-header {
background-color: #f8f9fa;
border-bottom: 1px solid #e9ecef;
}
.preorder-emails-view .text-info { color: #17a2b8 !important; }
.preorder-emails-view .text-warning { color: #ffc107 !important; }
.preorder-emails-view .text-success { color: #28a745 !important; }
.preorder-emails-view .text-danger { color: #dc3545 !important; }
</style>
</div>
<div
id="preorder-detail-<?=$preorder->id?>-map"
class="tab-pane"