{{ __('messages.search') }}
year @foreach ($years as $selectd_year) @endforeach
month @foreach ($months as $selected_month) @endforeach
@php $currencies = \App\Models\Currency::whereHas('monthly_targets', function ($query) { $query->where('month', $this->month); $query->where('year', $this->year); })->get(); $total_planned = 0; $total_collection = 0; @endphp @foreach ($currencies as $currency) @php $total_planned = 0; $total_collection = 0; @endphp @foreach (\App\Models\MonthlyTarget::where('month', $this->month)->where('year', $this->year)->where('currency_id', $currency->id)->orderBy('total_collection', 'desc')->get() as $user_monthly_target) @php if ($user_monthly_target->total_planned_amount == 0 && $user_monthly_target->total_collection > 0) { $user_total_percent = 100; } elseif ($user_monthly_target->total_planned_amount == 0 && $user_monthly_target->total_collection == 0) { $user_total_percent = 0; } else { $user_total_percent = round(($user_monthly_target->total_collection / $user_monthly_target->total_planned_amount) * 100); } @endphp @endforeach @foreach (\App\Models\Category::whereIn('id', \App\Models\MonthlyTargetPoint::distinct()->pluck('category_id'))->get() as $cat) @php $planned = 0; $collection = 0; $monthly_target_ids = \App\Models\MonthlyTarget::where('month', $this->month) ->where('year', $this->year) ->where('currency_id', $currency->id) ->pluck('id'); if ($monthly_target_ids->count() > 0) { $rslt = \App\Models\MonthlyTargetPoint::where('category_id', $cat->id) ->selectRaw('sum(planned_amount) planned_amount , sum(collection) collection ') ->whereIn('monthly_target_id', $monthly_target_ids) ->first(); if ($rslt) { $planned = round($rslt->planned_amount); $collection = round($rslt->collection); $total_planned += $planned; $total_collection += $collection; } } if ($planned == 0 && $collection > 0) { $percent = 100; } elseif ($planned == 0 && $collection == 0) { $percent = 0; } else { $percent = round(($collection / $planned) * 100); } @endphp @endforeach @php $mt = \App\Models\MonthlyTarget::where('month', $this->month) ->where('year', $this->year) ->where('currency_id', $currency->id) ->selectRaw('sum(total_planned_amount) total_planned_amount , sum(total_collection) total_collection ') ->first(); if ($mt) { $total_planned = $mt->total_planned_amount ? $mt->total_planned_amount : $total_planned; $total_collection = $mt->total_collection; } if ($total_planned == 0 && $total_collection > 0) { $total_percent = 100; } elseif ($total_planned == 0 && $total_collection == 0) { $total_percent = 0; } else { $total_percent = round(($total_collection / $total_planned) * 100); } @endphp @endforeach
{{ __('messages.User') }} {{ __('messages.planned') }} {{ __('messages.collection') }}
{{ $user_monthly_target->assigned_to_user->name }} {{ number_format($user_monthly_target->total_planned_amount, 2) }} {{ $user_monthly_target->currency_id ? $user_monthly_target->currency->name : '' }} {{ number_format($user_monthly_target->total_collection, 2) }} {{ $user_monthly_target->currency_id ? $user_monthly_target->currency->name : '' }}
{{ $user_total_percent }}%
{{ __('messages.Total Company Target') }} ({{ $currency->name }}) {{ number_format($total_planned, 2) }} {{ $currency->name }} {{ number_format($total_collection, 2) }} {{ $currency->name }}
{{ $total_percent }}%