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

Agenda

parent 7ebe434a
No related branches found
No related tags found
No related merge requests found
before '/:service_space_url_name/admin/agenda*' do
unless @user.has_permission?(Permission::SEE_AGENDA, @space)
raise Sinatra::NotFound
end
end
get '/:service_space_url_name/admin/agenda/' do
@breadcrumbs << {:text => 'Agenda'}
date = params[:date].nil? ? Time.now.midnight : Time.parse(params[:date])
reservations = Reservation.includes(:user, :resource, :event).in_day(date).order(:start_time)
events = Event.includes(:event_type).in_day(date).order(:start_time)
# get the hours for this day to show
hours = SpaceHour.where(:service_space_id => @space.id)
.where('effective_date <= ?', date.utc.strftime('%Y-%m-%d %H:%M:%S'))
.order(:effective_date => :desc, :id => :desc).all.to_a
correct_hour = nil
hours.each do |space_hour|
if date.wday == space_hour.day_of_week && (space_hour.effective_date.in_time_zone.midnight == date.in_time_zone.midnight || (!space_hour.one_off && space_hour.effective_date.in_time_zone.midnight <= date.in_time_zone.midnight))
correct_hour = space_hour
break
end
end
erb :'admin/agenda', :layout => :fixed, :locals => {
:reservations => reservations,
:events => events,
:date => date,
:space_hour => correct_hour
}
end
\ No newline at end of file
<form style="float: right; width: 320px;">
<div class="offset-field-group">
<label for="date">Go to another 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="<%= date.strftime('%m/%d/%Y') %>" />
</div>
</div>
</form>
<div id="pagetitle">
<h3>Today's Agenda<span class="wdn-subhead"><%= date.strftime('%B %d, %Y') %></h3>
</div>
<h4>
Today's Hours
</h4>
<% unless space_hour.nil? %>
<%= space_hour.hours.map do |record|
start_time = date + record[:start].minutes
end_time = date + record[:end].minutes
"#{record[:status].capitalize_all}: #{start_time.in_time_zone.strftime('%l:%M %P')} - #{end_time.in_time_zone.strftime('%l:%M %P')}"
end.join(', ') %>
<% else %>
The space is open all day.
<% end %>
<h4>
Today's Reservations
</h4>
<% if reservations.empty? %>
No reservations today. Hopefully someone will still come in to use the space!<br>
<% else %>
<table>
<thead>
<tr>
<th>Name</th>
<th>Tool</th>
<th>Time</th>
</tr>
</thead>
<tbody>
<% reservations.each do |reservation| %>
<tr>
<td>
<% if reservation.user %>
<%= reservation.user.full_name %>
<% elsif !reservation.event.nil? %>
<strong>Event:</strong> <%= reservation.event.title %>
<% end %>
</td>
<td>
<%= reservation.resource.name %>
</td>
<td>
<%= reservation.start_time.in_time_zone.strftime('%l:%M %P') %><br>
<%= reservation.length %> minutes
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<h4>
Today's Events
</h4>
<% if events.empty? %>
No events today. Perhaps you'd like to create one?<br>
<a href="/admin/events/create/" class="wdn-button wdn-button-brand">New Event</a>
<% else %>
<table>
<thead>
<tr>
<th>Title</th>
<th>Date/Location</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<% events.each do |event| %>
<tr>
<td>
<a title="Edit Event" href="<%= event.edit_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>
<%= event.type.name %>
</td>
</tr>
<% end %>
</tbody>
</table>
<br>
<a href="/admin/events/" class="wdn-button wdn-button-triad">Go To Events</a>
<% end %>
<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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment