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

130 lines
4.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> -->
<% if @data['edit_url'] %>
<%= link_to t("edit"), @data['edit_url'] %>
<% end %>
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
2023-06-05 14:55:26 +00:00
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?("@")
2023-06-05 14:55:26 +00:00
field = f
is_custom = true
2023-06-05 14:55:26 +00:00
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"
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
2023-06-05 14:55:26 +00:00
val = val[0].to_s.gsub('-', '/') + " ~ " + val[1].to_s.gsub('-', '/')
else
2023-06-05 14:55:26 +00:00
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
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>