Files
nomina_ventas/resources/views/reports/yearly.blade.php

109 lines
4.6 KiB
PHP
Executable File

@extends('layouts.app')
@section('title', 'Reporte Anual')
@section('content')
<div class="row">
<div class="col-12">
<h2 class="mb-4">Reporte Anual</h2>
</div>
</div>
<!-- Selector de año -->
<div class="row mb-4">
<div class="col-md-4">
<form method="GET" class="d-flex gap-2">
<select name="year" class="form-select" onchange="this.form.submit()">
@foreach($years as $y)
<option value="{{ $y }}" {{ $year == $y ? 'selected' : '' }}>{{ $y }}</option>
@endforeach
</select>
</form>
</div>
</div>
@if($report)
<!-- Resumen Anual -->
<div class="row mb-4">
<div class="col-12">
<div class="card">
<div class="card-header bg-dark text-white">
<h5 class="mb-0">Resumen del Año {{ $year }}</h5>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-2">
<h6 class="text-muted">Meses</h6>
<h4>{{ $report['months_count'] }}</h4>
</div>
<div class="col-md-2">
<h6 class="text-muted">Ventas Usuario</h6>
<h4>${{ number_format($report['total_user_sales'], 0) }}</h4>
</div>
<div class="col-md-2">
<h6 class="text-muted">Ventas Sistema</h6>
<h4>${{ number_format($report['total_system_sales'], 0) }}</h4>
</div>
<div class="col-md-2">
<h6 class="text-muted">Total Salario</h6>
<h4>${{ number_format($report['total_salary'], 2) }}</h4>
</div>
<div class="col-md-2">
<h6 class="text-muted">Total Comisión</h6>
<h4 class="text-success">${{ number_format($report['total_commission'], 2) }}</h4>
</div>
<div class="col-md-2">
<h6 class="text-muted">Total Año</h6>
<h4 class="text-primary">${{ number_format($report['total_earning'], 2) }}</h4>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Meses del año -->
<div class="card">
<div class="card-header">
<h5 class="mb-0">Detalle por Mes</h5>
</div>
<div class="card-body">
<table class="table table-sm table-striped">
<thead>
<tr>
<th>Mes</th>
<th class="text-end">Ventas Usuario</th>
<th class="text-end">Ventas Sistema</th>
<th class="text-end">Gastos</th>
<th class="text-end">Comisión</th>
<th class="text-end">Total</th>
</tr>
</thead>
<tbody>
@forelse($months as $month)
@php
$userSales = $month->dailySales()->sum('user_sales');
$systemSales = $month->dailySales()->sum('system_sales');
$expenses = $month->expenses()->sum('amount');
$commission = ($systemSales * auth()->user()->commission_percentage) / 100;
$total = auth()->user()->monthly_salary + $commission - $expenses;
@endphp
<tr>
<td>{{ $month->name }}</td>
<td class="text-end">${{ number_format($userSales, 2) }}</td>
<td class="text-end">${{ number_format($systemSales, 2) }}</td>
<td class="text-end text-danger">${{ number_format($expenses, 2) }}</td>
<td class="text-end text-success">${{ number_format($commission, 2) }}</td>
<td class="text-end"><strong>${{ number_format($total, 2) }}</strong></td>
</tr>
@empty
<tr><td colspan="6" class="text-center">No hay meses en este año</td></tr>
@endforelse
</tbody>
</table>
</div>
</div>
@else
<div class="alert alert-warning">No hay datos disponibles para este año.</div>
@endif
@endsection