mivita/resources/views/partials/incentive/_source_table.blade.php
2026-04-10 17:15:27 +02:00

89 lines
4.7 KiB
PHP

@php $total = 0; $colspan = 3 + count($calculation_months); @endphp
<div class="table-responsive">
<table class="table table-sm table-striped table-bordered mb-0">
<thead>
<tr>
<th>{{ $label_header }}</th>
<th>{{ $date_header }}</th>
<th class="text-right">{{ __('incentive.onetime') }}</th>
@foreach($calculation_months as $period)
<th class="text-right">{{ str_pad($period['month'], 2, '0', STR_PAD_LEFT) }}/{{ $period['year'] }}</th>
@endforeach
<th class="text-right font-weight-bold">{{ __('incentive.sum') }}</th>
</tr>
</thead>
<tbody>
@forelse($sources as $idx => $source)
<tr class="{{ count($source['transactions']) > 0 ? 'cursor-pointer' : '' }}"
@if(count($source['transactions']) > 0)
data-toggle="collapse" data-target="#transactions-{{ $type }}-{{ $source['id'] }}" aria-expanded="false"
@endif
>
<td>
@if(count($source['transactions']) > 0)
<i class="fa fa-chevron-right fa-xs text-muted mr-1 toggle-icon" id="icon-{{ $type }}-{{ $source['id'] }}"></i>
@endif
{{ $source['label'] }}
</td>
<td>{{ str_pad($source['month'], 2, '0', STR_PAD_LEFT) }}/{{ $source['year'] }}</td>
<td class="text-right">{{ number_format($source['onetime'], 0, ',', '.') }}</td>
@foreach($source['monthly'] as $mp)
<td class="text-right">{{ $mp > 0 ? number_format($mp, 0, ',', '.') : '-' }}</td>
@endforeach
<td class="text-right font-weight-bold">{{ number_format($source['total'], 0, ',', '.') }}</td>
</tr>
@if(count($source['transactions']) > 0)
<tr class="collapse" id="transactions-{{ $type }}-{{ $source['id'] }}">
<td colspan="{{ $colspan + 1 }}" class="p-0 border-0">
<table class="table table-sm mb-0 bg-light">
<thead>
<tr class="text-muted small">
<th class="pl-4">{{ __('incentive.transaction_date') }}</th>
<th>{{ __('incentive.transaction_description') }}</th>
<th>{{ __('incentive.transaction_period') }}</th>
<th class="text-right">{{ __('incentive.transaction_type') }}</th>
<th class="text-right pr-4">{{ __('incentive.transaction_points') }}</th>
</tr>
</thead>
<tbody>
@foreach($source['transactions'] as $tx)
<tr class="small">
<td class="pl-4">{{ $tx['date'] }}</td>
<td>{{ $tx['label'] }}</td>
<td>{{ str_pad($tx['month'], 2, '0', STR_PAD_LEFT) }}/{{ $tx['year'] }}</td>
<td class="text-right">
@if($tx['type'] === 'onetime')
<span class="badge badge-primary">{{ __('incentive.onetime') }}</span>
@else
<span class="badge badge-info">{{ __('incentive.accumulated') }}</span>
@endif
</td>
<td class="text-right pr-4 font-weight-bold">{{ number_format($tx['points'], 0, ',', '.') }}</td>
</tr>
@endforeach
</tbody>
</table>
</td>
</tr>
@endif
@php $total += $source['total']; @endphp
@empty
<tr>
<td colspan="{{ $colspan + 1 }}" class="text-center text-muted">{{ $empty_message }}</td>
</tr>
@endforelse
@if(count($sources) > 0)
<tr class="font-weight-bold table-secondary">
<td colspan="{{ $colspan }}">{{ __('incentive.subtotal') }}</td>
<td class="text-right">{{ number_format($total, 0, ',', '.') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
<style>
.cursor-pointer { cursor: pointer; }
.cursor-pointer:hover { background-color: rgba(0,0,0,.05) !important; }
.toggle-icon { transition: transform .2s; }
tr[aria-expanded="true"] .toggle-icon { transform: rotate(90deg); }
</style>