@php // Ensure $products_to_loop is always iterable and each item is an object if ($product instanceof \Illuminate\Support\Collection) { $products_to_loop = $product->map(function($p){ return (object)$p; }); } elseif (is_array($product)) { $products_to_loop = collect($product)->map(function($p){ return (object)$p; }); } else { $products_to_loop = collect([$product]); } if (is_array($product) || $product instanceof \Illuminate\Support\Collection) { $row_index_start = $row_index; // original index from request foreach ($product as $key => $p) { $p->row_index = $row_index_start + $key; // assign unique row_index per variation } } else { $product->row_index = $row_index; } @endphp @foreach($products_to_loop as $product) @php $max_qty_rule = $product->qty_available; $formatted_max_quantity = $product->formatted_qty_available; $max_qty_msg = __('validation.custom-messages.quantity_not_available', ['qty'=> $formatted_max_quantity, 'unit' => $product->unit ]); $allow_decimal = true; $row_index= $product->row_index; @endphp {{$product->product_name}}
{{$product->sub_sku}} @if( session()->get('business.enable_lot_number') == 1 || session()->get('business.enable_product_expiry') == 1) @php $lot_enabled = session()->get('business.enable_lot_number'); $exp_enabled = session()->get('business.enable_product_expiry'); $lot_no_line_id = ''; if(!empty($product->lot_no_line_id)){ $lot_no_line_id = $product->lot_no_line_id; } @endphp @if($product->enable_stock == 1)
@lang('report.current_stock'): {{$product->formatted_qty_available}} {{ $product->unit }} @endif @if(!empty($product->lot_numbers)) @endif @endif @php if(empty($product->quantity_ordered)) { $product->quantity_ordered = 1; } $multiplier = 1; if($product->unit_allow_decimal != 1) { $allow_decimal = false; } $qty_ordered = $product->quantity_ordered; @endphp @foreach($sub_units as $key => $value) @if(!empty($product->sub_unit_id) && $product->sub_unit_id == $key) @php $multiplier = $value['multiplier']; $max_qty_rule = $max_qty_rule / $multiplier; $unit_name = $value['name']; $max_qty_msg = __('validation.custom-messages.quantity_not_available', ['qty'=> $max_qty_rule, 'unit' => $unit_name ]); if(!empty($product->lot_no_line_id)){ $max_qty_msg = __('lang_v1.quantity_error_msg_in_lot', ['qty'=> $max_qty_rule, 'unit' => $unit_name ]); } if($value['allow_decimal']) { $allow_decimal = true; } @endphp @endif @endforeach @php $qty_ordered = $product->quantity_ordered / $multiplier; @endphp {{-- If edit then transaction sell lines will be present --}} @if(!empty($product->transaction_sell_lines_id)) @endif @if(empty($product->quantity_ordered)) @php $product->quantity_ordered = 1; @endphp @endif unit_allow_decimal == 1) data-decimal=1 @else data-rule-abs_digit="true" data-msg-abs_digit="@lang('lang_v1.decimal_value_not_allowed')" data-decimal=0 @endif data-rule-required="true" data-msg-required="@lang('validation.custom-messages.this_field_is_required')" @if($product->enable_stock) data-rule-max-value="{{$max_qty_rule}}" data-msg-max-value="{{$max_qty_msg}}" data-qty_available="{{$product->qty_available}}" data-msg_max_default="@lang('validation.custom-messages.quantity_not_available', ['qty'=> $product->formatted_qty_available, 'unit' => $product->unit ])" @endif > @if(!empty($sub_units))
@else {{$product->unit}} @endif @endforeach