{{-- the product form (flow م۷, slice 1: melted gold, manual price; slice 2: the trade limits). posts exactly App\Catalog\ProductEditor::FIELDS; each checkbox has a hidden «0» twin so an unticked box arrives as a value (+PARTIAL-SAVE). slice 5د۲: the spread fields of the drawn mode only, and the mode itself as a hidden field. --}} @extends('layouts.mz') @php $v = fn (string $field) => old($field, $values[$field]); $isOn = fn (string $field) => (string) old($field, $values[$field] ? '1' : '0') === '1'; @endphp @section('title', $product ? 'ویرایش کالا' : 'کالای تازه') @section('credit', '1') @section('nav') @include('panel._nav') @endsection @section('content')

{{ $product ? 'ویرایش «' . $product->title . '»' : 'کالای تازه: ' . $familyWord }}

@if ($product) {{-- slice 5د۱ (decision 86): the family is fixed after creation, so it is said, never posted --}}

نوع کالا: {{ $familyWord }}. نوع پس از ساخت عوض نمی‌شود.

@endif @if ($errors->any()) @endif @error('family') @enderror {{-- slice 6ب (PRD §4 «قیمت دستی پشتیبان … با کلید «استفاده از دستی»», owner plan questions 3, 6 and 9): a stored central-price product's backup — its own form, never a field of the product form; the price is ready in its field (the backup itself while on, else the central price customers last saw); its last ten switches below --}} @if ($backup) @php $mine = (string) old('backup_product') === (string) $product->id; @endphp

قیمت دستی پشتیبان

@if (session('mz.saved'))

{{ session('mz.saved') }}

@endif @if ($backup['on'])

روشن از {{ $backup['since'] }}، با {{ $backup['price'] }}. خرید و فروش این کالا با همین قیمت است و قیمت مرکزی دنبال نمی‌شود.

@else

خاموش: قیمت از قیمت مرکزی می‌آید. اگر قیمت مرکزی کهنه شد یا قیمت بازار تلفنی را می‌خواهید، قیمت را بنویسید و «استفاده از دستی» را بزنید.

@endif
@csrf
id) aria-invalid="true" @enderror> {{ $backup['on'] ? 'قیمت پشتیبان فعلی.' : 'خانه با آخرین قیمت مرکزی پر شده است.' }} اختلاف خرید و فروش همین کالا روی این قیمت می‌نشیند. @error('backup_' . $product->id)

{{ $message }}

@enderror
@if ($backup['on'])
@csrf
@endif @if ($backup['history'] !== [])

تاریخچه

@endif
@endif
@csrf @unless ($product) @endunless
@error('title')

{{ $message }}

@enderror
{{-- slice 5ه۲ (decision 106, owner plan question 1) and slice 6الف: a product is priced by hand, by the central feed, or — a coin only — «from gram 750». the mode is hidden fields switched by a plain post to the server (each button's formaction and its price_to) that draws this form again in that mode with what is typed — nothing saved, no script needed; each mode posts only its own fields --}} @if ($coinMode !== null) @endif @php $unitPhrase = match ($family) { 'silver' => 'هر گرم نقرهٔ مرجع', 'coin' => 'هر عدد', default => 'هر گرم ۷۵۰' }; $modeWords = [ 'manual' => ['قیمت دستی ' . $unitPhrase, 'قیمت دستی بنویسم', 'قیمت را خودتان می‌نویسید و تا وقتی عوضش نکنید ثابت می‌ماند.'], 'feed' => ['قیمت مرکزی (منبع قیمت مظنه)', 'قیمت مرکزی بگیرد', 'قیمت مرجع از دریافت مرکزی مظنه می‌آید و با هر دریافت خودش عوض می‌شود. اگر قیمت تازه از «آستانهٔ کهنگی قیمت» (تنظیمات) دیرتر برسد، خرید و فروش این کالا بسته می‌شود تا قیمت تازه برسد. اختلاف خرید و فروش روی همین قیمت می‌نشیند.'], 'from_750' => ['از قیمت گرم ۷۵۰ یک طلای آبشده', 'قیمت از گرم ۷۵۰ حساب شود', 'قیمت مرجع هر عدد = وزن یک سکه × عیار ÷ ۷۵۰ × قیمت مرجع گرم ۷۵۰ کالای پایه، تا یک ریال گرد می‌شود و با هر تغییر قیمت پایه خودش عوض می‌شود. اختلاف خرید و فروش روی همین قیمت می‌نشیند.'], ]; $otherModes = array_values(array_filter(['manual', 'feed', 'from_750'], fn ($m) => $m !== $priceMode && ($m !== 'from_750' || $family === 'coin'))); @endphp

حالت قیمت: {{ $modeWords[$priceMode][0] }}

{{ $modeWords[$priceMode][2] }} عوض کردن حالت چیزی ذخیره نمی‌کند؛ مقدارهای حالت دیگر سر جایشان می‌مانند.

@if (session('mz.price_mode'))

{{ session('mz.price_mode') }}

@endif @error('coin_price_mode') @enderror @error('price_source') @enderror
@foreach ($otherModes as $other) @endforeach
@if ($priceMode === 'feed') {{-- slice 6الف (PRD §4 «نگاشت هر کالا به یک قلم قیمت مرکزی»): the item this product follows, each option with its last good price and age; the manual price stays stored and is not posted --}}
قیمت مرکزی @if ($feed)

{{ $feed['text'] }}

@endif
@if ($feedItems === []) {{-- +NO-DEAD-END: no item of this family yet — the way back to a price that works today --}}

برای این نوع کالا هنوز قیمت مرکزی‌ای نیست؛ «قیمت دستی بنویسم» را بزنید.

@endif @if ($feedItems !== []) قیمت کنار هر قلم آخرین قیمت سالمی است که مرکز گرفته، به {{ $unitWord }}.@if ($family === 'silver') قیمت نقره برای هر گرم با عیار مرجع همین کالاست؛ قلمی با عیار دیگر پذیرفته نمی‌شود.@endif @endif @error('feed_item')

{{ $message }}

@enderror
@endif @if ($priceMode === 'from_750') {{-- slice 5ه۲: the base, the weight of ONE coin and its purity — the three inputs of the price --}}
قیمت از گرم ۷۵۰ @if ($formula)

ذخیره‌شده: {{ $formula }}.

@endif @if ($baseProblem)

{{ $baseProblem }}

@endif
@if ($bases === []) {{-- +NO-DEAD-END: no melted gold yet — the way to make one --}}

هنوز هیچ طلای آبشده‌ای نساخته‌اید؛ قیمت این سکه از قیمت گرم ۷۵۰ یکی از آن‌ها حساب می‌شود. ساخت طلای آبشدهٔ تازه

@endif @if ($bases !== []) قیمت مرجع گرم ۷۵۰ این کالا پایهٔ قیمت سکه است، نه قیمت مشتری یا دسته‌ای آن. اگر پایه قیمت نداشته باشد یا بایگانی شود، سکه هم قیمت ندارد. @endif @error('coin_base_product_id')

{{ $message }}

@enderror
وزن واقعی یک عدد، مثلاً ۸٫۱۳۳ گرم برای سکهٔ امامی؛ حداکثر ۱٬۰۰۰ گرم. @error('coin_weight_mg')

{{ $message }}

@enderror
در هزار؛ سکهٔ بهار آزادی ۹۰۰ است. @error('purity')

{{ $message }}

@enderror
@elseif ($family !== 'coin') {{-- slice 5ه۱: a coin priced by hand is counted, so its form has no purity (posting one is refused) --}}
@if ($family === 'silver') در هزار؛ ۹۹۹ یعنی نقرهٔ خالص. پیش‌فرض عیار روی برگهٔ مشتری همین است و مشتری عیار قطعهٔ خودش را می‌زند. @else در هزار؛ ۷۵۰ یعنی ۱۸ عیار. قیمت این کالا برای هر گرم ۷۵۰ گفته می‌شود. @endif @error('purity')

{{ $message }}

@enderror
@else @error('purity') @enderror @endif @if ($family === 'silver') {{-- slice 5د۱ (decision 87): the price below is per gram of THIS purity; it is locked on every offer --}}
در هزار؛ قیمت این کالا برای هر گرم نقره با همین عیار گفته می‌شود. مبلغ = وزن × عیار ÷ عیار مرجع × قیمت. @error('reference_purity')

{{ $message }}

@enderror
@endif @if ($priceMode === 'manual') {{-- slice 5ه۲ / 6الف: only the manual mode posts a manual price (the stored one is kept for the way back) --}}
قیمت دستی. خالی یعنی «قیمت ندارد» و هیچ طرفی باز نمی‌شود. @if ($priceAt && $source === 'manual' && !($product?->followsFeed())) آخرین ثبت قیمت: ساعت {{ $priceAt }}. @endif @error('manual_price')

{{ $message }}

@enderror
@else @if ($priceAt && $priceMode === 'from_750')

آخرین تغییر قیمت این سکه (پایه یا خود سکه): ساعت {{ $priceAt }}.

@endif @error('manual_price') @enderror @endif {{-- slice 5د۲ (decisions 82 and 92): the spread of both sides is a fixed amount or a percent of the reference price. «تبدیل» posts THIS form to the server, which converts what is typed and shows the form again — nothing saved, no script needed (owner plan question 4); the form then posts the fields of the new mode only --}}

اختلاف قیمت: {{ $mode === 'percent' ? 'درصدی از قیمت مرجع' : 'مبلغ ثابت (' . $unitWord . ')' }}

{{ $mode === 'percent' ? 'اختلاف هر طرف درصدی از قیمت مرجع است و با هر تغییر قیمت مرجع خودش عوض می‌شود؛ تا یک ریال گرد می‌شود. روی هر پیشنهاد قیمت همان مبلغ آن لحظه قفل می‌شود.' : 'اختلاف هر طرف یک مبلغ ثابت است و با تغییر قیمت مرجع عوض نمی‌شود.' }} تبدیل، مقدار فعلی را با قیمت مرجع همین فرم تبدیل می‌کند، نه صفر؛ اختلاف ویژهٔ دسته‌ها هم با ذخیره تبدیل می‌شود.

@if (session('mz.converted'))

{{ session('mz.converted') }}

@endif @error('spread_mode') @enderror
@php $spreadUnit = $mode === 'percent' ? '٪' : $unitWord; $spreadField = fn (string $side) => $side . '_spread' . ($mode === 'percent' ? '_bp' : ''); @endphp
خرید مشتری (مشتری از شما می‌خرد) @php $f = $spreadField('buy'); @endphp
@if ($mode === 'percent') درصدی از قیمت مرجع که روی آن افزوده می‌شود: قیمت خرید مشتری = مرجع + مرجع × این درصد. حداکثر دو رقم اعشار. @if ($now['buy']) با قیمت مرجع این فرم: {{ $now['buy'] }}. @endif @else روی قیمت مرجع افزوده می‌شود: قیمت خرید مشتری = مرجع + این عدد. @endif @error($f)

{{ $message }}

@enderror
@error('buy_open')

{{ $message }}

@enderror
فروش مشتری (مشتری به شما می‌فروشد) @php $f = $spreadField('sell'); @endphp
@if ($mode === 'percent') درصدی از قیمت مرجع که از آن کم می‌شود: قیمت فروش مشتری = مرجع − مرجع × این درصد. کمتر از ۱۰۰٪. @if ($now['sell']) با قیمت مرجع این فرم: {{ $now['sell'] }}. @endif @else از قیمت مرجع کم می‌شود: قیمت فروش مشتری = مرجع − این عدد. @endif @error($f)

{{ $message }}

@enderror
@error('sell_open')

{{ $message }}

@enderror
حد معامله ({{ $limitUnitWord }})

خالی یعنی بی‌حد. همین حدها برای خرید و فروش مشتری هر دو برقرارند و مشتری آن‌ها را پیش از ثبت سفارش می‌بیند.

@foreach (['trade_min' => 'کمترین مقدار هر معامله', 'trade_max' => 'بیشترین مقدار هر معامله', 'daily_cap' => 'سقف روزانهٔ هر مشتری'] as $limit => $limitLabel)
@if ($limit === 'daily_cap') جمع {{ $family === 'coin' ? 'تعداد' : 'وزن' }} سفارش‌های امروز یک مشتری در هر طرف، از نیمه‌شب؛ سفارش ردشده یا لغوشده شمرده نمی‌شود. @endif @error($limit)

{{ $message }}

@enderror
@endforeach @if ($family === 'coin') {{-- slice 5ه۲ (decision 110): the coin limits of the settings and of the category, a count summed over every coin --}}

حد به تعداد سکه است، نه وزن. حدهای سراسری سکه (تنظیمات) و حدهای سکهٔ دستهٔ مشتری هم برقرارند؛ سخت‌ترینِ آن‌ها حکم می‌کند. سقف روزانهٔ آن دو، تعداد همهٔ سکه‌ها را با هم می‌شمارد.

@else

حدهای سراسری {{ $family === 'silver' ? 'نقره' : 'طلای آبشده' }} (تنظیمات) و حدهای {{ $family === 'silver' ? 'نقرهٔ' : 'طلای آبشدهٔ' }} دستهٔ مشتری هم برقرارند؛ سخت‌ترینِ آن‌ها حکم می‌کند.

@endif
{{-- slice 5ب (پ۵-۲): an order inside this range is approved the moment it is placed; empty top = off --}}
@php $what = $family === 'coin' ? 'تعداد' : 'وزن'; @endphp تأیید خودکار ({{ $limitUnitWord }})

سفارشی که {{ $what }}ش در این بازه باشد، همان لحظهٔ ثبت تأیید می‌شود و به صف نمی‌آید. «تا {{ $what }}» خالی یعنی تأیید خودکار خاموش؛ «از {{ $what }}» خالی یعنی از صفر. اگر مشتری در دسته‌ای باشد که بازهٔ خودش را {{ match ($family) { 'silver' => 'برای نقره', 'coin' => 'برای سکه', default => 'برای طلای آبشده' } }} دارد، سفارش باید در هر دو بازه باشد.

@foreach (['auto_min' => 'از ' . $what, 'auto_max' => 'تا ' . $what] as $auto => $autoLabel)
@error($auto)

{{ $message }}

@enderror
@endforeach
کالای با عدد کوچک‌تر بالاتر دیده می‌شود. @error('sort_order')

{{ $message }}

@enderror
برگشت به کالاها
@if ($history !== null) @include('panel._history-card', ['history' => $history, 'subject' => 'این کالا']) @endif @endsection