@extends('backEnd.layouts.master')
@section('title','Add Office Expense')
@section('css')
<link href="{{asset('public/backEnd')}}/assets/libs/select2/css/select2.min.css" rel="stylesheet" type="text/css" />
<link href="{{asset('public/backEnd')}}/assets/css/switchery.min.css" rel="stylesheet" type="text/css" />
@endsection
@section('content')
<div class="container-fluid">
    
    <!-- start page title -->
    <div class="row">
        <div class="col-12">
            <div class="page-title-box">
                <div class="page-title-right">
                    <a href="{{route('office-expenses.index')}}" class="btn btn-primary rounded-pill">Manage</a>
                </div>
                <h4 class="page-title">Add Office Expense</h4>
            </div>
        </div>
    </div>       
    <!-- end page title --> 
   <div class="row justify-content-center">
    <div class="col-lg-8">
        <div class="card">
            <div class="card-body">
                <form action="{{route('office-expenses.store')}}" method="POST" class="row" data-parsley-validate="">
                    @csrf
                    
                    <div class="col-sm-12">
                        <div class="form-group mb-3">
                            <label for="expense_title" class="form-label">Expense Title *</label>
                            <input type="text" class="form-control @error('expense_title') is-invalid @enderror" 
                                   name="expense_title" value="{{ old('expense_title') }}" id="expense_title" 
                                   placeholder="e.g., Office Cleaning, Monthly Internet Bill" required>
                            @error('expense_title')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                            @enderror
                        </div>
                    </div>
                    
                    <div class="col-sm-12">
                        <div class="form-group mb-3">
                            <label for="expense_category" class="form-label">Category *</label>
                            <select class="form-control @error('expense_category') is-invalid @enderror" 
                                    name="expense_category" id="expense_category" required>
                                <option value="">Select Category</option>
                                @foreach($categories as $category)
                                    <option value="{{ $category }}" @if(old('expense_category') == $category) selected @endif>{{ $category }}</option>
                                @endforeach
                            </select>
                            @error('expense_category')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                            @enderror
                        </div>
                    </div>
                    
                    <div class="col-sm-12">
                        <div class="form-group mb-3">
                            <label for="amount" class="form-label">Amount (Tk.) *</label>
                            <input type="number" class="form-control @error('amount') is-invalid @enderror" 
                                   name="amount" value="{{ old('amount') }}" id="amount" 
                                   placeholder="0.00" min="0.01" step="0.01" required>
                            @error('amount')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                            @enderror
                        </div>
                    </div>
                    
                    <div class="col-sm-12">
                        <div class="form-group mb-3">
                            <label for="expense_date" class="form-label">Expense Date *</label>
                            <input type="date" class="form-control @error('expense_date') is-invalid @enderror" 
                                   name="expense_date" value="{{ old('expense_date', date('Y-m-d')) }}" 
                                   id="expense_date" required>
                            @error('expense_date')
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $message }}</strong>
                                </span>
                            @enderror
                        </div>
                    </div>
                    
                    <div class="col-sm-12">
                        <div class="form-group mb-3">
                            <label for="description" class="form-label">Description</label>
                            <textarea class="form-control" name="description" id="description" rows="4" 
                                      placeholder="Add additional details about this expense (optional)">{{ old('description') }}</textarea>
                        </div>
                    </div>
                    
                    <div class="col-sm-12">
                        <button type="submit" class="btn btn-success rounded-pill">
                            <i class="fe-save"></i> Save Expense
                        </button>
                        <a href="{{route('office-expenses.index')}}" class="btn btn-secondary rounded-pill">
                            <i class="fe-x"></i> Cancel
                        </a>
                    </div>
                </form>
            </div>
        </div>
    </div>
   </div>
</div>

@endsection
