| {{ @$product->item_sku }} |
{{ @$product->item_name }} |
{{ @$product->brand_name }} |
NA |
@foreach($allareas as $area)
@php
$item_id = $product->item_id;
$area_id = $area->id;
$total_qty_sold = 0;
if(in_array($area_id,$inareas) && in_array($item_id,$inproducts) ){
$disttype = '';
if($distributor_type_ids != ''){
$disttype = " order_contents_dist.distributor_type_id IN ($distributor_type_ids) AND ";
}
$total_qty_sold = DB::table('orders_dist')
->selectRaw("SUM(parent_qty_sold) as total_qty_sold")
->join('order_contents_dist', function($join) use($item_id) {
$join->on('order_contents_dist.order_id', '=', 'orders_dist.id')
->where('order_contents_dist.item_id', '=', $item_id)
->where('order_contents_dist.item_status', '=', 1)
->where('order_contents_dist.dispatch_status', '!=', 3);
})
->whereRaw(" $disttype orders_dist.booking_area= '{$area_id}' AND DATE(orders_dist.completed_at) >= '{$start_date}' AND DATE(orders_dist.completed_at) <= '{$end_date}' AND lower(orders_dist.status) = 'completed' ")
//->distinct('order_contents_dist.id')
->first()->total_qty_sold;
}
$item_sum = $item_sum+$total_qty_sold;
$areaWise[$area_id] = (int)@$areaWise[$area_id]+$total_qty_sold;
@endphp
{{spencerRound(@(int)$total_qty_sold)}} |
@endforeach
{{spencerRound(@$item_sum)}} |
@endforeach