property_hire/app/views/email/p_hire_email.html.erb

95 lines
3.7 KiB
Plaintext
Raw Permalink Normal View History

<% property = Property.where(id: @data['property_id']).first%>
<% email_set = property.hire_email_sets.select{|v| v.field_name == 'p_hire'} %>
2020-03-23 17:26:52 +00:00
<% if email_set.length != 0 %>
<% if !(email_set[0].content.nil?) %>
<%= email_set[0].content[@data['locale']].html_safe %>
<% end %>
<% else %>
<%= t('property_hire.email_p_hire_content') %>
<% end %>
<br>
2021-09-08 02:55:20 +00:00
<style>
.hire_infos td:first-child {
white-space: nowrap;
}
</style>
<% I18n.with_locale(@data['locale']) do %>
<h3><%= property.title rescue nil %></h3>
<% if !@data['hire_id'].nil? %>
<% hire = PHire.where(id: @data['hire_id']).first %>
2021-09-08 02:55:20 +00:00
<table id="hire_infos">
<thead>
<tr>
<td></td>
<td></td>
</tr>
</thead>
<tbody>
2021-09-19 07:56:01 +00:00
<%
2022-07-21 08:43:51 +00:00
p_hire_fields = property.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h
2021-09-19 07:56:01 +00:00
fields_name = property.get_all_fields
basic_keys = []
if (property.set_availability rescue false)
basic_keys = ['date','time','hiring_person_name','hiring_person_email','recurring','recurring_interval','recurring_end_date','passed']
else
basic_keys = ['hiring_person_name','hiring_person_email','start_time','end_time','recurring','recurring_interval','recurring_end_date','passed']
end
2021-09-19 07:56:01 +00:00
fields_name = fields_name - basic_keys
keys = basic_keys + fields_name
2024-08-21 13:48:11 +00:00
keys = keys.select do |field_name|
return true if field_name.include?('p_hire_fields.')
tmp = property[field_name]
tmp.is_a?(Hash) ? (tmp["enable"] == "1") : true
end
2022-07-21 08:43:51 +00:00
p_hire_fields = property.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h
2021-09-19 07:56:01 +00:00
has_p_hire_fields = p_hire_fields.count != 0
tmp_keys = []
all_trans = keys.map do |k|
if has_p_hire_fields && k.include?("p_hire_fields")
tmp_keys << k.sub("p_hire_fields.",'')
nil
else
tmp_keys << k
property.custom_text(k,"name")
end
end
%>
<% p_hire_field_values = hire.p_hire_field_values.to_a %>
<% keys.each_with_index do |k,i| %>
2021-09-19 07:56:01 +00:00
<% if has_p_hire_fields && k.include?("p_hire_fields")
p_hire_field_id = tmp_keys[i]
v = p_hire_field_values.select{|v| v.p_hire_field_id.to_s == p_hire_field_id}.first
field_info = v.get_field_value rescue {}
if field_info["title"].present? && !field_info["value"].nil?
all_trans[i] = field_info["title"]
v = field_info["value"]
end
else
v = hire.send(k)
end
%>
<% if !v.nil? && !(k.include?('recurring') && hire.recurring != true)%>
<tr>
<td>
<%= all_trans[i] %>:&nbsp;
</td>
<td>
<% if ['start_time','end_time','recurring','recurring_interval','recurring_end_date','passed'].exclude?(k) %>
2020-07-22 10:53:39 +00:00
<%= v.to_s.html_safe %>
<% elsif ['start_time','end_time','recurring_end_date'].include?(k) %>
<%= v.strftime('%Y/%m/%d %H:%M') rescue nil %>
<% elsif k == 'recurring_interval' %>
<%= t("property_hire.recurring_interval_types.#{v}") %>
<% elsif 'recurring' == k %>
<%= v ? t('property_hire.yes') : t('property_hire.no') %>
<% else %>
<%= v ? t('property_hire.yes') : t('property_hire.wait_for_permit') %>
<% end %>
</td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<% end %>
2020-03-23 17:26:52 +00:00
<% end %>