-
Jeff Sturek authoredJeff Sturek authored
resource_calendar.erb 10.70 KiB
<% reservation_groups = reservations.group_by do |reservation|
reservation.start_time.in_time_zone.strftime("%Y/%m/%d")
end
%>
<% if kiosk_mode %>
<% #FYI - HACK since ipad not playing nice with dcf-grid %>
<div class="dcf-width-100%">
<div class="dcf-d-inline-block dcf-pr-6" style="width:60%;">
<div id="kioskLogo"></div>
<h1 class="dcf-txt-h5 dcf-d-inline-block"><%= resource.name %></h1>
</div><div class="dcf-d-inline-block dcf-txt-right" style="width:40%;">
<% if @user %>
<a class="dcf-btn dcf-btn-tertiary dcf-mb-1" href="/kiosk-logout/?url_redirect=<%= url_encode("/#{@space.url_name}/resources/#{resource.id}/calendar/?kiosk_mode=true") %>">Log Out</a>
<% end %>
<a class="dcf-btn dcf-btn-primary dcf-mb-1" href="/<%= @space.url_name %>/resources/<%= resource.id %>/reserve/?kiosk_mode=true">Reserve</a>
</div>
</div>
<% else %>
<div class="dcf-grid dcf-col-gap-vw">
<div class="dcf-col-100% dcf-col-67%-start@sm">
<h1 class="dcf-txt-h5"><%= resource.name %></h1>
</div>
<div class="dcf-col-100% dcf-col-33%-end@sm dcf-txt-right">
<a class="dcf-btn dcf-btn-primary" href="/<%= @space.url_name %>/resources/<%= resource.id %>/reserve/">Reserve</a>
</div>
</div>
<% end %>
<div class="calendar dcf-pt-4">
<div class="calendar-header">
<a href="/<%= @space.url_name %>/resources/<%= resource.id %>/calendar/?date=<%= (date-7.days).strftime('%Y-%m-%d') %><%= defined?(kiosk_mode) && kiosk_mode == 'true' ? '&kiosk_mode=true' : ''%>" id="prev-week" class="schedulericon-angle-circled-left dcf-txt-decor-none"><span class="dcf-sr-only">Previous Week</span></a>
<a href="/<%= @space.url_name %>/resources/<%= resource.id %>/calendar/?date=<%= (date+7.days).strftime('%Y-%m-%d') %><%= defined?(kiosk_mode) && kiosk_mode == 'true' ? '&kiosk_mode=true' : ''%>" id="next-week" class="schedulericon-angle-circled-right dcf-txt-decor-none"><span class="dcf-sr-only">next week</span></a>
<h4 class="unl-font-sans">
<%= month = sunday.strftime('%B %Y') %><%= (month2 = (sunday+6.days).strftime('%B %Y')) == month ? '' : " - #{month2}" %>
</h4>
</div>
<div class="day-label-container">
<% (1..5).each do |i| %>
<% day = (sunday + i.days + 1.hour).midnight %>
<label class="day-header"><%= day.strftime("%^a %-m/%d") %></label>
<% end %>
</div>
<div class="calendar-container">
<div class="time-labels">
<div class="time-chart">
<% (12..39).each do |j| %>
<div class="calendar-half-hour">
<label><%= "#{(j / 2) % 12 + (j==24?12:0)} #{j >= 24 ? 'PM' : 'AM'}" if j % 2 == 0 %></label>
</div>
<% end %>
</div>
</div>
<% (1..5).each do |i| %>
<% day = (sunday + i.days + 1.hour).midnight %>
<% slots = [0] * 36 %>
<div class="calendar-day" data-day="<%= day.strftime("%Y/%m/%d") %>">
<!-- <label class="day-header"><%= day.strftime("%^a %-m/%d") %></label> -->
<div class="day-chart" title="Open">
<% if week_hours.has_key?(i) %>
<% # figure out where the closed divs need to be
# we can assume that all records in this space_hour are non-intertwined
closed_start = 0
closed_end = 0
starts = week_hours[i].hours.map{|record| record[:start]}
ends = week_hours[i].hours.map{|record| record[:end]}
%> <%
closeds = []
(360..1199).each do |j|
if starts.include?(j)