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

377 lines
16 KiB
Plaintext

<%
hire_method = Admin::PropertyHiresHelper::HireMethod
hire_method.set_input_name('property')
%>
<style type="text/css">
.tab-panel > .tab-content{
display: none;
}
.tab-panel > .tab-content.active{
display: block;
}
.tab-panel{
display: flex;
flex-wrap: wrap;
}
</style>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% 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="#tag" data-toggle="tab"><%= t(:tags) %></a></li>
<li><a href="#imageupload" data-toggle="tab"><%= t(:image) %></a></li>
<li><a href="#unavailability" data-toggle="tab"><%= t('property_hire.unavailability')%></a></li>
<li><a href="#auto_send_email_set" data-toggle="tab"><%= t('property_hire.auto_send_email_set') %></a></li>
</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">
<%= f.label :can_be_hired, t("property_hire.can_be_hired"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :can_be_hired %>
</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>
<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>
<!-- 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 %>
<img src="http://www.placehold.it/50x50/EFEFEF/AAAAAA" />
<% 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>
</div>
<!-- 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>
<%= hire_method.show_set_field(@email_set[index1].id,@email_set[index1]['title'],'hire_email_sets',index1,'title','text_field',action_name != 'new') %>
</td>
</tr>
<tr>
<td>
<%= t('property_hire.email_content') %>
</td>
<td>
<div class="form-group">
<%= hire_method.show_set_field(@email_set[index1].id,@email_set[index1]['content'],'hire_email_sets',index1,'content','text_area',action_name != 'new') %>
</div>
<%= hidden_field_tag("property[hire_email_sets][#{index1}][field_name]",@email_set[index1]['field_name']) %>
<%= hidden_field_tag("property[hire_email_sets][#{index1}][property_id]",@property.id) %>
</td>
</tr>
</tbody>
</table>
</div>
<% end %>
</div>
</div>
<!-- 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>
<% if @property.new_record? %>
<div id="set_unavailibility_div" style="display: none;">
<% elsif @property.set_unavailibility %>
<div id="set_unavailibility_div">
<% else %>
<div id="set_unavailibility_div" style="display: none;">
<% end %>
<div class="control-group">
<%= f.label :start_time, t("property_hire.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.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>
<div class="control-group">
<label class="control-label muted">Weekdays</label>
<div class="controls">
<% weekdays = @property.weekdays rescue [] %>
<label for="sunday">
<input id="sunday" type="checkbox" name="property[weekdays][]" value="0" <%= weekdays.include?("0") ? "checked=checked" : "" %> /> Sunday
</label>
<label for="monday">
<input id="monday" type="checkbox" name="property[weekdays][]" value="1" <%= weekdays.include?("1") ? "checked=checked" : "" %> /> Monday
</label>
<label for="tuesday">
<input id="tuesday" type="checkbox" name="property[weekdays][]" value="2" <%= weekdays.include?("2") ? "checked=checked" : "" %> /> Tuesday
</label>
<label for="wednesday">
<input id="wednesday" type="checkbox" name="property[weekdays][]" value="3" <%= weekdays.include?("3") ? "checked=checked" : "" %> /> Wednesday
</label>
<label for="thursday">
<input id="thursday" type="checkbox" name="property[weekdays][]" value="4" <%= weekdays.include?("4") ? "checked=checked" : "" %> /> Thursday
</label>
<label for="friday">
<input id="friday" type="checkbox" name="property[weekdays][]" value="5" <%= weekdays.include?("5") ? "checked=checked" : "" %> /> Friday
</label>
<label for="saturday">
<input id="saturday" type="checkbox" name="property[weekdays][]" value="6" <%= weekdays.include?("6") ? "checked=checked" : "" %> /> Saturday
</label>
</div>
</div>
<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>
<div class="control-group">
<%= 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>
<% @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 do |f| %>
<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>
</div>
</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| %>
<%= f.text_area locale, class: "input-block-level", placeholder: t("property_hire.property_usage"), value: (@property.property_usage_translations[locale] rescue nil) %>
<% 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| %>
<%= f.text_area locale, class: "input-block-level", placeholder: t("property_hire.note"), value: (@property.note_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<% end %>
</div>
<!-- Form Actions -->
<div class="form-actions">
<% if params[:page] %>
<input type="hidden" name="page" value="<%= params[:page] %>" />
<% end %>
<%= hidden_field_tag("property[id]",@property.id) %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= link_to t('cancel'), admin_property_hires_path, :class=>"btn" %>
</div>
<script type="text/javascript">
$("#property_set_unavailibility").on("click",function(){
if($(this).is(":checked")){
$("#set_unavailibility_div").show();
}else{
$("#set_unavailibility_div").hide();
}
})
$("#property_property_location").on("change",function(){
if($(this).val() == "other_location"){
$("#other-location-div").show();
}else{
$("#other-location-div").hide();
}
})
</script>