diff --git a/app/models/p_hire_field.rb b/app/models/p_hire_field.rb index 17c8785..2b07bd2 100644 --- a/app/models/p_hire_field.rb +++ b/app/models/p_hire_field.rb @@ -131,7 +131,7 @@ class PHireField def self.add_p_hire_field(property,property_param, p_hire_field_id=nil,field_status) @field_name = 'property' if field_status.eql?(true) - @p_hire_field_counter = property.p_hire_fields.count rescue nil + @p_hire_field_counter = property.p_hire_fields_enabled.count rescue nil @p_hire_field = self.find(p_hire_field_id) rescue nil old_key = @p_hire_field.key @p_hire_field.update(property_param) @@ -145,7 +145,7 @@ class PHireField end @p_hire_field[:af_count] = @p_hire_field_counter else - @p_hire_field_counter = property.p_hire_fields.count rescue nil + @p_hire_field_counter = property.p_hire_fields_enabled.count rescue nil @p_hire_field = property.p_hire_fields.build(property_param) rescue nil @p_hire_field.save @p_hire_field[:af_count] = @p_hire_field_counter diff --git a/app/models/property.rb b/app/models/property.rb index db36517..98721ec 100644 --- a/app/models/property.rb +++ b/app/models/property.rb @@ -125,6 +125,9 @@ class Property after_save do self.change_day_setting_status end + def p_hire_fields_enabled + self.p_hire_fields.where(disabled: false) + end def all_day_settings self.property_day_settings.asc(:key).group_by(&:day) end @@ -468,10 +471,10 @@ class Property end def check_require_fields(booking_p) fields_name = self.get_all_fields - has_p_hire_fields = self.p_hire_fields.count != 0 + has_p_hire_fields = self.p_hire_fields_enabled.count != 0 p_hire_fields = {} if has_p_hire_fields - p_hire_fields = self.p_hire_fields.map{|rf| [rf.id.to_s,rf]}.to_h + p_hire_fields = self.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h end error_messages = "" form_index = 0 @@ -546,7 +549,7 @@ class Property if @default_field_names.nil? basic_fields = self.get_basic_fields custom_fields = [] - self.p_hire_fields.each do |p_hire_field| + self.p_hire_fields_enabled.each do |p_hire_field| unless p_hire_field.disabled custom_fields << "p_hire_fields.#{p_hire_field.id}" end diff --git a/app/views/admin/property_hires/custom_fields.erb b/app/views/admin/property_hires/custom_fields.erb index d641bf8..250238f 100644 --- a/app/views/admin/property_hires/custom_fields.erb +++ b/app/views/admin/property_hires/custom_fields.erb @@ -23,7 +23,7 @@
- <%= render partial: "attribute_field",collection: @attribute.p_hire_fields.asc(:_id)%> + <%= render partial: "attribute_field",collection: @attribute.p_hire_fields_enabled.asc(:_id)%>
diff --git a/app/views/admin/property_hires/edit_hire.html.erb b/app/views/admin/property_hires/edit_hire.html.erb index 5bbd78f..19e58ef 100644 --- a/app/views/admin/property_hires/edit_hire.html.erb +++ b/app/views/admin/property_hires/edit_hire.html.erb @@ -714,10 +714,10 @@ ul.list-unstyled li { <% custom_field_inputs["note_for_hire"] = render(:partial=>"note_for_hire",:locals=>{:f=>f,:property=>property}) %> <% end %> <% fields_name = property.get_all_fields %> - <% has_p_hire_fields = property.p_hire_fields.count != 0 + <% has_p_hire_fields = property.p_hire_fields_enabled.count != 0 p_hire_fields = {} if has_p_hire_fields - p_hire_fields = property.p_hire_fields.map{|rf| [rf.id.to_s,rf]}.to_h + p_hire_fields = property.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h end %> <% @form_index = 0 %> diff --git a/app/views/admin/property_hires/fields_display_order.html.erb b/app/views/admin/property_hires/fields_display_order.html.erb index be9384b..31517d7 100644 --- a/app/views/admin/property_hires/fields_display_order.html.erb +++ b/app/views/admin/property_hires/fields_display_order.html.erb @@ -17,7 +17,7 @@ } <%= form_for @property , :url => {:action => "update_fields_display_order"}, html: {class: "form-horizontal main-forms"} do |f| %> - <% p_hire_fields = @property.p_hire_fields.map{|rf| [rf.id.to_s,rf]}.to_h %> + <% p_hire_fields = @property.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h %>
<%= @property.title %>
diff --git a/app/views/email/p_hire_email.html.erb b/app/views/email/p_hire_email.html.erb index db51134..4d48949 100644 --- a/app/views/email/p_hire_email.html.erb +++ b/app/views/email/p_hire_email.html.erb @@ -26,7 +26,7 @@ <% - p_hire_fields = property.p_hire_fields.map{|rf| [rf.id.to_s,rf]}.to_h + p_hire_fields = property.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h fields_name = property.get_all_fields basic_keys = [] if (property.set_availability rescue false) @@ -37,7 +37,7 @@ fields_name = fields_name - basic_keys keys = basic_keys + fields_name keys = keys.select{|field_name| (property[field_name]["enable"] == "1" rescue true) } - p_hire_fields = property.p_hire_fields.map{|rf| [rf.id.to_s,rf]}.to_h + p_hire_fields = property.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h has_p_hire_fields = p_hire_fields.count != 0 tmp_keys = [] all_trans = keys.map do |k| diff --git a/app/views/property_hires/hire.html.erb b/app/views/property_hires/hire.html.erb index cafbdb0..7b4092b 100644 --- a/app/views/property_hires/hire.html.erb +++ b/app/views/property_hires/hire.html.erb @@ -558,10 +558,10 @@ <% custom_field_inputs["note_for_hire"] = render(:partial=>"note_for_hire",:locals=>{:f=>f,:property=>property}) %> <% end %> <% fields_name = property.get_all_fields %> - <% has_p_hire_fields = property.p_hire_fields.count != 0 + <% has_p_hire_fields = property.p_hire_fields_enabled.count != 0 p_hire_fields = {} if has_p_hire_fields - p_hire_fields = property.p_hire_fields.map{|rf| [rf.id.to_s,rf]}.to_h + p_hire_fields = property.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h end %> <% @form_index = 0 %> diff --git a/app/views/property_hires/hire_old.html.erb b/app/views/property_hires/hire_old.html.erb index a93c0e5..48846cd 100644 --- a/app/views/property_hires/hire_old.html.erb +++ b/app/views/property_hires/hire_old.html.erb @@ -308,10 +308,10 @@
<% end %> <% end %> - <% if property.p_hire_fields.count != 0 %> + <% if property.p_hire_fields_enabled.count != 0 %> <% p_hire = PHire.new(:id=>nil) %> <% @form_index = 0 %> - <% property.p_hire_fields.asc(:_id).each do |rf| %> + <% property.p_hire_fields_enabled.asc(:_id).each do |rf| %>
<%= rf.block_helper(property,@form_index,false,"p_hire",p_hire, rf.to_require) %>