127 lines
8.3 KiB
PHP
127 lines
8.3 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('content')
|
|
<div class="max-w-3xl mx-auto space-y-6">
|
|
<!-- Page Header -->
|
|
<div class="flex items-center gap-4">
|
|
<a href="{{ isset($expense) ? route('expenses.show', $expense) : route('expenses.index') }}" class="p-2 text-gray-500 hover:text-gray-900 hover:bg-gray-100 rounded-lg transition-colors">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/></svg>
|
|
</a>
|
|
<h1 class="text-2xl font-bold text-gray-900">
|
|
{{ isset($expense) ? __('expense.edit_expense') : __('expense.create_expense') }}
|
|
</h1>
|
|
</div>
|
|
|
|
<!-- Form -->
|
|
<form method="POST" action="{{ isset($expense) ? route('expenses.update', $expense) : route('expenses.store') }}" class="bg-white rounded-xl border border-gray-200 p-6 space-y-5" enctype="multipart/form-data">
|
|
@csrf
|
|
@if(isset($expense))
|
|
@method('PUT')
|
|
@endif
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
|
|
<!-- Title -->
|
|
<div class="md:col-span-2">
|
|
<label for="title" class="block text-sm font-medium text-gray-700 mb-1">{{ __('expense.title') }} <span class="text-red-500">*</span></label>
|
|
<input type="text" id="title" name="title" value="{{ old('title', $expense?->title ?? '') }}"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500 focus:border-teal-500" required>
|
|
</div>
|
|
|
|
<!-- Project -->
|
|
<div>
|
|
<label for="project_id" class="block text-sm font-medium text-gray-700 mb-1">{{ __('expense.project') }} <span class="text-red-500">*</span></label>
|
|
<select id="project_id" name="project_id" class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500" required>
|
|
<option value="">{{ __('common.select') }}</option>
|
|
@foreach($projects as $project)
|
|
<option value="{{ $project->id }}" {{ old('project_id', $expense?->project_id ?? '') == $project->id ? 'selected' : '' }}>{{ $project->name }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Category -->
|
|
<div>
|
|
<label for="category" class="block text-sm font-medium text-gray-700 mb-1">{{ __('expense.category') }} <span class="text-red-500">*</span></label>
|
|
<select id="category" name="category" class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500" required>
|
|
@foreach($categories as $cat)
|
|
<option value="{{ $cat }}" {{ old('category', $expense?->category ?? '') === $cat ? 'selected' : '' }}>{{ __('expense.category_' . $cat) }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Amount -->
|
|
<div>
|
|
<label for="amount" class="block text-sm font-medium text-gray-700 mb-1">{{ __('expense.amount') }} <span class="text-red-500">*</span></label>
|
|
<input type="number" id="amount" name="amount" value="{{ old('amount', $expense?->original_amount ?? $expense?->amount ?? '') }}" step="0.01" min="0"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500" required>
|
|
</div>
|
|
|
|
<!-- Currency -->
|
|
<div>
|
|
<label for="currency_id" class="block text-sm font-medium text-gray-700 mb-1">{{ __('expense.currency') }} <span class="text-red-500">*</span></label>
|
|
<select id="currency_id" name="currency_id" class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500" required>
|
|
@foreach($currencies as $currency)
|
|
<option value="{{ $currency->id }}" {{ old('currency_id', $expense?->currency_id ?? $baseCurrency?->id ?? '') == $currency->id ? 'selected' : '' }}>
|
|
{{ $currency->code }} - {{ $currency->name }}
|
|
@if($currency->id === $baseCurrency?->id) ({{ __('expense.base_currency') }})@endif
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
<p class="mt-1 text-xs text-gray-400">{{ __('expense.currency_conversion_note') }}</p>
|
|
</div>
|
|
|
|
<!-- Expense Date -->
|
|
<div>
|
|
<label for="expense_date" class="block text-sm font-medium text-gray-700 mb-1">{{ __('expense.date') }} <span class="text-red-500">*</span></label>
|
|
<x-date-input name="expense_date" :value="old('expense_date', $expense?->expense_date?->format('Y-m-d'))" required="true" />
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500" required>
|
|
</div>
|
|
|
|
<!-- Invoice Number -->
|
|
<div>
|
|
<label for="invoice_number" class="block text-sm font-medium text-gray-700 mb-1">{{ __('expense.invoice_number') }}</label>
|
|
<input type="text" id="invoice_number" name="invoice_number" value="{{ old('invoice_number', $expense?->invoice_number ?? '') }}"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500">
|
|
</div>
|
|
|
|
<!-- Receipt -->
|
|
<div>
|
|
<label for="receipt" class="block text-sm font-medium text-gray-700 mb-1">{{ __('expense.receipt') }}</label>
|
|
@if(isset($expense) && $expense?->receipt_path)
|
|
<div class="mb-2 flex items-center gap-2">
|
|
<svg class="w-4 h-4 text-teal-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/></svg>
|
|
<a href="{{ Storage::url($expense->receipt_path) }}" target="_blank" class="text-sm text-teal-600 hover:text-teal-800 underline">{{ __('expense.current_receipt') }}</a>
|
|
</div>
|
|
@endif
|
|
<input type="file" id="receipt" name="receipt" accept="image/*,.pdf"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500">
|
|
</div>
|
|
|
|
<!-- Description -->
|
|
<div class="md:col-span-2">
|
|
<label for="description" class="block text-sm font-medium text-gray-700 mb-1">{{ __('expense.description') }}</label>
|
|
<textarea id="description" name="description" rows="3"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500">{{ old('description', $expense?->description ?? '') }}</textarea>
|
|
</div>
|
|
|
|
<!-- Additional Attachments -->
|
|
<div class="md:col-span-2">
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('attachment.additional_files') }}</label>
|
|
<input type="file" name="attachments[]" multiple accept=".jpg,.jpeg,.png,.pdf,.doc,.docx"
|
|
class="w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-lg file:border-0 file:text-sm file:font-medium file:bg-gray-50 file:text-gray-700 hover:file:bg-gray-100">
|
|
<p class="mt-1 text-xs text-gray-400">{{ __('attachment.max_files_help') }}</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Actions -->
|
|
<div class="flex items-center justify-end gap-3 pt-4 border-t border-gray-200">
|
|
<a href="{{ isset($expense) ? route('expenses.show', $expense) : route('expenses.index') }}" class="px-4 py-2 text-sm font-medium text-gray-700 bg-gray-100 rounded-lg hover:bg-gray-200 transition-colors">
|
|
{{ __('common.cancel') }}
|
|
</a>
|
|
<button type="submit" class="px-6 py-2 text-sm font-medium text-white bg-teal-600 rounded-lg hover:bg-teal-700 transition-colors">
|
|
{{ isset($expense) ? __('common.save_changes') : __('common.create') }}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
@endsection
|