@php use Hekmatinasser\Verta\Verta; @endphp @extends('panel.layouts.master') @section('content')
نرخ جذب کارشناسان
{{-- --}}
@csrf
{{--
--}} {{--
--}} {{-- --}} {{-- --}} {{--
--}} {{--
--}} {{--
--}} {{--
--}} {{-- --}} {{-- --}} {{--
--}} {{--
--}}
@foreach($data as $key => $item) @php $cashes = $item->phones()->whereBetween('takmil_variz', [$from_date, $to_date])->whereStatus('takmil_variz')->whereNotNull('takmil_variz')->whereHas('user', function ($q){ $q->whereHas('payments', function ($q){ $q->whereStatus('success'); $q->wherePayType('cash'); }); })->count(); $installments = $item->phones()->whereBetween('takmil_variz', [$from_date, $to_date])->whereNotNull('takmil_variz')->whereHas('user', function ($q){ $q->whereHas('payments', function ($q){ $q->whereStatus('success'); $q->wherePayType('installment'); }); $q->whereDoesntHave('payments', function ($q){ $q->whereStatus('success'); $q->wherePayType('cash'); }); })->count(); $installments_2 = $item->phones()->whereStatus('takmil_variz_2')->whereNotNull('takmil_variz')->whereHas('user', function ($q) use($from_date, $to_date){ $q->whereHas('payments', function ($q) use($from_date, $to_date){ $q->whereStatus('success'); $q->wherePayType('installment'); $q->whereHas('installment', function ($q) use($from_date, $to_date){ $from_date = Verta::parse($from_date)->formatGregorian('Y-m-d H:i:s'); $to_date = Verta::parse($to_date)->formatGregorian('Y-m-d H:i:s'); $q->whereNumber(2); $q->whereStatus('success'); $q->whereBetween('updated_at', [$from_date, $to_date]); }); }); $q->whereDoesntHave('payments', function ($q){ $q->whereStatus('success'); $q->wherePayType('cash'); }); })->count(); $installments_3 = $item->phones() ->whereStatus('takmil_variz') ->whereNotNull('takmil_variz') ->whereHas('user', function ($q) use($from_date, $to_date) { $q->whereHas('payments', function ($q) use($from_date, $to_date) { $q->whereStatus('success') ->wherePayType('installment')->latest('updated_at') ->whereHas('installment', function ($q) use($from_date, $to_date) { $q->whereStatus('success') ->whereBetween('updated_at', [ Verta::parse($from_date)->formatGregorian('Y-m-d H:i:s'), Verta::parse($to_date)->formatGregorian('Y-m-d H:i:s') ]); }); }) ->whereDoesntHave('payments', function ($q) { $q->whereStatus('success') ->wherePayType('cash'); }); }) ->count(); $withAdvisers = $item->phones()->whereBetween('date', [$from_date, $to_date])->whereNotNull('date')->count(); if($withAdvisers){ $rate = (($cashes + $installments) / $withAdvisers) * 100; }else{ $rate = 0; } @endphp @endforeach
ردیف نام و نام خانوادگی فروش نقدی فروش اقساط (قسط اول) فروش اقساط (قسط دوم) فروش اقساط (قسط سوم) تعداد تحویل نرخ برحسب درصد
{{ ++$key }} {{ $item->fullName }} {{ $cashes }} {{ $installments }} {{ $installments_2 }} {{ $installments_3 }} {{ $withAdvisers }} {{ number_format($rate, 2) }}%
{{ $data->appends(Request::all())->links() }}
@endsection