Fix some important bugs.Add extra fields(can set enabled) to hire page.
This commit is contained in:
parent
9afb891362
commit
6f3333a857
|
@ -6,8 +6,7 @@ class Admin::PropertyHiresController < OrbitAdminController
|
|||
@filter_fields = filter_fields(@categories, @tags)
|
||||
@table_fields = ["property_hire.title", :category, "property_hire.location", "property_hire.available_for_hire"]
|
||||
|
||||
@properties = Property.where(:title.ne => "")
|
||||
.order_by(sort)
|
||||
@properties = Property.order_by(sort)
|
||||
.with_categories(filters("category"))
|
||||
.with_tags(filters("tag"))
|
||||
|
||||
|
@ -60,9 +59,9 @@ class Admin::PropertyHiresController < OrbitAdminController
|
|||
email = User.all.select{|v| v.is_admin? && v.user_name != 'rulingcom'}.collect{|v| v.member_profile.email} if email.length == 0
|
||||
Admin::PropertyHiresHelper::HireMethod.send_mail('edit',email,property.id,nil,nil,current_user.id)
|
||||
if params[:page]
|
||||
redirect_to admin_property_hires_path(:page => params[:page])
|
||||
redirect_to admin_property_hires_path(:page => params[:page],:locale => params[:locale])
|
||||
else
|
||||
redirect_to admin_property_hires_path
|
||||
redirect_to admin_property_hires_path(:locale => params[:locale])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ class PropertyHiresController < ApplicationController
|
|||
end
|
||||
{
|
||||
"title" => property.title,
|
||||
"image" => property.image.url,
|
||||
"image-thumb" => property.image.thumb.url,
|
||||
"image" => (property.image.url.blank? ? '" style="display: none;' : property.image.url),
|
||||
"image-thumb" => (property.image.thumb.url.blank? ? '" style="display: none;' : property.image.thumb.url),
|
||||
"url_to_show" => OrbitHelper.url_to_show(property.to_param),
|
||||
"location" => property.get_location_name,
|
||||
"actions" => actions
|
||||
|
@ -30,7 +30,7 @@ class PropertyHiresController < ApplicationController
|
|||
"column" => t("property_hire.title")
|
||||
},
|
||||
{
|
||||
"column" => t("property_hire.image")
|
||||
"column" => ""
|
||||
},
|
||||
{
|
||||
"column" => t("property_hire.location")
|
||||
|
|
|
@ -16,7 +16,15 @@ class PHire
|
|||
field :recurring, type: Boolean, :default => false
|
||||
field :recurring_end_date, type: DateTime
|
||||
field :recurring_interval
|
||||
|
||||
field :organization
|
||||
field :person_in_charge
|
||||
field :tel_of_person_in_charge
|
||||
field :department
|
||||
field :contact_person
|
||||
field :tel_of_contact_person
|
||||
field :mobile_phone_of_contact_person
|
||||
field :contact_person_Email
|
||||
field :contact_person_department
|
||||
belongs_to :property
|
||||
|
||||
def as_json(options = {})
|
||||
|
|
|
@ -30,7 +30,15 @@ class Property
|
|||
field :end_date, type: DateTime
|
||||
field :description, :localize => true
|
||||
field :unavailibility_note, :localize => true
|
||||
|
||||
field :organization
|
||||
field :person_in_charge
|
||||
field :tel_of_person_in_charge
|
||||
field :department
|
||||
field :contact_person
|
||||
field :tel_of_contact_person
|
||||
field :mobile_phone_of_contact_person
|
||||
field :contact_person_Email
|
||||
field :contact_person_department
|
||||
belongs_to :property_location
|
||||
has_many :p_hires
|
||||
has_many :hire_email_sets, :autosave => true, :dependent => :destroy, :inverse_of => :property
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
<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>
|
||||
<li><a href="#settings" data-toggle="tab"><%= t('property_hire.settings') %></a></li>
|
||||
</ul>
|
||||
<!-- Module -->
|
||||
<div class="tab-content module-area">
|
||||
|
@ -291,7 +292,7 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<%= f.fields_for :unavailibility_note do |f| %>
|
||||
<%= f.fields_for :unavailibility_note_translations 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">
|
||||
|
@ -302,6 +303,28 @@
|
|||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="settings">
|
||||
<% fields_name = ["organization" ,"person_in_charge" , "tel_of_person_in_charge" , "department" , "contact_person" , "tel_of_contact_person" , "mobile_phone_of_contact_person" , "contact_person_Email" , "contact_person_department"] %>
|
||||
<% fields_name.each do |field_name| %>
|
||||
<div class="control-group">
|
||||
<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}][enable]", "0" %>
|
||||
<%= f.check_box_tag "property[#{field_name}][enable]", "1" , (@property[field_name]["enable"] == "1" rescue false) %>
|
||||
Enable
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls required">
|
||||
<label class="radio inline"><%= t("property_hire.required") %></label>
|
||||
<%= f.fields_for field_name do |sub_f|%>
|
||||
<label class="radio inline"><%= sub_f.radio_button "required", "true", checked: ((@property[field_name]["required"] rescue "false") == "true") %><%= t(:yes_) %></label>
|
||||
<label class="radio inline"><%= sub_f.radio_button "required", "false", checked: ((@property[field_name]["required"] rescue "false") == "false") %><%= t(:no_) %></label>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Language Tabs -->
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
<div class="bottomnav clearfix">
|
||||
<%= content_tag(:div, paginate(@locations), class: "pagination pagination-centered") %>
|
||||
<div class="pull-right">
|
||||
<%= link_to t(:add), add_location_admin_property_hires_path, :class => "btn btn-primary", :data => {"toggle" => "modal", "target" => "#location-modal"} %>
|
||||
<%= link_to t(:add), add_location_admin_property_hires_path, :id=>'create_new_location', :class => "btn btn-primary", :data => {"toggle" => "modal", "target" => "#location-modal"} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -72,4 +72,10 @@
|
|||
$("#edit-location-btn").on("click",function(){
|
||||
$("#edit-location-modal form").submit();
|
||||
})
|
||||
$("#create_new_location").on("click",function(){
|
||||
var url = $(this).attr("href");
|
||||
$.get(url).done(function(data){
|
||||
$("#location-modal .modal-body").html(data);
|
||||
})
|
||||
})
|
||||
</script>
|
|
@ -36,6 +36,15 @@
|
|||
<td><%= t("property_hire.note_for_hire") %></td>
|
||||
<td><%= @booking.note_for_hire %></td>
|
||||
</tr>
|
||||
<% fields_name = ["organization" ,"person_in_charge" , "tel_of_person_in_charge" , "department" , "contact_person" , "tel_of_contact_person" , "mobile_phone_of_contact_person" , "contact_person_Email" , "contact_person_department"] %>
|
||||
<% fields_name.each do |field_name| %>
|
||||
<% if(@booking.property[field_name]["enable"] == "1" rescue false) %>
|
||||
<tr>
|
||||
<td><%= t("property_hire.#{field_name}") %></td>
|
||||
<td><%= @booking[field_name].to_s %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<tr>
|
||||
<td><%= t("property_hire.passed") %></td>
|
||||
<td>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<% email_set = Property.where(id: @data['property_id']).first.hire_email_sets.select{|v| v.field_name == 'p_hire'} %>
|
||||
<% property = Property.where(id: @data['property_id']).first%>
|
||||
<% email_set = property.hire_email_sets.select{|v| v.field_name == 'p_hire'} %>
|
||||
<% if email_set.length != 0 %>
|
||||
<% if !(email_set[0].content.nil?) %>
|
||||
<%= email_set[0].content[@data['locale']].html_safe %>
|
||||
|
@ -8,7 +9,7 @@
|
|||
<% end %>
|
||||
<br>
|
||||
<% I18n.with_locale(@data['locale']) do %>
|
||||
<h3><%= Property.where(id: @data['property_id']).first.title rescue nil %></h3>
|
||||
<h3><%= property.title rescue nil %></h3>
|
||||
<% if !@data['hire_id'].nil? %>
|
||||
<% hire = PHire.where(id: @data['hire_id']).first %>
|
||||
<table>
|
||||
|
@ -19,7 +20,11 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% ['hiring_person_name','hiring_person_email','start_time','end_time','recurring','recurring_interval','recurring_end_date','passed','reason_for_hire','note_for_hire'].each do |k| %>
|
||||
<% extra_fields_name = ["organization" ,"person_in_charge" , "tel_of_person_in_charge" , "department" , "contact_person" , "tel_of_contact_person" , "mobile_phone_of_contact_person" , "contact_person_Email" , "contact_person_department"] %>
|
||||
<% keys = ['hiring_person_name','hiring_person_email','start_time','end_time','recurring','recurring_interval','recurring_end_date','passed','reason_for_hire','note_for_hire'] %>
|
||||
<% used_extra_fields_name = extra_fields_name.select{|field_name| (property[field_name]["enable"] == "1" rescue false) } %>
|
||||
<% keys.concat( used_extra_fields_name ) %>
|
||||
<% keys.each do |k| %>
|
||||
<% v = hire.send(k) %>
|
||||
<% if !v.nil? && !(k.include?('recurring') && hire.recurring != true)%>
|
||||
<tr>
|
||||
|
|
|
@ -28,13 +28,13 @@
|
|||
<% end %>
|
||||
<%= form_for hire, :url => "/xhr/property_hires/make_booking", html: { class: "form-horizontal" } do |f| %>
|
||||
<div class="form-group">
|
||||
<%= f.label :start_time, t("property_hire.start_time"), :class => "col-sm-2 control-label" %>
|
||||
<%= f.label :start_time, "*"+t("property_hire.start_time"), :class => "col-sm-2 control-label" %>
|
||||
<div class="col-sm-10">
|
||||
<%= f.datetime_picker :start_time, :no_label => true, :new_record => hire.new_record?, :data=>{"picker-type" => "range", "range" => "start", "fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.label :end_time, t("property_hire.end_time"), :class => "col-sm-2 control-label" %>
|
||||
<%= f.label :end_time, "*"+t("property_hire.end_time"), :class => "col-sm-2 control-label" %>
|
||||
<div class="col-sm-10">
|
||||
<%= f.datetime_picker :end_time, :no_label => true, :new_record => hire.new_record?, :data=>{"picker-type" => "range", "range" => "end", "fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
||||
</div>
|
||||
|
@ -55,7 +55,7 @@
|
|||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.label :recurring_end_date, t("property_hire.recurring_end_date"), :class => "col-sm-2 control-label" %>
|
||||
<%= f.label :recurring_end_date, "*"+t("property_hire.recurring_end_date"), :class => "col-sm-2 control-label" %>
|
||||
<div class="col-sm-10">
|
||||
<%= f.datetime_picker :recurring_end_date, :no_label => true, :new_record => hire.new_record?, :data=>{"fv-validation" => "requiredifrecurring;", "fv-messages" => "Cannot be empty;"} %>
|
||||
</div>
|
||||
|
@ -70,7 +70,7 @@
|
|||
</div>
|
||||
<% if property.set_unavailibility %>
|
||||
<div class="col-sm-offset-2 col-sm-5">
|
||||
<b>Unavailibility Schedule</b>
|
||||
<b><%= t("property_hire.Unavailibility_Schedule") %></b>
|
||||
<div>
|
||||
This property is unavaliable <%= !property.start_date.nil? ? " from " + property.start_date.strftime("%Y-%m-%d") : "" %> <%= !property.end_date.nil? ? " to " + property.end_date.strftime("%Y-%m-%d") : "" %> every
|
||||
<% property.weekdays.each_with_index do |d,i| %>
|
||||
|
@ -94,26 +94,26 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.label :hiring_person_email, t("property_hire.hiring_person_email"), :class => "col-sm-2 control-label" %>
|
||||
<%= f.label :hiring_person_email, "*"+t("property_hire.hiring_person_email"), :class => "col-sm-2 control-label" %>
|
||||
<div class="col-sm-5">
|
||||
<%= f.text_field :hiring_person_email, :class => "form-control", :value => current_user.member_profile.email, :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.label :hiring_person_number, t("property_hire.hiring_person_number"), :class => "col-sm-2 control-label" %>
|
||||
<%= f.label :hiring_person_number, "*"+t("property_hire.hiring_person_number"), :class => "col-sm-2 control-label" %>
|
||||
<div class="col-sm-5">
|
||||
<%= f.text_field :hiring_person_number, :class => "form-control", :value => current_user.member_profile.mobile_no, :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.label :hiring_person_name, t("property_hire.hiring_person_name"), :class => "col-sm-2 control-label" %>
|
||||
<%= f.label :hiring_person_name, "*"+t("property_hire.hiring_person_name"), :class => "col-sm-2 control-label" %>
|
||||
<div class="col-sm-5">
|
||||
<%= f.text_field :hiring_person_name, :class => "form-control", :value => (current_user.name rescue ""), :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
||||
<%= f.hidden_field :hiring_person_id, :value => (current_user.member_profile.id.to_s rescue "") %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.label :reason_for_hire, t("property_hire.reason_for_hire"), :class => "col-sm-2 control-label" %>
|
||||
<%= f.label :reason_for_hire, "*"+t("property_hire.reason_for_hire"), :class => "col-sm-2 control-label" %>
|
||||
<div class="col-sm-5">
|
||||
<%= f.text_field :reason_for_hire, :class => "form-control", :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
||||
</div>
|
||||
|
@ -124,6 +124,22 @@
|
|||
<%= f.text_area :note_for_hire, :class => "form-control" %>
|
||||
</div>
|
||||
</div>
|
||||
<% fields_name = ["organization" ,"person_in_charge" , "tel_of_person_in_charge" , "department" , "contact_person" , "tel_of_contact_person" , "mobile_phone_of_contact_person" , "contact_person_Email" , "contact_person_department"] %>
|
||||
<% fields_name.each do |field_name| %>
|
||||
<% if(property[field_name]["enable"] == "1" rescue false) %>
|
||||
<% required = (property[field_name]["required"] == "true" rescue false) %>
|
||||
<div class="form-group">
|
||||
<%= f.label field_name, (required ? "*" : "") + t("property_hire.#{field_name}"), :class => "col-sm-2 control-label" %>
|
||||
<div class="col-sm-5">
|
||||
<% if required %>
|
||||
<%= f.text_field field_name, :class => "form-control", :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
||||
<% else %>
|
||||
<%= f.text_field field_name, :class => "form-control" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<%= f.submit t("property_hire.save"), :class => "btn btn-primary" %>
|
||||
|
|
|
@ -68,3 +68,14 @@ en:
|
|||
wait_for_permit: 'Wait for permit'
|
||||
select_interval: Select interval
|
||||
check_availibility: Check Availibility
|
||||
Unavailibility_Schedule: Unavailibility Schedule
|
||||
required: Required
|
||||
organization: Organization
|
||||
person_in_charge: Person in charge
|
||||
tel_of_person_in_charge: Tel. of person in charge
|
||||
department: Department
|
||||
contact_person: Contact person
|
||||
tel_of_contact_person: Tel. of contact person
|
||||
mobile_phone_of_contact_person: Mobile phone of contact person
|
||||
contact_person_Email: Contact person Email
|
||||
contact_person_department: Contact person department
|
|
@ -1,10 +1,10 @@
|
|||
zh_tw:
|
||||
property_hire:
|
||||
editor: 編輯者
|
||||
email_p_hire_success: 租借成功
|
||||
email_p_hire_success: 借用成功
|
||||
email_edit_success: '租借模組:編輯成功'
|
||||
email_delete_success: '租借模組:刪除成功'
|
||||
email_p_hire_content: 租借成功
|
||||
email_p_hire_content: 借用成功
|
||||
email_edit_content: '租借模組:編輯成功'
|
||||
email_delete_content: '租借模組:刪除成功'
|
||||
edit: 編輯
|
||||
|
@ -12,26 +12,26 @@ zh_tw:
|
|||
auto_send_email_set: 自動發信設定
|
||||
email_title: 主旨
|
||||
email_content: 內文
|
||||
recurring: 週期性租借
|
||||
recurring_interval: 租借週期
|
||||
recurring: 週期性借用
|
||||
recurring_interval: 借用週期
|
||||
recurring_interval_types:
|
||||
month: 月
|
||||
week: 周
|
||||
recurring_end_date: 週期結束時間
|
||||
save: Save
|
||||
my_bookings: My Bookings
|
||||
settings: Settings
|
||||
property_hire: 租借管理
|
||||
settings: 設定
|
||||
property_hire: 借用管理
|
||||
manage_locations: Manage Locations
|
||||
location: Location
|
||||
location: 位置
|
||||
auto_approve: Auto approve
|
||||
property_count: Property Count
|
||||
edit_location: Edit Location
|
||||
add_location: Add Location
|
||||
unavailability: Unavailability
|
||||
unavailability: 不可借用
|
||||
title: 名稱
|
||||
select_interval: 選則週期
|
||||
check_availibility: 檢查是否可租借
|
||||
check_availibility: 檢查是否可借用
|
||||
property_usage: 用途
|
||||
note: 說明
|
||||
property_number: 編號
|
||||
|
@ -42,9 +42,9 @@ zh_tw:
|
|||
owner_email: 管理人Email
|
||||
owner_phone: 管理人聯絡電話
|
||||
price: Price
|
||||
set_unavailibility: 設定為不可租借
|
||||
start_time: 租借開始時間
|
||||
end_time: 租借結束時間
|
||||
set_unavailibility: 設定為不可借用
|
||||
start_time: 借用開始時間
|
||||
end_time: 借用結束時間
|
||||
weekdays: Weekdays
|
||||
start_date: From Date
|
||||
end_date: To Date
|
||||
|
@ -55,16 +55,27 @@ zh_tw:
|
|||
hire: 線上借用
|
||||
view_calendar: 查詢目前借用狀況
|
||||
image: Property Image
|
||||
actions: Actions
|
||||
start_time: 租借開始時間
|
||||
end_time: 租借結束時間
|
||||
hiring_person_email: 租借人電子信箱
|
||||
hiring_person_number: 租借人聯絡電話
|
||||
hiring_person_name: 租借人姓名
|
||||
reason_for_hire: 租借原因
|
||||
actions: 操作
|
||||
start_time: 借用開始時間
|
||||
end_time: 借用結束時間
|
||||
hiring_person_email: 借用人電子信箱
|
||||
hiring_person_number: 借用人聯絡電話
|
||||
hiring_person_name: 借用人姓名
|
||||
reason_for_hire: 使用用途
|
||||
note_for_hire: 備註
|
||||
period: Period
|
||||
passed: 租借允許
|
||||
passed: 借用允許
|
||||
'yes': 是
|
||||
'no': 否
|
||||
wait_for_permit: 等待授權
|
||||
Unavailibility_Schedule: 不提供借用時間
|
||||
required: 必填
|
||||
organization: 借用單位
|
||||
person_in_charge: 單位負責人
|
||||
tel_of_person_in_charge: 負責人聯絡電話
|
||||
department: 服務單位
|
||||
contact_person: 聯絡人
|
||||
tel_of_contact_person: 聯絡人聯絡電話
|
||||
mobile_phone_of_contact_person: 聯絡人行動電話
|
||||
contact_person_Email: 聯絡Email
|
||||
contact_person_department: 聯絡人服務單位
|
Loading…
Reference in New Issue