@extends('backend.layouts.app')

@section('content')
<div class="container">
    <h1>Edit Travel Expense Log</h1>
    <form action="{{ route('travel.expense.logs.update', $travelExpenseLog->id) }}" method="POST">
        @csrf
        @method('PUT')

        <div class="form-group">
            <label for="travel_expense_id">Travel Expense</label>
            <select name="travel_expense_id" id="travel_expense_id" class="form-control" required>
                @foreach ($travelExpenses as $expense)
                    <option value="{{ $expense->id }}" {{ $expense->id == $travelExpenseLog->travel_expense_id ? 'selected' : '' }}>
                        {{ $expense->id }}
                    </option>
                @endforeach
            </select>
        </div>

        <div class="form-group">
            <label for="expense_category_id">Expense Category</label>
            <select name="expense_category_id" id="expense_category_id" class="form-control" required>
                @foreach ($expenseCategories as $category)
                    <option value="{{ $category->id }}" {{ $category->id == $travelExpenseLog->expense_category_id ? 'selected' : '' }}>
                        {{ $category->name }}
                    </option>
                @endforeach
            </select>
        </div>

        <div class="form-group">
            <label for="amount">Amount</label>
            <input type="number" name="amount" id="amount" class="form-control" step="0.01" value="{{ $travelExpenseLog->amount }}">
        </div>

        <div class="form-group">
            <label for="file_id">File</label>
            <select name="file_id" id="file_id" class="form-control">
                <option value="">N/A</option>
                @foreach ($uploads as $upload)
                    <option value="{{ $upload->id }}" {{ $upload->id == $travelExpenseLog->file_id ? 'selected' : '' }}>
                        {{ $upload->filename }}
                    </option>
                @endforeach
            </select>
        </div>

        <div class="form-group">
            <label for="remark">Remark</label>
            <textarea name="remark" id="remark" class="form-control">{{ $travelExpenseLog->remark }}</textarea>
        </div>

        <input type="hidden" name="company_id" value="{{ auth()->user()->company_id }}">
        <input type="hidden" name="branch_id" value="{{ auth()->user()->branch_id }}">

        <button type="submit" class="btn btn-primary">Update</button>
    </form>
</div>
@endsection
