

<div class="schedule">
	<div class="timeslots">
		<div class="date-header"></div>
		@for($h = 0; $h < 24; $h += 0.5)
			<div class="time-header">{{$time = gmdate("H:i", $h * 3600)}} uur</div>
		@endfor
	</div>
	

	@php($date = null)
	@php($hour = 0)
	@php($now = new \DateTime("now"))
	@foreach($schedule as $item)
			@php($diff = $item['endtime']->diff($item['starttime']))
			@php($duration = $diff->d * 24 + $diff->h + $diff->i / 60)
			@php($isCurrent = ($now >= $item['starttime']) && ($now <= $item['endtime']))
			@php($class = ($item['program']->priority < 2 ? ' special' : '')
						. ($item['program']->nonstop || $item['program']->rerun ? ' non-stop' : '')
						. ($isCurrent ? ' current' : ''))
			@php($starttime = $item['starttime'])

			@while($duration > 0)
				@if(($formattedDate = Formatter::fullDate($starttime, 'W d/M')) != $date)
					@if($date != null) 
						</div> 
					@endif
						<div class="date-column">
							<div class="date-header">{{$formattedDate}}</div>
					@php($date = $formattedDate)
					@php($hour = 0)
				@endif
				@php($durationToday = ($hour + $duration <= 24) ? $duration : (24 - $hour))

				<a href="{{url('/radio/programma' . $item['program']->url)}}" class="program{{$class}}" style="height: {{$durationToday * $pixelsPerHour - 2 * $border - $margin}}px;" title="{{$item['program']->name . ($item['program']->tagline ? "\n" . $item['program']->tagline : "")}}">
					<div class="program-title">{{$item['program']->name}}</div>
					@if($isCurrent) <div class="current-marker"><span>Nu op NH Gooi</span></div> @endif
					<div class="program-content">
						<div class="program-times"><span class="fa fa-clock"></span> {{$item['starttime']->format('H:i')}} &ndash; {{$item['endtime']->format('H:i')}}</div>
						@if($item['program']->tagline)
						<hr/>
						<div class="tagline">{{$item['program']->tagline}}</div>	
						@endif					
					</div>
				</a>
				@php($hour += $durationToday)
				@php($duration -= $durationToday)
				@if($duration > 0)
					@php($starttime->add(new \DateInterval('P1D'))->setTime(0, 0, 0))
				@endif
			@endwhile
	@endforeach
		</div>

</div>

