@extends('layouts/layoutMaster')
@php
use Carbon\Carbon;
use Illuminate\Support\Str;
$pageConfigs = [
'myLayout' => 'blank',
'navbarType' => 'hidden',
'menuFixed' => false,
'contentLayout' => 'compact',
];
$user = auth()->user();
$firstName = Str::of($user?->name ?? 'Rider')->explode(' ')->first();
$locale = app()->getLocale();
$monthStart = Carbon::parse($monthly['period']['month_start'])->locale($locale);
$periodEnd = Carbon::parse($monthly['period']['end'])->locale($locale);
$monthLabel = Str::ucfirst($monthStart->isoFormat('MMMM YYYY'));
$todayLabel = $periodEnd->isoFormat('D MMM');
$ordersActual = (float) ($monthly['actual']['orders'] ?? 0);
$ordersExpectedToDate = (float) ($monthly['target']['expected_orders_to_date'] ?? 0);
$ordersExpectedFull = (float) ($monthly['target']['expected_orders_full'] ?? 0);
$ordersProgressPercent = (float) ($monthly['progress']['orders'] ?? 0);
$ordersRemainingToDate = (float) ($monthly['progress']['orders_remaining'] ?? 0);
$ordersRemainingFull = (float) ($monthly['progress']['orders_remaining_full'] ?? 0);
$hoursActual = (float) ($monthly['actual']['hours'] ?? 0);
$hoursExpectedToDate = (float) ($monthly['target']['expected_hours_to_date'] ?? 0);
$hoursExpectedFull = (float) ($monthly['target']['expected_hours_full'] ?? 0);
$hoursProgressPercent = (float) ($monthly['progress']['hours'] ?? 0);
$ordersPerHourActual = (float) ($monthly['actual']['ratio'] ?? 0);
$ordersPerHourTarget = (float) ($monthly['target']['orders_per_hour'] ?? 0);
$targetWeeklyHours = (float) ($monthly['target']['weekly_hours'] ?? 0);
$userWeeklyHours = (float) ($monthly['target']['user_weekly_hours'] ?? $targetWeeklyHours);
$targetOrdersMonth = (float) ($monthly['target']['orders_per_month'] ?? $ordersExpectedFull);
$targetSource = $monthly['target']['source'] ?? [];
$targetSourceType = $targetSource['type'] ?? 'global';
$scopeTranslations = [
'global' => 'Global',
'company' => 'Empresa',
'city' => 'Ciudad',
'zone' => 'Zona',
];
$targetScopeLabel = $scopeTranslations[$targetSourceType] ?? ($targetSource['label'] ?? 'Global');
$targetScopeName = $targetSource['name'] ?? null;
$targetSourceText = $targetScopeLabel . ($targetScopeName ? ' · '.$targetScopeName : '');
$assignmentStart = Carbon::parse($monthly['period']['assignment_start'])->locale($locale);
$assignmentStartLabel = $assignmentStart->isoFormat('D MMM');
$daysActive = (int) ($monthly['period']['days_active'] ?? 0);
$daysInMonth = (int) ($monthly['period']['days_in_month'] ?? 0);
$ordersProgressDisplay = max(0, min(140, $ordersProgressPercent));
$hoursProgressDisplay = max(0, min(140, $hoursProgressPercent));
$ordersAhead = $ordersActual - $ordersExpectedToDate;
$ordersAheadAbs = abs($ordersAhead);
$hoursAhead = $hoursActual - $hoursExpectedToDate;
$hoursAheadAbs = abs($hoursAhead);
$hoursRemainingToDate = max(0, $hoursExpectedToDate - $hoursActual);
$ordersActualFormatted = number_format($ordersActual, 0, ',', '.');
$ordersExpectedToDateFormatted = number_format($ordersExpectedToDate, 0, ',', '.');
$ordersExpectedFullFormatted = number_format($ordersExpectedFull, 0, ',', '.');
$ordersRemainingToDateFormatted = number_format(max(0, $ordersRemainingToDate), 0, ',', '.');
$ordersRemainingFullFormatted = number_format(max(0, $ordersRemainingFull), 0, ',', '.');
$ordersProgressPercentFormatted = number_format($ordersProgressPercent, 1, ',', '.');
$hoursActualFormatted = number_format($hoursActual, 1, ',', '.');
$hoursExpectedToDateFormatted = number_format($hoursExpectedToDate, 1, ',', '.');
$hoursExpectedFullFormatted = number_format($hoursExpectedFull, 1, ',', '.');
$hoursRemainingToDateFormatted = number_format($hoursRemainingToDate, 1, ',', '.');
$hoursProgressPercentFormatted = number_format($hoursProgressPercent, 1, ',', '.');
$ordersPerHourActualFormatted = number_format($ordersPerHourActual, 2, ',', '.');
$ordersPerHourTargetFormatted = number_format($ordersPerHourTarget, 2, ',', '.');
$targetOrdersMonthFormatted = number_format($targetOrdersMonth, 0, ',', '.');
$targetWeeklyHoursFormatted = number_format($targetWeeklyHours, 1, ',', '.');
$userWeeklyHoursFormatted = number_format($userWeeklyHours, 1, ',', '.');
$walletBalanceFormatted = $wallet['balance_formatted'] ?? '0,00';
$walletCurrency = $wallet['currency'] ?? 'EUR';
$walletTransactions = collect($wallet['transactions'] ?? [])->map(function ($transaction) use ($locale) {
$transaction->amount_formatted = number_format((float) $transaction->amount, 2, ',', '.');
$transaction->date_label = $transaction->created_at
? $transaction->created_at->copy()->locale($locale)->isoFormat('D MMM · HH:mm')
: '';
$transaction->type_label = $transaction->type === 'credit' ? 'Ingreso' : 'Cargo';
return $transaction;
});
$walletLastTx = $wallet['last_transaction'] ?? null;
$walletLastAmount = $walletLastTx ? number_format((float) $walletLastTx->amount, 2, ',', '.') : null;
$walletLastLabel = $walletLastTx && $walletLastTx->created_at
? $walletLastTx->created_at->copy()->locale($locale)->diffForHumans(null, null, 2)
: null;
$walletLastDescription = $walletLastTx ? ($walletLastTx->description ?? ($walletLastTx->type === 'credit' ? 'Ingreso a monedero' : 'Cargo en monedero')) : null;
$walletLastTypeClass = $walletLastTx ? ($walletLastTx->type === 'credit' ? 'positive' : 'negative') : 'neutral';
if ($ordersAhead > 0.5) {
$ordersMessage = 'Llevas '.number_format($ordersAheadAbs, 1, ',', '.').' pedidos por encima de lo esperado.';
$ordersDeltaClass = 'positive';
} elseif ($ordersRemainingToDate > 0.5) {
$ordersMessage = 'Te faltan '.$ordersRemainingToDateFormatted.' pedidos para ponerte al día.';
$ordersDeltaClass = 'negative';
} else {
$ordersMessage = 'Estás cumpliendo el objetivo de pedidos.';
$ordersDeltaClass = 'neutral';
}
if ($hoursAhead > 0.25) {
$hoursMessage = 'Has acumulado '.number_format($hoursAheadAbs, 1, ',', '.').' horas extra este mes.';
$hoursDeltaClass = 'positive';
} elseif ($hoursRemainingToDate > 0.25) {
$hoursMessage = 'Te faltan '.$hoursRemainingToDateFormatted.' horas para llegar al objetivo.';
$hoursDeltaClass = 'negative';
} else {
$hoursMessage = 'Horas registradas en línea con el objetivo.';
$hoursDeltaClass = 'neutral';
}
$compareCards = [
['key' => 'today', 'label' => 'Hoy'],
['key' => 'yesterday', 'label' => 'Ayer'],
['key' => 'this_week', 'label' => 'Semana actual'],
['key' => 'last_week', 'label' => 'Semana pasada'],
];
@endphp
@section('title')
Dashboard Rider
@endsection
@section('page-style')
@endsection
@section('content')
- {{ $ordersActualFormatted }} pedidos completados
- {{ $ordersExpectedToDateFormatted }} pedidos objetivo a hoy
- {{ $ordersExpectedFullFormatted }} pedidos meta del mes
{{ $ordersMessage }}
Para cerrar el mes necesitas {{ $ordersRemainingFullFormatted }} pedidos más.
- {{ $hoursActualFormatted }} horas registradas
- {{ $hoursExpectedToDateFormatted }} horas objetivo a hoy
- {{ $hoursExpectedFullFormatted }} horas meta del mes
{{ $hoursMessage }}
Objetivo mensual basado en {{ $targetWeeklyHoursFormatted }} h/sem.
- Objetivo: {{ $ordersPerHourTargetFormatted }} pedidos por hora
- Pedidos meta del mes: {{ $targetOrdersMonthFormatted }}
- Contratación semanal planificada: {{ $targetWeeklyHoursFormatted }} h
Mantén el ratio por encima del objetivo para asegurar tus pedidos.
Monedero
Saldo actual
{{ $walletBalanceFormatted }} {{ $walletCurrency }}
Gestiona tus pagos y recargas desde soporte o contacta con tu coordinador.
El saldo reflejado incluye los últimos movimientos registrados.
Movimientos recientes
{{ $walletTransactions->count() }} registros
@if($walletTransactions->isEmpty())
Aún no tienes movimientos en tu monedero.
@else
@foreach($walletTransactions as $transaction)
-
{{ $transaction->description ?? $transaction->type_label }}
{{ $transaction->date_label }}
{{ $transaction->type === 'credit' ? '+' : '-' }}{{ $transaction->amount_formatted }} {{ $walletCurrency }}
@endforeach
@endif
Comparativa rápida
@foreach ($compareCards as $card)
@php
$data = $compare[$card['key']] ?? [];
$cOrders = number_format((float) ($data['orders'] ?? 0), 0, ',', '.');
$cHours = number_format((float) ($data['hours'] ?? 0), 1, ',', '.');
$cRatio = number_format((float) ($data['ratio'] ?? 0), 2, ',', '.');
@endphp
{{ $card['label'] }}
{{ $cOrders }} pedidos
{{ $cHours }} h • {{ $cRatio }} ped/h
@endforeach
Objetivo aplicado
- Nivel: {{ $targetSourceText }}
- Horas contrato (configuradas): {{ $targetWeeklyHoursFormatted }} h/sem
- Pedidos esperados al mes: {{ $targetOrdersMonthFormatted }}
- Pedidos esperados al día de hoy: {{ $ordersExpectedToDateFormatted }}
- Pedidos restantes para el mes: {{ $ordersRemainingFullFormatted }}
Si cambias de zona o empresa, el objetivo puede actualizarse automáticamente para ajustarse a la nueva configuración.
@include('rider.partials.nav', ['navActive' => 'home'])
@endsection