109 lines
3.5 KiB
Plaintext
109 lines
3.5 KiB
Plaintext
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
</head>
|
||
<body>
|
||
<!-- <h1><%= @data['title'] %></h1> -->
|
||
<% if @data['edit_url'] %>
|
||
<%= link_to t("edit"), @data['edit_url'] %>
|
||
<% end %>
|
||
<table>
|
||
<% question = AskQuestion.find(@data['ask_question_id']) rescue nil %>
|
||
<% if question %>
|
||
<%
|
||
yes_trans = t('ask.yes')
|
||
no_trans = t('ask.no')
|
||
locale = I18n.locale.to_s
|
||
%>
|
||
<% @data['disp_fields_infos'].each do |f, field_info| %>
|
||
<% next if f == 'recaptcha' %>
|
||
<tr>
|
||
<%
|
||
trans = field_info["trans"]
|
||
is_cat = false
|
||
is_custom = false
|
||
if f.include?("@")
|
||
f = field_info["key"]
|
||
is_custom = true
|
||
elsif f == 'ask_category_id'
|
||
f = 'category_id'
|
||
is_cat = true
|
||
end
|
||
val = question[f]
|
||
if val == true || val == false
|
||
val = val ? yes_trans : no_trans
|
||
else
|
||
val = question.custom_values[f] if is_custom
|
||
type = field_info["type"]
|
||
if ["select", "radio_button", "checkbox"].include?(type)
|
||
if type == "checkbox"
|
||
val = val.values rescue []
|
||
else
|
||
val = Array(val)
|
||
end
|
||
val = val.map{|v| field_info["options"][v][locale] rescue ""}.join("<br>").html_safe
|
||
elsif ["file", "image"].include?(type)
|
||
if val.present?
|
||
val = "<a href=\"#{@data['site_host']}#{val[1]}\">#{val[0]}</a>".html_safe
|
||
end
|
||
elsif type == "date"
|
||
val = val["datetime"].values[0].values rescue []
|
||
if val.count == 2
|
||
val = val[0].gsub('-', '/') + " ~ " + val[1].gsub('-', '/')
|
||
else
|
||
val = val[0].gsub('-', '/')
|
||
end
|
||
elsif type == "instructions"
|
||
val = field_info["instructions"][locale].to_s.html_safe rescue ""
|
||
else
|
||
if is_cat
|
||
val = Category.find(val).title rescue ''
|
||
elsif f == 'usage_rule'
|
||
val = @data['usage_rule'].to_s.html_safe
|
||
elsif f == 'appointment'
|
||
val = question.appointment.strftime('%Y/%m/%d %H:%M') rescue ""
|
||
else
|
||
val = val.to_s.html_safe
|
||
end
|
||
end
|
||
end
|
||
%>
|
||
<th><%= trans %></th>
|
||
<td><%= val %></td>
|
||
</tr>
|
||
<% end %>
|
||
<% else %>
|
||
<tr>
|
||
<th><%= AskQuestion.human_attribute_name(:name) %>:</th>
|
||
<td><%= @data['name'] %></td>
|
||
</tr>
|
||
<!-- <tr>
|
||
<th><%= AskQuestion.human_attribute_name(:identity) %>:</th>
|
||
<td>
|
||
<% Tag.where({:id => @data['identity']}).each do |tag| %>
|
||
<%= tag.name %>
|
||
<% end %>
|
||
</td>
|
||
</tr> -->
|
||
<tr>
|
||
<th><%= AskQuestion.human_attribute_name(:mail) %>:</th>
|
||
<td><%= @data['mail'] %></td>
|
||
</tr>
|
||
<tr>
|
||
<th><%= AskQuestion.human_attribute_name(:phone) %>:</th>
|
||
<td><%= @data['phone'] %></td>
|
||
</tr>
|
||
<!-- <tr>
|
||
<th><%= AskQuestion.human_attribute_name(:fax) %>:</th>
|
||
<td><%= @data['fax'] %></td>
|
||
</tr> -->
|
||
<tr>
|
||
<th><%= AskQuestion.human_attribute_name(:name) %>:</th>
|
||
<td><%= @data['name'].to_s.gsub(/[(\n)(\r)]/, "\n" => "<br/>", "\r" => "" ).html_safe %></td>
|
||
</tr>
|
||
<% end %>
|
||
</table>
|
||
<p>此為系統自動發信,請勿直接回覆</p>
|
||
</body>
|
||
</html> |