@extends('layouts.manager') @section('title','Тімліди') @section('page_title','Тімліди') @section('page_actions') Додати тімліда @endsection @push('head') @endpush @section('content') @php $tz = config('app.timezone', 'Europe/Kyiv'); $selectedMonth = $selectedMonth ?? \Carbon\Carbon::now($tz)->format('Y-m'); $currentMonthKey = $currentMonthKey ?? \Carbon\Carbon::now($tz)->format('Y-m'); $prevMonthKey = $prevMonthKey ?? \Carbon\Carbon::now($tz)->subMonthNoOverflow()->format('Y-m'); $totalTL = $teamLeads->count(); // ✔ Скільки тімлідів виконали норму по балансах (умовно: balance_score >= 90) $completedNorms = $teamLeads->filter(function ($u) use ($teamLeadRatings) { $rating = $teamLeadRatings[$u->id] ?? null; if (!$rating) return false; $balanceScore = $rating['balance_score'] ?? null; return $balanceScore !== null && $balanceScore >= 90; })->count(); // ✔ Скільки мають високий рейтинг по статистиці (умовно: stats_score >= 70) $highStats = $teamLeads->filter(function ($u) use ($teamLeadRatings) { $rating = $teamLeadRatings[$u->id] ?? null; if (!$rating) return false; $statsScore = $rating['stats_score'] ?? null; return $statsScore !== null && $statsScore >= 70; })->count(); $enriched = $teamLeads->map(function ($u) use ($teamLeadRatings) { $rating = $teamLeadRatings[$u->id] ?? null; $balanceRank = $rating['balance_rank'] ?? null; $statsRank = $rating['stats_rank'] ?? null; $balanceScore = $rating['balance_score'] ?? null; $statsScore = $rating['stats_score'] ?? null; $avgBalanceAmount = $rating['avg_balance_amount'] ?? null; $bestRank = null; if ($balanceRank) $bestRank = $balanceRank; if ($statsRank && ($bestRank === null || $statsRank < $bestRank)) $bestRank = $statsRank; // ✅ Комбінований рейтинг: 40% баланс + 60% статистика $combined = null; if ($balanceScore !== null && $statsScore !== null) { $combined = round(($balanceScore * 0.4) + ($statsScore * 0.6), 2); } return [ 'model' => $u, 'balance_rank' => $balanceRank, 'stats_rank' => $statsRank, 'balance_score' => $balanceScore, 'stats_score' => $statsScore, 'avg_balance' => $avgBalanceAmount, 'best_rank' => $bestRank, 'combined_score' => $combined, ]; }); // ✅ ТОП-3 "по всьому разом" (тільки ті, у кого є і баланс, і статистика) $topThree = $enriched ->filter(fn($row) => $row['combined_score'] !== null) ->sortByDesc('combined_score') ->take(3) ->values(); $ratedCount = $enriched->filter(fn($r) => $r['balance_score'] !== null || $r['stats_score'] !== null)->count(); @endphp {{-- Full width wrapper --}}
| Тімлід | Email / Очима тімліда | Кабінети | Рейтинг (баланси) | Рейтинг (статистика) | Дії |
|---|---|---|---|---|---|
|
{{ $initial }}
{{ $u->name }}
@php
$parts = [];
if ($balanceRank) $parts[] = "Баланси: #{$balanceRank} із {$totalTL}";
if ($statsRank) $parts[] = "Статистика: #{$statsRank} із {$totalTL}";
@endphp
{!! implode(' • ', $parts) !!}
|
{{ $u->email }}
Очима тімліда
|
@if($cabCount)
@foreach($u->cabinets as $c)
{{ $c->slug }}
@endforeach
Всього: {{ $cabCount }}
@else
—
@endif
|
@if($balanceScore !== null)
{{ $balanceScore }} / 100
@else
немає даних
@endif
@if($avgBalanceAmount !== null)
{{ number_format($avgBalanceAmount, 2) }} $
@endif
Середній рейтинг по всіх кабінетах (баланси змін).
@if($balanceRank)
Місце: #{{ $balanceRank }}
@endif
|
@if($statsScore !== null)
{{ $statsScore }} / 100
@else
немає даних
@endif
New / Young / Old / Spend (середній рейтинг).
@if($statsRank)
Місце: #{{ $statsRank }}
@endif
|
Редагувати |
| Поки немає тімлідів | |||||