Application_Form/app/views/application_forms/con_upload.html.erb

107 lines
4.8 KiB
Plaintext

<% # encoding: utf-8 %>
<% @@session = session %>
<%= yield %>
<%
data = action_data
@application_form = data["application_form"]
@application_form_signup = data["application_form_signup"]
@time_now = data["time_now"]
data1 = @application_form.application_form_submission_field_sets.select{|v| v.field_name=='title'}[0]
data2 = @application_form.application_form_submission_field_sets.select{|v| v.field_name=='description'}[0]
data3 = @application_form.application_form_submission_field_sets.select{|v| v.field_name=='file'}[0]
show1 = !(data1.disabled) rescue false
show2 = !(data2.disabled) rescue false
show3 = !(data3.disabled) rescue false
name1 = data1['name'][I18n.locale]
name2 = data2['name'][I18n.locale]
name3 = data3['name'][I18n.locale]
application_form_submission_field = @application_form.application_form_submission_fields.where(:markup=>"application_form_preferred_session").first
if data["prefix_url"]
prefix_url = data["prefix_url"]
else
prefix_url = OrbitHelper.url_to_show(@application_form.to_param)
end
%>
<% if @application_form.contribute_start_date <= @time_now and ( @application_form.contribute_end_date.nil? or @application_form.contribute_end_date+1 >= @time_now ) %>
<% begin %>
<% if !session[:application_form_signup_id].blank? %>
<%=t('application_form_signup.serial_number') %>: <%=@application_form_signup.display_serial_number rescue ""%>
<a href="<%= prefix_url %>?method=con_logout&con_no=<%= @application_form.id %>" class='btn btn-primary'><%= t('application_form_signup.logout') %></a>
<table class="table table-hover table-striped application_form-index">
<caption>
<h3><%= @application_form.title %></h3>
</caption>
<thead>
<tr>
<% if show1 %>
<th class="col-md-2"><%= name1 %></th>
<% end %>
<% if show2 %>
<th class="col-md-2"><%= name2 %></th>
<% end %>
<% if show3 %>
<th class="col-md-2"><%= name3 %></th>
<% end %>
<% if application_form_submission_field %>
<th class="col-md-2"><%= application_form_submission_field.title %></th>
<% end %>
<th class="col-md-2"><%= t(:action) %></th>
</tr>
</thead>
<tbody>
<%
@application_form_signup.application_form_signup_contributes.each do |application_form_signup_contribute|
%>
<tr>
<td><%= application_form_signup_contribute.title %></td>
<% description = application_form_signup_contribute.description.to_s %>
<% if @application_form.enable_summary_choice
if (application_form_signup_contribute.description.to_s.to_i.to_s == application_form_signup_contribute.description)
description = @application_form.summary_chioices[application_form_signup_contribute.description.to_i] rescue application_form_signup_contribute.description
else
description = application_form_signup_contribute.description.map{|i| @application_form.summary_chioices[i.to_i] rescue "" }.join("<br>") rescue application_form_signup_contribute.description
end
end %>
<td><%= description.html_safe %></td>
<td><%= link_to File.basename(application_form_signup_contribute.file.path), application_form_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(description.gsub("<br>"," , ")).text} if application_form_signup_contribute.file.file %></td>
<% if application_form_submission_field %>
<td><%= application_form_signup_contribute.application_form_submission_values.where(:application_form_submission_field=>application_form_submission_field).first.get_value_by_locale(I18n.locale) %></td>
<% end %>
<td>
<%= link_to t(:edit), prefix_url + '?method=edit_file&con_no=' + application_form_signup_contribute.id, :class => 'btn btn-primary' %>
<form method="post" action="<%= del_file_application_forms_path %>">
<%= submit_tag t(:delete_), class: "btn btn-primary" %>
<input type="hidden" name="referer_url" value="<%= request.original_url.split(request.env["HTTP_HOST"]).last.split('?').first %>">
<input type="hidden" name="con_no" value="<%= application_form_signup_contribute.id %>">
</form>
</td>
</tr>
<% end %>
</tbody>
</table>
<% if ( @application_form.contribute_file_count.blank? or @application_form_signup.application_form_signup_contributes.count < @application_form.contribute_file_count.to_i ) %>
<%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('application_form_signup.new_'), prefix_url + '?method=add_file', :class => 'btn btn-primary' %>
<% end %>
<br />
<br />
<!-- 檔案上限: <%#= @application_form.contribute_file_count.blank? ? '無' : @application_form.contribute_file_count %> -->
<% else %>
<%= t("application_form.please_login_first") %>
<br />
<a href="<%= page_for_application_form_url %>"><%=t("application_form.back")%></a>
<% end %>
<%
rescue => e
puts e
end%>
<% else %>
<%= t("application_form.out_of_date") %>
<% end %>