js map controlles updated, README updated

This commit is contained in:
s416422 2019-12-07 22:16:05 +01:00
parent 3d13bdb8bb
commit 81a03268a7
10 changed files with 60 additions and 9 deletions

View File

@ -3,5 +3,6 @@
``` ```
atcheck$ php artisan migrate:fresh atcheck$ php artisan migrate:fresh
atcheck$ php artisan db:seed atcheck$ php artisan db:seed
atcheck$ composer dump-autoload
atcheck$ php artisan serve atcheck$ php artisan serve
``` ```

View File

@ -21,6 +21,16 @@ class UserClassesController extends Controller
$subjects = Subject::where('user_id', $user_id)->get(); $subjects = Subject::where('user_id', $user_id)->get();
$subjects_ids = $subjects->pluck('id')->toArray(); $subjects_ids = $subjects->pluck('id')->toArray();
$classes = Classes::whereIn('subject_id', $subjects_ids)->get(); $classes = Classes::whereIn('subject_id', $subjects_ids)->get();
foreach($classes as $classes_item) {
$current_date = date('Y-m-d H:i:s');
$classes_date = $classes_item->date;
$hours_difference = checkHoursDifference($classes_date, $current_date);
if ($hours_difference > 24) {
$classes_item->classes_code = null;
$classes_item->save();
$classes_item->refresh();
}
}
$classes_grouped = $classes->groupBy($groupBy); $classes_grouped = $classes->groupBy($groupBy);
$defaultDate = date("Y-m-d"); $defaultDate = date("Y-m-d");
return view('user.user_classes', ['classes' => $classes, 'classes_grouped' => $classes_grouped, 'subjects' => $subjects, 'grouped_by' => $groupBy, 'defaultDate' => $defaultDate]); return view('user.user_classes', ['classes' => $classes, 'classes_grouped' => $classes_grouped, 'subjects' => $subjects, 'grouped_by' => $groupBy, 'defaultDate' => $defaultDate]);
@ -58,7 +68,9 @@ class UserClassesController extends Controller
$classes_code = generateRandomString(10); $classes_code = generateRandomString(10);
$classes->classes_code = $classes_code; $classes->classes_code = $classes_code;
$classes->save(); $classes->save();
$classes->refresh();
} }
return view('map.start_map', ['classes_code' => $classes_code, 'classes' => $classes]); return view('map.start_map', ['classes_code' => $classes_code, 'classes' => $classes]);
} }

View File

@ -8,3 +8,11 @@ function generateRandomString($length = 10) {
} }
return $randomString; return $randomString;
} }
function checkHoursDifference($dateStart, $dateEnd) {
$dateStart = strtotime($dateStart);
$dateEnd = strtotime($dateEnd);
$diff = $dateEnd - $dateStart;
$hours = floor(($diff / (60*60)));
return $hours;
}

View File

@ -24,7 +24,7 @@ body {
bottom: -20%; bottom: -20%;
transform: translate(-50%, -10%); transform: translate(-50%, -10%);
background-color: rgba(139, 152, 172, 0.856); background-color: rgba(139, 152, 172, 0.856);
padding: 30px 80px; padding: 30px 40px;
font-family: monospace; font-family: monospace;
font-size: 30px; font-size: 30px;
} }
@ -38,7 +38,16 @@ body {
.code-p { .code-p {
text-align: center; text-align: center;
} }
.test-form {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.test-form div {
width: 100%;
display: flex;
justify-content: space-between;
}
.main-text { .main-text {
font-family: "Oswald", Tahoma, sans-serif; font-family: "Oswald", Tahoma, sans-serif;

View File

@ -19,7 +19,7 @@
<a href="{{ route('user_subjects') }}" class="btn btn-primary"> Moje przedmioty </a> <a href="{{ route('user_subjects') }}" class="btn btn-primary"> Moje przedmioty </a>
{{--<a href="{{ route('user_classes') }}" class="btn btn-primary"> My classes </a>--}} {{--<a href="{{ route('user_classes') }}" class="btn btn-primary"> My classes </a>--}}
<a href="{{ route('user_classes') }}" class="btn btn-primary"> Sprawdź obecność </a> <a href="{{ route('user_classes') }}" class="btn btn-primary"> Sprawdź obecność </a>
<a href="{{ route('user_attendances') }}" class="btn btn-primary"> Statystyki </a> <a href="{{ route('user_attendances') }}" class="btn btn-primary"> Obecności </a>
</div> </div>
<div class="card-body"> <div class="card-body">
@yield('user_content') @yield('user_content')

View File

@ -14,6 +14,7 @@
<body> <body>
<div class="wrapper"> <div class="wrapper">
<a href="{{ route('user_classes') }}"> Zakończ zapisy </a>
@yield('map_content') @yield('map_content')
</div> </div>

View File

@ -9,4 +9,26 @@
@section('map_content') @section('map_content')
<p class="code-p"> <b>Kod:</b> {{ $classes_code }}</p> <p class="code-p"> <b>Kod:</b> {{ $classes_code }}</p>
<h1 class="main-text">Przyłóż legitymację do czytnika</h1> <h1 class="main-text">Przyłóż legitymację do czytnika</h1>
<div class="czytnik">
<h3> CZYTNIK </h3>
<form method="POST" action="{{ route('user_start_classes_verified') }}" class="test-form">
<div>
<label for="classes_code"> Kod: </label>
<input type="text" name="classes_code" id="classes_code">
</div>
<div>
<label for="student_id_number"> ID studenta: </label>
<input type="number" name="student_id_number" id="student_id_number">
</div>
<div>
<label for="student_name"> Imię studenta: </label>
<input type="text" name="student_name" id="student_name">
</div>
<div>
<label for="student_surname"> Nazwisko studenta: </label>
<input type="text" name="student_surname" id="student_surname">
</div>
<button type="submit"> Wyślij requesta </button>
</form>
</div>
@endsection @endsection

View File

@ -149,7 +149,7 @@
</table> </table>
@endforeach @endforeach
@else @else
<p> No attendance data yet. </p> <p> Brak zarejestrowantch obecności. </p>
@endif @endif
</div> </div>
</div> </div>

View File

@ -86,14 +86,13 @@
{{ App\Subject::find($classes_item->subject_id)->weekday }} {{ App\Subject::find($classes_item->subject_id)->time }}</td> {{ App\Subject::find($classes_item->subject_id)->weekday }} {{ App\Subject::find($classes_item->subject_id)->time }}</td>
<td> {{ $classes_item->date }} </td> <td> {{ $classes_item->date }} </td>
<td> <td>
<a href="{{ route('user_start_classes', [$classes_item->id]) }}" name="start-classes-btn" class="btn btn-warning"> Kontynuuj zapisy </a> @if($classes_item->classes_code)
<a href="{{ route('user_start_classes', [$classes_item->id]) }}" name="start-classes-btn" class="btn btn-warning"> Kontynuuj zapisy </a>
@endif
</td> </td>
<td> <td>
<a href="{{ route('user_delete_classes', [$classes_item->id]) }}" name="delete-classes-btn" class="btn btn-danger"> Usuń </a> <a href="{{ route('user_delete_classes', [$classes_item->id]) }}" name="delete-classes-btn" class="btn btn-danger"> Usuń </a>
</td> </td>
<td>
<a href="{{ route('user_edit_classes', [$classes_item->id]) }}" name="edit-classes-btn" class="btn btn-secondary"> Edytuj </a>
</td>
</tr> </tr>
@endforeach @endforeach
</table> </table>

View File

@ -73,7 +73,6 @@ Route::group(array('prefix' => 'user', 'namespace' => 'User'), function() { //TO
Route::group(array('prefix' => 'edit'), function() { Route::group(array('prefix' => 'edit'), function() {
Route::get('/subject/{subject_id}/{groupBy?}', 'UserSubjectsController@edit_subject')->name('user_edit_subject'); Route::get('/subject/{subject_id}/{groupBy?}', 'UserSubjectsController@edit_subject')->name('user_edit_subject');
Route::get('/classes/{classes_id}/{groupBy?}', 'UserClassesController@edit_classes')->name('user_edit_classes');
Route::get('/attendance/{attendance_id}/{groupBy?}', 'UserAttendancesController@edit_attendance')->name('user_edit_attendance'); Route::get('/attendance/{attendance_id}/{groupBy?}', 'UserAttendancesController@edit_attendance')->name('user_edit_attendance');
}); });