@php // Get the first variation if the product has variations. // If single product, it's just the "default" variation or no variation needed. $first_variation = $product->variations->first(); // Variation details $variation_display_name = ''; $variation_id = null; $default_purchase_price = $product->default_purchase_price; if (!empty($first_variation)) { $variation_id = $first_variation->id; $default_purchase_price = $first_variation->default_purchase_price; if ($product->type == 'variable') { $variation_display_name = " ({$first_variation->product_variation->name} : {$first_variation->name})"; } } @endphp
@forelse($locations as $key => $value)

@lang('sale.location'): {{$value}}

@if($enable_expiry == 1 && $product->enable_stock == 1) @endif @if($enable_lot == 1) @endif @php // We'll call sub_key = 0 for this first row $sub_key = 0; @endphp @if($enable_expiry == 1 && $product->enable_stock == 1) @endif @if($enable_lot == 1) @endif
@lang('product.product_name') @lang('lang_v1.quantity_left') @lang('purchase.unit_cost_before_tax')Exp. Date@lang('lang_v1.lot_number')@lang('purchase.subtotal_before_tax') @lang('lang_v1.date') @lang('brand.note')  
{{-- Product name + variation name if variable --}} {{ $product->name }}{!! $variation_display_name !!}
{!! Form::text( "stocks[$key][$variation_id][$sub_key][quantity]", @format_quantity(0), [ 'class' => 'form-control input-sm input_number purchase_quantity input_quantity', 'required', ] ) !!} {{ $product->unit->short_name }}
@if(!empty($product->second_unit))
@lang('lang_v1.quantity_in_second_unit', ['unit' => $product->second_unit->short_name])*
{!! Form::text( "stocks[$key][$variation_id][$sub_key][secondary_unit_quantity]", @format_quantity(1), [ 'class' => 'form-control input-sm input_number input_quantity', 'required' ] ) !!} @endif
{!! Form::text( "stocks[$key][$variation_id][$sub_key][purchase_price]", @num_format($default_purchase_price), [ 'class' => 'form-control input-sm input_number unit_price', 'required' ] ) !!} {!! Form::text( "stocks[$key][$variation_id][$sub_key][exp_date]", null, [ 'class' => 'form-control input-sm os_exp_date', 'readonly' ] ) !!} {!! Form::text( "stocks[$key][$variation_id][$sub_key][lot_number]", null, [ 'class' => 'form-control input-sm' ] ) !!} 0.00
{!! Form::text( "stocks[$key][$variation_id][$sub_key][transaction_date]", null, [ 'class' => 'form-control input-sm os_date', 'readonly' ] ) !!}
{!! Form::textarea( "stocks[$key][$variation_id][$sub_key][purchase_line_note]", null, [ 'class' => 'form-control input-sm', 'rows' => 3 ] ) !!}
@lang('sale.total'): 0.00
@empty @endforelse