@extends('layouts.app') @section('title', __('re_order.edit')) @php use App\Product; use App\StockReOrderProducts; use Illuminate\Support\Facades\DB; @endphp @section('content')

@lang('re_order.edit')

{!! Form::open([ 'url' => action('StockReOrderController@update', [$stock_re_order->id]), 'method' => 'put', 'id' => 'stock_re_order_form', ]) !!}
{!! Form::label('location_id', __('purchase.business_location') . ':') !!} {{-- {!! Form::select('select_location_id', $business_locations, $stock_re_order->location_from, [ 'class' => 'form-control select2', 'id' => 'select_location_id', 'disabled', 'required', ]) !!} --}}
{!! Form::label('ref_no', __('purchase.ref_no') . ':') !!} @show_tooltip(__('lang_v1.leave_empty_to_autogenerate')) {!! Form::text('ref_no', $stock_re_order->re_order_ref, ['class' => 'form-control']) !!}
{!! Form::label('transaction_date', __('messages.date') . ':*') !!}
{!! Form::text('transaction_date', @format_datetime($stock_re_order->re_order_date), [ 'class' => 'form-control', 'readonly', 'required', ]) !!}
{!! Form::label('re_order_status', __('re_order.status') . ':') !!} {!! Form::select('re_order_status', $re_order_status, $stock_re_order->re_order_status, [ 'class' => 'form-control select2', 'id' => 're_order_status', ]) !!}

{{ __('stock_adjustment.search_products') }}

{!! Form::select('brand_id', $brands, null, [ 'placeholder' => 'Select Brand', 'class' => 'form-control select2 brand_id', ]) !!}
{!! Form::select('category_id', $categories, null, [ 'placeholder' => 'Select Category', 'class' => 'form-control select2 category_id', ]) !!}
{!! Form::text('search_product', null, [ 'class' => 'form-control', 'id' => 'search_product_for_stock_reorder', 'placeholder' => __('re_order.search_product'), 'autofocus', ]) !!}
@foreach ($locations_for_table_headers as $business_location) @if ($is_admin) @if ($stock_re_order->location_from != $business_location->id) @else @endif @endforeach @foreach ($order_product_groups as $product) @php $main_product = DB::table('product_locations') ->where('product_id', $product->product_id) ->where('location_id', $stock_re_order->location_from) ->first(); $total_re_order_qty = StockReOrderProducts::where( 're_order_id', $stock_re_order->id, ) ->where('product_id', $product->product_id) ->where('variation_id', $product->variation_id) ->sum('re_order_quantity'); $av_qty = App\VariationLocationDetails::where( 'product_id', $product->product_id, ) ->where('variation_id', $product->variation_id) ->where('location_id', $stock_re_order->location_from) ->first(); @endphp @php $StockReOrderProducts = StockReOrderProducts::where( 'stock_re_order_products.re_order_id', $stock_re_order->id, ) ->where( 'stock_re_order_products.variation_id', $product->variation_id, ) ->join( 'business_locations', 'stock_re_order_products.location_id', '=', 'business_locations.id', ) ->orderBy('stock_re_order_products.id', 'ASC') ->get(); @endphp @foreach ($StockReOrderProducts as $product_location) @php // $maximum_release = 0; // $maximum_release = // $product->qty_available - $main_product->product_re_order_level; $total_reorder_quantity = StockReOrderProducts::where( 'stock_re_order_products.re_order_id', $stock_re_order->id, ) ->where( 'stock_re_order_products.variation_id', $product->variation_id, ) ->sum('re_order_quantity'); @endphp @endforeach @endforeach
@lang('sale.product') @lang('re_order.current_stock') {{ $business_location->name }} @endif {{ $business_location->location->name }}
{{ $product->product_name }} ({{ $product->sub_sku }})
Re-order level: {{ $main_product->product_re_order_level }} {{ $product->unit }}
{{ number_format($av_qty->qty_available - $total_re_order_qty, 2) }} {{ $product->unit }}
@php $qty_available = Product::leftJoin( 'variation_location_details as VLD', 'VLD.product_id', '=', 'products.id', ) ->where('VLD.product_id', $product->product_id) ->where('VLD.location_id', $product_location->id) ->sum('VLD.qty_available'); $product_has_location = DB::table('product_locations') ->where('product_id', $product->product_id) ->where('location_id', $product_location->id) ->first(); $total_curr_stock = $qty_available + $product_location->re_order_quantity; $color = 'red'; if (!empty($product_location->product_max_order_level)) { $product_max_order_level = $product_location->product_max_order_level; } else { $product_max_order_level = 0; } if (!empty($product_location->product_re_order_level)) { $product_re_order_level = $product_location->product_re_order_level; } else { $product_re_order_level = 0; } if ( $total_curr_stock <= $product_max_order_level && $total_curr_stock >= $product_re_order_level ) { $color = 'green'; } @endphp Current Stock: {{ number_format($total_curr_stock, 2) }} {{ $product->unit }}
Re-order level: @if (!empty($product_has_location->product_re_order_level)) {{ $product_has_location->product_re_order_level }} @endif {{ $product->unit }}
Max-order level: @if (!empty($product_has_location->product_max_order_level)) {{ $product_has_location->product_max_order_level }} @endif {{ $product->unit }}
@php $requirement = 0; if ($product_re_order_level > $qty_available) { $requirement = $product_re_order_level - $qty_available - $product_location->re_order_quantity; } @endphp Requirement: {{ number_format($requirement, 2) }} {{ $product->unit }}
{{-- --}}


{!! Form::hidden('is_save_and_print_1', 0, ['id' => 'is_save_and_print_1']) !!} {!! Form::hidden('is_save_and_print_2', 0, ['id' => 'is_save_and_print_2']) !!}
{!! Form::close() !!}
@stop @section('javascript') @endsection