@extends('layouts.app')
@section('title',$product->name_en)
@section('content')
<div class="page-head"><div><div class="d-flex align-items-center gap-2"><h1>{{ $product->name_en }}</h1><span class="badge status-{{ $product->status }}">{{ strtoupper($product->status) }}</span></div><p dir="rtl" class="text-start">{{ $product->name_ar }}</p></div><div class="d-flex gap-2"><a class="btn btn-light border" href="{{ route('products.barcodes.print',['product_id'=>$product->id]) }}">Barcode label</a><a class="btn btn-primary" href="{{ route('products.edit',$product) }}">Edit product</a></div></div>
<div class="row g-2"><div class="col-lg-8"><div class="card-erp"><div class="card-erp-header">Product master</div><div class="card-erp-body"><div class="row g-3">@foreach([['Product code',$product->product_code],['SKU',$product->sku],['Barcode',$product->barcode],['Category',$product->category?->name_en],['Brand',$product->brand?->name_en],['Pack size',$product->pack_size],['Packing',$product->packing_desc_en],['VAT',$product->vat_rate.'%'],['Price mode',$product->price_mode],['Rack / shelf',trim($product->rack_number.' / '.$product->shelf_number,' /')]] as [$l,$v])<div class="col-6 col-md-4"><small class="text-muted d-block">{{ $l }}</small><strong>{{ $v?:'—' }}</strong></div>@endforeach</div></div></div><div class="card-erp"><div class="card-erp-header">Multiple units</div><div class="table-responsive"><table class="table table-dense"><thead><tr><th>Unit</th><th class="text-end">Conversion to base</th><th class="text-end">Purchase</th><th class="text-end">Selling</th><th>Usage</th></tr></thead><tbody>@foreach($product->productUnits as $u)<tr><td>{{ $u->unit?->code }}</td><td class="text-end">{{ number_format((float)$u->conversion_factor,4) }}</td><td class="text-end">{{ number_format((float)$u->purchase_price,2) }}</td><td class="text-end">{{ number_format((float)$u->selling_price,2) }}</td><td>@if($u->is_base_unit)<span class="badge bg-accent-soft text-accent">BASE</span>@endif @if($u->is_purchase_unit)<span class="badge bg-light text-dark">PURCHASE</span>@endif @if($u->is_sales_unit)<span class="badge bg-light text-dark">SALES</span>@endif</td></tr>@endforeach</tbody></table></div></div></div><div class="col-lg-4"><div class="card-erp"><div class="card-erp-header">Pricing & cost</div><div class="card-erp-body">@foreach([['Purchase price',$product->cost_price,4],['Average base cost',$product->avg_cost,4],['Last base cost',$product->last_purchase_cost,4],['Selling price',$product->sale_price,2],['Wholesale price',$product->wholesale_price,2],['Retail price',$product->retail_price,2],['Minimum selling',$product->min_sale_price,2]] as [$l,$v,$d])<div class="d-flex justify-content-between py-1"><span>{{ $l }}</span><b>{{ number_format((float)$v,$d) }}</b></div>@endforeach</div></div><div class="card-erp"><div class="card-erp-header">Warehouse stock</div><div class="table-responsive"><table class="table table-dense"><tbody>@forelse($product->warehouseStocks as $s)<tr><td>{{ $s->warehouse?->code }}</td><td class="text-end fw-bold">{{ number_format((float)$s->qty,4) }}</td><td class="text-end">SAR {{ number_format((float)$s->qty*(float)$s->avg_cost,2) }}</td></tr>@empty<tr><td class="text-muted">No stock.</td></tr>@endforelse</tbody></table></div></div></div></div>
@endsection
