@extends('backend.layouts.app')

@section('content')
<div class="container">
    <h1>Travel Expense Logs</h1>
    <a href="{{ route('travel.expense.logs.create') }}" class="btn btn-primary">Add New Travel Expense Log</a>
    
    <table class="table mt-4">
        <thead>
            <tr>
                <th>ID</th>
                <th>Travel Expense</th>
                <th>Expense Category</th>
                <th>Amount</th>
                <th>File</th>
                <th>Remark</th>
                <th>Actions</th>
            </tr>
        </thead>
        <tbody>
            @foreach ($travelExpenseLogs as $log)
                <tr>
                    <td>{{ $log->id }}</td>
                    <td>{{ $log->travelExpense->id ?? 'N/A' }}</td>
                    <td>{{ $log->expenseCategory->name ?? 'N/A' }}</td>
                    <td>${{ number_format($log->amount, 2) }}</td>
                    <td>{{ $log->file->filename ?? 'N/A' }}</td>
                    <td>{{ $log->remark ?? 'N/A' }}</td>
                    <td>
                        <a href="{{ route('travel.expense.logs.show', $log->id) }}" class="btn btn-info btn-sm">View</a>
                        <a href="{{ route('travel.expense.logs.edit', $log->id) }}" class="btn btn-warning btn-sm">Edit</a>
                        <form action="{{ route('travel.expense.logs.destroy', $log->id) }}" method="POST" style="display:inline;">
                            @csrf
                            @method('DELETE')
                            <button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')">Delete</button>
                        </form>
                    </td>
                </tr>
            @endforeach
        </tbody>
    </table>
    
    {{ $travelExpenseLogs->links() }}
</div>
@endsection
