property_hire/app/views/admin/property_hires/_form.html.erb

1016 lines
49 KiB
Plaintext
Raw Normal View History

2020-03-23 17:26:52 +00:00
<%
hire_method = Admin::PropertyHiresHelper::HireMethod
hire_method.set_input_name('property')
2024-05-14 00:59:52 +00:00
with_id = !(@property.new_record?)
2020-03-23 17:26:52 +00:00
%>
<style type="text/css">
.tab-panel > .tab-content{
display: none;
}
.tab-panel > .tab-content.active{
display: block;
}
.tab-panel{
display: flex;
flex-wrap: wrap;
}
2020-07-22 10:13:50 +00:00
.label_left{
float: left;
margin-right: 0.5em;
}
.select_field_block{
border: 0.2em solid #666;
padding: 1em;
}
.remove_btn:hover{
font-size: 1.3em;
}
.remove_btn{
cursor: pointer;
}
2021-09-06 16:45:14 +00:00
.card-header a{
text-align: center;
display: block;
}
.card-header:hover{
background: aquamarine;
}
.card-header:hover a{
text-decoration: none;
}
.add_weekday_setting{
text-align: center;
align-self: center;
}
.time_setting_form, .image_group{
border: 0.2em solid #333;
padding-top: 0;
}
.add-on.iconbtn{
display: none;
}
.time_setting_form:last-child, .image_group:last-child {
margin-bottom: 1em;
}
.card-header {
padding: 0;
}
.card-header a {
padding: .75rem 1.25rem;
}
.card-header h4 {
margin: 0;
}
2021-10-23 02:34:18 +00:00
.apply_default_time_settings{
margin-bottom: 1em;
}
2020-03-23 17:26:52 +00:00
</style>
2017-01-20 09:02:50 +00:00
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
2021-09-06 16:45:14 +00:00
<%= stylesheet_link_tag "admin/card" %>
2017-01-20 09:02:50 +00:00
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li>
<li><a href="#page_setting" data-toggle="tab"><%= t("property_hire.page_setting") %></a></li>
2021-09-06 16:45:14 +00:00
<li><a href="#files_links" data-toggle="tab"><%= t("property_hire.files_links") %></a></li>
2017-01-20 09:02:50 +00:00
<li><a href="#tag" data-toggle="tab"><%= t(:tags) %></a></li>
<li><a href="#imageupload" data-toggle="tab"><%= t(:image) %></a></li>
2021-09-06 16:45:14 +00:00
<li><a href="#carousel_image_upload" data-toggle="tab" title="<%= t('property_hire.carousel_image_title') %>"><%= t('property_hire.carousel_image') %></a></li>
<li><a href="#unavailability" data-toggle="tab"><%= t('property_hire.unavailable_time')%></a></li>
<li><a href="#available_time" data-toggle="tab"><%= t('property_hire.available_time')%></a></li>
2020-03-23 17:26:52 +00:00
<li><a href="#auto_send_email_set" data-toggle="tab"><%= t('property_hire.auto_send_email_set') %></a></li>
2021-09-06 16:45:14 +00:00
<li><a href="#settings" data-toggle="tab"><%= t('property_hire.reservation_fields') %></a></li>
2017-01-20 09:02:50 +00:00
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<!-- Category -->
<div class="control-group">
<label class="control-label muted"><%= t(:category) %></label>
<div class="controls">
<%= select_category(f, @module_app) %>
</div>
</div>
<div class="control-group">
<%= f.label :property_location, t("property_hire.property_location"), :class => "control-label muted" %>
<div class="controls">
<% if @property.new_record? %>
<%= f.select :property_location, @locations %>
<% elsif @property.property_location.nil? %>
<%= f.select :property_location, @locations, {:selected => "other_location"} %>
<% else %>
<%= f.select :property_location, @locations %>
<% end %>
</div>
</div>
<div class="control-group" id="other-location-div" style="<%= @property.new_record? || !@property.property_location.nil? ? "display: none;" : "" %>">
<%= f.label :other_location, t("property_hire.other_location"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :other_location %>
</div>
</div>
<div class="control-group">
<%= f.label :property_number, t("property_hire.property_number"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :property_number %>
</div>
</div>
<div class="control-group">
2024-07-11 07:42:16 +00:00
<%= f.label :p_hire_start_time, t("property_hire.p_hire_start_time"), :class => "control-label muted" %>
2017-01-20 09:02:50 +00:00
<div class="controls">
2024-07-11 07:42:16 +00:00
<%= f.datetime_picker :p_hire_start_time, :picker_type => "date", :no_label => true, :new_record => @property.new_record?, :data=>{"picker-type" => "range", "range" => "start"}, :format => "yyyy/MM/dd hh:mm" %>
</div>
</div>
<div class="control-group">
<%= f.label :p_hire_end_time, t("property_hire.p_hire_end_time"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :p_hire_end_time, :picker_type => "date", :no_label => true, :new_record => @property.new_record?, :data=>{"picker-type" => "range", "range" => "end"}, :format => "yyyy/MM/dd hh:mm" %>
</div>
</div>
<div class="control-group">
<%= f.label :recurring_enable, t("property_hire.recurring_enable"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :recurring_enable %>
</div>
</div>
<div id="open-time" >
<div class="control-group">
<%= f.label :p_open_start_time, t("property_hire.p_open_start_time"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :p_open_start_time, :picker_type => "date", :no_label => true, :new_record => @property.new_record?, :data=>{"picker-type" => "range", "range" => "start"}, :format => "yyyy/MM/dd" %>
</div>
</div>
<div class="control-group">
<%= f.label :p_open_end_time, t("property_hire.p_open_end_time"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :p_open_end_time, :picker_type => "date", :no_label => true, :new_record => @property.new_record?, :data=>{"picker-type" => "range", "range" => "end"}, :format => "yyyy/MM/dd" %>
</div>
2017-01-20 09:02:50 +00:00
</div>
</div>
<div class="control-group">
<%= f.label :purchase_date, t("property_hire.purchase_date"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :purchase_date, :no_label => true, :new_record => @property.new_record?, :picker_type => "date", :format => "yyyy/MM/dd" %>
</div>
</div>
<div class="control-group">
<%= f.label :owners, t("property_hire.owners"), :class => "control-label muted" %>
<div class="controls">
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'property[owners][]', email_members: @property.owner_profiles} %>
</div>
</div>
<div class="control-group">
<%= f.label :other_owner, t("property_hire.other_owner"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :other_owner %>
</div>
</div>
<div class="control-group">
<%= f.label :owner_email, t("property_hire.owner_email"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :owner_email %>
</div>
</div>
2024-08-24 03:00:08 +00:00
<div class="control-group">
<%= f.label :owner_email_rule, t("property_hire.owner_email_rule"), :class => "control-label muted" %>
<div class="controls">
<%= f.select :owner_email_rule, options_for_select([0,1,2].map{|i| [t("property_hire.owner_email_rules.#{i}"), i]}, f.object.owner_email_rule) %>
</div>
</div>
2017-01-20 09:02:50 +00:00
<div class="control-group">
<%= f.label :owner_phone, t("property_hire.owner_phone"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :owner_phone %>
</div>
</div>
<div class="control-group">
<%= f.label :price, t("property_hire.price"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :price %>
</div>
</div>
</div>
<!-- page_setting -->
<div class="tab-pane fade" id="page_setting">
<div class="control-group">
<%= f.label :custom_calendar_type, t("property_hire.display_calendar"), :class => "control-label muted" %>
<div class="controls">
<%= f.select :custom_calendar_type, options_for_select(Property::CAlENDARTYPE.map.with_index{|type,i| [t("property_hire.custom_calendar_type.#{type}"), i]}, f.object.custom_calendar_type) %>
</div>
</div>
</div>
2021-09-06 16:45:14 +00:00
<!-- files_links -->
<div class="tab-pane fade" id="files_links">
<%= render :partial => "form_file_link", :locals=>{:f=>f} %>
</div>
2017-01-20 09:02:50 +00:00
<!-- tags -->
<div class="tab-pane fade" id="tag">
<div class="control-group">
<label class="control-label muted"><%= t(:tags) %></label>
<%= select_tags(f, @module_app) %>
</div>
</div>
<!-- image -->
<div class="tab-pane fade" id="imageupload">
<div class="control-group">
<label class="control-label muted"><%= t(:image) %></label>
<div class="controls">
<div class="fileupload fileupload-new clearfix <%= 'fileupload-edit' if @property.image.file %>" data-provides="fileupload">
<div class="fileupload-new thumbnail pull-left">
<% if @property.image.file %>
<%= image_tag @property.image %>
<% else %>
2021-09-19 07:56:01 +00:00
<img src="/assets/property_hire/AAAAAA.png" />
2017-01-20 09:02:50 +00:00
<% end %>
</div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<span class="btn btn-file">
<span class="fileupload-new"><%= t(:select_image) %></span>
<span class="fileupload-exists"><%= t(:change) %></span>
<%= f.file_field :image %>
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn btn-danger fileupload-remove">
<%= f.check_box :remove_image %><%= t(:remove) %>
</label>
</div>
</div>
</div>
</div>
2021-09-06 16:45:14 +00:00
<!-- display img src -->
<div class="control-group">
<%= f.label :display_img, t("property_hire.display_img"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :display_img %>
</div>
</div>
<!-- Image display setting -->
<% image_display_class_relation = {"full_width"=>"full-size-img","up_left_corner"=>"pull-left","up_right_corner"=>"pull-right"} %>
<div class="control-group <%='hide' if !f.object.display_img %>" id="image_display_setting">
<%= f.label :image_display_class, t("property_hire.cover_image_display_setting"), :class => "control-label muted" %>
<div class="controls">
<% image_display_class_relation.each.with_index do |(key,value),i| %>
<label>
<%= radio_button_tag "#{f.object_name}[image_display_class]", value , (f.object.image_display_class == value) %>
<%= t("property_hire.#{key}") %>
</label>
<% end %>
</div>
</div>
</div>
<!-- Images Module -->
<div class="tab-pane fade" id="carousel_image_upload">
<div class="control-group">
<label class="control-label muted" for="carousel_image_width"><%= t("property_hire.carousel_image_width") %></label>
<div class="controls">
<%= f.text_field :custom_carousel_image_width, :placeholder => t("property_hire.custom_carousel_image_width_hint") %>
</div>
</div>
<% if f.object && !f.object.property_carousel_images.blank? %>
<div class="exist">
<% f.object.property_carousel_images.each_with_index do |property_carousel_image, i| %>
<%= f.fields_for :property_carousel_images, property_carousel_image do |f| %>
<%= render :partial => 'form_image', :object => property_carousel_image, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn controls">
<%= hidden_field_tag 'property_carousel_image_count', f.object.property_carousel_images.count %>
<a id="add_carousel_image" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
2017-01-20 09:02:50 +00:00
</div>
2020-03-23 17:26:52 +00:00
<!-- Email Set Module -->
<div class="tab-pane fade" id="auto_send_email_set" style="padding: 1.2em;">
<ul class="nav nav-pills module-nav">
<li class="active">
<a href="#email_set0" data-toggle="tab">
<%= t('property_hire.hire') %>
</a>
</li>
<li class="">
<a href="#email_set1" data-toggle="tab">
<%= t('property_hire.edit') %>
</a>
</li>
<li class="">
<a href="#email_set2" data-toggle="tab">
<%= t('property_hire.delete') %>
</a>
</li>
</ul>
<div class="tab-content">
<% (0..2).each do |index1| %>
<% active_email_set = index1==0 ? ' active' : '' %>
<div class="tab-pane<%= active_email_set %>" id="email_set<%= index1 %>" style="padding: 1.2em;">
<table style="width:100%;">
<tbody>
<tr>
<td>
<%= t('disable') %>
</td>
<td>
<input type="hidden" class="field_set" name='<%= "property[hire_email_sets][#{index1}][disabled]" %>' value="false">
<%= check_box_tag("property[hire_email_sets][#{index1}][disabled]", true ,@email_set[index1].disabled) %>
</td>
</tr>
<tr>
<td>
<%= t('property_hire.email_title') %>
</td>
<td>
2024-05-14 00:59:52 +00:00
<%= hire_method.show_set_field(@email_set[index1].id,@email_set[index1]['title'],'hire_email_sets',index1,'title','text_field',with_id) %>
2020-03-23 17:26:52 +00:00
</td>
</tr>
<tr>
<td>
<%= t('property_hire.email_content') %>
</td>
<td>
<div class="form-group">
2024-05-14 00:59:52 +00:00
<%= hire_method.show_set_field(@email_set[index1].id,@email_set[index1]['content'],'hire_email_sets',index1,'content','text_area',with_id) %>
2020-03-23 17:26:52 +00:00
</div>
<%= hidden_field_tag("property[hire_email_sets][#{index1}][field_name]",@email_set[index1]['field_name']) %>
2024-05-14 00:59:52 +00:00
<% unless @property.new_record? %>
<%= hidden_field_tag("property[hire_email_sets][#{index1}][property_id]",@property.id) %>
<% end %>
2020-03-23 17:26:52 +00:00
</td>
</tr>
</tbody>
</table>
</div>
<% end %>
</div>
</div>
2017-01-20 09:02:50 +00:00
<!-- unavailability -->
<div class="tab-pane fade" id="unavailability">
<div class="control-group">
<%= f.label :set_unavailibility, t("property_hire.set_unavailibility"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :set_unavailibility %>
</div>
</div>
2024-05-14 00:59:52 +00:00
<% if @property.set_unavailibility %>
2017-01-20 09:02:50 +00:00
<div id="set_unavailibility_div">
<% else %>
<div id="set_unavailibility_div" style="display: none;">
<% end %>
<div class="control-group">
<%= f.label :can_hire_before_months, t("property_hire.how_many_months_ago_can_be_hired"), :class => "control-label muted" %>
2017-01-20 09:02:50 +00:00
<div class="controls">
<%= f.select :can_hire_before_months, options_for_select([[t("property_hire.no_limit"),0]] + (1..12).to_a.map{|month| [t("property_hire.month", month: month), month]},f.object.can_hire_before_months) %>
2017-01-20 09:02:50 +00:00
</div>
</div>
<div class="control-group">
<%= f.label :need_hire_before, t("property_hire.need_hire_before"), :class => "control-label muted" %>
<div class="controls">
<% units = ['month', 'day', 'hour', 'minute'] %>
<%= f.number_field :need_hire_before, :min=>0 %>
<%= f.select :need_hire_before_unit, options_for_select(units.map{|unit| [t("property_hire._#{unit}"), unit]},f.object.need_hire_before_unit) %>
</div>
</div>
2017-01-20 09:02:50 +00:00
<div class="control-group">
<label class="control-label muted"><%=t("property_hire.weekdays").html_safe%></label>
2017-01-20 09:02:50 +00:00
<div class="controls">
<% weekdays = @property.weekdays rescue [] %>
<% Property::WEEKDAYS.each_with_index do |weekday,i| %>
<label for="<%=weekday%>">
<input id="<%=weekday%>" type="checkbox" name="property[weekdays][]" value="<%=i%>" <%= weekdays.include?(i.to_s) ? "checked=checked" : "" %> /> <% trans = t("property_hire.#{weekday}") %><%= (trans.class == ActiveSupport::SafeBuffer ? weekday : trans) %>
</label>
<% end %>
2017-01-20 09:02:50 +00:00
</div>
</div>
2024-07-11 07:42:16 +00:00
<div class="control-group">
<label class="control-label muted"><%=t("property_hire.special_unavailable_date")%></label>
<div class="controls" id="special_unavailable_date_holder">
<% @property.special_unavailable_dates.each_with_index do |dt, idx| %>
<div class="temp_date_holder" style="margin-bottom:5px;">
<div class="date_picker input-append" style="margin-bottom:3px;">
<input placeholder="yyyy/MM/dd" class="input-large" data-format="yyyy/MM/dd" type="text" name="property[special_unavailable_dates][]" title="yyyy/MM/dd" autocomplete="off" value="<%= dt %>">
<span class="add-on clearDate"><i class="icons-cross-3"></i></span>
<span class="add-on deleteDate"><i class="icon-trash"></i></span>
</div>
<div class="tab-panel">
<div class="tab-content active" id="special_unavailable_title_<%= idx %>_en">
<input type="text" name="property[special_unavailable_dates_title][][en]" value="<%= @property.special_unavailable_dates_title[idx]["en"] %>">
</div>
<div class="tab-content" id="special_unavailable_title_<%= idx %>_zh_tw">
<input type="text" name="property[special_unavailable_dates_title][][zh_tw]" value="<%= @property.special_unavailable_dates_title[idx]["zh_tw"] %>">
</div>
<div class="btn-group" data-toggle="buttons-radio">
<a data-toggle="tab" class="btn active" for="en" href="#special_unavailable_title_<%= idx %>_en" aria-expanded="true" aria-pressed="true"><%= t("en") %></a>
<a data-toggle="tab" class="btn" for="zh_tw" href="#special_unavailable_title_<%= idx %>_zh_tw" aria-expanded="true" aria-pressed="true"><%= t("zh_tw") %></a>
</div>
</div>
</div>
<% end %>
</div>
<div class="controls">
<button class="primary" id="add_special_unavailable_date">Add</button>
</div>
</div>
2017-01-20 09:02:50 +00:00
<div class="control-group">
<%= f.label :start_date, t("property_hire.start_date"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :start_date, :picker_type => "date", :no_label => true, :new_record => @property.new_record?, :data=>{"picker-type" => "range", "range" => "start"}, :format => "yyyy/MM/dd" %>
</div>
</div>
2020-03-23 17:26:52 +00:00
<div class="control-group">
2017-01-20 09:02:50 +00:00
<%= f.label :end_date, t("property_hire.end_date"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :end_date, :picker_type => "date", :no_label => true, :new_record => @property.new_record?, :data=>{"picker-type" => "range", "range" => "end"}, :format => "yyyy/MM/dd" %>
</div>
</div>
<div class="control-group">
<%= f.label :start_time, t("property_hire.limit_start_time"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :start_time, :picker_type => "time", :no_label => true, :new_record => @property.new_record?, :value => (Time.parse(@property.start_time) rescue "") %>
</div>
</div>
<div class="control-group">
<%= f.label :end_time, t("property_hire.limit_end_time"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :end_time, :picker_type => "time", :no_label => true, :new_record => @property.new_record?, :value => (Time.parse(@property.end_time) rescue "") %>
</div>
</div>
2017-01-20 09:02:50 +00:00
<% @site_in_use_locales.each do |locale| %>
<%= f.fields_for :description_translations do |f| %>
<div class="control-group">
<label class="control-label muted" for="description_<%= locale.to_s %>"><%= t(:description) + " (#{t(locale.to_s)})" %></label>
<div class="controls">
<%= f.text_field locale, value: (@property.description_translations[locale.to_s] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
<% @site_in_use_locales.each do |locale| %>
<%= f.fields_for :unavailibility_note_translations do |f| %>
2017-01-20 09:02:50 +00:00
<div class="control-group">
<label class="control-label muted" for="note_<%= locale.to_s %>"><%= t(:note) + " (#{t(locale.to_s)})" %></label>
<div class="controls">
<%= f.text_area locale, value: (@property.unavailibility_note_translations[locale.to_s] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
2021-09-06 16:45:14 +00:00
<!-- available_time -->
<div class="tab-pane fade" id="available_time">
<div class="control-group">
<%= f.label :set_availability, t("property_hire.set_availability"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :set_availability %>
</div>
</div>
<% if @property.set_availability %>
<div id="set_availability_div">
<% else %>
<div id="set_availability_div" style="display: none;">
<% end %>
<ul>
<% all_day_settings = f.object.all_day_settings %>
2021-09-06 16:45:14 +00:00
<% setting_count = 0 %>
<% Property::WEEKDAYS.each_with_index do |weekday,i| %>
<li class="card">
<div class="card-header">
<h4>
<a data-toggle="collapse" href="#<%=weekday%>_setting" role="button" aria-expanded="false" aria-controls="<%=weekday%>_setting"><% trans = t("property_hire.#{weekday}") %><%= (trans.class == ActiveSupport::SafeBuffer ? weekday : trans) %></a>
</h4>
</div>
<div class="collapse" id="<%=weekday%>_setting">
<div class="card card-body">
2021-10-23 02:34:18 +00:00
<div>
<button type="button" class="btn btn-primary apply_default_time_settings pull-right" data-target="#add_target_weekday_<%=i%>" data-count="0" data-day="<%=i%>"><%=t("property_hire.apply_default_time_settings")%></button>
</div>
2021-09-06 16:45:14 +00:00
<div id="add_target_weekday_<%=i%>">
<% if all_day_settings[i.to_s] %>
<% all_day_settings[i.to_s].each_with_index do |setting,j| %>
<%= f.fields_for :property_day_settings, setting,:child_index => setting_count do |f| %>
<%= render :partial => "time_form", :locals=>{:key=>j,:day=>i,:f=>f} %>
<% setting_count += 1 %>
<% end %>
<% end %>
<% end %>
</div>
<a class="btn btn-primary add_weekday_setting" data-target="#add_target_weekday_<%=i%>" data-count="<%= all_day_settings[i] ? all_day_settings[i].count : 0 %>" data-day="<%=i%>"><%=t(:add)%></a>
</div>
</div>
</li>
<% end %>
</ul>
</div>
</div>
<div class="tab-pane fade" id="settings">
2021-09-19 07:56:01 +00:00
<% fields_name = f.object.class::FIELDSNAME %>
2021-09-06 16:45:14 +00:00
<div style="padding: 1.2em;">
<table style="margin: 0;">
<thead>
<th><%= t('property_hire.field_name') %></th>
<th><%= t('property_hire.name') %></th>
<th><%= t('property_hire.placeholder') %></th>
<th><%= t('property_hire.disable') %></th>
<th><%= t('property_hire.required') %></th>
</thead>
<tbody>
<% fields_name.each do |field_name| %>
<tr>
<td>
<%= t("property_hire.#{field_name}") %>
</td>
<td>
<%= render_custom_text_field(f,field_name,"name") %>
</td>
<td>
<%= render_custom_text_field(f,field_name,"placeholder") %>
</td>
<td>
<input type="hidden" name='<%= "#{f.object_name}[#{field_name}][enable]" %>' value="1">
<%= check_box_tag("#{f.object_name}[#{field_name}][enable]", "0" , (f.object.send(field_name)["enable"] == "0" rescue false)) %>
</td>
<td>
<input type="hidden" name='<%= "#{f.object_name}[#{field_name}][required]" %>' value="false">
<%= check_box_tag("#{f.object_name}[#{field_name}][required]", "true" , (f.object.send(field_name)["required"] == "true" rescue false)) %>
</td>
</tr>
<% end %>
2021-09-06 16:45:14 +00:00
</tbody>
</table>
</div>
2020-07-22 10:13:50 +00:00
<hr style="border-color: black; ">
<div class="control-group">
<% field_name = "enable_notes_selector" %>
<label class="control-label muted"><%= t("property_hire.#{field_name}") %></label>
<div class="controls">
<label for="act_enabled_name" class="checkbox inline">
<%= hidden_field_tag "property[#{field_name}]", "0" %>
<%= f.check_box_tag "property[#{field_name}]", "1" , (@property[field_name] rescue false) %>
Enable
</label>
</div>
</div>
<div class="control-group" id="selector_block">
<% field_name = "notes_selector" %>
<label class="control-label muted"><%= t("property_hire.#{field_name}") %></label>
<div class="controls">
<div id="select_choice_block">
<% @property[field_name].each do |index,sub_hash| %>
<div id="select_choice<%=index.to_s%>" class="select_field_block">
<span class="remove_btn">❌</span>
<div class="field_name_block">
<div>
<label for="select_choice_type_index<%=index.to_s%>" class="label_left"><%=t("property_hire.field_type")%>:</label>
<select name="<%="property[#{field_name}][#{index}][type]"%>">
<option value="radio" <%=(@property["#{field_name}"]["#{index}"]["type"] == "radio") ? 'selected="selected"' : ''%>><%=t("property_hire.radio")%></option>
<option value="checkbox" <%=(@property["#{field_name}"]["#{index}"]["type"] == "checkbox") ? 'selected="selected"' : ''%>><%=t("property_hire.checkbox")%></option>
</select>
</div>
<div><label for="select_choice_name_index<%=index.to_s%>" class="label_left"><%=t("property_hire.field_name")%>:</label>
<div class="input-append">
<div class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="select_choice_name_index<%=index%>_<%=locale.to_s%>">
<input type="text" value="<%=sub_hash['name'][locale.to_s] rescue ''%>" name="<%="property[#{field_name}][#{index}][name][#{locale}]"%>">
</div>
<% end %>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#select_choice_name_index<%=index%>_<%=locale.to_s%>" data-toggle="tab"><%= t(locale.to_s) %></a>
<% end %>
</div>
</div>
</div>
</div>
<div class="field_value_block">
<label><%=t("property_hire.field_value")%></label>
<% @property["#{field_name}"]["#{index}"]["value"].values.first.each_with_index do |v,val_index|%>
<div class="value_choice">
<span class="remove_btn">❌</span>
<div class="input-append">
<div class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="select_choice_value_index<%=index.to_s%>_<%=locale.to_s%>_<%=val_index%>">
<input type="text" name="property[notes_selector][<%=index.to_s%>][value][<%=locale.to_s%>][]" value="<%=@property["#{field_name}"][index.to_s]["value"][locale.to_s][val_index]%>">
</div>
<% end %>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#select_choice_value_index<%=index.to_s%>_<%=locale.to_s%>_<%=val_index%>" data-toggle="tab"><%= t(locale.to_s) %></a>
<% end %>
</div>
</div>
</div>
<% end %>
<div style="clear: both;"></div>
<a class="btn btn-primary add_choice" data-index="<%=index.to_s%>"><%=t("property_hire.add_choice")%></a>
</div>
</div>
<% end %>
</div>
<a id="add_note_select_field" class="btn btn-primary"><%=t(:add)%></a>
</div>
</div>
2020-03-23 17:26:52 +00:00
</div>
2017-01-20 09:02:50 +00:00
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- Title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("property_hire.title") %></label>
<div class="controls">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("property_hire.title"), value: (@property.title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<div class="control-group input-title">
<label class="control-label muted"><%= t("property_hire.property_usage") %></label>
<div class="controls">
<%= f.fields_for :property_usage_translations do |f| %>
2021-09-06 16:45:14 +00:00
<%= f.text_area locale, class: "ckeditor input-block-level", placeholder: t("property_hire.property_usage"), value: (@property.property_usage_translations[locale] rescue nil) %>
2017-01-20 09:02:50 +00:00
<% end %>
</div>
</div>
<div class="control-group input-title">
<label class="control-label muted"><%= t("property_hire.note") %></label>
<div class="controls">
<%= f.fields_for :note_translations do |f| %>
2021-09-06 16:45:14 +00:00
<%= f.text_area locale, class: "ckeditor input-block-level", placeholder: t("property_hire.note"), value: (@property.note_translations[locale] rescue nil) %>
2017-01-20 09:02:50 +00:00
<% end %>
</div>
</div>
</div>
<% end %>
</div>
<!-- Form Actions -->
<div class="form-actions">
2021-09-19 07:56:01 +00:00
<% referer = request.referer rescue nil %>
<% referer = get_referer_url if referer.blank? || request.host != URI.parse(URI.encode(referer)).host %>
<input type="hidden" name="referer_url" value="<%= referer %>">
2024-05-14 00:59:52 +00:00
<% unless @property.new_record? %>
<%= hidden_field_tag("property[id]", @property.id) %>
<% end %>
2017-01-20 09:02:50 +00:00
<%= f.submit t('submit'), class: 'btn btn-primary' %>
2021-09-19 07:56:01 +00:00
<%= link_to t('cancel'), referer, :class=>"btn" %>
2017-01-20 09:02:50 +00:00
</div>
<script type="text/javascript">
2021-09-06 16:45:14 +00:00
$("#bulletin_display_img").click(function(){$("#image_display_setting").toggleClass("hide")})
2020-07-22 10:13:50 +00:00
$(document).ready(function(){
if($("[type=checkbox][name='property[enable_notes_selector]']:checked").length == 0){
$("#selector_block").css("display","none");
}else{
$("#selector_block").css("display","");
}
})
2017-01-20 09:02:50 +00:00
$("#property_set_unavailibility").on("click",function(){
if($(this).is(":checked")){
$("#set_unavailibility_div").show();
}else{
$("#set_unavailibility_div").hide();
}
})
2021-09-06 16:45:14 +00:00
$("#property_set_availability").on("click",function(){
if($(this).is(":checked")){
$("#set_availability_div").show();
}else{
$("#set_availability_div").hide();
}
})
2017-01-20 09:02:50 +00:00
$("#property_property_location").on("change",function(){
if($(this).val() == "other_location"){
$("#other-location-div").show();
}else{
$("#other-location-div").hide();
}
})
2020-07-22 10:13:50 +00:00
$("#add_note_select_field").on("click",function(){
var index = ($("#select_choice_block").find(">div").length == 0) ? 0 : (Number($("#select_choice_block").find(">div").eq(-1).attr("id").split("select_choice").last()) + 1);
$("#select_choice_block").append('<div id="select_choice'+String(index)+'" class="select_field_block"><span class="remove_btn">❌</span>'+
'<div class="field_name_block">'+
'<div>'+
'<label for="select_choice_type_index'+String(index)+'" class="label_left"><%=t("property_hire.field_type")%>:</label>'+
'<select name="property[notes_selector]['+String(index)+'][type]">'+
'<option value="radio"><%=t("property_hire.radio")%></option>'+
'<option value="checkbox"><%=t("property_hire.checkbox")%></option>'+
'</select>'+
'</div>'+
'<div><label for="select_choice_name_index'+String(index)+'" class="label_left"><%=t("property_hire.field_name")%>:</label>'+
'<div class="input-append" id="select_choice_name_index'+String(index)+'">'+
'<div class="tab-content">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="select_choice_name_index'+String(index)+'_<%=locale.to_s%>">'+
'<input type="text" name="property[notes_selector]['+String(index)+'][name][<%=locale.to_s%>]">'+
'</div>'+
<% end %>
'</div>'+
'<div class="btn-group" data-toggle="buttons-radio">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#select_choice_name_index'+String(index)+'_<%=locale.to_s%>" data-toggle="tab"><%= t(locale.to_s) %></a>'+
<% end %>
'</div>'+
'</div>'+
'</div>'+
'</div>'+
'<div class="field_value_block">'+
'<label><%=t("property_hire.field_value")%></label>'+
'<div class="value_choice">'+
'<span class="remove_btn">❌</span>'+
'<div class="input-append">'+
'<div class="tab-content">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="select_choice_value_index'+String(index)+'_<%=locale.to_s%>_0">'+
'<input type="text" name="property[notes_selector]['+String(index)+'][value][<%=locale.to_s%>][]">'+
'</div>'+
<% end %>
'</div>'+
'<div class="btn-group" data-toggle="buttons-radio">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#select_choice_value_index'+String(index)+'_<%=locale.to_s%>_0" data-toggle="tab"><%= t(locale.to_s) %></a>'+
<% end %>
'</div>'+
'</div>'+
'</div>'+
'<div style="clear: both;"></div>'+
'<a class="btn btn-primary add_choice" data-index="'+String(index)+'"><%=t("property_hire.add_choice")%></a>'+
'</div>'+
'</div>');
$(".add_choice").off("click").on("click",function(){
var index = $(this).attr("data-index");
var val_index = $(this).siblings(".value_choice").length;
var $last_item = $(this).siblings(".value_choice").eq(-1);
if(val_index == 0){
$last_item = $(this).siblings("label").eq(-1);
}
$last_item.after('<div class="value_choice"><span class="remove_btn">❌</span><div class="input-append">'+
'<div class="tab-content">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="select_choice_value_index'+String(index)+'_<%=locale.to_s%>_'+String(val_index)+'">'+
'<input type="text" name="property[notes_selector]['+String(index)+'][value][<%=locale.to_s%>][]">'+
'</div>'+
<% end %>
'</div>'+
'<div class="btn-group" data-toggle="buttons-radio">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#select_choice_value_index'+String(index)+'_<%=locale.to_s%>_'+String(val_index)+'" data-toggle="tab"><%= t(locale.to_s) %></a>'+
<% end %>
'</div>'+
'</div></div>');
$(".remove_btn").off("click").on("click",function(){
$(this).parent().remove();
})
})
$(".remove_btn").off("click").on("click",function(){
$(this).parent().remove();
})
})
$(".add_choice").off("click").on("click",function(){
var index = $(this).attr("data-index");
var val_index = $(this).siblings(".value_choice").length;
var $last_item = $(this).siblings(".value_choice").eq(-1);
if(val_index == 0){
$last_item = $(this).siblings("label").eq(-1);
}
$last_item.after('<div class="value_choice"><span class="remove_btn">❌</span><div class="input-append">'+
'<div class="tab-content">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" id="select_choice_value_index'+String(index)+'_<%=locale.to_s%>_'+String(val_index)+'">'+
'<input type="text" name="property[notes_selector]['+String(index)+'][value][<%=locale.to_s%>][]">'+
'</div>'+
<% end %>
'</div>'+
'<div class="btn-group" data-toggle="buttons-radio">'+
<% @site_in_use_locales.each_with_index do |locale, i| %>
'<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#select_choice_value_index'+String(index)+'_<%=locale.to_s%>_'+String(val_index)+'" data-toggle="tab"><%= t(locale.to_s) %></a>'+
<% end %>
'</div>'+
'</div></div>');
$(".remove_btn").off("click").on("click",function(){
$(this).parent().remove();
})
});
$(".remove_btn").off("click").on("click",function(){
$(this).parent().remove();
})
$("[type=checkbox][name='property[enable_notes_selector]']").click(function(){
if(!$(this).prop("checked")){
$("#selector_block").css("display","none");
}else{
$("#selector_block").css("display","");
}
})
2021-09-06 16:45:14 +00:00
var setting_count = <%=setting_count%>;
2021-10-23 02:34:18 +00:00
var default_time_settings = <%= PropertyHireSetting.first.default_time_settings.map{|s| s.attributes.except("_id","created_at","updated_at")}.to_s.gsub("=>",": ").html_safe rescue "[]" %>
$(".apply_default_time_settings").click(function(){
var target = $($(this).data("target"));
var key = $(this).data("count");
var day = $(this).data("day");
var new_key = $(this).prev().attr('value');
var old_key = new RegExp("new_key", "g");
var new_day = day;
var old_day = new RegExp("new_day", "g");
var new_key = key;
target.empty();
default_time_settings.forEach(function(setting){
var old_index = new RegExp("new_index", "g");
var new_index = setting_count;
setting_count += 1;
<% property_day_setting = f.object.property_day_settings.new(:id=>nil) %>
<%= f.fields_for :property_day_settings,property_day_setting,:child_index => "new_index" do |f| %>
var template_html = "<%= escape_javascript(render(:partial=>"time_form",:locals=>{:f=>f})) %>";
<%end%>
var tmp = $(template_html.replace(old_index,new_index).replace(old_key,new_key).replace(old_day,new_day));
Object.keys(setting).forEach(function(k){
if(tmp.find("[name*='["+k+"]'").length != 0){
tmp.find("[name*='["+k+"]']").val(setting[k]);
console.log([k,setting[k]])
}
});
target.append(tmp);
key += 1;
})
$(this).data("count",key);
target.find("input[data-format]").each(function(i,input){
var $input = $(input);
var format = $input.data("format"),
timeOnly = !(format.match(/Y|M|d/)), timeFormat, dateFormat = "";
if(timeOnly){
timeFormat = format;
}else{
dateFormat = format.match(/yy(\/|-|)(mm|)(\/|-|)(dd|)/i)[0];
timeFormat = $.trim(format.replace(dateFormat,""));
}
var options = {dateFormat: dateFormat,timeFormat: timeFormat,timeOnly: timeOnly};
var additionalOptions = $input.data();
$.extend(options, additionalOptions);
$input.ui_datetimepicker(options);
$input.siblings('.clearDate').click(function(){
$input.val('');
$input.trigger('change');
});
})
})
2021-09-06 16:45:14 +00:00
$(".add_weekday_setting").click(function(){
var target = $($(this).data("target"));
2021-10-23 02:34:18 +00:00
var key = $(this).data("count");
2021-09-06 16:45:14 +00:00
var day = $(this).data("day");
var new_key = $(this).prev().attr('value');
var old_key = new RegExp("new_key", "g");
var new_day = day;
var old_day = new RegExp("new_day", "g");
var new_key = key;
key += 1;
2021-10-23 02:34:18 +00:00
$(this).data("count",key);
2021-09-06 16:45:14 +00:00
var old_index = new RegExp("new_index", "g");
var new_index = setting_count;
setting_count += 1;
<% property_day_setting = f.object.property_day_settings.new(:id=>nil) %>
<%= f.fields_for :property_day_settings,property_day_setting,:child_index => "new_index" do |f| %>
var template_html = "<%= escape_javascript(render(:partial=>"time_form",:locals=>{:f=>f})) %>";
<%end%>
var tmp = $(template_html.replace(old_index,new_index).replace(old_key,new_key).replace(old_day,new_day));
target.append(tmp);
tmp.find("input[data-format]").each(function(i,input){
var $input = $(input);
var format = $input.data("format"),
timeOnly = !(format.match(/Y|M|d/)), timeFormat, dateFormat = "";
if(timeOnly){
timeFormat = format;
}else{
dateFormat = format.match(/yy(\/|-|)(mm|)(\/|-|)(dd|)/i)[0];
timeFormat = $.trim(format.replace(dateFormat,""));
}
var options = {dateFormat: dateFormat,timeFormat: timeFormat,timeOnly: timeOnly};
var additionalOptions = $input.data();
$.extend(options, additionalOptions);
$input.ui_datetimepicker(options);
$input.siblings('.clearDate').click(function(){
$input.val('');
$input.trigger('change');
});
})
})
$(document).on('click', '.setting-form-remove', function(){
if($(this).find(".remove_existing_record").length != 0){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).find('.should_destroy').attr('value', 1);
$(this).parents('.time_setting_form').hide();
}
}else{
$(this).parents('.time_setting_form').remove();
}
});
$(document).on('click', '.image-form-remove', function(){
if($(this).find(".remove_existing_record").length != 0){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).find('.should_destroy').attr('value', 1);
$(this).parents('.image_group').hide();
}
}else{
$(this).parents('.image_group').remove();
}
});
$(document).on('click', '#add_carousel_image', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_property_carousel_images", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_image', f, :property_carousel_images) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
});
});
$(document).on('click', '.fileupload-remove', function(){
if($(this).find(".delete_image").length != 0){
$(this).parents('.image_group').remove();
}
});
2024-07-11 07:42:16 +00:00
// $(document).on("click", "#property_can_be_hired", function () {
// if($(this).is(":checked")){
// $("#open-time").attr("class","show");
// }else{
// $("#open-time").attr("class","hide");
// $("#open-time").find("input").val("");
// }
// })
var special_unavailable_title_counter = <%= @property.special_unavailable_dates.count %>;
$(document).on("click","#add_special_unavailable_date", function(){
var datepicker = $('<div class="date_picker input-append" style="margin-bottom:3px;"> \
<input placeholder="yyyy/MM/dd" class="input-large" data-format="yyyy/MM/dd" type="text" name="property[special_unavailable_dates][]" title="yyyy/MM/dd" autocomplete="off"> \
<span class="add-on clearDate"><i class="icons-cross-3"></i></span> \
<span class="add-on deleteDate"><i class="icon-trash"></i></span> \
</div>');
var id = "special_unavailable_title_" + special_unavailable_title_counter;
var title = $('<div class="tab-panel"> \
<div class="tab-content active" id="' + id + '_en"> \
<input type="text" name="property[special_unavailable_dates_title][][en]" value=""> \
</div> \
<div class="tab-content" id="' + id + '_zh_tw"> \
<input type="text" name="property[special_unavailable_dates_title][][zh_tw]" value=""> \
</div> \
<div class="btn-group" data-toggle="buttons-radio"> \
<a data-toggle="tab" class="btn active" for="en" href="#' + id + '_en" aria-expanded="true" aria-pressed="true"><%= t("en") %></a> \
<a data-toggle="tab" class="btn" for="zh_tw" href="#' + id + '_zh_tw" aria-expanded="true" aria-pressed="true"><%= t("zh_tw") %></a> \
</div> \
</div>');
datepicker.find('input').datepicker({
dateFormat : "yy/mm/dd"
});
var html = $('<div class="temp_date_holder" style="margin-bottom:5px;"></div>');
html.append(datepicker);
html.append(title);
$("#special_unavailable_date_holder").append(html);
special_unavailable_title_counter++;
return false;
})
$(document).on("click","#special_unavailable_date_holder .clearDate", function (params) {
$(this).parents('.default_picker,.time_picker,.date_picker').eq(-1).find('input').val('')
$(this).parents('.default_picker,.time_picker,.date_picker').eq(-1).find('input').trigger('change')
})
$(document).on("click","#special_unavailable_date_holder .deleteDate", function (params) {
$(this).parents('#special_unavailable_date_holder .temp_date_holder').eq(-1).remove();
})
2017-01-20 09:02:50 +00:00
</script>