Skip to content

Instantly share code, notes, and snippets.

@nafiesl
Created January 15, 2020 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nafiesl/a8942f31a78ec88480dcedf0831d16f8 to your computer and use it in GitHub Desktop.
Save nafiesl/a8942f31a78ec88480dcedf0831d16f8 to your computer and use it in GitHub Desktop.
Room Schedule
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">Penggunaan Ruangan</h3></div>
<table class="table table-condensed text-center table-hover table-bordered">
<thead>
<th class="text-center col-md-1">{{ __('schedule.session') }}</th>
@foreach(getDays() as $dayId => $day)
<th class="text-center col-md-1">{{ $day }}</th>
@endforeach
</thead>
<tbody>
<?php $dayIdn = 0?>
@foreach($sessions as $sessionId => $session)
<tr>
<td>{{ $session }}</td>
@foreach(getDays() as $dayId => $day)
<?php
$schedule = $schedules->filter(function ($schedule) use ($dayId, $sessionId) {
return $schedule->day_id == $dayId && in_array($sessionId, $schedule->sessions) && $schedule->type_id == 1;
})->first();
if ($schedule) {
$lecturing = $schedule->lecturing;
if ($sessionId == $schedule->sessions[0]) {
echo '<td style="text-align:left" rowspan="'.count($schedule->sessions).'">';
if (auth()->user()->can('view', $lecturing)) {
echo Html::decode(link_to_route('lecturings.show', '<span class="glyphicon glyphicon-search" aria-hidden="true"></span>', $lecturing, [
'class' => 'pull-right',
'title' => 'Lihat perkuliahan '.$lecturing->course_name,
]));
}
echo '<strong>'.$lecturing->course->name.'</strong>';
if ($schedule->lecturer) {
echo '<br>Dosen : '.$schedule->lecturer->name;
}
echo '<br><span class="text-success">Prodi : '.$lecturing->prodi->name.'</span>';
echo '<br><span class="text-primary">Smt : '.$lecturing->semester.'</span>';
echo '<br><span class="text-info">Kelas : '.$lecturing->class->name.'</span>';
echo '</td>';
}
} else {
echo '<td>';
if (auth()->user()->can('manage_curriculum') && Request::has('prodi_id')) {
$inputScheduleLinkParams = [
'prodi_id' => request('prodi_id'),
'periode' => $periode,
'room_id' => $room->id,
'day_id' => $dayId,
'session_id' => $sessionId,
'return' => Route::currentRouteName(),
];
echo Html::decode(link_to_route('lecturings.create', '<i class="fa fa-plus"></i>', $inputScheduleLinkParams, [
'class' => 'btn btn-link btn-xs schedule-create-link',
'title' => 'Input perkuliahan ('.$day.', jam '.$session.')',
]));
}
echo '</td>';
}
?>
@endforeach
</tr>
<?php $dayIdn = $dayId?>
@endforeach
</tbody>
</table>
</div>
$schedules = Schedule::where('room_id', $roomId)
->where('periode', $periode)
->where('type_id', 1)
->whereHas('lecturing', function ($query) use ($prodiId) {
if ($prodiId) {
$query->where('prodi_id', $prodiId);
}
})
->with(['lecturing.course'])
->get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment