@extends('layouts.app')

@php
    use App\Models\Expense;
    $labels = config('tracker.labels');
@endphp

@section('title', config('tracker.title').' — Print')

@section('appbar')
    <header class="appbar no-print">
        <div class="appbar-inner">
            <div class="appbar-brand">
                <span class="brand-mark"><x-icon name="printer" :size="18"/></span>
                <span class="brand-text">
                    <span class="brand-name">প্রিন্ট প্রিভিউ</span>
                    <span class="brand-sub">যেভাবে কাগজে ছাপা হবে</span>
                </span>
            </div>
            <div class="appbar-actions">
                <button type="button" class="btn btn-primary btn-sm" onclick="window.print()">
                    <x-icon name="printer" :size="16"/>
                    প্রিন্ট করুন
                </button>
                <a class="btn btn-sm" href="{{ route('expenses.index') }}">ফিরে যান</a>
            </div>
        </div>
    </header>
@endsection

@section('content')
    @include('partials.banner')

    <div class="panel">
        <div class="table-wrap" style="display:block">
            <table class="sheet">
                <thead>
                    <tr>
                        <th class="col-date">{{ $labels['date'] }}</th>
                        <th class="col-cat">{{ $labels['category'] }}</th>
                        <th>{{ $labels['description'] }}</th>
                        <th class="col-pay">{{ $labels['payment_method'] }}</th>
                        <th class="col-remark">{{ $labels['remark'] }}</th>
                        <th class="col-amount">{{ $labels['amount'] }}</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($expenses as $expense)
                        <tr>
                            <td class="col-date tabular">{{ $expense->expense_date?->format('d/m/Y') }}</td>
                            <td class="col-cat">{{ $expense->categoryName() }}</td>
                            <td>{{ $expense->description }}</td>
                            <td class="col-pay">{{ $expense->payment_method }}</td>
                            <td class="col-remark tabular">{{ $expense->remark }}</td>
                            <td class="col-amount tabular">{{ Expense::money($expense->amount) }}</td>
                        </tr>
                    @endforeach
                </tbody>
                <tfoot>
                    <tr>
                        <td colspan="5" class="total-label">{{ $labels['total'] }}</td>
                        <td class="total-value tabular">{{ Expense::money($summary['total']) }}</td>
                    </tr>
                </tfoot>
            </table>
        </div>
    </div>
@endsection
