<ul class="list-product">
    @if(@$stock_item && count($stock_item) > 0)
        @foreach ($stock_item as $row)
            <?php
            $pro_unit = findProductUnitByCode($row->barcode, 'product');
            ?>
            @if($pro_unit)
                <?php
                $my_p = getProductById($row->product_id);
                $id = $pro_unit ? $pro_unit->id : "";
                $product_name = $my_p ? $my_p->product_name : "";
                $barcode = $row ? $row->barcode : "";
                $size = findSize($pro_unit ? $pro_unit->size_id : 0);
                $category_name = $my_p ? optional($my_p->get_category)->category_name : "";
                $user_currency = user_currency();
                $unit = findUnit($pro_unit->unit_id);
                if ($type) {
                    if ($user_currency->id == 2) {
                        $price = $pro_unit->wholesale_price_usd;
                    } else if ($user_currency->id == 3) {
                        $price = $pro_unit->wholesale_price_baht;
                    }
                } else {
                    if ($user_currency->id == 2) {
                        $price = $pro_unit->retail_price_usd;
                    } else if ($user_currency->id == 3) {
                        $price = $pro_unit->retail_price_baht;
                    }
                }


                ?>
                <li class="listings cursor" title="{{$product_name}} (Size:{{$size?$size->size:''}})"
                    data-name="{{  $product_name}}"
                    data-stock="{{$row->sum_stock}}"
                    data-code="{{$barcode}}"
                    data-price="{{$price}}"
                    data-currency="{{$user_currency->id}}"
                    data-symbol="{{$user_currency->symbol}}"
                    data-size="{{  $size?$size->size:''}}"
                    data-unit="{{  $unit?$unit->unit:''}}"
                    data-id="{{ $id }}" style="border: 1px solid rgb(51, 122, 183)">
                    <div class="bg-img" style="
                        background: url({{findImg($my_p)}});
                        height: 10.5vh;
                        width: 100%;
                        background-position: center;
                        background-size: cover;
                        background-repeat: no-repeat;
                        ">
                                <span style="
                                background: #337ab7;
                                font-weight: 100;
                                border-radius: 0 0 4px 0;
                                position: absolute;
                    " class="label text-center size_label">{{$row->sum_stock}} ក្នុងស្តុក</span>
                    </div>
                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center" style="
                                   padding: 0px;
                                   background: #337ab7;
                                   color: white;
                                   ">
                    <span style="font-size: 12px">{{ $barcode }} <br>{{__('administrator.size')}}  {{$size->size }}
                        <br> {{ str_limit($product_name,15) }}</span>
                    </div>
                </li>
            @endif
        @endforeach
    @endif
</ul>
<div class="col-sm-12 col-xs-12">
    <div class="pagin">
        @if(@$stock_item)
            {!! $stock_item->render() !!}
        @endif
    </div>
</div>
