seminar/app/views/admin/seminars/seminar_signup.html.erb

216 lines
8.7 KiB
Plaintext

<span id="index_table">
<script>
if(document.querySelectorAll("#orbit-bar").length==0) location.reload();
</script>
<form id="module-search-form">
<div class="sc-field">
<input id="filter-input" class="search-query input-medium" type="text" name="search" value="<%= params[:search] %>" placeholder="搜尋">
</div>
</form>
<h4><%= @seminar.title %></h4>
<table class="table main-list">
<thead>
<tr class="sort-header">
<% if @seminar.seminar_signup_field_sets.count != 0 %>
<% @seminar.seminar_signup_field_sets.each do |field_set| %>
<% if !(field_set.hidden) %>
<th class='span2'><%= field_set.name[I18n.locale] %></th>
<% end %>
<% end %>
<% else %>
<th class='span2'><%= t('seminar_signup.name')%></th>
<th class='span2'><%= t('seminar_signup.tel')%></th>
<th class='span2'><%= t('seminar.registration_status')%></th>
<% end %>
<% if @seminar.seminar_signup_field_customs.count != 0 %>
<% @seminar.seminar_signup_field_customs.each do |field_set| %>
<% if !(field_set.hidden) %>
<th class='span2'><%= SeminarSignupField.where(id:field_set.seminar_signup_field_id).first.title rescue '' %></th>
<% end %>
<% end %>
<% end %>
<% if @seminar.seminar_submission_field_sets.count != 0 %>
<% show1 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='title'}[0].hidden)
show2 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='file'}[0].hidden)
show3 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='description'}[0].hidden)
%>
<% else %>
<% show1 = true
show2 = true
show3 = true
%>
<% end %>
<% if show1 %>
<th class='span2'><%= t('seminar_signup.title')%></th>
<% end %>
<% if show2 %>
<th class='span2'><%= t('seminar_signup.file')%></th>
<% end %>
<% if show3 %>
<th class='span2'><%= t('seminar_signup.description')%></th>
<% end %>
<% @seminar.seminar_submission_fields.asc(:_id).each do |submission_field| %>
<th class='span2'><%= submission_field.title %></th>
<% end %>
</tr>
</thead>
<tbody>
<% @seminar_signups.each do |seminar_signup| %>
<% len = seminar_signup.seminar_signup_contributes.count %>
<tr>
<% if @seminar.seminar_signup_field_sets.count != 0 %>
<% @seminar.seminar_signup_field_sets.each do |field_set| %>
<% if !(field_set.hidden) %>
<td rowspan="<%= len==0? 1 : len %>">
<% if field_set.field_name== 'name' %>
<%= seminar_signup.name %>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(seminar_signup) %>
<li><a href="/admin/seminar_signups/<%=seminar_signup.id.to_s%>/edit"><%= t(:edit) %></a></li>
<li><a href="#" class="delete text-error" rel="/admin/seminar_signups/<%=seminar_signup.id.to_s%>"><%= t(:delete_) %></a></li>
<% end %>
</ul>
</div>
<% elsif field_set.field_name== 'status' %>
<%= t("seminar.registration_status_#{seminar_signup.status}") if !seminar_signup.status.blank? %>
<% elsif field_set.field_name != 'recaptcha' %>
<%= seminar_signup.send("#{field_set.field_name}") %>
<% end %>
</td>
<% end %>
<% end %>
<% else %>
<td rowspan="<%= len==0? 1 : len %>">
<%= seminar_signup.name %>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(seminar_signup) %>
<li><a href="/admin/seminar_signups/<%=seminar_signup.id.to_s%>/edit"><%= t(:edit) %></a></li>
<li><a href="#" class="delete text-error" rel="/admin/seminar_signups/<%=seminar_signup.id.to_s%>"><%= t(:delete_) %></a></li>
<% end %>
</ul>
</div>
</td>
<td rowspan="<%= len==0? 1 : len %>"><%= seminar_signup.tel %></td>
<td rowspan="<%= len==0? 1 : len %>"><%= t("seminar.registration_status_#{seminar_signup.status}") if !seminar_signup.status.blank? %>
</td>
<% end %>
<% if @seminar.seminar_signup_field_customs.count != 0 %>
<% @seminar.seminar_signup_field_customs.each do |field_set| %>
<% if !(field_set.hidden) %>
<td rowspan="<%= len==0? 1 : len %>">
<% seminar_signup.seminar_signup_values.each do |seminar_signup_values| %>
<% if seminar_signup_values.seminar_signup_field_id == field_set.seminar_signup_field_id %>
<% if seminar_signup_values.value.class == String || seminar_signup_values.value.nil? %>
<%= seminar_signup_values.get_value_by_locale(I18n.locale,seminar_signup_values) %>
<% else %>
<% seminar_signup_values.value.each do |key,v| %>
<%= "#{I18n.t(key)}:#{seminar_signup_values.get_value_by_locale(key,seminar_signup_values)}" %>
<br>
<% end %>
<% end %>
<% end %>
<% end %>
</td>
<% end %>
<% end %>
<% end %>
<% count_set = 0 %>
<% if @seminar.seminar_submission_field_sets.count != 0 %>
<% show1 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='title'}[0].hidden)
show2 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='file'}[0].hidden)
show3 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='description'}[0].hidden)
%>
<% @seminar.seminar_submission_field_sets.each do |field_set| %>
<% if !(field_set.hidden) %>
<% count_set+=1 %>
<% end %>
<% end %>
<% else %>
<% show1 = true
show2 = true
show3 = true
%>
<% count_set = 2 %>
<% end %>
<% if len==0 %>
<%
count_field = @seminar.seminar_submission_fields.count
%>
<ul>
<% for i in 1..count_field+count_set %>
<td rowspan="1">
</td>
<% end %>
</ul>
</tr>
<% end %>
<ul>
<% seminar_signup.seminar_signup_contributes.collect do |seminar_signup_contribute| %>
<% if show1 %>
<td>
<li><%= seminar_signup_contribute.title.to_s %></li>
</td>
<% end %>
<% if show2 %>
<td>
<li>
<%= link_to (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(seminar_signup_contribute.description).text} if seminar_signup_contribute.file.file %>
</li>
</td>
<% end %>
<% if show3 %>
<td>
<li><%= seminar_signup_contribute.description.to_s.html_safe %></li>
</td>
<% end %>
<%
count_value = seminar_signup_contribute.seminar_submission_values.count
count_field = @seminar.seminar_submission_fields.count
%>
<% if count_value == count_field %>
<% seminar_signup_contribute.seminar_submission_values.asc(:seminar_submission_field_id).each do |value| %>
<td>
<span style="display: list-item;">
<% if value.value.class == String || value.value.nil? %>
<%= value.get_value_by_locale(I18n.locale,value) %>
<% else %>
<% value.value.each do |key,v| %>
<%= "#{I18n.t(key)}:#{value.get_value_by_locale(key,value)}" %>
<br>
<% end %>
<% end %>
</span>
</td>
<% end %>
<% else %>
<% for i in 1..(count_field-count_value) %>
<td>
</td>
<% end %>
<% end %>
</tr>
<tr>
<% end %>
</ul>
</tr>
<% end %>
</tbody>
</table>
<%=
content_tag :div, class: "bottomnav clearfix" do
content_tag :div, paginate(@seminar_signups), class: "pagination pagination-centered"
end
%>
</span>
<%= render 'layouts/delete_modal', delete_options: @delete_options %>