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

130 lines
4.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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
ask_setting = AskCategorySetting.enabled.where(category_id: question.category_id.to_s).first
ask_setting = AskSetting.first if ask_setting.nil?
is_cat_record = (ask_setting.class == AskCategorySetting)
tmp_ask_cat_id = (is_cat_record ? ask_setting.id.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?("@")
field = f
is_custom = true
is_field_enable = false
if field.start_with?("default@")
f = is_cat_record ? field : field[8..-1]
v = ask_setting.custom_fields[f]
if v
is_field_enable = true
end
elsif field.start_with?("custom@") && is_cat_record
if field.include?(tmp_ask_cat_id)
f = field[8+tmp_ask_cat_id.length..-1]
v = ask_setting.custom_fields[f]
if v
is_field_enable = true
end
end
end
next if !is_field_enable
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].to_s.gsub('-', '/') + " ~ " + val[1].to_s.gsub('-', '/')
else
val = val[0].to_s.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>