attendance notes added, sorting in classes preview added

This commit is contained in:
s416422 2019-12-19 00:10:39 +01:00
parent a795177918
commit 494b04277e
15 changed files with 199 additions and 45 deletions

View File

@ -21,7 +21,7 @@ class AttendanceExportView implements FromView
public function view(): View
{
$attendances = Attendance::where('classes_id', $this->classes_id)->get();
return view('user.attendances_table_preview', ['attendances' => $attendances]);
return view('user.attendances_table_preview', ['attendances' => $attendances, 'export' => 1]);
}
}

View File

@ -34,26 +34,28 @@ class UserAttendancesController extends Controller
$student_name = $request->input('student_name');
$student_surname = $request->input('student_surname');
$seat_number = $request->input('seat_number');
$note = $request->input('note');
Attendance::create([
'classes_id' => $classes_id,
'student_id_number' => $student_id_number,
'student_name' => $student_name,
'student_surname' => $student_surname,
'seat_number' => $seat_number,
'notes' => $note
]);
return redirect(route('user_attendances'));
return redirect()->back();
}
public function delete_attendance($attendance_id)
{
Attendance::find($attendance_id)->delete();
return redirect(route('user_attendances'));
return redirect()->back();
}
public function edit_attendance($attendance_id)
{
Attendance::find($attendance_id);
return redirect(route('user_attendances'));
return redirect()->back();
}
public function export($classes_id)
@ -72,4 +74,15 @@ class UserAttendancesController extends Controller
return Excel::download(new AttendanceGroupedExportView($groupBy), "all-attendance-grouped-by-{$groupByLabel}-{$today_date}.xlsx");
}
public function add_attendance_note(Request $request)
{
$attendance_id = $request->input('attendance_id');
$note = $request->input('note_content');
$attendance = Attendance::find($attendance_id);
$attendance->notes = $note;
$attendance->save();
$attendance->refresh();
return redirect()->back();
}
}

View File

@ -51,13 +51,13 @@ class UserClassesController extends Controller
public function delete_classes($classes_id)
{
Classes::find($classes_id)->delete();
return redirect(route('user_classes'));
return redirect()->back();
}
public function edit_classes($classes_id)
{
Classes::find($classes_id);
return redirect(route('user_classes'));
return redirect()->back();
}
public function start_classes($classes_id)
@ -120,16 +120,16 @@ class UserClassesController extends Controller
'student_id_number' => $student_id_number,
'student_name' => $student_name,
'student_surname' => $student_surname,
'seat_number' => $seat_number,
'seat_number' => $seat_number
]);
return view('map.summary_map', ['student_name' => $student_name, 'student_surname' => $student_surname, 'seat_number' => $seat_number, 'student_id_number' => $student_id_number, 'classes_id' => $classes_id]);
}
public function preview_classes($classes_id)
public function preview_classes($classes_id, $orderBy='student_surname', $orderDirection='ASC')
{
if(!$classes_id == 0) {
$classes = Classes::find($classes_id);
$attendances = Attendance::where('classes_id', $classes->id)->get();
$attendances = Attendance::where('classes_id', $classes->id)->orderBy($orderBy,$orderDirection)->get();
$seat_numbers = $attendances->pluck('seat_number')->toArray();
$subject = Subject::find($classes->subject_id);
$room_arrangement = Room::find($subject->room_id)->arrangement;
@ -137,6 +137,6 @@ class UserClassesController extends Controller
$room_arrangement = Room::where('name', 'Inna sala')->first()->arrangement;
}
}
return view('user.user_preview_classes', ['classes_id' => $classes_id, 'room_arrangement' => $room_arrangement, 'attendances' => $attendances, 'seat_numbers' => $seat_numbers]);
return view('user.user_preview_classes', ['classes_id' => $classes_id, 'room_arrangement' => $room_arrangement, 'attendances' => $attendances, 'seat_numbers' => $seat_numbers, 'orderBy' => $orderBy, 'orderDirection' => $orderDirection]);
}
}

View File

@ -14,7 +14,7 @@ class UserSubjectsController extends Controller
public function index($groupBy = 'weekday') {
setlocale(LC_ALL, 'pl', 'pl_PL', 'pl_PL.ISO8859-2', 'plk', 'polish', 'Polish');
$user_id = Auth::id();
$subjects = Subject::where('user_id', $user_id)->get();
$subjects = Subject::where('user_id', $user_id)->orderBy('name','ASC')->get();
$subjects_grouped = $subjects->groupBy($groupBy);
$rooms = Room::all();
$weekdays = ['Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota', 'Niedziela'];
@ -43,18 +43,18 @@ class UserSubjectsController extends Controller
'room_id' => $room_id,
'user_id' => $user_id_n
]);
return redirect(route('user_subjects'));
return redirect()->back();
}
public function delete_subject($subject_id)
{
Subject::find($subject_id)->delete();
return redirect(route('user_subjects'));
return redirect()->back();
}
public function edit_subject($subject_id)
{
Subject::find($subject_id);
return redirect(route('user_subjects'));
return redirect()->back();
}
}

View File

@ -11199,3 +11199,14 @@ a.text-dark:focus {
.card-header {
background-color: #ececec;
}
.card-custom {
display: flex;
justify-content: flex-start;
align-items: center;
}
.sort-span {
margin-right: 20px;
}
.form-custom {
width: auto;
}

View File

@ -1,6 +1,5 @@
$(document).ready(function(){
$('.add-mn-btn').on('click', function () {
console.log($('.add-mn-btn'));
$('.czytnik').toggleClass('open');
});
@ -22,4 +21,43 @@ $(document).ready(function(){
$(this).text('Dodaj nowy wpis')
}
});
$(".modal").on("hidden.bs.modal", function(){
const originalText = $(this).find("#note_content_hidden").first().val();
$(this).find("#note_content").first().val(originalText);
});
$('#sort-select').on('change', function() {
$(location).attr('href', $(this).val())
});
$('#group-select').on('change', function() {
$(location).attr('href', $(this).val())
});
function setSelectedOptionSortAttendances() {
const orderBy = $('#orderBy-hidden').first().val();
const orderDirection = $('#orderDirection-hidden').first().val();
const pattern = `/${orderBy}/${orderDirection}`;
const options = $('#sort-select').find('option');
options.each(function() {
if($(this).val().search(pattern) !== -1) {
$('#sort-select').val($(this).val());
}
});
}
setSelectedOptionSortAttendances();
function setSelectedOptionGroup() {
const groupBy = $('#groupBy-hidden').first().val();
const pattern = `/${groupBy}`;
const options = $('#group-select').find('option');
options.each(function() {
if($(this).val().search(pattern) !== -1) {
$('#group-select').val($(this).val());
}
});
}
setSelectedOptionGroup();
});

View File

@ -30,6 +30,7 @@
</p>
<p>
Dane dotyczące obecności znajdziesz także w zakładce <a href="{{ route('user_attendances') }}"><b>Obecności</b></a>.
<br> Do każdej obecności możesz dodać notatkę.
<br> Rekordy dotyczące wszystkich obecności możesz grupować i wyeksportować. Przy eksporcie każda tabela-grupa trafi do pliku xlsx jako osobny arkusz.
</p>
@endsection

View File

@ -0,0 +1,29 @@
<div class="modal fade" id="noteModal-{{ $attendance->id }}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">{{ $attendance->student_name }} {{ $attendance->student_surname }} ({{ $attendance->student_id_number }})</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<form method="POST" action="{{ route('user_add_attendance_note') }}">
@csrf
<input type="hidden" class="form-control" id="attendance_id" name="attendance_id" value="{{ $attendance->id }}">
<input type="hidden" id="note_content_hidden" name="note_content_hidden" value="{{ $attendance->notes }}">
<div class="form-group">
<label for="note_content" class="col-form-label">Treść notatki:</label>
<textarea class="form-control" id="note_content" name="note_content">{{ $attendance->notes }}</textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Anuluj</button>
<button type="submit" class="btn btn-primary">Zapisz</button>
</div>
</form>
</div>
</div>
</div>
</div>

View File

@ -2,11 +2,14 @@
<tr class="thead-dark">
<th> Nazwa zajęć </th>
<th> Nr indeksu </th>
<th> Imię </th>
<th> Nazwisko </th>
<th> Imię </th>
<th> Nr miejsca </th>
@if(!$export == 1)
<th></th>
<th></th>
@else
<th> Notatka </th>
@endif
</tr>
@foreach ($attendances_list as $attendance)
@ -14,13 +17,27 @@
<td> {{ App\Subject::find(App\Classes::find($attendance->classes_id)->subject_id)->name }},
{{ App\Classes::find($attendance->classes_id)-> date }} {{ App\Subject::find(App\Classes::find($attendance->classes_id)->subject_id)->time }}, sala {{ App\Room::find(App\Subject::find(App\Classes::find($attendance->classes_id)->subject_id)->room_id)->name }} </td>
<td> {{ $attendance->student_id_number }} </td>
<td> {{ $attendance->student_name}}</td>
<td> {{ $attendance->student_surname}}</td>
<td> {{ $attendance->student_name}}</td>
<td> {{ $attendance->seat_number }} </td>
@if(!$export == 1)
<td>
<a href="{{ route('user_delete_attendance', [$attendance->id]) }}" name="delete-attendance-btn" class="btn btn-danger"> Usuń </a>
</td>
@if(!$attendance->notes)
<td>
<button type="button" name="note-attendance-btn" class="btn btn-info" data-toggle="modal" data-target="#noteModal-{{ $attendance->id }}"> Dodaj notatkę </button>
</td>
@else
<td>
<button type="button" name="note-attendance-btn" class="btn btn-info" data-toggle="modal" data-target="#noteModal-{{ $attendance->id }}"> Edytuj notatkę </button>
</td>
@endif
@include('user.attendance_note', [$attendance])
@else
<td>
{{ $attendance->notes }}
</td>
@endif
</tr>
@endforeach

View File

@ -1,16 +1,41 @@
<table class="table subjects-table">
<tr class="thead-light">
<th> Nr indeksu </th>
<th> Imię </th>
<th> Nazwisko </th>
<th> Imię </th>
<th> Nr miejsca </th>
@if(!$export == 1)
<th></th>
<th></th>
@else
<th> Notatka </th>
@endif
</tr>
@foreach ($attendances as $attendance)
<tr class="attendance-id" id="{{ $attendance->seat_number }}++{{ $attendance->student_name}}++{{ $attendance->student_surname}}">
<td> {{ $attendance->student_id_number }} </td>
<td> {{ $attendance->student_name}}</td>
<td> {{ $attendance->student_surname}}</td>
<td> {{ $attendance->student_name}}</td>
<td> {{ $attendance->seat_number }} </td>
@if(!$export == 1)
<td>
<a href="{{ route('user_delete_attendance', [$attendance->id]) }}" name="delete-attendance-btn" class="btn btn-danger"> Usuń </a>
</td>
@if(!$attendance->notes)
<td>
<button type="button" name="note-attendance-btn" class="btn btn-info" data-toggle="modal" data-target="#noteModal-{{ $attendance->id }}"> Dodaj notatkę </button>
</td>
@else
<td>
<button type="button" name="note-attendance-btn" class="btn btn-info" data-toggle="modal" data-target="#noteModal-{{ $attendance->id }}"> Edytuj notatkę </button>
</td>
@endif
@include('user.attendance_note', [$attendance])
@else
<td>
{{ $attendance->notes }}
</td>
@endif
</tr>
@endforeach
</table>

View File

@ -103,16 +103,17 @@
</div>
@if ($attendances->count() > 0)
<div class="card-body">
<span> Grupuj: </span>
<a href="{{ route('user_attendances', ['classes_id']) }}" class="btn btn-primary"> po nazwie zajęć </a>
<a href="{{ route('user_attendances', ['student_id_number']) }}" class="btn btn-primary"> po numerze indeksu </a>
<a href="{{ route('user_attendances', ['seat_number']) }}" class="btn btn-primary"> po numerze miejsca </a>
<a href="{{ route('user_export_grouped', [$grouped_by]) }}" class="btn btn-success btn-export"> Wyeksportuj do xlsx </a>
<div class="card-body card-custom">
<span class="sort-span"> Grupuj: </span>
<input type="hidden" id="groupBy-hidden" value="{{ $grouped_by }}">
<select id="group-select" class="form-control form-custom" name="group-select">
<option value="{{ route('user_attendances', ['classes_id']) }}"> po nazwie zajęć </option>
<option value="{{ route('user_attendances', ['student_id_number']) }}"> po numerze indeksu </option>
<option value="{{ route('user_attendances', ['seat_number']) }}"> po numerze miejsca </option>
</select>
</div>
<div class="card-body">
@foreach ($attendances_grouped as $attendances_group_name => $attendances_list)
@if($attendances_group_name)
@if($grouped_by == 'classes_id')
@ -136,4 +137,5 @@
</div>
</div>
@endsection

View File

@ -58,10 +58,13 @@
<h4> Moje zajęcia: ({{ $classes->count() }}) </h4>
</div>
<div class="card-body">
<span> Grupuj: </span>
<a href="{{ route('user_classes', ['subject_id']) }}" class="btn btn-primary"> po nazwie przedmiotu </a>
<a href="{{ route('user_classes', ['date']) }}" class="btn btn-primary"> po dacie </a>
<div class="card-body card-custom">
<span class="sort-span"> Grupuj: </span>
<input type="hidden" id="groupBy-hidden" value="{{ $grouped_by }}">
<select id="group-select" class="form-control form-custom" name="group-select">
<option value="{{ route('user_classes', ['subject_id']) }}"> po nazwie przedmiotu </option>
<option value="{{ route('user_classes', ['date']) }}"> po dacie </option>
</select>
</div>
<div class="card-body">

View File

@ -31,8 +31,20 @@
<h4> Lista obecności </h4>
<a href="{{ route('user_export', [$classes_id]) }}" class="btn btn-success btn-export"> Wyeksportuj do xlsx </a>
</div>
@include('user.attendances_table_preview', $attendances)
<div class="card-body card-custom">
<span class="sort-span"> Sortuj: </span>
<input type="hidden" id="orderBy-hidden" value="{{ $orderBy }}">
<input type="hidden" id="orderDirection-hidden" value="{{ $orderDirection }}">
<select id="sort-select" class="form-control form-custom" name="sort-select">
<option value="{{ route('user_preview_classes', ['classes_id' => $classes_id, 'orderBy' => 'student_surname', 'orderDirection' => 'ASC']) }}">po nazwisku A-Z</option>
<option value="{{ route('user_preview_classes', ['classes_id' => $classes_id, 'orderBy' => 'student_surname', 'orderDirection' => 'DESC']) }}">po nazwisku Z-A</option>
<option value="{{ route('user_preview_classes', ['classes_id' => $classes_id, 'orderBy' => 'student_id_number', 'orderDirection' => 'ASC']) }}">po numerze indeksu rosnąco</option>
<option value="{{ route('user_preview_classes', ['classes_id' => $classes_id, 'orderBy' => 'student_id_number', 'orderDirection' => 'DESC']) }}">po numerze indeksu malejąco</option>
<option value="{{ route('user_preview_classes', ['classes_id' => $classes_id, 'orderBy' => 'seat_number', 'orderDirection' => 'ASC']) }}">po numerze miejsca rosnąco</option>
<option value="{{ route('user_preview_classes', ['classes_id' => $classes_id, 'orderBy' => 'seat_number', 'orderDirection' => 'DESC']) }}">po numerze miejsca malejąco</option>
</select>
</div>
@include('user.attendances_table_preview', ['attendances' => $attendances, 'export' => 0])
</div>
<div class="seat-chart-wrapper">
<div id="seat-map"></div>

View File

@ -34,7 +34,7 @@
<div class="col-md-6">
<select id="weekday" class="form-control @error('weekday') is-invalid @enderror" name="weekday" required>
<option label="-- select day of the week -- "></option>
<option label="-- wybierz dzień tygodnia -- "></option>
@foreach ($weekdays as $weekday)
@if ($weekday == $defaultWeekday)
<option value="{{ $weekday }}" selected="selected">{{ $weekday }}</option>
@ -110,14 +110,18 @@
</div>
@if ($subjects->count() > 0)
<div class="card-body">
<span> Grupuj: </span>
<a href="{{ route('user_subjects', ['name']) }}" class="btn btn-primary btn-custom"> po nazwie </a>
{{--<a href="{{ route('user_subjects', ['type']) }}" class="btn btn-primary"> Type </a>--}}
<a href="{{ route('user_subjects', ['weekday']) }}" class="btn btn-primary btn-custom"> po dniu tygodnia </a>
<a href="{{ route('user_subjects', ['time']) }}" class="btn btn-primary btn-custom"> po godzinie </a>
<a href="{{ route('user_subjects', ['room_id']) }}" class="btn btn-primary btn-custom"> po sali </a>
<div class="card-body card-custom">
<span class="sort-span"> Grupuj: </span>
<input type="hidden" id="groupBy-hidden" value="{{ $grouped_by }}">
<select id="group-select" class="form-control form-custom" name="group-select">
<option value="{{ route('user_subjects', ['weekday']) }}"> po dniu tygodnia </option>
<option value="{{ route('user_subjects', ['name']) }}"> po nazwie </option>
<option value="{{ route('user_subjects', ['time']) }}"> po godzinie </option>
<option value="{{ route('user_subjects', ['room_id']) }}"> po sali </option>
</select>
</div>
<div class="card-body">
@foreach ($subjects_grouped as $subject_group_name => $subjects_list)
@if($subject_group_name)

View File

@ -61,12 +61,13 @@ Route::group(array('prefix' => 'user', 'namespace' => 'User'), function() { //TO
Route::get('/classes/start/{classes_id}', 'UserClassesController@start_classes')->name('user_start_classes');
Route::post('/classes/start', 'UserClassesController@start_classes_verified')->name('user_start_classes_verified')->middleware('classesCode');
Route::post('/classes/save', 'UserClassesController@save_classes_data')->name('user_save_classes_data');
Route::get('/classes/preview/{classes_id?}', 'UserClassesController@preview_classes')->name('user_preview_classes');
Route::get('/classes/preview/{classes_id}/{orderBy?}/{orderDirection?}', 'UserClassesController@preview_classes')->name('user_preview_classes');
Route::group(array('prefix' => 'add'), function() {
Route::post('/subject', 'UserSubjectsController@add_subject')->name('user_add_subject');
Route::post('/classes', 'UserClassesController@add_classes')->name('user_add_classes');
Route::post('/attendance', 'UserAttendancesController@add_attendance')->name('user_add_attendance');
Route::post('/attendance/note', 'UserAttendancesController@add_attendance_note')->name('user_add_attendance_note');
});
Route::group(array('prefix' => 'delete'), function() {
@ -83,5 +84,3 @@ Route::group(array('prefix' => 'user', 'namespace' => 'User'), function() { //TO
Route::get('/export/attendances/{classes_id}', 'UserAttendancesController@export')->name('user_export');
Route::get('/export/attendances/grouped/{groupBy}', 'UserAttendancesController@export_grouped')->name('user_export_grouped');
});