Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Displaying perms day by day #310

Merged
merged 5 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/Http/Controllers/Admin/PermController.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,16 @@ public function import()
public function shotgun() {
$perms = Perm::orderby('start')->get();
$user = Auth::user(); // user that make the request
if (!array_key_exists('day', Request::query())) {
return redirect(route('dashboard.perm.shotgun', ['day' => 1]));
}
$day = Request::query()['day'];
if (!$day || $day < 1 || $day > 7) {
return redirect(route('dashboard.perm.shotgun', ['day' => 1]));
}
$perms = $perms->filter(function ($perm) use ($day) {
return date('N', $perm->start) == $day;
});
foreach ($perms as $perm) {
$found = false;
foreach ($perm->permanenciers as $permanencier) {
Expand All @@ -336,7 +346,7 @@ public function shotgun() {
$perm->isOpen = $open < new \DateTime('now');
}
setlocale(LC_TIME, 'fr_FR.utf8');
return view('dashboard.perms.shotgun', compact('perms'));
return view('dashboard.perms.shotgun', compact('perms', 'day'));
}

public function doShotgun($id) {
Expand Down
16 changes: 14 additions & 2 deletions resources/views/dashboard/perms/shotgun.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
<div class="callout callout-info">
<h4>Shotgun des permanences</h4>
</div>
<div class="box-body">
<a href="{{ route('dashboard.perm.shotgun', ['day' => 1]) }}">
<button class="btn btn-primary" {{ $day == 1 ? 'disabled' : '' }}>Lundi</button>
</a>
<a href="{{ route('dashboard.perm.shotgun', ['day' => 2]) }}">
<button class="btn btn-primary" {{ $day == 2 ? 'disabled' : '' }}>Mardi</button>
</a>
<a href="{{ route('dashboard.perm.shotgun', ['day' => 3]) }}">
<button class="btn btn-primary" {{ $day == 3 ? 'disabled' : '' }}>Mercredi</button>
</a>
<a href="{{ route('dashboard.perm.shotgun', ['day' => 4]) }}">
<button class="btn btn-primary" {{ $day == 4 ? 'disabled' : '' }}>Jeudi</button>
</a>
</div>
<div class="box box-default">
<div class="box-body table-responsive no-padding">
<table class="table table-hover align-middle text-center">
Expand All @@ -20,7 +34,6 @@
<th>Rejoindre</th>
<th>Nom</th>
<th>Lieu</th>
<th>Jour</th>
<th>Début</th>
<th>Fin</th>
<th>Permanenciers</th>
Expand All @@ -36,7 +49,6 @@
</td>
<td>{{ $perm->type->name }}</td>
<td>{{ $perm->place }}</td>
<td>{{ strftime('%A', $perm->start) }}</td>
<td>{{ date('G\\Hi', $perm->start) }}</td>
<td>{{ date('G\\Hi', $perm->end) }}</td>
<td>{{ $perm->permanenciers->count().'/'.$perm->nbr_permanenciers }}</td>
Expand Down
Loading