Created
November 19, 2012 23:29
-
-
Save CamonZ/4114822 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| $(document).ready(function() { | |
| function fillCalendar(rota_days) { | |
| /* fubar */ | |
| for ( i = 0; i < rota_days.length; i++) { | |
| rota_day = rota_days[0]; | |
| console.log(rota_days); | |
| /* doing stuffs with rota_day */ | |
| $('td.day-'+ rota_day.day +' hospital-' + rota_day.hospital) | |
| } | |
| } | |
| var month = $('.month').data('month'); | |
| $.get('/rota_days/nextmonth.json?mon=' + month).success(function(data) { | |
| fillCalendar(data); | |
| }); | |
| $('#nextmonth').on('click', function(e) { | |
| $.get('/rota_days/nextmonth.json?mon=12').success(function(data) { | |
| fillCalendar(data); | |
| }); | |
| e.preventDefault(); | |
| }); | |
| }); |
This file contains hidden or 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
| def nextmonth | |
| dfrom = Date.parse("#{Date.today.year}-#{sprintf("%02d", params[:mon].to_i)}-01") | |
| dto = dfrom + 1.month | |
| @rota_days = RotaDay.where('rota_days.day BETWEEN ? AND ?', dfrom, dto) | |
| respond_with do |format| | |
| format.json {render json: @rota_days.to_json(:include => {:hospital => {:include => :shortname}}) } | |
| end | |
| end |
This file contains hidden or 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> | |
| <tr> | |
| <!-- This element will carry the month number for initializing this table correctly. --> | |
| <th class="month"> | |
| days | |
| <%= hidden_field_tag("month_number", @dates.first.month) %> | |
| </th> | |
| <% @hospitals.each do |hsp| %> | |
| <th class="hospital-<%= hsp.shortname %>"><%= hsp.name %></th> | |
| <% end %> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <% @dates.each do |d| %> | |
| <tr> | |
| <th><%= d.to_s(:short) %></th> | |
| <% @hospitals.each do |hsp| %> | |
| <td class="day-<%= d.to_s(:short) %> hospital-<%= hsp.shortname %>"> </td> | |
| <% end %> | |
| </tr> | |
| <% end %> | |
| </tbody> | |
| </table> | |
| <%= link_to 'Next Month', rota_days_path(:mon => 12), :id => 'nextmonth' %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment