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

Allow daily recurring reservations

parent 86e6381a
No related branches found
No related tags found
No related merge requests found
......@@ -233,9 +233,10 @@ post '/:service_space_url_name/resources/:resource_id/reserve/?' do
# use the recurring type to increment the date here
starts = []
if params[:recurring_type] == 'weekly' || params[:recurring_type] == 'biweeekly'
if %w(daily weekly biweekly).include?(params[:recurring_type])
inc = 7.days
inc = 14.days if params[:recurring_type] == 'biweeekly'
inc = 14.days if params[:recurring_type] == 'biweekly'
inc = 1.day if params[:recurring_type] == 'daily'
new_start = start_time.dup
while (new_start = new_start + inc) <= recurs_until_date + 1.day
# reset in case we moved past DST change
......@@ -413,7 +414,12 @@ post '/:service_space_url_name/resources/:resource_id/reserve/?' do
flash :success, 'Recurring Reservations Created', "You have created #{successful+1} total reservations."
end
unless messages.empty?
flash :alert, 'Some recurring reservations were not created', "<ul><li>#{messages.join('</li><li>')}</li></ul>"
if params[:recurring_type] == 'daily'
flash :alert, 'Some recurring reservations were not created', "#{messages.count} recurring reservations were not made. This may be just because the space is closed for certain days."
puts messages
else
flash :alert, 'Some recurring reservations were not created', "<ul><li>#{messages.join('</li><li>')}</li></ul>"
end
end
end
......
......@@ -184,6 +184,7 @@ end %>
<label for="recurring">Make this reservation recur</label>
<div id="recurring-container" class="date-time-select" style="display: none;">
<select id="recurring-type" name="recurring_type">
<option value="daily">Daily</option>
<option value="weekly">Weekly</option>
<option value="biweekly">Biweekly</option>
<optgroup label="Monthly" id="monthly-group">
......
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