app/views/time_tables/_show_time_table.html.erb
<div class="time_table_show" id="time_table_show">
<p>
<span class="state-code <%= @time_table.presenter.time_table_state_code %>"><i class="fa fa-certificate"></i></span>
<label>
<% if @time_table.bounding_dates.empty? %>
<%= t(".resume_empty") %>
<% else %>
<%= t(".resume", :start_date => l(@time_table.bounding_dates.min), :end_date => l(@time_table.bounding_dates.max)) %>
<% end %>
</label>
</p>
<p>
<label><%= @time_table.human_attribute_name("tag_list") %>: </label>
<%= @time_table.tag_list %>
</p>
<ul id="tabs" class="nav nav-tabs" data-tabs="tabs">
<li class="active"><a href="#time_tables" data-toggle="tab"><%= @time_table.human_attribute_name("calendars") %></a></li>
<li><a href="#time_tables_datas" data-toggle="tab"><%= @time_table.human_attribute_name("calendar_details") %></a></li>
</ul>
<div id="my-tab-content" class="tab-content">
<div class="tab-pane active" id="time_tables">
<div class="well legend">
<span class="title"><%= t(".legend") %></span>
<span class="label excluded_date">X</span><%= t(".excluded_date") %>
<span class="label overlaped_date">X</span><%= t(".overlap_date") %>
<span class="label selected_date">X</span><%= t(".selected_date") %>
<span class="label selected_period">X</span><%= t(".selected_period") %>
</div>
<div id="calendars">
<div class="year_choice">
<span class="previous"> <%= link_to("<", referential_time_table_path(@referential, @time_table, :year => (@year - 1)) ) %> </span>
<span class="year"> <%= "#{@year}" %> </span>
<span class="next"> <%= link_to(">", referential_time_table_path(@referential, @time_table, :year => (@year + 1)) ) %> </span>
</div>
<div class="calendar_helper">
<%=
cal = ""
(1..12).each do |month|
cal << calendar(:year => @year, :month => month, :first_day_of_week => 1) do |d|
class_names = ['day']
if @time_table.excluded_date?(d)
class_names << 'excluded_date'
elsif @time_table.include_in_overlap_dates?(d)
class_names << 'overlaped_date'
elsif @time_table.include_in_dates?(d)
class_names << 'selected_date'
elsif @time_table.include_in_periods?(d)
class_names << 'selected_period'
else
next
end
[
(
policy(:application).write? ?
link_to(d.mday, edit_referential_time_table_path(@referential, @time_table)) :
d.mday
),
{ class: class_names.join(' ') }
]
end
end
cal.html_safe
%>
</div>
</div>
</div>
<div class="tab-pane" id="time_tables_datas">
<div class="summary">
<p>
<label><%= @time_table.human_attribute_name("version") %>: </label>
<%= @time_table.version %>
</p>
<p>
<label><%= @time_table.human_attribute_name("day_types") %>: </label>
<% if @time_table.int_day_types & 508 == 0 %>
<label><%= @time_table.human_attribute_name("none") %></label>
<% else %>
<% %w(monday tuesday wednesday thursday friday saturday sunday).each do |day_type| %>
<span class="<%= @time_table.send( day_type) ? "included_day_type" : "excluded_day_type" %>">
<%= @time_table.human_attribute_name(day_type) %>
</span>
<% end %>
<% end %>
</p>
</div>
<% if @time_table.periods.present? %>
<h3 class="time_table_periods"><%= @time_table.human_attribute_name("periods") %></h3>
<div class="periods content">
<%= render "time_tables/periods" %>
</div>
<% end %>
<% if @time_table.dates.where("in_out = true").present? %>
<h3 class="time_table_dates"><%= @time_table.human_attribute_name("dates") %></h3>
<div class="dates content">
<%= render "time_tables/dates" %>
</div>
<% end %>
<% if @time_table.dates.where("in_out = false").present? %>
<h3 class="time_table_dates"><%= @time_table.human_attribute_name("excluded_dates") %></h3>
<div class="excluded_dates content">
<%= render "time_tables/excluded_dates" %>
</div>
<% end %>
</div>
</div>
</div>