@php
use App\Product;
use App\BusinessLocation;
use Illuminate\Support\Facades\DB;
$main_product = DB::table('product_locations')
->where('product_id', $product->product_id)
->where('location_id', $location_id)
->first();
@endphp
{{ $product->product_name }} ({{ $product->sub_sku }})
Re-order level: {{ $main_product->product_re_order_level }}
{{ $product->unit }}
|
{{ number_format($product->qty_available, 2) }}
{{ $product->unit }}
|
@php
$user_id = request()->session()->get('user.id');
// $business_locations = BusinessLocation::where('business_locations.id', '!=', $location_id)->orderBy('id', 'ASC');
// $business_locations = $business_locations->get();
// $business_locations = UserAccessStockTransferLocation::where('id', '!=', $location_id)->where('location_type', 'to')->get();
// $permitted_locations = auth()->user()->permitted_locations();
// if ($permitted_locations != 'all') {
// $business_locations->whereIn('id', $permitted_locations);
// }
if ($is_admin) {
$business_locations = BusinessLocation::where('id', '!=', $location_id)
->orderBy('id', 'ASC')
->where('is_stock_location', '0')
->select('business_locations.*', 'business_locations.id as location_id')
->Active();
$business_locations = $business_locations->get();
} else {
$business_locations = BusinessLocation::join(
'user_access_stock_transfer_locations',
'user_access_stock_transfer_locations.location_id',
'=',
'business_locations.id',
)
->where('is_stock_location', '0')
->where('business_locations.id', '!=', $location_id)
->where('user_access_stock_transfer_locations.user_id', '=', $user_id)
->where('user_access_stock_transfer_locations.location_type', 'to')
->orderBy('business_locations.id', 'ASC')
->select('business_locations.*', 'user_access_stock_transfer_locations.location_id as location_id')
->get();
}
@endphp
@foreach ($business_locations as $business_location)
{{-- @if ($business_location->is_stock_location == '0') --}}
@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', $business_location->location_id)
->sum('VLD.qty_available');
$product_location = DB::table('product_locations')
->where('product_id', $product->product_id)
->where('location_id', $business_location->location_id)
->first();
$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 ($qty_available <= $product_max_order_level && $qty_available >= $product_re_order_level) {
$color = 'green';
}
@endphp
Current
Stock: {{ number_format($qty_available, 2) }}
{{ $product->unit }}
Re-order level:
@if (!empty($product_location->product_re_order_level))
{{ $product_location->product_re_order_level }}
@endif
{{ $product->unit }}
Max-order level:
@if (!empty($product_location->product_max_order_level))
{{ $product_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;
}
@endphp
Requirement:
{{ number_format($requirement, 2) }}
{{ $product->unit }}
|
{{-- @endif --}}
@endforeach
|
|