vernova/resources/views/petty-cashes/form.blade.php
2026-07-26 19:58:27 +03:30

109 lines
7.1 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($pettyCash) ? route('petty-cashes.show', $pettyCash) : route('petty-cashes.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($pettyCash) ? __('pettyCash.edit') : __('pettyCash.create') }}
</h1>
</div>
<!-- Form -->
<form method="POST" action="{{ isset($pettyCash) ? route('petty-cashes.update', $pettyCash) : route('petty-cashes.store') }}" enctype="multipart/form-data" class="bg-white rounded-xl border border-gray-200 p-6 space-y-5">
@csrf
@if(isset($pettyCash))
@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">{{ __('pettyCash.title') }} <span class="text-red-500">*</span></label>
<input type="text" id="title" name="title" value="{{ old('title', $pettyCash?->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">{{ __('pettyCash.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.all') }}</option>
@foreach($projects as $project)
<option value="{{ $project->id }}" {{ old('project_id', $pettyCash?->project_id ?? '') == $project->id ? 'selected' : '' }}>{{ $project->name }}</option>
@endforeach
</select>
</div>
<!-- Amount -->
<div>
<label for="amount" class="block text-sm font-medium text-gray-700 mb-1">{{ __('pettyCash.amount') }} <span class="text-red-500">*</span></label>
<input type="number" id="amount" name="amount" value="{{ old('amount', $pettyCash?->original_amount ?? $pettyCash?->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">{{ __('pettyCash.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', $pettyCash?->currency_id ?? $baseCurrency?->id ?? '') == $currency->id ? 'selected' : '' }}>
{{ $currency->code }} - {{ $currency->name }}
@if($currency->id === $baseCurrency?->id) ({{ __('pettyCash.base_currency') }})@endif
</option>
@endforeach
</select>
<p class="mt-1 text-xs text-gray-400">{{ __('pettyCash.currency_conversion_note') }}</p>
</div>
<!-- Request Date -->
<div>
<x-date-input name="request_date" :value="old('request_date', $pettyCash?->request_date?->format('Y-m-d'))" required="true" />
</div>
<!-- Description -->
<div class="md:col-span-2">
<label for="description" class="block text-sm font-medium text-gray-700 mb-1">{{ __('pettyCash.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', $pettyCash?->description ?? '') }}</textarea>
</div>
<!-- Receipt Upload -->
<div class="md:col-span-2">
<label for="receipt" class="block text-sm font-medium text-gray-700 mb-1">{{ __('pettyCash.receipt') }}</label>
@if(isset($pettyCash) && $pettyCash?->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($pettyCash->receipt_path) }}" target="_blank" class="text-sm text-teal-600 hover:text-teal-800 underline">{{ __('pettyCash.current_receipt') }}</a>
</div>
@endif
<input type="file" id="receipt" name="receipt" 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-teal-50 file:text-teal-700 hover:file:bg-teal-100">
<p class="mt-1 text-xs text-gray-400">{{ __('pettyCash.receipt_help') }}</p>
</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($pettyCash) ? route('petty-cashes.show', $pettyCash) : route('petty-cashes.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($pettyCash) ? __('common.save') : __('common.create') }}
</button>
</div>
</form>
</div>
@endsection