-
-
Save hron84/4062410 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#nextmonth').on('click', fuction(e)) { | |
$.get('/rota_days/show.json?mon=12').success(function(data) { | |
rota_days = data | |
for ( i = 0; i < rota_days.length; i++) | |
{ | |
rota_day = rota_days[0]; | |
/* doing stuffs with rota_day */ | |
} | |
}); | |
)}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table class = "rota"> | |
<thead> | |
<th>Date</th> | |
<% @hospitals.each do |hosp| %> | |
<th><%= hosp.name%></th> | |
<% end %> | |
</thead> | |
<tbody> | |
<% @dates.each do |date| %> | |
<tr> | |
<td><%= date.to_s(:short) %></td> | |
<% ([email protected]).each do %> | |
<td></td> | |
<% end %> | |
</tr> | |
<% end %> | |
</tbody> | |
</table> | |
<%= link_to 'Next Month', rota_days_path(:month => 12), :id => 'nextmonth' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RotaDaysController < ApplicationController | |
# GET /rota_days | |
# GET /rota_days.json | |
# load_and_authorize_resource | |
respond_to :json, :html | |
def index | |
@rota_days = RotaDay.all | |
# @dates = @rota_days.collect(&:day) | |
@hospitals = Hospital.all | |
t1 = Date.today.at_beginning_of_month | |
t2 = Date.today.end_of_month | |
@dates = (t1..t2).to_a | |
@title = "Rota" | |
respond_to do |format| | |
format.html # index.html.erb | |
format.json { render json: @rota_days } | |
end | |
end | |
def nextmonth | |
dfrom = Date.parse("#{Date.today.year}-#{sprintf("%02d", params[:mon].to_i)}-01") | |
dto = Date.parse("#{Date.today.year}-#{sprintf("%02d", params[:mon].to_i + 1)}-01") | |
@rota_days = RotaDay.where('rota_days.day BETWEEN ? AND ?', dfrom, dto) | |
respond_with(@rota_days) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment