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

174 lines
8.7 KiB
PHP
Raw Normal View History

2019-12-01 23:36:12 +01:00
@extends('home')
@section('title') Mój Panel - Przedmioty @endsection
2019-12-01 23:36:12 +01:00
@section('user_content')
<div class="row justify-content-center">
<div class="col-md-12">
2019-12-13 23:28:16 +01:00
<div class="card-header custom-header">
<h4> Moje przedmioty: ({{ $subjects->count() }}) </h4>
<button type="button" class="btn btn-primary btn-custom add-subject-btn"> Dodaj nowy </button>
</div>
<div class="card-body add-subject">
<h5> Dodaj nowy przedmiot </h5>
<form method="POST" action="{{ route('user_add_subject') }}">
2019-12-01 23:36:12 +01:00
@csrf
<div class="form-group row">
<label for="name" class="col-md-4 col-form-label text-md-right">{{ __('Nazwa') }}</label>
2019-12-01 23:36:12 +01:00
<div class="col-md-6">
<input id="name" type="text" class="form-control @error('name') is-invalid @enderror" name="name" value="{{ old('name') }}" required autocomplete="name" autofocus>
@error('name')
<span class="invalid-feedback" role="alert">
2019-12-13 23:28:16 +01:00
<strong>{{ $message }}</strong>
</span>
2019-12-01 23:36:12 +01:00
@enderror
</div>
</div>
<div class="form-group row">
<label for="weekday" class="col-md-4 col-form-label text-md-right">{{ __('Dzień tygodnia') }}</label>
2019-12-01 23:36:12 +01:00
<div class="col-md-6">
2019-12-13 23:28:16 +01:00
<select id="weekday" class="form-control @error('weekday') is-invalid @enderror" name="weekday" required>
<option label="-- wybierz dzień tygodnia -- "></option>
2019-12-01 23:36:12 +01:00
@foreach ($weekdays as $weekday)
@if ($weekday == $defaultWeekday)
<option value="{{ $weekday }}" selected="selected">{{ $weekday }}</option>
@else
2019-12-01 23:36:12 +01:00
<option value="{{ $weekday }}">{{ $weekday }}</option>
@endif
2019-12-01 23:36:12 +01:00
@endforeach
</select>
@error('weekday')
<span class="invalid-feedback" role="alert">
2019-12-13 23:28:16 +01:00
<strong>{{ $message }}</strong>
</span>
2019-12-01 23:36:12 +01:00
@enderror
</div>
</div>
<div class="form-group row">
<label for="time" class="col-md-4 col-form-label text-md-right">{{ __('Godzina') }}</label>
2019-12-01 23:36:12 +01:00
<div class="col-md-6">
2019-12-13 23:28:16 +01:00
<input id="time" type="time" class="form-control @error('time') is-invalid @enderror" name="time" value="{{ $defaultTime }}" required autocomplete="time">
2019-12-01 23:36:12 +01:00
@error('time')
<span class="invalid-feedback" role="alert">
2019-12-13 23:28:16 +01:00
<strong>{{ $message }}</strong>
</span>
2019-12-01 23:36:12 +01:00
@enderror
</div>
</div>
2019-12-09 12:17:23 +01:00
<div class="form-group row">
<label for="room_id" class="col-md-4 col-form-label text-md-right">{{ __('Sala') }}</label>
2019-12-01 23:36:12 +01:00
2019-12-09 12:17:23 +01:00
<div class="col-md-6">
<select id="room_id" class="form-control @error('room_id') is-invalid @enderror" name="room_id" required>
@foreach ($rooms as $room)
<option value="{{ $room->id }}">{{ $room->name }}</option>
@endforeach
</select>
2019-12-01 23:36:12 +01:00
2019-12-09 12:17:23 +01:00
@error('room_id')
<span class="invalid-feedback" role="alert">
2019-12-13 23:28:16 +01:00
<strong>{{ $message }}</strong>
</span>
2019-12-09 12:17:23 +01:00
@enderror
</div>
</div>
2019-12-01 23:36:12 +01:00
<div class="form-group row">
<label for="user_id" class="col-md-4 col-form-label text-md-right">{{ __('Prowadzący') }}</label>
2019-12-01 23:36:12 +01:00
<div class="col-md-6">
2019-12-13 23:28:16 +01:00
<input id="user_id" type="text" class="@error('user_id') is-invalid @enderror form-control-plaintext" name="user_id" value="{{ Auth::user()->name }} {{ Auth::user()->surname }}" required readonly>
2019-12-01 23:36:12 +01:00
@error('user_id')
<span class="invalid-feedback" role="alert">
2019-12-13 23:28:16 +01:00
<strong>{{ $message }}</strong>
</span>
2019-12-01 23:36:12 +01:00
@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">
{{ __('Dodaj') }}
2019-12-01 23:36:12 +01:00
</button>
</div>
</div>
</form>
</div>
2019-12-13 23:28:16 +01:00
@if ($subjects->count() > 0)
<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>
2019-12-13 23:28:16 +01:00
</div>
2019-12-13 23:28:16 +01:00
<div class="card-body">
2019-12-01 23:36:12 +01:00
@foreach ($subjects_grouped as $subject_group_name => $subjects_list)
@if($subject_group_name)
@if($grouped_by == 'room_id')
<h5 class="card-title"> {{ App\Room::find($subject_group_name)->name }} ({{ $subjects_list->count() }}) </h5>
@else
<h5 class="card-title"> {{ $subject_group_name }} ({{ $subjects_list->count() }})</h5>
@endif
@else
<h5 class="card-title"> Inne ({{ $subjects_list->count() }})</h5>
2019-12-01 23:36:12 +01:00
@endif
2019-12-13 23:28:16 +01:00
<table class="table table-striped subjects-table">
2019-12-01 23:36:12 +01:00
<tr class="thead-dark">
<th> Nazwa </th>
{{--<th> Type </th>--}}
<th> Dzień tygodnia </th>
<th> Godzina </th>
<th> Prowadzący </th>
2019-12-09 12:17:23 +01:00
<th> Sala </th>
2019-12-01 23:36:12 +01:00
<th></th>
<th></th>
</tr>
@foreach ($subjects_list as $subject)
<tr>
<td> {{ $subject->name }} </td>
{{--<td> {{ $subject->type }} </td>--}}
2019-12-01 23:36:12 +01:00
<td> {{ $subject->weekday }} </td>
<td> {{ $subject->time }} </td>
<td> {{ App\User::find($subject->user_id)->name }} {{ App\User::find($subject->user_id)->surname }}</td>
2019-12-09 12:17:23 +01:00
<td> {{ App\Room::find($subject->room_id)->name }} </td>
2019-12-01 23:36:12 +01:00
<td>
<a href="{{ route('user_delete_subject', [$subject->id]) }}" name="delete-subject-btn" class="btn btn-danger"> Usuń </a>
2019-12-01 23:36:12 +01:00
</td>
2019-12-09 12:17:23 +01:00
{{--<td>--}}
{{--<a href="{{ route('user_edit_subject', [$subject->id]) }}" name="edit-subject-btn" class="btn btn-secondary"> Edytuj </a>--}}
{{--</td>--}}
2019-12-01 23:36:12 +01:00
</tr>
@endforeach
</table>
@endforeach
2019-12-13 23:28:16 +01:00
</div>
@else
<div class="card-body">
<p> Brak przedmiotów. </p>
2019-12-13 23:28:16 +01:00
</div>
@endif
2019-12-01 23:36:12 +01:00
</div>
</div>
@endsection