@include('admin.layout.title_header', ['title'=>'SALES SUMMERY(ITEM WISE)'])
{{-- --}}
{{--
--}}
@php
$showroom_order_total=[];
$showroom_delivery_total=[];
$printData['title']='ORDER SUMMERY '.($type==0?'(ORDER VS DELIVERY)':($type==1?'(PRODUCT VS SHOWROOM)':'(SHOWROOM VS SECTIONWISE-PRODUCT)'));
$printData['start_date']=Request()->date_from?date('d-M-Y',strtotime(Request()->date_from)):date('d-M-Y');
$printData['end_date']=Request()->date_to?date('d-M-Y',strtotime(Request()->date_to)):date('d-M-Y');
$printData['showroom']=Request()->group?$groups->where('id',Request()->group)->first()->name_eng:(Request()->showroom && Request()->showroom!=0?$customers->where('id',Request()->showroom)->first()->name_eng:'All Showroom');
$printData['search_by']=$type==2?(Request()->category_code && Request()->category_code!=0?$categories->where('id',Request()->category_code)->first()->chart_name:'All Section'):(Request()->category_code && Request()->category_code!=0?$categories->where('code',Request()->category_code)->first()->name_eng:'All Category');
$routeName=Route::currentRouteName();
$printData=getPrintData($routeName,$printData);
@endphp
{!!$printData['head']!!}
@if($type==0 || $type==2)
@php
$tr='';
$tr2=' ';
@endphp
@forelse ($transacted_products as $a=>$transacted_product)
@php
$showroom_order_total[$a]=0;
$showroom_delivery_total[$a]=0;
$tr2.='';
@endphp
@empty
@endforelse
@php
$tr2.='';
@endphp
{!!$tr2.''!!}
@php
$i=1;
@endphp
{{-- @forelse (Request()->showroom?$customers->where('id',Request()->showroom):$customers as $showroom) --}}
@forelse (Request()->showroom?$loopableCustomers->where('id',Request()->showroom):$loopableCustomers as $showroom)
@php
$s_order_qty=0;
$s_qty=0;
@endphp
{{$i++}}
{{$showroom->user_name}}
@forelse ($transacted_products as $k=>$transacted_product)
@php
$transaction_pro=$transacted_product->where('party_id',$showroom->id)->where('product_id',$k);
$s_order_qty+=$order_qty=$transaction_pro->sum('order_qty');
$s_qty+=$qty=$transaction_pro->sum('quantity');
$showroom_order_total[$k]+=$order_qty;
$showroom_delivery_total[$k]+=$qty;
@endphp
{{ number_format($order_qty,2) }}
{{ number_format($qty,2) }}
@empty
@endforelse
{{ number_format($s_order_qty,2) }}
{{ number_format($s_qty,2) }}
@empty
No Data Available
@endforelse
Total
@forelse ($transacted_products as $m=>$transacted_product)
{{ number_format($showroom_order_total[$m],2) }}
{{ number_format($showroom_delivery_total[$m],2)}}
@empty
@endforelse
{{ number_format(array_sum($showroom_order_total),2) }}
{{ number_format(array_sum($showroom_delivery_total),2) }}
@else
@php
$tr='';
$tr2=' ';
@endphp
{{-- @forelse (Request()->showroom?$customers->where('id',Request()->showroom):$customers as $showroom) --}}
@forelse (Request()->showroom?$loopableCustomers->where('id',Request()->showroom):$loopableCustomers as $showroom)
@php
$showroom_order_total[$showroom->id]=0;
$showroom_delivery_total[$showroom->id]=0;
$tr2.='';
@endphp
@empty
@endforelse
@php
$tr2.='';
@endphp
{!!$tr2.''!!}
@php
$i=1;
@endphp
@forelse ($transacted_products as $a=>$transacted_product)
@php
$p_order_qty=0;
$p_qty=0;
@endphp
{{$i++}}
{{Request()->name_type==1?$transacted_product->first()->product->name_local:$transacted_product->first()->product->name_eng}}
@forelse (Request()->showroom?$loopableCustomers->where('id',Request()->showroom):$loopableCustomers as $showroom)
@php
$transaction_pro=$transacted_product->where('party_id',$showroom->id)->where('product_id',$a);
$p_order_qty+=$order_qty=$transaction_pro->sum('order_qty');
$p_qty+=$qty=$transaction_pro->sum('quantity');
$showroom_order_total[$showroom->id]+=$order_qty;
$showroom_delivery_total[$showroom->id]+=$qty;
@endphp
{{ number_format($order_qty,2) }}
{{ number_format($qty,2) }}
@empty
@endforelse
{{-- @php
$pro_tran=$transacted_product->where('product_id',$a);
@endphp --}}
{{number_format($p_order_qty,2) }}
{{number_format($p_qty,2) }}
@empty
No Data Available
@endforelse
Total
@forelse (Request()->showroom?$loopableCustomers->where('id',Request()->showroom):$loopableCustomers as $showroom)
{{-- @forelse (Request()->showroom?$customers->where('id',Request()->showroom):$customers as $showroom) --}}
@php
// $tras_total=count($transactions)?$transactions->where('party_id',$showroom->id):[];
@endphp
{{ number_format($showroom_order_total[$showroom->id],2) }}
{{ number_format($showroom_delivery_total[$showroom->id],2)}}
@empty
@endforelse
{{ number_format(array_sum($showroom_order_total),2) }}
{{ number_format(array_sum($showroom_delivery_total),2) }}
@endif
{{-- vice varcaa dynamic --}}