NIM_E31220400/resources/views/laporan/semua.blade.php

106 lines
5.3 KiB
PHP

@extends('layouts.app')
@section('content')
<div style="background-color: #e0e0e0; width: 100%; min-height: 100vh; border-radius: 15px; padding: 1rem;">
<div style="background-color: #000; color: #fff; padding: 0.1rem; border-radius: 0.5rem;">
<h1 class="m-0">Laporan Cetak Semua</h1>
</div>
<div class="container mt-4">
<div class="mb-3">
<a href="{{ route('laporan.exportPdf') }}" class="btn btn-primary">Export PDF</a>
<a href="{{ route('dashboard') }}" class="btn btn-secondary">Kembali</a>
</div>
<div class="card p-4 border border-secondary" style="border-radius: 15px; background-color: #fff; max-height: 70vh; overflow-y: auto;">
<div class="table-responsive">
<table class="table table-bordered table-hover mb-0">
<thead class="table-dark text-center">
<tr>
<th>No</th>
<th>Tanggal</th>
<th>Nama</th>
<th>Kategori</th>
<th>Quantity</th>
<th>Harga Satuan</th>
<th>Subtotal</th>
<th>Masuk</th>
<th>Keluar</th>
<th>Keterangan</th>
</tr>
</thead>
<tbody>
@php
$no = 1;
$totalMasuk = 0;
$totalKeluar = 0;
$gabungan = collect($pemasukan)->map(function($item) {
$item->jenis = 'masuk';
return $item;
})->merge(
collect($pengeluaran)->map(function($item) {
$item->jenis = 'keluar';
return $item;
})
)->sortByDesc('tanggal');
@endphp
@forelse($gabungan as $item)
@php
$qty = $item->quantity ?? 1;
$harga = $item->harga ?? $item->jumlah; // fallback kalau harga tidak ada
$subtotal = $item->kategori === 'barang' ? ($qty * $harga) : $item->jumlah;
if ($item->jenis == 'masuk') {
$totalMasuk += $subtotal;
} else {
$totalKeluar += $subtotal;
}
@endphp
<tr>
<td class="text-center">{{ $no++ }}</td>
<td>{{ \Carbon\Carbon::parse($item->tanggal)->format('d-m-Y') }}</td>
<td>{{ $item->nama }}</td>
<td class="text-center">{{ ucfirst($item->kategori) }}</td>
<td class="text-center">{{ $item->kategori === 'barang' ? $qty : '-' }}</td>
<td class="text-end">{{ $item->kategori === 'barang' ? 'Rp ' . number_format($harga, 0, ',', '.') : '-' }}</td>
<td class="text-end">Rp {{ number_format($subtotal, 0, ',', '.') }}</td>
<td class="text-end">
{{ $item->jenis == 'masuk' ? 'Rp ' . number_format($subtotal, 0, ',', '.') : '-' }}
</td>
<td class="text-end">
{{ $item->jenis == 'keluar' ? 'Rp ' . number_format($subtotal, 0, ',', '.') : '-' }}
</td>
<td>{{ $item->keterangan ?: '-' }}</td>
</tr>
@empty
<tr>
<td colspan="10" class="text-center">Tidak ada data ditemukan.</td>
</tr>
@endforelse
</tbody>
<tfoot>
<tr class="fw-bold bg-light">
<td colspan="7" class="text-end">Total Masuk</td>
<td class="text-end">Rp {{ number_format($totalMasuk, 0, ',', '.') }}</td>
<td colspan="2"></td>
</tr>
<tr class="fw-bold bg-light">
<td colspan="8" class="text-end">Total Keluar</td>
<td class="text-end">Rp {{ number_format($totalKeluar, 0, ',', '.') }}</td>
<td></td>
</tr>
<tr class="fw-bold bg-success text-white">
<td colspan="6" class="text-end">Saldo Akhir</td>
<td class="text-end">Rp {{ number_format($totalMasuk - $totalKeluar, 0, ',', '.') }}</td>
<td colspan="3"></td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
@endsection