<%= t('customer.check_billing.title', 'Cek Tagihan') %>

<%= settings.company_header || 'OPEN-ISP' %> — <%= t('customer.check_billing.subtitle', 'tanpa perlu login') %>
<%= t('customer.check_billing.search_note', 'Bisa pakai: Nama pelanggan, Nomor WhatsApp, PPPoE Username, GenieACS Tag, atau ID pelanggan.') %>
<% if (error) { %>
<%= error %>
<% } %> <% if (info) { %>
<%= info %>
<% } %> <% if (query && !customer && (!matches || matches.length === 0)) { %>
<%= t('customer.check_billing.not_found', 'Pelanggan tidak ditemukan. Pastikan input sudah benar.') %>
<% } %> <% if (!customer && matches && matches.length > 0) { %>
<%= t('customer.check_billing.results', 'Hasil Pencarian') %>
<%= t('customer.check_billing.results_hint', 'Pilih pelanggan untuk melihat detail tagihan') %>
<% matches.forEach(function(m){ %> <% }); %>
<%= t('customer.check_billing.col_customer', 'Pelanggan') %><%= t('customer.check_billing.unpaid', 'Belum Bayar') %><%= t('customer.check_billing.col_total', 'Total') %>
<%= m.customer_name %>
ID: <%= m.customer_id %><% if (m.customer_phone) { %> • WA: <%= m.customer_phone %><% } %>
<%= Number(m.unpaid_count || 0) %> Rp <%= Number(m.total_amount || 0).toLocaleString('id-ID') %> <%= t('customer.check_billing.view', 'Lihat') %>
<% } %> <% if (customer) { %>
<%= customer.name %>
ID: <%= customer.id %><% if (customer.phone) { %> • WA: <%= customer.phone %><% } %><% if (customer.package_name) { %> • Paket: <%= customer.package_name %><% } %>
<% const unpaidCount = unpaidInvoices ? unpaidInvoices.length : 0; %> <% if (unpaidCount > 0) { %> <%= unpaidCount %> <%= t('customer.check_billing.unpaid', 'Belum Bayar') %> <% } else { %> <%= t('customer.check_billing.paid', 'Lunas') %> <% } %>
<% const monthNames = ['','Jan','Feb','Mar','Apr','Mei','Jun','Jul','Agu','Sep','Okt','Nov','Des']; %> <% if (!unpaidInvoices || unpaidInvoices.length === 0) { %>
<%= t('customer.check_billing.all_paid', 'Semua tagihan sudah lunas.') %>
<% } else { %>
<%= t('customer.check_billing.unpaid_bills', 'Tagihan Belum Dibayar') %>
<% unpaidInvoices.forEach(function(inv, idx){ %> <% }); %>
<%= t('customer.check_billing.col_period', 'Periode') %><%= t('customer.check_billing.col_amount', 'Nominal') %><%= t('customer.check_billing.col_select', 'Pilih') %>
<%= monthNames[Number(inv.period_month)] %> <%= inv.period_year %>
INV-<%= inv.id %>
Rp <%= Number(inv.amount || 0).toLocaleString('id-ID') %> <%= idx === 0 ? 'required' : '' %>>
<%= t('customer.check_billing.payment', 'Pembayaran') %>
<%= t('customer.check_billing.pay_method', 'QRIS / Transfer Bank / E-Wallet') %> <%= t('customer.check_billing.pay_note', 'Metode dipilih di halaman pembayaran') %>
<% } %> <% const paidInvoices = (invoices || []).filter(function(i){ return i.status === 'paid'; }); %> <% if (paidInvoices.length > 0) { %>
<%= t('customer.check_billing.history', 'Riwayat (Lunas)') %>
<%= t('customer.check_billing.showing', 'Menampilkan') %> <%= Math.min(paidInvoices.length, 10) %> <%= t('customer.check_billing.data_latest', 'data terbaru') %>
<% paidInvoices.slice(0, 10).forEach(function(inv){ %> <% }); %>
<%= t('customer.check_billing.col_period', 'Periode') %><%= t('customer.check_billing.col_amount', 'Nominal') %><%= t('customer.check_billing.col_date', 'Tanggal') %>
<%= monthNames[Number(inv.period_month)] %> <%= inv.period_year %>
INV-<%= inv.id %>
Rp <%= Number(inv.amount || 0).toLocaleString('id-ID') %> <%= inv.paid_at ? new Date(inv.paid_at).toLocaleString('id-ID') : '-' %>
<% } %> <% } %>
© <%= new Date().getFullYear() %> <%= settings.company_header || '' %>