atcheck/resources/views/user/user_attendances.blade.php

160 lines
8.9 KiB
PHP

@extends('home')
@section('title') My Panel - Attendance @endsection
@section('user_content')
<div class="row justify-content-center">
<div class="col-md-12">
<div class="card-body">
<h4 class="card-header"> Add new attendance record </h4>
<form method="POST" action="{{ route('user_add_attendance') }}" class="col-md-12">
@csrf
<div class="form-group row">
<label for="classes_id" class="col-md-4 col-form-label text-md-right">{{ __('Classes') }}</label>
<div class="col-md-6">
<select id="classes_id" class="form-control @error('classes_id') is-invalid @enderror" name="classes_id" required>
@foreach ($classes as $classes_item)
<option value="{{ $classes_item->id }}">{{ App\Subject::find(App\Classes::find($classes_item->id)->subject_id)->name }},
{{ App\Subject::find(App\Classes::find($classes_item->id)->subject_id)->type }},
{{ App\Classes::find($classes_item->id)-> date }} {{ App\Subject::find(App\Classes::find($classes_item->id)->subject_id)->time }}
</option>
@endforeach
</select>
@error('classes_id')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="student_id" class="col-md-4 col-form-label text-md-right">{{ __('Student ID') }}</label>
<div class="col-md-6">
<input id="student_id" type="number" class="form-control @error('student_id') is-invalid @enderror" name="student_id" value="{{ old('student_id') }}" required autocomplete="student_id" autofocus>
@error('student_id')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="student_name" class="col-md-4 col-form-label text-md-right">{{ __('Student name') }}</label>
<div class="col-md-6">
<input id="student_name" type="text" class="form-control @error('student_name') is-invalid @enderror" name="student_name" value="{{ old('student_name') }}" autocomplete="student_name">
@error('student_name')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="student_surname" class="col-md-4 col-form-label text-md-right">{{ __('Student surname') }}</label>
<div class="col-md-6">
<input id="student_surname" type="text" class="form-control @error('student_surname') is-invalid @enderror" name="student_surname" value="{{ old('student_surname') }}" autocomplete="student_surname">
@error('student_surname')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row">
<label for="seat_number" class="col-md-4 col-form-label text-md-right">{{ __('Seat number') }}</label>
<div class="col-md-6">
<input id="seat_number" type="number" class="form-control @error('seat_number') is-invalid @enderror" name="seat_number" value="{{ old('seat_number') }}" required autocomplete="seat_number" autofocus>
@error('seat_number')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
@enderror
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary">
{{ __('Add') }}
</button>
</div>
</div>
</form>
</div>
<div class="card-body">
@if ($attendances->count() > 0)
<h4 class="card-header"> My all attendance records: ({{ $attendances->count() }}) </h4>
<div class="card-body">
<span> Group by: </span>
<a href="{{ route('user_attendances', ['classes_id']) }}" class="btn btn-primary"> Classes name </a>
<a href="{{ route('user_attendances', ['student_id_number']) }}" class="btn btn-primary"> Student ID </a>
<a href="{{ route('user_attendances', ['seat_number']) }}" class="btn btn-primary"> Seat number </a>
</div>
@foreach ($attendances_grouped as $attendances_group_name => $attendances_list)
@if($attendances_group_name)
@if($grouped_by == 'classes_id')
<h5 class="card-title"> {{ App\Subject::find(App\Classes::find($attendances_group_name)->subject_id)->name }},
{{ App\Subject::find(App\Classes::find($attendances_group_name)->subject_id)->type }},
{{ App\Classes::find($attendances_group_name)-> date }} {{ App\Subject::find(App\Classes::find($attendances_group_name)->subject_id)->time }}
({{ $attendances_list->count() }}) </h5>
@else
<h5 class="card-title"> {{ $attendances_group_name }} ({{ $attendances_list->count() }}) </h5>
@endif
@else
<h5 class="card-title"> Other ({{ $attendances_list->count() }})</h5>
@endif
<table class="table table-striped">
<tr class="thead-dark">
<th> Classes name </th>
<th> Student ID </th>
<th> Student name </th>
<th> Student surname </th>
<th> Seat number </th>
<th></th>
<th></th>
</tr>
@foreach ($attendances_list as $attendance)
<tr>
<td> {{ App\Subject::find(App\Classes::find($attendance->classes_id)->subject_id)->name }},
{{ App\Subject::find(App\Classes::find($attendance->classes_id)->subject_id)->type }},
{{ App\Classes::find($attendance->classes_id)-> date }} {{ App\Subject::find(App\Classes::find($attendance->classes_id)->subject_id)->time }} </td>
<td> {{ $attendance->student_id_number }} </td>
<td> {{ $attendance->student_name}}</td>
<td> {{ $attendance->student_surname}}</td>
<td> {{ $attendance->seat_number }} </td>
<td>
<a href="{{ route('user_delete_attendance', [$attendance->id]) }}" name="delete-attendance-btn" class="btn btn-danger"> Delete </a>
</td>
<td>
<a href="{{ route('user_edit_attendance', [$attendance->id]) }}" name="edit-attendance-btn" class="btn btn-secondary"> Edit </a>
</td>
</tr>
@endforeach
</table>
@endforeach
@else
<p> No attendance data yet. </p>
@endif
</div>
</div>
</div>
@endsection