@extends('layouts.app') @section('title', __('lang_v1.stock_movement')) @section('content') @php $img = $product->image_url ?? null; $total_rows = $total_rows ?? (is_countable($stock_history) ? count($stock_history) : 0); $filters = $filters ?? []; $f_location_id = $filters['location_id'] ?? ''; $f_created_by = $filters['created_by'] ?? ''; $f_movement_type = $filters['movement_type'] ?? ''; $f_start_date = $filters['start_date'] ?? ''; $f_end_date = $filters['end_date'] ?? ''; @endphp

Movement

Filters
{!! Form::label('sm_date_filter', __('report.date_range') . ':', ['class' => 'control-label']) !!} {!! Form::text('sm_date_filter', null, ['placeholder' => __('lang_v1.select_a_date_range'), 'class' => 'form-control', 'readonly', 'id' => 'sm_date_filter']); !!}
{!! Form::label('location_id', __('business.business_locations') . ':', ['class' => 'control-label']) !!} {!! Form::select('location_id', $business_locations ?? [], $f_location_id, ['class' => 'form-control select2', 'style' => 'width:100%;']) !!}
{!! Form::label('created_by', __('lang_v1.added_by') . ':', ['class' => 'control-label']) !!} {!! Form::select('created_by', $users ?? [], $f_created_by, ['class' => 'form-control select2', 'style' => 'width:100%;']) !!}
{!! Form::label('movement_type', __('lang_v1.type') . ':', ['class' => 'control-label']) !!} {!! Form::select('movement_type', $movement_types ?? [], $f_movement_type, ['class' => 'form-control select2', 'style' => 'width:100%;']) !!}
@lang('messages.clear')
@if(!empty($img)) Product image @else Product image @endif
{{ $product->name }}
{{ $product->sku }}
@forelse($stock_history as $row) @php $type = $row['type'] ?? ''; $qty = (float) ($row['quantity_change'] ?? 0); $abs_qty = abs($qty); $stock_after = $row['stock'] ?? null; $row_offset = method_exists($stock_history, 'firstItem') ? (($stock_history->firstItem() ?? 1) - 1) : 0; $row_no = $total_rows - $row_offset - $loop->index; // Icon $icon_html = ''; if ($type === 'sell_transfer') { $icon_html = ''; } elseif ($type === 'purchase_transfer') { $icon_html = ''; } elseif ($qty > 0) { $icon_html = ''; } else { $icon_html = ''; } // Primary label (match screenshot-style) $type_labels = [ 'purchase' => __('purchase.purchase'), 'sell' => __('sale.sale'), 'opening_stock' => __('lang_v1.opening_stock'), 'stock_adjustment' => __('stock_adjustment.stock_adjustment'), 'sell_transfer' => __('lang_v1.stock_transfer'), 'purchase_transfer' => __('lang_v1.stock_transfer'), 'sell_return' => __('lang_v1.sell_return'), 'purchase_return' => __('lang_v1.purchase_return'), 'production_purchase' => 'Manufacturing: ' . __('purchase.purchase'), 'production_sell' => 'Manufacturing: ' . __('sale.sale'), ]; // Prefer server-provided label, then our mapping, then a readable fallback. $primary = $row['type_label'] ?? ($type_labels[$type] ?? ucwords(str_replace('_', ' ', (string) $type))); $primary = html_entity_decode((string) $primary, ENT_QUOTES, 'UTF-8'); $who = html_entity_decode((string) ($row['user_name'] ?? ''), ENT_QUOTES, 'UTF-8'); $when = !empty($row['date']) ? \Carbon::parse($row['date'])->format('n/j/Y g:i A') : ''; $loc = html_entity_decode((string) ($row['location_name'] ?? ''), ENT_QUOTES, 'UTF-8'); @endphp
{!! $icon_html !!}
{{ $primary }}: {{ $abs_qty }}
#{{ $row_no }} @if(!empty($when)) - {{ $when }} @endif @if(!empty($who)) - {{ $who }} @endif @if(!empty($loc)) - {{ $loc }} @endif
Stock @if(!is_null($stock_after)) {{ $stock_after }} @else 0 @endif
@empty
@lang('lang_v1.no_stock_history_found')
@endforelse @if(method_exists($stock_history, 'hasPages') && $stock_history->hasPages())
{{ $stock_history->appends(request()->except('page'))->links() }}
@endif
@endsection @section('javascript') @endsection