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

158 lines
10 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.inventory') ?? 'انبار' }}</h1>
</div>
<!-- Summary Cards -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
<!-- Total Items -->
<div class="bg-white rounded-xl border border-gray-200 p-5">
<div class="flex items-center gap-3">
<div class="w-10 h-10 bg-teal-50 rounded-lg flex items-center justify-center flex-shrink-0">
<svg class="w-5 h-5 text-teal-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"/></svg>
</div>
<div>
<p class="text-xs text-gray-500">{{ __('inventory.items') }}</p>
<p class="text-xl font-bold text-gray-900">{{ persian_num($totalItems) }}</p>
</div>
</div>
</div>
<!-- Active Items -->
<div class="bg-white rounded-xl border border-gray-200 p-5">
<div class="flex items-center gap-3">
<div class="w-10 h-10 bg-emerald-50 rounded-lg flex items-center justify-center flex-shrink-0">
<svg class="w-5 h-5 text-emerald-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
</div>
<div>
<p class="text-xs text-gray-500">{{ __('inventory.active_items') ?? 'اقلام فعال' }}</p>
<p class="text-xl font-bold text-gray-900">{{ persian_num($activeItems) }}</p>
</div>
</div>
</div>
<!-- Active Warehouses -->
<div class="bg-white rounded-xl border border-gray-200 p-5">
<div class="flex items-center gap-3">
<div class="w-10 h-10 bg-sky-50 rounded-lg flex items-center justify-center flex-shrink-0">
<svg class="w-5 h-5 text-sky-600" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4"/></svg>
</div>
<div>
<p class="text-xs text-gray-500">{{ __('inventory.warehouses') }}</p>
<p class="text-xl font-bold text-gray-900">{{ persian_num($totalWarehouses) }}</p>
</div>
</div>
</div>
<!-- Low Stock -->
<div class="bg-white rounded-xl border border-gray-200 p-5">
<div class="flex items-center gap-3">
<div class="w-10 h-10 bg-amber-50 rounded-lg flex items-center justify-center flex-shrink-0">
<svg class="w-5 h-5 text-amber-600" 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>
</div>
<div>
<p class="text-xs text-gray-500">{{ __('inventory.low_stock_items') ?? 'موجودی کم' }}</p>
<p class="text-xl font-bold {{ $lowStockItems->count() > 0 ? 'text-amber-600' : 'text-gray-900' }}">{{ persian_num($lowStockItems->count()) }}</p>
</div>
</div>
</div>
</div>
<!-- Quick Action Buttons -->
<div class="flex flex-wrap gap-3">
<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>
<a href="{{ route('inventory.warehouses.create') }}"
class="inline-flex items-center gap-2 px-4 py-2 bg-sky-600 text-white text-sm font-medium rounded-lg hover:bg-sky-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_warehouse') ?? 'افزودن انبار' }}
</a>
<a href="{{ route('inventory.transactions') }}"
class="inline-flex items-center gap-2 px-4 py-2 bg-gray-100 text-gray-700 text-sm font-medium rounded-lg hover:bg-gray-200 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="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/></svg>
{{ __('inventory.transactions') ?? 'رسید و حواله' }}
</a>
</div>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<!-- Recent Transactions -->
<div class="bg-white rounded-xl border border-gray-200 overflow-hidden">
<div class="px-5 py-4 border-b border-gray-200 flex items-center justify-between">
<h3 class="text-sm font-bold text-gray-900">{{ __('inventory.recent_transactions') ?? 'آخرین تراکنش‌ها' }}</h3>
<a href="{{ route('inventory.transactions') }}" class="text-xs font-medium text-teal-600 hover:text-teal-700">{{ __('common.view_all') ?? 'مشاهده همه' }}</a>
</div>
@if($recentTransactions->count() > 0)
<div class="divide-y divide-gray-100">
@foreach($recentTransactions as $txn)
<div class="px-5 py-3 flex items-center gap-3">
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium
{{ $txn->type === 'in' ? 'bg-emerald-50 text-emerald-700' :
($txn->type === 'out' ? 'bg-red-50 text-red-700' :
($txn->type === 'transfer' ? 'bg-purple-50 text-purple-700' :
($txn->type === 'return' ? 'bg-sky-50 text-sky-700' : 'bg-amber-50 text-amber-700'))) }}">
{{ __('inventory.type_' . $txn->type) }}
</span>
<div class="flex-1 min-w-0">
<p class="text-sm font-medium text-gray-900 truncate">{{ $txn->item?->name ?? '-' }}</p>
<p class="text-xs text-gray-400">{{ $txn->warehouse?->name ?? '-' }}</p>
</div>
<div class="text-end">
<p class="text-sm font-medium {{ $txn->type === 'out' ? 'text-red-600' : 'text-emerald-600' }}">
{{ $txn->type === 'out' ? '-' : '+' }}{{ persian_num(number_format($txn->quantity, 2)) }}
</p>
<p class="text-xs text-gray-400">{{ $txn->created_at ? calendar_date($txn->created_at) : '' }}</p>
</div>
</div>
@endforeach
</div>
@else
<div class="px-5 py-8 text-center text-sm text-gray-400">
{{ __('inventory.no_transactions') ?? 'تراکنشی ثبت نشده است' }}
</div>
@endif
</div>
<!-- Low Stock Items -->
<div class="bg-white rounded-xl border border-gray-200 overflow-hidden">
<div class="px-5 py-4 border-b border-gray-200 flex items-center justify-between">
<h3 class="text-sm font-bold text-gray-900">{{ __('inventory.low_stock_alert') ?? 'هشدار موجودی' }}</h3>
<a href="{{ route('inventory.items') }}" class="text-xs font-medium text-teal-600 hover:text-teal-700">{{ __('common.view_all') ?? 'مشاهده همه' }}</a>
</div>
@if($lowStockItems->count() > 0)
<div class="divide-y divide-gray-100">
@foreach($lowStockItems as $item)
<div class="px-5 py-3 flex items-center gap-3">
<div class="w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 {{ $item->current_stock <= 0 ? 'bg-red-50' : 'bg-amber-50' }}">
<svg class="w-4 h-4 {{ $item->current_stock <= 0 ? 'text-red-500' : 'text-amber-500' }}" 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>
</div>
<div class="flex-1 min-w-0">
<p class="text-sm font-medium text-gray-900 truncate">{{ $item->name }}</p>
<p class="text-xs text-gray-400">{{ $item->code ?? '-' }} &middot; {{ $item->unit ?? '-' }}</p>
</div>
<div class="text-end">
<p class="text-sm font-bold {{ $item->current_stock <= 0 ? 'text-red-600' : 'text-amber-600' }}">
{{ persian_num(number_format($item->current_stock, 2)) }}
</p>
<p class="text-xs text-gray-400">{{ __('inventory.min_stock') ?? 'حداقل' }}: {{ persian_num(number_format($item->min_stock ?? 0, 2)) }}</p>
</div>
</div>
@endforeach
</div>
@else
<div class="px-5 py-8 text-center">
<svg class="w-10 h-10 mx-auto text-emerald-300 mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
<p class="text-sm text-gray-400">{{ __('inventory.all_stock_ok') ?? 'همه اقلام موجودی کافی دارند' }}</p>
</div>
@endif
</div>
</div>
</div>
@endsection