Skip to content
Snippets Groups Projects
Commit 7ebe434a authored by Tyler Lemburg's avatar Tyler Lemburg
Browse files

Events and Resources

parent c37ee1d0
No related branches found
No related tags found
No related merge requests found
...@@ -13,8 +13,8 @@ end %> ...@@ -13,8 +13,8 @@ end %>
<h4 style="text-align: center; margin: 0;"> <h4 style="text-align: center; margin: 0;">
<%= month = sunday.strftime('%B %Y') %><%= (month2 = (sunday+6.days).strftime('%B %Y')) == month ? '' : " - #{month2}" %> <%= month = sunday.strftime('%B %Y') %><%= (month2 = (sunday+6.days).strftime('%B %Y')) == month ? '' : " - #{month2}" %>
</h4> </h4>
<a href="/calendar/?date=<%= (date-7.days).strftime('%Y-%m-%d') %>" class="wdn-button wdn-button-triad" id="prev-week">&lt; PREV</a> <a href="/<%= @space.url_name %>/calendar/?date=<%= (date-7.days).strftime('%Y-%m-%d') %>" class="wdn-button wdn-button-triad" id="prev-week">&lt; PREV</a>
<a href="/calendar/?date=<%= (date+7.days).strftime('%Y-%m-%d') %>" class="wdn-button wdn-button-triad" style="float: right;" id="next-week">NEXT &gt;</a> <a href="/<%= @space.url_name %>/calendar/?date=<%= (date+7.days).strftime('%Y-%m-%d') %>" class="wdn-button wdn-button-triad" style="float: right;" id="next-week">NEXT &gt;</a>
</div> </div>
<div class="calendar-container"> <div class="calendar-container">
......
<div class="event-details">
<div>
<h3>
<%= event.title %><span class="wdn-subhead"><%= event.type.description %></span>
</h3>
</div>
<div>
<span class="date-wrapper eventicon-calendar-empty">
<time class="dtstart"><%= event.start_time.in_time_zone.strftime('%b %d, %Y') %></time>
</span>
<span class="time-wrapper eventicon-clock">
<%= event.start_time.in_time_zone.strftime('%l:%M %P') %><%= event.end_time.in_time_zone.strftime('%l:%M %P') %>
</span>
<div class="location eventicon-location">
<%= event.location.name %>
</div>
<% unless event.imagedata.nil? %>
<div class="inset-image">
<img src="<%= event.image_src %>" alt="Image for Event: <%= event.title %>">
</div>
<% end %>
<div class="description">
<%= event.description.nl2br.force_encoding("UTF-8") %>
</div>
</div>
</div>
<% # free events do not require signup but users can mark it on their homepage %>
<% if @user && event.signups.map(&:user_id).include?(@user.id) %>
<% # the user is already signed up %>
<% if event.type.description == 'Free Event' %>
This event is noted on your homepage.<br>
<a href="<%= @space.href %>" class="wdn-button wdn-button-triad">View Homepage</a>
<% else %>
You have signed up for this event.<br>
<a href='<%= @space.href %>' class="wdn-button wdn-button-triad">View Homepage</a>
<% end %>
<% elsif @user %>
<% # the user is logged in but not signed up %>
<% if event.max_signups.nil? || event.signups.count < event.max_signups %>
<form action="/<%= @space.url_name %>/events/<%= event.id %>/sign_up/" method="POST">
<button type="submit" class="wdn-button wdn-button-brand">
<% if event.type.description == 'Free Event' %>
Note event on my homepage
<% else %>
Sign up for this event
<% end %>
</a>
</form>
<% else %>
All slots for this event are filled.
<% end %>
<% else %>
<% # a non user. May still sign up for the event UNLESS it is a tool training %>
<% if event.type.description != 'Machine Training' %>
<% if event.max_signups.nil? || event.signups.count < event.max_signups %>
<a class="wdn-button wdn-button-brand" href="/<%= @space.url_name %>/events/<%= event.id %>/sign_up_as_non_member/">Sign up for this event</a>
<% else %>
All slots for this event are filled.
<% end %>
<% end %>
<% end %>
\ No newline at end of file
<div id="pagetitle">
<h3>Welcome to UNL Resource Scheduler<span class="wdn-subhead"><%= @user.full_name %></span></h3>
</div>
<% if spaces.empty? %>
Sorry, you don't have any spaces right now. If you'd like to use UNL Resource Scheduler for your organization, please request a service space here.
<% else %>
<h5 class="wdn-center wdn-brand">Your Service Spaces</h5>
<div class="wdn-grid-set-thirds">
<% spaces.each do |space| %>
<div class="wdn-col">
<a href="<%= space.href %>"><%= space.name %></a>
</div>
<% end %>
</div>
<% end %>
\ No newline at end of file
<%
start_hour = nil
start_minute = nil
start_am_pm = nil
unless reservation.nil?
start_hour = reservation.start_time.in_time_zone.hour
if start_hour >= 12
start_hour -= 12
start_am_pm = 'pm'
else
start_am_pm = 'am'
end
start_hour += 12 if start_hour == 0
start_minute = reservation.start_time.in_time_zone.min
end %>
<div id="pagetitle">
<h3><%= reservation.nil? ? 'Reserve Time for ' : 'Edit Reservation for ' %><%= resource.name %></h3>
</div>
<form action="" method="POST">
<section class="wdn-grid-set">
<div class="bp1-wdn-col-one-third">
<label for="date">Date</label>
<div class="date-time-select">
<span class="wdn-icon-calendar"></span>
<input style="width: 90%;" id="date" name="date" title="Reservation Date" type="text" class="datepicker" value="<%= day.strftime('%m/%d/%Y') %>" />
</div>
</div>
<div class="bp1-wdn-col-one-third">
<label>Schedule for <span id="current-date"><%= day.strftime('%m/%d/%Y') %></span></label>
<div class="calendar-container individual-day">
<div class="time-labels">
<div class="time-chart">
<% (12..47).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>
<% 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">
<% reservations.each do |res| %>
<% end_slot = [(((res.end_time.in_time_zone - day.midnight) / 60 - 360) / 30).floor, 35].min
if end_slot < 0
next
end
top = (((res.start_time.in_time_zone - day.midnight) / 60 - 360) / 30) * 20
height = res.length * 20 / 30
%>
<div class="reservation <%= 'editing' if !reservation.nil? && reservation.id == res.id %>"
style="top: <%= top %>px; height: <%= height %>px;">
<% if !res.event.nil? %>
<%= res.event.title %>
<% else %>
<%= res.user_id == @user.id ? 'My Reservation' : 'busy' %>
<% end %>
<%= '(Editing)' if !reservation.nil? && reservation.id == res.id %>
</div>
<% end %>
<% unless space_hour.nil?
# 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 = space_hour.hours.map{|record| record[:start]}
ends = space_hour.hours.map{|record| record[:end]}
%> <%
closeds = []
(360..1439).each do |j|
if starts.include?(j)
closed_end = j
closeds << [closed_start, closed_end]
closed_start = 0
closed_end = 0
end
if ends.include?(j)
closed_start = j
end
end
closed_end = 1440
closeds << [closed_start, closed_end]
closeds.each do |closed|
start_time = closed[0] %>
<% end_time = closed[1] %>
<%
if [((end_time - 360) / 30).floor, 35].min < 0
next
end
top = ((start_time - 360) / 30) * 20
height = (end_time - start_time) * 20 / 30
if top < 0
height += top
top = 0
end
if top + height > 720
height = 720 - top
end
%>
<div class="status closed" title="Closed" style="top: <%= top %>px; height: <%= height %>px;">
&nbsp;
</div>
<%
end %>
<% space_hour.hours.each do |record| %>
<% if record[:status] != 'open' && record[:status] != 'closed' %>
<% start_time = record[:start] %>
<% end_time = record[:end] %>
<% if [((end_time - 360) / 30).floor, 35].min < 0
next
end
top = ((start_time - 360) / 30) * 20
height = (end_time - start_time) * 20 / 30
if top < 0
height += top
top = 0
end
if top + height > 720
height = 720 - top
end
%>
<div title="<%= record[:status].split('_').join(' ').capitalize_all %>" class="status <%= record[:status].downcase.split('_').join('-') %>" style="top: <%= top %>px; height: <%= height %>px;">
&nbsp;
</div>
<% end %>
<% end %>
<% end %>
<div>
<% (12..47).each do |j| %>
<div class="calendar-half-hour">
&nbsp;
</div>
<% end %>
</div>
</div>
</div>
</div>
</div>
<div class="bp1-wdn-col-one-third">
<label for="start-minutes">Start Time</label>
<div class="date-time-select">
<% if available_start_times.empty? %>
No available times today.
<% else %>
<select id="start-minutes" name="start_minutes" style="width: 90%">
<% available_start_times.each do |minutes| %>
<option <%='selected="selected"' if !reservation.nil? && reservation.start_time.in_time_zone.midnight == day && reservation.start_time.in_time_zone.minutes_after_midnight == minutes %> value="<%= minutes %>"><%= Time.from_minutes(minutes).strftime("%l:%M %p") %></option>
<% end %>
</select>
<% end %>
</div>
<label for="reservation-length">Reserve resource for:</label><br>
<% if resource.minutes_per_reservation.nil? %>
<select id="reservation-length" name="length">
<% (1..4).each do |i| %>
<option value="<%=i*15%>"><%=i*15%> minutes</option>
<% end %>
<option value="90">1.5 hours</option>
<option value="120">2 hours</option>
</select>
<% else %>
<input style="width: 50px" disabled="disabled" value="<%= resource.minutes_per_reservation %>" />&nbsp;&nbsp;<label>minutes</label>
<input type="hidden" name="length" value="<%= resource.minutes_per_reservation %>" />
<% end %>
<br><br>
<button type="submit" class="wdn-button wdn-button-brand"><%= reservation.nil? ? 'Reserve' : 'Update' %></button>
</div>
</section>
</form>
<script type="text/javascript">
WDN.initializePlugin('jqueryui', [function() {
$ = require('jquery');
$('.datepicker').datepicker();
$("LINK[href^='//unlcms.unl.edu/wdn/templates_4.0/scripts/plugins/ui/css/jquery-ui.min.css']").remove();
$('#date').change(function () {
var date = $('#date').val().split('/');
window.location = window.location.href.split('?')[0] + '?date=' + date[2] + '-' + date[0] + '-' + date[1];
});
}]);
</script>
\ No newline at end of file
<div id="pagetitle">
<h3>Resources You Can Reserve</h3>
</div>
<% if available_resources.count > 0 %>
<table>
<thead>
<tr>
<th>Resource</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% available_resources.each do |resource| %>
<tr>
<td>
<%= resource.name %>
</td>
<td class="table-actions">
<% if resource.is_reservable %>
<a href="/<%= @space.url_name %>/resources/<%= resource.id %>/reserve/" class="wdn-button wdn-button-brand">Reserve Time</a>
<% else %>
Reservation not required
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p>
There are no resources currently available for you to reserve.
</p>
<% end %>
\ No newline at end of file
<div id="pagetitle">
<h3>Welcome to <%= @space.name %> Resource Scheduler<span class="wdn-subhead">Hello, <%= @user.full_name %></span></h3>
</div>
<h4>
My Reservations
</h4>
<% if reservations.empty? %>
You have no upcoming reservations. You can view upcoming trainings to get certified, or check out the list of resources you can reserve.<br>
<a href="<%= @space.resources_href %>" class="wdn-button wdn-button-brand">View Resources</a>
<% else %>
<table>
<thead>
<tr>
<th>Tool</th>
<th>Model</th>
<th>Time</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% reservations.each do |reservation| %>
<tr>
<td>
<%= reservation.resource.name %>
<% if !reservation.event.nil? %>
<br><small><%= reservation.event.title %></small>
<% end %>
</td>
<td>
<%= reservation.resource.model %>
</td>
<td>
<%= reservation.start_time.in_time_zone.strftime('%m/%d/%Y @ %l:%M %P') %><br>
<%= reservation.length %> minutes
</td>
<td class="table-actions">
<a href="/<%= @space.url_name %>/resources/<%= reservation.resource.id %>/edit_reservation/<%= reservation.id %>/" class="wdn-button wdn-button-brand">Edit</a>
<form method="POST" action="/<%= @space.url_name %>/resources/<%= reservation.resource.id %>/cancel/<%= reservation.id %>/" class="delete-form">
<button class="wdn-button" type="submit">Remove</button>
</form>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<h4>
My Events
</h4>
<% if events.empty? %>
You have not signed up for any upcoming events. Why not check out the calendar to find some?<br>
<a href="<%= @space.calendar_href %>" class="wdn-button wdn-button-triad">View Calendar</a>
<% else %>
<table>
<thead>
<tr>
<th>Title</th>
<th>Date/Location</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% events.each do |event| %>
<tr>
<td>
<a href="<%= event.info_link %>"><%= event.title %></a>
</td>
<td>
<%= event.start_time.in_time_zone.strftime('%m/%d/%Y @ %l:%M %P') %><br>
<%= event.location.name %>
</td>
<td class="table-actions">
<form action="/events/<%= event.id %>/remove_signup/" method="POST" class="delete-form">
<button class="wdn-button" type="submit">
Remove
</button>
</form>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
\ No newline at end of file
<ul> <ul>
<li><a href="/" title="UNL Resource Scheduler">Home</a> <li><a href="/" title="UNL Resource Scheduler">Home</a></li>
<% unless @space.nil? %>
<li><a href="<%= @space.calendar_href %>">Calendar</a></li>
<% unless @user.nil? || !@user.is_admin?(@space) %>
<li><a href="<%= @space.admin_href %>" title="Admin">Admin</a>
<ul>
<% if @user.has_permission?(Permission::MANAGE_USERS, @space) || @user.has_permission?(Permission::SUPER_USER, @space) %>
<li><a href="/<%= @space.url_name %>/admin/users/" title="Users">Users</a></li>
<% end %>
<% if @user.has_permission?(Permission::MANAGE_EVENTS, @space) %>
<li><a href="/<%= @space.url_name %>/admin/events/" title="Events">Events</a></li>
<% end %>
<% if @user.has_permission?(Permission::MANAGE_RESOURCES, @space) %>
<li><a href="/<%= @space.url_name %>/admin/resources/" title="Resources">Resources</a></li>
<% end %>
<% if @user.has_permission?(Permission::MANAGE_SPACE_HOURS, @space) %>
<li><a href="/<%= @space.url_name %>/admin/hours/" title="Hours">Hours</a></li>
<% end %>
<% if @user.has_permission?(Permission::MANAGE_EMAILS, @space) %>
<li><a href="/<%= @space.url_name %>/admin/email/" title="Email">Email</a></li>
<% end %>
<% if @user.has_permission?(Permission::SEE_AGENDA, @space) %>
<li><a href="/<%= @space.url_name %>/admin/agenda/" title="Agenda">Agenda</a></li>
<% end %>
</ul>
</li>
<% end %>
<% end %>
</ul> </ul>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment