@extends('layouts.app')

@section('title', 'View Inventory Item')

@section('content')

<div class="row">
    <div class="col-sm-12">

        <div class="card">

            <div class="card-header d-flex justify-content-between">
                <div class="header-title">
                    <h4 class="card-title">Inventory Item Details</h4>
                </div>
            </div>

            <div class="card-body">

                <div class="row">

                    <div class="col-md-6">
                        <div class="form-group">
                            <label><strong>Item Name</strong></label>
                            <p>{{ $item->item_name }}</p>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label><strong>Item Code</strong></label>
                            <p>{{ $item->item_code }}</p>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label><strong>Category</strong></label>
                            <p>
                                {{ $item->category->category_name ?? 'N/A' }}
                            </p>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label><strong>Quantity</strong></label>
                            <p>{{ $item->item_quantity }}</p>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label><strong>Purchase Price</strong></label>
                            <p>
                                RS {{ number_format($item->item_purchase_price, 2) }}
                            </p>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label><strong>Sale Price</strong></label>
                            <p>
                                RS {{ number_format($item->item_saleprice, 2) }}
                            </p>
                        </div>
                    </div>

                    <div class="col-md-6">
                        <div class="form-group">
                            <label><strong>Minimum Stock</strong></label>
                            <p>{{ $item->minimum_stock }}</p>
                        </div>
                    </div>

<div class="col-md-6">
    <div class="form-group">
        <label><strong>Added By</strong></label>
        <p>{{ $item->addedBy->user_name ?? 'Unknown User' }}</p>
    </div>
</div>
                    <div class="col-md-6">
                        <div class="form-group">
                            <label><strong>Added At</strong></label>
                            <p>{{ $item->added_at }}</p>
                        </div>
                    </div>

                </div>

                <a
                    href="{{ route('inventory.list') }}"
                    class="btn btn-primary"
                >
                    Back to Inventory
                </a>

                <a
                    href="{{ route('inventory.edit', $item->item_id) }}"
                    class="btn btn-success"
                >
                    Edit Item
                </a>

            </div>

        </div>

    </div>
</div>

@endsection