ask/app/views/asks/email.html.erb

106 lines
3.5 KiB
Plaintext
Raw Normal View History

2014-10-02 06:00:35 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
2016-11-07 02:08:04 +00:00
<!-- <h1><%= @data['title'] %></h1> -->
2014-10-02 06:00:35 +00:00
<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"
2022-08-18 03:07:45 +00:00
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)
2022-08-18 03:07:45 +00:00
if val.present?
val = "<a href=\"#{@data['site_host']}#{val[1]}\">#{val[0]}</a>".html_safe
end
elsif type == "date"
2022-08-18 03:07:45 +00:00
val = val["datetime"].values[0].values rescue []
if val.count == 2
2022-08-18 03:07:45 +00:00
val = val[0].gsub('-', '/') + " ~ " + val[1].gsub('-', '/')
else
2022-08-18 03:07:45 +00:00
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
2022-08-18 03:07:45 +00:00
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 %>
2014-10-02 06:00:35 +00:00
<tr>
2014-10-23 07:03:21 +00:00
<th><%= AskQuestion.human_attribute_name(:name) %></th>
2014-10-02 06:00:35 +00:00
<td><%= @data['name'] %></td>
</tr>
2016-11-07 02:08:04 +00:00
<!-- <tr>
2014-10-23 07:03:21 +00:00
<th><%= AskQuestion.human_attribute_name(:identity) %></th>
<td>
<% Tag.where({:id => @data['identity']}).each do |tag| %>
<%= tag.name %>
<% end %>
</td>
2016-11-07 02:08:04 +00:00
</tr> -->
2014-10-02 06:00:35 +00:00
<tr>
2014-10-23 07:03:21 +00:00
<th><%= AskQuestion.human_attribute_name(:mail) %></th>
2014-10-02 06:00:35 +00:00
<td><%= @data['mail'] %></td>
</tr>
<tr>
2014-10-23 07:03:21 +00:00
<th><%= AskQuestion.human_attribute_name(:phone) %></th>
2014-10-02 06:00:35 +00:00
<td><%= @data['phone'] %></td>
</tr>
2016-11-07 02:08:04 +00:00
<!-- <tr>
2014-10-23 07:03:21 +00:00
<th><%= AskQuestion.human_attribute_name(:fax) %></th>
2014-10-02 06:00:35 +00:00
<td><%= @data['fax'] %></td>
2016-11-07 02:08:04 +00:00
</tr> -->
2014-10-02 06:00:35 +00:00
<tr>
2016-11-07 02:08:04 +00:00
<th><%= AskQuestion.human_attribute_name(:name) %></th>
2021-02-23 09:21:47 +00:00
<td><%= @data['name'].to_s.gsub(/[(\n)(\r)]/, "\n" => "<br/>", "\r" => "" ).html_safe %></td>
</tr>
<% end %>
2014-10-02 06:00:35 +00:00
</table>
<p>此為系統自動發信,請勿直接回覆</p>
</body>
</html>