@extends('layouts.panel') @section('content')
بازگشت

اطلاعات پایه

درخواست‌دهنده
{{ optional($purchaseRequest->requester)->name ?? '—' }}
وضعیت
{{ $purchaseRequest->status_label }}
تاریخ ایجاد
{{ $purchaseRequest->inquiry_date ? jdate($purchaseRequest->inquiry_date)->format('Y/m/d') : (jdate($purchaseRequest->created_at)->format('Y/m/d H:i')) }}
نوع خرید
{{ $purchaseRequest->purchase_type === 'official' ? 'رسمی' : 'غیررسمی' }}
مقصد
{{ $purchaseRequest->destination === 'warehouse' ? 'برای انبار' : 'برای فروش' }}
بازاریاب
@if($purchaseRequest->destination === 'warehouse') انبار @elseif($purchaseRequest->destination === 'sales') {{ $purchaseRequest->salesUser ? ($purchaseRequest->salesUser->full_name ?? $purchaseRequest->salesUser->name ?? 'واحد فروش') : 'واحد فروش' }} @else — @endif

محصولات و استعلام‌ها

@forelse($purchaseRequest->items as $item)
{{ optional($item->product)->name ?? ($item->product_name ?? '—') }}
مقدار: {{ number_format($item->quantity) }} {{ $item->unit }}
@forelse($item->offers as $offer) @empty @endforelse
تامین‌کننده قیمت برند کشور انتخاب
{{ optional($offer->supplier)->name ?? '—' }} {{ $offer->price ? number_format($offer->price) . ' تومان' : '—' }} @if($offer->price)
فی قیمت
@endif
{{ $offer->brand ?: '—' }} {{ $offer->country ?? '—' }} @if($offer->is_selected)انتخاب‌شده@endif
استعلامی ثبت نشده است.
@empty
محصولی ثبت نشده است.
@endforelse

جزئیات کامل استعلام‌های ثبت‌شده

@forelse($purchaseRequest->items as $item)
{{ optional($item->product)->name ?? ($item->product_name ?? '—') }}
@forelse($item->offers as $offer) @empty @endforelse
تامین‌کننده قیمت واحد پول برند کشور گرید بسته‌بندی تاریخ استعلام انتخاب‌شده؟
{{ optional($offer->supplier)->name ?? '—' }} {{ $offer->price ? number_format($offer->price) . ' تومان' : '—' }} @if($offer->price)
فی قیمت
@endif
{{ $offer->currency ?? 'تومان' }} {{ $offer->brand ?: '—' }} {{ $offer->country ?: '—' }} {{ $offer->grade ?: '—' }} {{ $offer->packaging ?: '—' }} {{ $offer->quoted_at ? jdate($offer->quoted_at)->format('Y/m/d') : '—' }} @if($offer->is_selected) بلی @else خیر @endif
جزئیاتی ثبت نشده است.
@php $conditions = collect($item->offers) ->map(function($o){ $text = trim((string)($o->conditions ?? '')); if ($text === '') { $text = trim((string)($o->notes ?? '')); } return [ 'supplier' => optional($o->supplier)->name, 'text' => $text, ]; }) ->filter(fn($r) => $r['text'] !== '') ->values(); @endphp @if($conditions->count())
📝 شرایط خرید تامین‌کنندگان
@foreach($conditions as $c)
{{ $c['supplier'] ?: '—' }}
{{ $c['text'] }}
@endforeach
@endif
@empty
محصولی ثبت نشده است.
@endforelse

جمع‌کل و هزینه‌ها

@php $totalItemsPrice = 0; @endphp @forelse($purchaseRequest->items as $item) @php $selectedOffer = $item->offers->where('is_selected', true)->first(); $unitPrice = $selectedOffer ? $selectedOffer->price : 0; $itemTotal = $unitPrice * $item->quantity; $totalItemsPrice += $itemTotal; @endphp @empty @endforelse @php $costsTotal = $purchaseRequest->costs->sum('amount'); $subtotal = $totalItemsPrice + $costsTotal; $isOfficial = $purchaseRequest->purchase_type === 'official'; $vat = $isOfficial ? floor($subtotal * 0.10) : 0; $grandTotal = $subtotal + $vat; @endphp @if($purchaseRequest->costs->count() > 0) @endif @if($isOfficial && $vat > 0) @endif
نام محصول مقدار درخواستی فی هر واحد قیمت کل
{{ optional($item->product)->name ?? ($item->product_name ?? '—') }} {{ number_format($item->quantity, 0) }} {{ $item->unit }} {{ number_format($unitPrice) }} تومان {{ number_format($itemTotal) }} تومان
محصولی ثبت نشده است.
جمع آیتم‌ها: {{ number_format($totalItemsPrice) }} تومان
هزینه‌های اضافی: {{ number_format($costsTotal) }} تومان
مالیات (۱۰٪): {{ number_format($vat) }} تومان
جمع کل{{ $isOfficial ? ' (با احتساب ۱۰٪ مالیات)' : '' }}: {{ number_format($grandTotal) }} تومان
@if($purchaseRequest->costs->count() > 0)

جزئیات هزینه‌های اضافی:

@foreach($purchaseRequest->costs as $cost) @endforeach
عنوانمبلغ
{{ $cost->title }}{{ number_format($cost->amount) }} تومان
@endif

یادداشت‌ها

@php $rawNotes = $purchaseRequest->notes ?: ''; // Remove legacy appended sales user id text $cleanNotes = preg_replace('/\n?\s*مقصد\s+فروش\s+برای\s+کاربر\s+ID:\s*\d+\s*/u', '', (string)$rawNotes); // Remove appended payer details JSON block $cleanNotes = preg_replace('/\n?\s*جزئیات\s+پرداخت\s*:\s*\{[\s\S]*?\}\s*/u', '', (string)$cleanNotes); $cleanNotes = trim((string)$cleanNotes); @endphp
ثبت توسط: {{ optional($purchaseRequest->requester)->name ?? optional($purchaseRequest->requester)->username ?? '—' }}
{{ $cleanNotes !== '' ? $cleanNotes : '—' }}

وضعیت نهایی

@php $hs = $purchaseRequest->history_status; $last = is_array($hs) && count($hs) ? end($hs) : null; $lastStatus = $last['status'] ?? (is_string($hs) ? $hs : null); @endphp @if($lastStatus === 'completed') خرید انجام شده @elseif($lastStatus === 'failed')
خرید انجام نشد @if($purchaseRequest->failure_reason)
علت: {{ $purchaseRequest->failure_reason }}
@endif
@else ثبت نشده @endif
@endsection @push('scripts') @endpush