2025-04-27 22:36:03 +07:00

144 lines
9.0 KiB
PHP

@extends('layouts.app')
@section('title', 'Daftar Billing')
@section('content')
<div class="flex justify-center items-start mt-16">
<div class="container max-w-6xl px-6 mx-auto">
@include('partials.messages')
<div class="flex justify-between items-center mb-6">
<h2 class="text-lg font-semibold text-gray-700 dark:text-gray-200">
Daftar Billing
</h2>
<a href="{{ route('billing.create') }}"
class="px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple">
<div class="flex items-center">
<svg class="w-4 h-4 mr-2" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd"
d="M10 5a1 1 0 011 1v3h3a1 1 0 110 2h-3v3a1 1 0 11-2 0v-3H6a1 1 0 110-2h3V6a1 1 0 011-1z"
clip-rule="evenodd" />
</svg>
<span>Tambah Billing Baru</span>
</div>
</a>
</div>
<div class="w-full overflow-hidden rounded-lg shadow-xs">
<div class="w-full overflow-x-auto">
<table class="w-full whitespace-no-wrap">
<thead>
<tr
class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800">
<th class="px-4 py-3">ID Billing</th>
<th class="px-4 py-3">ID Registrasi</th>
<th class="px-4 py-3">Tanggal</th>
<th class="px-4 py-3">Total Biaya</th>
<th class="px-4 py-3">Dibayar</th>
<th class="px-4 py-3">Sisa</th>
<th class="px-4 py-3">Status</th>
<th class="px-4 py-3">Aksi</th>
</tr>
</thead>
<tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800">
@forelse($billings as $billing)
<tr class="text-gray-700 dark:text-gray-400">
<td class="px-4 py-3 text-sm">{{ $billing->IdBilling }}</td>
<td class="px-4 py-3 text-sm">{{ $billing->IdRegistrasi }}</td>
<td class="px-4 py-3 text-sm">{{ date('d/m/Y', strtotime($billing->TanggalBilling)) }}
</td>
<td class="px-4 py-3 text-sm">Rp {{ number_format($billing->TotalBiaya, 0, ',', '.') }}
</td>
<td class="px-4 py-3 text-sm">Rp {{ number_format($billing->Dibayar, 0, ',', '.') }}
</td>
<td class="px-4 py-3 text-sm">Rp {{ number_format($billing->Sisa, 0, ',', '.') }}</td>
<td class="px-4 py-3 text-sm">
@if ($billing->StatusPembayaran == 'Lunas')
<span
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
Lunas
</span>
@else
<span
class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">
Belum Lunas
</span>
@endif
</td>
<td class="px-4 py-3 text-sm">
<div class="flex items-center space-x-4 text-sm">
<a href="{{ route('billing.show', $billing->IdBilling) }}"
class="flex items-center justify-between px-2 py-2 text-sm font-medium leading-5 text-purple-600 rounded-lg dark:text-gray-400 focus:outline-none focus:shadow-outline-gray"
aria-label="Detail">
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
<path d="M1 10s3-7 9-7 9 7 9 7-3 7-9 7-9-7-9-7z" />
<path d="M10 13a3 3 0 100-6 3 3 0 000 6z" />
</svg>
</a>
<a href="{{ route('billing.edit', $billing->IdBilling) }}"
class="flex items-center justify-between px-2 py-2 text-sm font-medium leading-5 text-purple-600 rounded-lg dark:text-gray-400 focus:outline-none focus:shadow-outline-gray"
aria-label="Edit">
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
<path
d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z" />
</svg>
</a>
<form id="delete-form-{{ $billing->IdBilling }}"
action="{{ route('billing.destroy', $billing->IdBilling) }}" method="POST"
class="inline-block">
@csrf
@method('DELETE')
<button type="button" onclick="confirmDelete('{{ $billing->IdBilling }}')"
class="flex items-center justify-between px-2 py-2 text-sm font-medium leading-5 text-purple-600 rounded-lg dark:text-gray-400 focus:outline-none focus:shadow-outline-gray"
aria-label="Delete">
<svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd"
d="M6 2a1 1 0 00-.894.553L4.618 4H3a1 1 0 000 2h1v10a2 2 0 002 2h8a2 2 0 002-2V6h1a1 1 0 100-2h-1.618l-.488-1.447A1 1 0 0014 2H6zm2 4a1 1 0 112 0v8a1 1 0 11-2 0V6zm4 0a1 1 0 112 0v8a1 1 0 11-2 0V6z"
clip-rule="evenodd" />
</svg>
</button>
</form>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="8" class="px-4 py-3 text-center text-gray-500">
Tidak ada data billing
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<!-- Pagination -->
<div class="px-4 py-3 border-t dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-500">
{{ $billings->links() }}
</div>
</div>
</div>
</div>
@endsection
@section('scripts')
<script>
const confirmDelete = (IdBilling) => {
Swal.fire({
title: "Hapus billing?",
text: "Billing yang dihapus tidak bisa dikembalikan. Yakin ingin lanjut?",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Ya, hapus!",
cancelButtonText: "Batal"
}).then((result) => {
if (result.isConfirmed) {
document.getElementById(`delete-form-${IdBilling}`).submit();
}
});
}
</script>
@endsection