{{ __('messages.Sales Collection Report') }}

{{ __('messages.search') }}

@foreach(\App\Models\User::has("owner_orders")->get() as $user) @endforeach
{{ __('messages.search result') }}
{{ __('messages.owner') }} : @foreach ($owner_ids as $user_id) @php $uuu = App\Models\User::find($user_id); @endphp ({{ $uuu ? $uuu ->name : '' }}) @endforeach
{{ __('hr_messages.Start From') }} :{{ $start_from }}
{{ __('hr_messages.End To') }} :{{ $end_to }}
@php $all_count = 0; $total_collection = 0; @endphp @if ($type == 1) @php $p = $items ->where('item_type', 'App\Models\Product') ->select('item_id', DB::raw('count(distinct(order_details.id)) as c '), DB::raw('sum(order_details.price_with_tax) as p ')) ->groupBy('item_id') ->get(); @endphp @forelse ($p as $item) @empty @endforelse @endif @if ($type == 2) @php $po = $items ->where('order_details.item_type', 'App\Models\ProductOffer') ->join('product_offers',"order_details.item_id","=","product_offers.id") ->select('product_offers.offer_id', DB::raw('count(distinct(order_details.id)) as c ') , DB::raw('sum(order_details.price_with_tax) as p ')) ->groupBy('product_offers.offer_id') ->get(); @endphp @forelse ($po as $key => $item) @empty @endforelse @endif @if ($type == 3) @php $pp = $items ->where('item_type', 'App\Models\PackageProduct') ->join('package_products',"order_details.item_id","=","package_products.id") // ->select('package_products.package_id', DB::raw('count(package_products.id) as c ')) ->select('package_products.package_id', DB::raw('count(distinct(order_details.id)) as c '), DB::raw('sum(order_details.price_with_tax) as p ')) ->groupBy('package_products.package_id') ->get(); @endphp @forelse ($pp as $item) @empty @endforelse @endif @if ($type == 5) @php $cc = $items ->where('item_type', 'App\Models\ClubMembership') ->join('club_memberships',"order_details.item_id","=","club_memberships.id") ->select('club_memberships.id', DB::raw('count(distinct(order_details.id)) as c '), DB::raw('sum(order_details.price_with_tax) as p ')) ->groupBy('club_memberships.id') ->get(); @endphp @forelse ($cc as $item) @empty @endforelse @endif @if ($type == 4) @php $ipp = $items ->where('item_type', 'App\Models\InstallmentPackageProduct') ->join('installment_package_products',"order_details.item_id","=","installment_package_products.id") ->select('installment_package_products.installment_package_id', DB::raw('count(distinct(order_details.id)) as c '), DB::raw('sum(order_details.price_with_tax) as p ')) ->groupBy('installment_package_products.installment_package_id') ->get(); @endphp @forelse ($ipp as $item) @empty @endforelse @endif

{{ __('messages.Product') }}

{{ __('messages.Count') }}

{{ __('messages.collection') }}

{{ App\Models\Product::find($item->item_id)->name }} {{ $item->c }} @php $all_count += $item->c; @endphp {{ number_format((float) $item->p , 2) }} @php $total_collection += $item->p; @endphp
{{ __('messages.Empty Result') }}

{{ __('messages.Offer') }}

{{ __('messages.Count') }}

{{ __('messages.collection') }}

@php $off =App\Models\Offer::find($item->offer_id); @endphp {{ $off? $off->name :""}} {{ $item->c }} @php $all_count += $item->c; @endphp {{ number_format((float) $item->p , 2) }} @php $total_collection += $item->p; @endphp
{{ __('messages.Empty Result') }}

{{ __('messages.Package') }}

{{ __('messages.Count') }}

{{ __('messages.collection') }}

@php $pack = App\Models\Package::find($item->package_id); $pack_item_count =$pack->package_products->count(); @endphp {{ $pack?$pack->name :""}} {{ round($item->c / $pack_item_count)}} @php $all_count += round($item->c /$pack_item_count); @endphp {{ number_format((float) $item->p , 2) }} @php $total_collection += round($item->p /$pack_item_count) ; @endphp
{{ __('messages.Empty Result') }}

{{ __('messages.Club MemberShip') }}

{{ __('messages.Count') }}

{{ __('messages.collection') }}

@php $club = App\Models\ClubMembership::find($item->id); @endphp {{ $club?$club->name :""}} {{ $item->c }} @php $all_count += $item->c; @endphp {{ number_format((float) $item->p , 2) }} @php $total_collection += $item->p; @endphp
{{ __('messages.Empty Result') }}

{{ __('messages.installment package') }}

{{ __('messages.Count') }}

{{ __('messages.collection') }}

@php $inst_pack = App\Models\InstallmentPackageProduct::find($item->installment_package_id); @endphp {{ $inst_pack?$inst_pack->name :""}} {{ $item->c }} @php $all_count += $item->c; @endphp {{ number_format((float) $item->p , 2) }} @php $total_collection += $item->p; @endphp
{{ __('messages.Empty Result') }}

{{ __('messages.Total') }}

{{ $all_count }} {{ number_format((float) $total_collection , 2) }}