{{-- resources/views/expenses/show.blade.php --}}
@extends('layouts.app')

@section('title', 'Expense Details')
@section('header', 'Expense Details')

@section('content')
<div class="card">
    <div class="card-header">
        <h5 class="mb-0">
            <i class="fas fa-receipt me-2"></i>Expense Information
        </h5>
    </div>
    <div class="card-body">
        <div class="row">
            <div class="col-md-6">
                <table class="table table-bordered">
                    <tr>
                        <th width="30%">Expense No:</th>
                        <td>{{ $expense->expense_no }}</td>
                    </tr>
                    <tr>
                        <th>Title:</th>
                        <td>{{ $expense->title }}</td>
                    </tr>
                    <tr>
                        <th>Category:</th>
                        <td>{{ $expense->category->name ?? 'N/A' }}</td>
                    </tr>
                    <tr>
                        <th>Amount:</th>
                        <td><strong class="text-danger">${{ number_format($expense->amount, 2) }}</strong></td>
                    </tr>
                    <tr>
                        <th>Expense Date:</th>
                        <td>{{ $expense->expense_date->format('F d, Y') }}</td>
                    </tr>
                </table>
            </div>
            <div class="col-md-6">
                <table class="table table-bordered">
                    <tr>
                        <th width="30%">Payment Method:</th>
                        <td>{{ ucfirst($expense->payment_method) }}</td>
                    </tr>
                    <tr>
                        <th>Status:</th>
                        <td>
                            @if($expense->status == 'approved')
                                <span class="badge bg-success">Approved</span>
                            @elseif($expense->status == 'pending')
                                <span class="badge bg-warning">Pending</span>
                            @else
                                <span class="badge bg-danger">Rejected</span>
                            @endif
                        </td>
                    </tr>
                    <tr>
                        <th>Created By:</th>
                        <td>{{ $expense->user->name }}</td>
                    </tr>
                    <tr>
                        <th>Created At:</th>
                        <td>{{ $expense->created_at->format('F d, Y H:i') }}</td>
                    </tr>
                    <tr>
                        <th>Last Updated:</th>
                        <td>{{ $expense->updated_at->format('F d, Y H:i') }}</td>
                    </tr>
                </table>
            </div>
            <div class="col-md-12">
                <div class="card">
                    <div class="card-header">
                        <strong>Description</strong>
                    </div>
                    <div class="card-body">
                        {{ $expense->description ?? 'No description provided.' }}
                    </div>
                </div>
            </div>
            @if($expense->receipt)
            <div class="col-md-12 mt-3">
                <div class="card">
                    <div class="card-header">
                        <strong>Receipt</strong>
                    </div>
                    <div class="card-body text-center">
                        <a href="{{ Storage::url($expense->receipt) }}" target="_blank" class="btn btn-primary">
                            <i class="fas fa-download"></i> View Receipt
                        </a>
                    </div>
                </div>
            </div>
            @endif
        </div>
        
        <div class="mt-3">
            <a href="{{ route('expenses.index') }}" class="btn btn-secondary">
                <i class="fas fa-arrow-left"></i> Back
            </a>
            <a href="{{ route('expenses.edit', $expense) }}" class="btn btn-warning">
                <i class="fas fa-edit"></i> Edit
            </a>
        </div>
    </div>
</div>
@endsection