vernova/resources/views/inventory/items.blade.php
2026-07-26 19:58:27 +03:30

121 lines
8.5 KiB
PHP

@extends('layouts.app')
@section('content')
<div class="space-y-6">
<!-- Page Header -->
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
<h1 class="text-2xl font-bold text-gray-900">{{ __('inventory.items') }}</h1>
<a href="{{ route('inventory.items.create') }}"
class="inline-flex items-center gap-2 px-4 py-2 bg-teal-600 text-white text-sm font-medium rounded-lg hover:bg-teal-700 transition-colors">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/></svg>
{{ __('inventory.create_item') ?? 'افزودن قلم' }}
</a>
</div>
<!-- Filters -->
<div class="bg-white rounded-xl border border-gray-200 p-4">
<form method="GET" action="{{ route('inventory.items') }}" class="flex flex-wrap gap-3 items-end">
<div class="w-52">
<label class="block text-xs font-medium text-gray-500 mb-1">{{ __('common.search') }}</label>
<input type="text" name="search" value="{{ request('search') }}"
placeholder="{{ __('inventory.item_name') }} / {{ __('inventory.item_code') }}"
class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500">
</div>
<div class="w-40">
<label class="block text-xs font-medium text-gray-500 mb-1">{{ __('inventory.category') }}</label>
<select name="category" class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500">
<option value="">{{ __('common.all') }}</option>
@foreach($categories as $cat)
<option value="{{ $cat }}" {{ request('category') === $cat ? 'selected' : '' }}>{{ $cat }}</option>
@endforeach
</select>
</div>
<div class="w-32">
<label class="block text-xs font-medium text-gray-500 mb-1">{{ __('common.status') }}</label>
<select name="is_active" class="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-teal-500">
<option value="">{{ __('common.all') }}</option>
<option value="1" {{ request('is_active') === '1' ? 'selected' : '' }}>{{ __('inventory.active') }}</option>
<option value="0" {{ request('is_active') === '0' ? 'selected' : '' }}>{{ __('inventory.inactive') }}</option>
</select>
</div>
<button type="submit" class="px-4 py-2 bg-gray-100 text-gray-700 text-sm font-medium rounded-lg hover:bg-gray-200 transition-colors">
{{ __('common.filter') }}
</button>
</form>
</div>
<!-- Items List -->
<div class="bg-white rounded-xl border border-gray-200 overflow-hidden">
<div class="overflow-x-auto">
<table class="w-full">
<thead class="bg-gray-50 border-b border-gray-200">
<tr>
<th class="px-5 py-3 text-start text-xs font-medium text-gray-500">{{ __('inventory.item_code') }}</th>
<th class="px-5 py-3 text-start text-xs font-medium text-gray-500">{{ __('inventory.item_name') }}</th>
<th class="px-5 py-3 text-start text-xs font-medium text-gray-500">{{ __('inventory.category') }}</th>
<th class="px-5 py-3 text-start text-xs font-medium text-gray-500">{{ __('inventory.unit') }}</th>
<th class="px-5 py-3 text-start text-xs font-medium text-gray-500">{{ __('inventory.current_stock') }}</th>
<th class="px-5 py-3 text-start text-xs font-medium text-gray-500">{{ __('common.status') }}</th>
<th class="px-5 py-3 text-start text-xs font-medium text-gray-500"></th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
@forelse($items as $item)
<tr class="hover:bg-gray-50 transition-colors">
<td class="px-5 py-3 text-sm text-gray-600 font-mono">{{ $item->code ?? '-' }}</td>
<td class="px-5 py-3 text-sm font-medium text-gray-900">{{ $item->name }}</td>
<td class="px-5 py-3 text-sm text-gray-600">{{ $item->category ?? '-' }}</td>
<td class="px-5 py-3 text-sm text-gray-600">{{ $item->unit ?? '-' }}</td>
<td class="px-5 py-3">
@php
$stock = $item->current_stock ?? 0;
$minStock = $item->min_stock ?? 0;
@endphp
<span class="text-sm font-medium {{ $stock <= 0 ? 'text-red-600' : ($stock <= $minStock ? 'text-amber-600' : 'text-emerald-600') }}">
{{ persian_num(number_format($stock, 2)) }}
</span>
@if($stock <= $minStock && $stock > 0)
<svg class="w-3.5 h-3.5 inline text-amber-500 ms-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4.5c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z"/></svg>
@elseif($stock <= 0)
<svg class="w-3.5 h-3.5 inline text-red-500 ms-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4.5c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z"/></svg>
@endif
</td>
<td class="px-5 py-3">
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium
{{ $item->is_active ? 'bg-emerald-50 text-emerald-700' : 'bg-gray-100 text-gray-500' }}">
{{ $item->is_active ? __('inventory.active') : __('inventory.inactive') }}
</span>
</td>
<td class="px-5 py-3">
<div class="flex items-center gap-1">
<a href="{{ route('inventory.items.edit', $item) }}" class="p-1.5 text-gray-400 hover:text-teal-600 hover:bg-teal-50 rounded-lg transition-colors" title="{{ __('inventory.edit_item') }}">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/></svg>
</a>
@if($item->inventoryTransactions()->count() === 0)
<form method="POST" action="{{ route('inventory.items.destroy', $item) }}" onsubmit="return confirm('{{ __('common.confirm_delete') ?? 'آیا مطمئن هستید؟' }}')">
@csrf @method('DELETE')
<button type="submit" class="p-1.5 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition-colors" title="{{ __('common.delete') }}">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/></svg>
</button>
</form>
@endif
</div>
</td>
</tr>
@empty
<tr>
<td colspan="7" class="text-center py-12 text-gray-500">{{ __('inventory.no_items') }}</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
<!-- Pagination -->
<div class="flex justify-center">
{{ $items->withQueryString()->links() }}
</div>
</div>
@endsection