File manager - Edit - /home/webapp69.cm.in.th/u69319090028/Shop/views/admin/payments/accounts.php
Back
<?php /** * Admin Payment Accounts * Route: GET /admin/payments/accounts */ $methodLabel = ['PromptPay' => 'PromptPay / QR', 'BankTransfer' => 'Bank Transfer']; $grouped = ['PromptPay' => [], 'BankTransfer' => []]; foreach ($accounts as $acc) { $grouped[$acc['method']][] = $acc; } ?> <div class="d-flex justify-content-between align-items-start mb-4 flex-wrap gap-2"> <div> <h4 class="fw-bold mb-1 text-dark"><i class="bi bi-bank me-2 text-primary"></i>บัญชีรับเงิน</h4> <p class="text-muted small mb-0">จัดการบัญชีที่ลูกค้าใช้โอนเงินชำระสินค้า</p> </div> <a href="<?= url('/admin/payments/accounts/create') ?>" class="btn btn-primary btn-sm"> <i class="bi bi-plus-lg me-1"></i>เพิ่มบัญชีรับเงิน </a> </div> <?php foreach (['PromptPay', 'BankTransfer'] as $method): ?> <div class="card border-0 shadow-sm mb-4"> <div class="card-header bg-white border-bottom d-flex align-items-center gap-2"> <?php if ($method === 'PromptPay'): ?> <i class="bi bi-qr-code text-primary fs-5"></i> <span class="fw-bold text-dark">PromptPay / QR Code</span> <?php else: ?> <i class="bi bi-bank text-primary fs-5"></i> <span class="fw-bold text-dark">Bank Transfer</span> <?php endif; ?> </div> <div class="card-body p-0"> <?php if (empty($grouped[$method])): ?> <div class="text-center py-4 text-muted small"> <i class="bi bi-plus-circle fs-4 d-block mb-2"></i> ยังไม่มีบัญชี — <a href="<?= url('/admin/payments/accounts/create') ?>" class="text-primary">เพิ่มบัญชี</a> </div> <?php else: ?> <div class="table-responsive"> <table class="table align-middle mb-0 small"> <thead class="table-light"> <tr> <th class="ps-3">ชื่อบัญชี</th> <?php if ($method === 'BankTransfer'): ?> <th>ธนาคาร</th> <?php endif; ?> <th>หมายเลข</th> <?php if ($method === 'PromptPay'): ?> <th class="text-center">QR</th> <?php endif; ?> <th class="text-center">Default</th> <th class="text-center">สถานะ</th> <th class="text-muted">สร้างโดย</th> <th class="pe-3"></th> </tr> </thead> <tbody> <?php foreach ($grouped[$method] as $acc): ?> <tr class="<?= !(int)$acc['is_active'] ? 'opacity-50' : '' ?>"> <td class="ps-3 fw-medium text-dark"><?= e($acc['account_name']) ?></td> <?php if ($method === 'BankTransfer'): ?> <td class="text-muted"><?= e($acc['bank_name'] ?? '—') ?></td> <?php endif; ?> <td><code class="text-dark"><?= e($acc['account_number']) ?></code></td> <?php if ($method === 'PromptPay'): ?> <td class="text-center"> <?php if (!empty($acc['qr_image'])): ?> <a href="<?= asset('/uploads/payment/' . e($acc['qr_image'])) ?>" target="_blank"> <img src="<?= asset('/uploads/payment/' . e($acc['qr_image'])) ?>" alt="QR" style="width:40px;height:40px;object-fit:cover;" class="rounded-1 border"> </a> <?php else: ?> <a href="<?= asset('/assets/images/payment/promtpay.png') ?>" target="_blank" title="Official Marketplace QR"> <img src="<?= asset('/assets/images/payment/promtpay.png') ?>" alt="Official QR" style="width:40px;height:40px;object-fit:cover;" class="rounded-1 border"> </a> <?php endif; ?> </td> <?php endif; ?> <td class="text-center"> <?php if ((int)$acc['is_default']): ?> <span class="badge bg-primary rounded-pill">Default</span> <?php else: ?> <button class="btn btn-outline-secondary btn-sm py-0 set-default-btn" data-id="<?= (int)$acc['id'] ?>" style="font-size:.72rem;"> ตั้ง Default </button> <?php endif; ?> </td> <td class="text-center"> <div class="form-check form-switch d-flex justify-content-center mb-0"> <input class="form-check-input toggle-account" type="checkbox" data-id="<?= (int)$acc['id'] ?>" <?= (int)$acc['is_active'] ? 'checked' : '' ?> style="cursor:pointer;"> </div> </td> <td class="text-muted"><?= e($acc['created_by_name'] ?? '—') ?></td> <td class="pe-3"> <a href="<?= url('/admin/payments/accounts/' . (int)$acc['id'] . '/edit') ?>" class="btn btn-outline-secondary btn-sm px-2 py-1"> <i class="bi bi-pencil"></i> </a> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <?php endif; ?> </div> </div> <?php endforeach; ?> <script> // Toggle active document.querySelectorAll('.toggle-account').forEach(chk => { chk.addEventListener('change', async function() { const id = this.dataset.id; const res = await fetch(`<?= url('/admin/payments/accounts/') ?>${id}/toggle`, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'X-Requested-With': 'XMLHttpRequest' }, body: 'csrf_token=<?= Security::csrfToken() ?>' }); const data = await res.json(); if (!data.success) { this.checked = !this.checked; alert(data.message); } }); }); // Set default document.querySelectorAll('.set-default-btn').forEach(btn => { btn.addEventListener('click', async function() { if (!confirm('ตั้งบัญชีนี้เป็น Default?')) return; const id = this.dataset.id; const res = await fetch(`<?= url('/admin/payments/accounts/') ?>${id}/set-default`, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'X-Requested-With': 'XMLHttpRequest' }, body: 'csrf_token=<?= Security::csrfToken() ?>' }); const data = await res.json(); if (data.success) location.reload(); else alert(data.message); }); }); </script>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.24 |
proxy
|
phpinfo
|
Settings