Skip to content

Commit

Permalink
On balance overview split users list into active and inacive tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
rjackson committed Jan 3, 2025
1 parent 6823917 commit 6bfa834
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 30 deletions.
6 changes: 4 additions & 2 deletions app/Http/Controllers/PaymentBalancesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public function index()
$inactiveUsersInDebtQty = User::where('active', false)->where('cash_balance', '<', 0)->count();
$inactiveUsersInDebtSum = User::where('active', false)->where('cash_balance', '<', 0)->sum('cash_balance') / 100;

$users = User::where('cash_balance', '!=', 0)->get();
$activeUsers = User::where('active', true)->where('cash_balance', '!=', 0)->orderBy('cash_balance', 'desc')->get();
$inactiveUsers = User::where('active', false)->where('cash_balance', '!=', 0)->orderBy('cash_balance', 'desc')->get();

return \View::make('payment_balances.index')->with([
'activeUsersInCreditQty' => $activeUsersInCreditQty,
Expand All @@ -30,7 +31,8 @@ public function index()
'inactiveUsersInCreditSum' => $inactiveUsersInCreditSum,
'inactiveUsersInDebtQty' => $inactiveUsersInDebtQty,
'inactiveUsersInDebtSum' => $inactiveUsersInDebtSum,
'users' => $users,
'activeUsers' => $activeUsers,
'inactiveUsers' => $inactiveUsers,
]);
}
}
95 changes: 67 additions & 28 deletions resources/views/payment_balances/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,71 @@
</tbody>
</table>

<table class="table memberList">
<thead>
<tr>
<th>Member name</th>
<th>Member Status</th>
<th>Balance status (in debt or in credit)</th>
<th>Balance amount</th>
</tr>
</thead>
<tbody>
@foreach ($users as $user)
<tr>
<td>
<a href="{{ route('account.show', $user->id) }}">{{ $user->name }}</a>
</td>
<td>{!! HTML::statusLabel($user->status) !!}</td>
<td>
@if ($user->cash_balance < 0)
<span class="label label-danger">In debt</span>
@else
<span class="label label-info">In credit</span>
@endif
</td>
<td>{{ $user->present()->cashBalance }}</td>
</tr>
@endforeach
</tbody>
</table>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#active-users">Active Users</a></li>
<li><a data-toggle="tab" href="#inactive-users">Inactive Users</a></li>
</ul>

<div class="tab-content">
<div id="active-users" class="tab-pane fade in active">
<table class="table memberList">
<thead>
<tr>
<th>Member name</th>
<th>Member Status</th>
<th>Balance status (in debt or in credit)</th>
<th>Balance amount</th>
</tr>
</thead>
<tbody>
@foreach ($activeUsers as $user)
<tr>
<td>
<a href="{{ route('account.show', $user->id) }}">{{ $user->name }}</a>
</td>
<td>{!! HTML::statusLabel($user->status) !!}</td>
<td>
@if ($user->cash_balance < 0)
<span class="label label-danger">In debt</span>
@else
<span class="label label-info">In credit</span>
@endif
</td>
<td>{{ $user->present()->cashBalance }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div id="inactive-users" class="tab-pane fade">
<table class="table memberList">
<thead>
<tr>
<th>Member name</th>
<th>Member Status</th>
<th>Balance status (in debt or in credit)</th>
<th>Balance amount</th>
</tr>
</thead>
<tbody>
@foreach ($inactiveUsers as $user)
<tr>
<td>
<a href="{{ route('account.show', $user->id) }}">{{ $user->name }}</a>
</td>
<td>{!! HTML::statusLabel($user->status) !!}</td>
<td>
@if ($user->cash_balance < 0)
<span class="label label-danger">In debt</span>
@else
<span class="label label-info">In credit</span>
@endif
</td>
<td>{{ $user->present()->cashBalance }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@stop

0 comments on commit 6bfa834

Please sign in to comment.