File manager - Edit - /home/webapp69.cm.in.th/u69319090028/Shop/views/seller/notifications/index.php
Back
<div class="cargoo-card"> <div class="cargoo-card-header d-flex flex-column flex-sm-row justify-content-between align-items-sm-center gap-3"> <div> <h5 class="mb-1 fw-bold"><i class="bi bi-bell-fill text-warning me-2"></i>การแจ้งเตือนร้านค้า (Store Notifications)</h5> <p class="text-muted small mb-0">แจ้งเตือนคำสั่งซื้อใหม่ รีวิวสินค้า สินค้าใกล้หมดสต็อก และประกาศสำคัญสำหรับผู้ขาย</p> </div> <?php if ($unreadCount > 0): ?> <form action="<?= url('/account/notifications/mark-all-read') ?>" method="POST" class="m-0" id="markAllReadSellerForm"> <?= Security::csrfField() ?> <input type="hidden" name="role_target" value="seller"> <button type="submit" class="btn btn-outline-primary btn-sm px-3"> <i class="bi bi-check2-all me-1"></i> อ่านแล้วทั้งหมด </button> </form> <?php endif; ?> </div> <!-- Filter Bar --> <div class="px-4 py-3 bg-light border-bottom d-flex flex-wrap gap-2 align-items-center justify-content-between"> <div class="d-flex gap-2"> <a href="<?= url('/seller/notifications') ?>" class="btn btn-sm <?= ($filters['is_read'] ?? 'all') === 'all' ? 'btn-primary' : 'btn-outline-secondary' ?>"> ทั้งหมด (<?= (int)$totalCount ?>) </a> <a href="<?= url('/seller/notifications?is_read=0') ?>" class="btn btn-sm <?= ($filters['is_read'] ?? '') === '0' ? 'btn-primary' : 'btn-outline-secondary' ?>"> ยังไม่ได้อ่าน (<?= (int)$unreadCount ?>) </a> <a href="<?= url('/seller/notifications?is_read=1') ?>" class="btn btn-sm <?= ($filters['is_read'] ?? '') === '1' ? 'btn-primary' : 'btn-outline-secondary' ?>"> อ่านแล้ว </a> </div> </div> <!-- Notification List --> <div class="cargoo-card-body p-0"> <?php if (empty($notifications)): ?> <div class="text-center py-5"> <i class="bi bi-bell-slash text-muted" style="font-size: 3rem;"></i> <h6 class="mt-3 fw-bold text-dark">ไม่มีการแจ้งเตือนร้านค้า</h6> <p class="text-muted small mb-0">เมื่อมีคำสั่งซื้อหรือกิจกรรมใหม่ของร้าน ระบบจะแจ้งเตือนที่นี่</p> </div> <?php else: ?> <div class="list-group list-group-flush"> <?php foreach ($notifications as $n): ?> <?php $isUnread = empty($n['is_read']); $t = $n['type']; if ($t === 'order_new') { $iconClass = 'bi-bag-check-fill text-success'; $typeLabel = 'คำสั่งซื้อใหม่'; } elseif ($t === 'order_cancelled') { $iconClass = 'bi-bag-x-fill text-danger'; $typeLabel = 'ลูกค้ายกเลิกคำสั่งซื้อ'; } elseif ($t === 'order_payment_awaiting') { $iconClass = 'bi-receipt-cutoff text-warning'; $typeLabel = 'ลูกค้ารอตรวจสลิป'; } elseif ($t === 'order_payment_confirmed') { $iconClass = 'bi-check-circle-fill text-success'; $typeLabel = 'คำสั่งซื้อชำระแล้ว'; } elseif ($t === 'low_stock') { $iconClass = 'bi-boxes text-danger'; $typeLabel = 'สินค้าใกล้หมด'; } elseif ($t === 'review_received') { $iconClass = 'bi-star-fill text-warning'; $typeLabel = 'รีวิวใหม่'; } elseif ($t === 'settlement_paid') { $iconClass = 'bi-cash-stack text-primary'; $typeLabel = 'รอบโอนเงิน'; } else { $iconClass = 'bi-bell-fill text-secondary'; $typeLabel = 'การแจ้งเตือนร้านค้า'; } ?> <div class="list-group-item p-3 p-md-4 d-flex align-items-start gap-3 notif-item-row <?= $isUnread ? 'bg-primary-subtle bg-opacity-25' : '' ?>" id="notif-seller-row-<?= (int)$n['id'] ?>"> <div class="rounded-circle bg-white border p-2 d-flex align-items-center justify-content-center flex-shrink-0 shadow-sm" style="width: 44px; height: 44px;"> <i class="bi <?= $iconClass ?> fs-5"></i> </div> <div class="flex-grow-1 min-w-0"> <div class="d-flex align-items-center justify-content-between gap-2 mb-1"> <h6 class="fw-bold text-dark mb-0 small <?= $isUnread ? 'text-primary' : '' ?>"> <?= e($n['title']) ?> <?php if ($isUnread): ?> <span class="badge bg-danger rounded-pill ms-1 notif-unread-badge" style="font-size: 0.6rem;">ใหม่</span> <?php endif; ?> <span class="badge bg-light text-muted border ms-1" style="font-size: 0.65rem;"><?= $typeLabel ?></span> </h6> <small class="text-muted text-nowrap"><?= date('d/m/Y H:i', strtotime($n['created_at'])) ?></small> </div> <p class="text-secondary small mb-2 text-break" style="white-space: pre-line;"><?= e($n['message']) ?></p> <div class="d-flex align-items-center gap-2 flex-wrap"> <button type="button" class="btn btn-sm btn-cargoo-primary py-1 px-3 btn-view-notif" data-id="<?= (int)$n['id'] ?>" data-title="<?= e($n['title']) ?>" data-message="<?= e($n['message']) ?>" data-date="<?= date('d/m/Y H:i', strtotime($n['created_at'])) ?>" data-type="<?= e($typeLabel) ?>" data-action-url="<?= !empty($n['action_url']) ? e(url($n['action_url'])) : '' ?>" data-is-read="<?= (int)$n['is_read'] ?>" style="font-size: 0.75rem;"> <i class="bi bi-eye me-1"></i> ดูรายละเอียด </button> <?php if (!empty($n['action_url'])): ?> <a href="<?= url('/account/notifications/' . (int)$n['id'] . '/read') ?>" class="btn btn-sm btn-outline-secondary py-1 px-3" style="font-size: 0.75rem;"> ไปยังหน้ารายการ <i class="bi bi-box-arrow-up-right ms-1"></i> </a> <?php endif; ?> <form action="<?= url('/account/notifications/' . (int)$n['id'] . '/delete') ?>" method="POST" class="d-inline ms-auto"> <?= Security::csrfField() ?> <button type="submit" class="btn btn-link text-muted p-0 border-0" title="ลบการแจ้งเตือน" onclick="return confirm('ลบการแจ้งเตือนนี้?');"> <i class="bi bi-trash" style="font-size: 0.85rem;"></i> </button> </form> </div> </div> </div> <?php endforeach; ?> </div> <!-- Pagination --> <?php if ($totalPages > 1): ?> <div class="p-3 border-top d-flex justify-content-between align-items-center"> <small class="text-muted">หน้า <?= $currentPage ?> จาก <?= $totalPages ?></small> <ul class="pagination pagination-sm mb-0"> <?php for ($p = 1; $p <= $totalPages; $p++): ?> <?php $queryParams = array_merge($_GET, ['page' => $p]); $pageUrl = url('/seller/notifications') . '?' . http_build_query($queryParams); ?> <li class="page-item <?= $p === $currentPage ? 'active' : '' ?>"> <a class="page-link" href="<?= $pageUrl ?>"><?= $p ?></a> </li> <?php endfor; ?> </ul> </div> <?php endif; ?> <?php endif; ?> </div> </div> <!-- Notification Detail Modal --> <div class="modal fade" id="notificationDetailModal" tabindex="-1" aria-labelledby="notifModalTitle" aria-hidden="true"> <div class="modal-dialog modal-dialog-centered"> <div class="modal-content rounded-4 border-0 shadow"> <div class="modal-header border-bottom py-3 px-4 bg-light rounded-top-4"> <div class="d-flex align-items-center gap-2"> <div class="rounded-circle bg-warning bg-opacity-10 text-warning p-2 d-flex align-items-center justify-content-center" style="width: 38px; height: 38px;"> <i class="bi bi-bell-fill fs-6"></i> </div> <div> <h6 class="modal-title fw-bold text-dark mb-0" id="notifModalTitle">รายละเอียดการแจ้งเตือนร้านค้า</h6> <small class="text-muted" id="notifModalDate" style="font-size: 0.75rem;"></small> </div> </div> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body p-4"> <div class="d-flex align-items-center gap-2 mb-3"> <span class="badge bg-warning-subtle text-warning border" id="notifModalType">ร้านค้า</span> <span class="badge bg-light text-muted border" id="notifModalReadStatus">อ่านแล้ว</span> </div> <div class="p-3 bg-light rounded-3 text-dark small lh-lg" id="notifModalMessage" style="white-space: pre-line; word-break: break-word; font-size: 0.9rem;"> </div> </div> <div class="modal-footer py-2 px-4 bg-light border-top rounded-bottom-4 d-flex justify-content-between"> <button type="button" class="btn btn-sm btn-secondary px-3" data-bs-dismiss="modal">ปิด</button> <a href="#" id="notifModalActionBtn" class="btn btn-sm btn-cargoo-primary px-3 d-none"> ไปยังหน้าที่เกี่ยวข้อง <i class="bi bi-arrow-right ms-1"></i> </a> </div> </div> </div> </div> <script> document.addEventListener('DOMContentLoaded', function () { const notifModalEl = document.getElementById('notificationDetailModal'); const notifModal = notifModalEl ? new bootstrap.Modal(notifModalEl) : null; document.querySelectorAll('.btn-view-notif').forEach(function (btn) { btn.addEventListener('click', function () { const notifId = this.getAttribute('data-id'); const title = this.getAttribute('data-title'); const message = this.getAttribute('data-message'); const date = this.getAttribute('data-date'); const type = this.getAttribute('data-type'); const actionUrl = this.getAttribute('data-action-url'); if (notifModalEl) { document.getElementById('notifModalTitle').textContent = title || 'รายละเอียดการแจ้งเตือน'; document.getElementById('notifModalDate').textContent = date || ''; document.getElementById('notifModalType').textContent = type || 'ร้านค้า'; document.getElementById('notifModalMessage').textContent = message || ''; const actionBtn = document.getElementById('notifModalActionBtn'); if (actionUrl && actionUrl.trim() !== '') { actionBtn.href = actionUrl; actionBtn.classList.remove('d-none'); } else { actionBtn.classList.add('d-none'); } notifModal.show(); } // Mark as read via AJAX fetch('/CARGOO/api/v1/notifications/' + notifId + '/read', { method: 'POST', headers: { 'X-Requested-With': 'XMLHttpRequest' } }) .then(res => res.json()) .then(data => { if (data.success) { const row = document.getElementById('notif-seller-row-' + notifId); if (row) { row.classList.remove('bg-primary-subtle', 'bg-opacity-25'); const unreadBadge = row.querySelector('.notif-unread-badge'); if (unreadBadge) unreadBadge.remove(); } const navBadge = document.getElementById('navNotifBadge'); if (navBadge) { if (data.unread_count > 0) { navBadge.textContent = data.unread_count; navBadge.classList.remove('d-none'); } else { navBadge.classList.add('d-none'); } } } }) .catch(err => console.error('Error marking as read:', err)); }); }); }); </script>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.23 |
proxy
|
phpinfo
|
Settings