Compare commits

..

No commits in common. "master" and "revert-e1e90a83" have entirely different histories.

19 changed files with 154 additions and 628 deletions

View File

@ -77,7 +77,7 @@ var Calendar = function(dom,property_id){
c.modeBtns.each(function(){
if ($(this).data("mode") == view)
$(this).addClass("active");
});
})
if(view != "agenda"){
if(c.currentView == "agenda"){
// $("#sec1").addClass("span3").removeClass("span7");
@ -97,23 +97,23 @@ var Calendar = function(dom,property_id){
c.calendar.fullCalendar("refetchEvents");
loadeventsonviewchange = false;
}
};
}
if(c.currentView == "agenda"){toggleViews("agenda");loadeventsonviewchange = true;}
};
}
this.renderEvent = function(eventStick){
if(eventStick.recurring === true)
if(eventStick.recurring == true)
c.calendar.fullCalendar("refetchEvents");
else
c.calendar.fullCalendar("renderEvent",eventStick);
};
}
$(document).ready(function() {
c.initialize();
});
};
}
var EventDialog = function(calendar,event){
_t = this;
@ -148,12 +148,13 @@ var EventDialog = function(calendar,event){
}
event_quick_view = $('<div class="calendar-modal" style="display:none;"></div>');
template = '<div class="modal-content">' +
'<div class="modal-header">' +
'<div class="modal-header">' +
'<button type="button" class="close event-close-btn" data-dismiss="modal" aria-hidden="true">&times;</button>' +
'<h3>' + _event.title + '</h3>' +
'</div>' +
'<div class="modal-body">' +
'<div class="event_summary">' + time_string + '</br>' + _event.hiring_person_name + '</div>' + _event.note +
'<div class="event_summary">' + time_string + '<br>' + _event.hiring_person_name + '</div>'
_event.note +
'</div>' +
'<div class="modal-footer" />' +
'</div>';
@ -563,4 +564,34 @@ var AgendaView = function(calendar){
renderMonth();
}
}
}

View File

@ -1,12 +1,13 @@
class Admin::PropertyHiresController < OrbitAdminController
include Admin::PropertyHiresHelper
def index
@tags = @module_app.tags
@categories = @module_app.categories.enabled
@filter_fields = filter_fields(@categories, @tags)
@table_fields = ["property_hire.title", :category, "property_hire.location", "property_hire.available_for_hire"]
@properties = Property.order_by(sort)
@properties = Property.where(:title.ne => "")
.order_by(sort)
.with_categories(filters("category"))
.with_tags(filters("tag"))
@ -14,20 +15,18 @@ class Admin::PropertyHiresController < OrbitAdminController
end
def my_bookings
@table_fields = ["property_hire.title","property_hire.hiring_person_name", "property_hire.reason_for_hire", "property_hire.hiring_person_number", "property_hire.period", "property_hire.passed", :actions]
@table_fields = ["property_hire.hiring_person_name", "property_hire.reason_for_hire", "property_hire.hiring_person_number", "property_hire.period", "property_hire.passed", :actions]
@bookings = PHire.where(:hiring_person_id => current_user.member_profile.id.to_s).desc(:created_at).page(params[:page]).per(10)
end
def new
@property = Property.new
create_set (false)
@locations = PropertyLocation.all.desc(:created_at).collect{|loc| [loc.title, loc.id.to_s]}
@locations << ["Other", "other_location"]
end
def edit
@property = Property.where(:uid => params[:id].split("-").last).first rescue nil
create_set (true)
@locations = PropertyLocation.all.desc(:created_at).collect{|loc| [loc.title, loc.id.to_s]}
@locations << ["Other", "other_location"]
end
@ -40,9 +39,6 @@ class Admin::PropertyHiresController < OrbitAdminController
def destroy
property = Property.find(params[:id]) rescue nil
email = Array(MemberProfile.find(property.owners)).collect{|v| v.email} rescue []
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('delete',email,property.id,nil,nil,current_user.id)
property.destroy if !property.nil?
if params[:page]
redirect_to admin_property_hires_path(:page => params[:page])
@ -55,18 +51,16 @@ class Admin::PropertyHiresController < OrbitAdminController
property = Property.where(:uid => params[:id].split("-").last).first rescue nil
redirect_to admin_property_hires_path and return if property.nil?
property.update_attributes(property_params)
email = Array(MemberProfile.find(property.owners)).collect{|v| v.email} rescue []
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],:locale => params[:locale])
redirect_to admin_property_hires_path(:page => params[:page])
else
redirect_to admin_property_hires_path(:locale => params[:locale])
redirect_to admin_property_hires_path
end
end
def create
if Property.create(property_params)
property = Property.new(property_params)
if property.save
redirect_to admin_property_hires_path
end
end
@ -184,28 +178,5 @@ class Admin::PropertyHiresController < OrbitAdminController
prop.delete(:property_location) if prop[:property_location] == "other"
prop
end
def create_set (save_flag)
@email_set = []
['p_hire','edit','delete'].each do |field_name|
email_set = @property.hire_email_sets.select{|v| v.field_name==field_name}
if email_set.length==0
title = Hash.new
content = Hash.new
I18n.available_locales.each do |locale|
I18n.with_locale(locale) do
title[locale] = t("property_hire.email_#{field_name}_success")
content[locale] = t("property_hire.email_#{field_name}_content")
end
end
if save_flag
email_set = @property.hire_email_sets.create(field_name:field_name,title:title,content:content)
else
email_set = @property.hire_email_sets.new(field_name:field_name,title:title,content:content)
end
else
email_set = email_set[0]
end
@email_set << email_set
end
end
end

View File

@ -18,8 +18,8 @@ class PropertyHiresController < ApplicationController
end
{
"title" => property.title,
"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),
"image" => property.image.url,
"image-thumb" => 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" => ""
"column" => t("property_hire.image")
},
{
"column" => t("property_hire.location")
@ -165,12 +165,6 @@ class PropertyHiresController < ApplicationController
hire = PHire.new(booking_p)
hire.passed = true if PropertyHireSetting.auto_approve_enabled?
hire.save
if !property.nil?
email = Array(MemberProfile.find(property.owners)).collect{|v| v.email} rescue []
email = User.all.select{|v| v.is_admin? && v.user_name != 'rulingcom'}.collect{|v| v.member_profile.email} if email.length == 0
email << hire.hiring_person_email
Admin::PropertyHiresHelper::HireMethod.send_mail('p_hire',email,property.id,nil,hire.id)
end
redirect_to params[:url]
else
session["hire-save-msg"] = data["msg"]

View File

@ -3,21 +3,9 @@ module Admin::PropertyHiresHelper
def check_for_availability(stime, etime, pid, interval=nil, recurring_end_date=nil)
property = Property.find(pid)
return {"success" => false, "msg" => "Values are not ok."} if property.nil? || stime.blank? || etime.blank?
if !stime.blank?
stime = DateTime.parse(stime + Time.zone.to_s) rescue nil
else
stime = nil
end
if !etime.blank?
etime = DateTime.parse(etime + Time.zone.to_s) rescue nil
else
etime = nil
end
if !recurring_end_date.blank?
recurring_end_date = DateTime.parse(recurring_end_date + Time.zone.to_s) rescue nil
else
recurring_end_date = nil
end
stime = DateTime.parse(stime + Time.zone.to_s) rescue nil
etime = DateTime.parse(etime + Time.zone.to_s) rescue nil
recurring_end_date = DateTime.parse(recurring_end_date + Time.zone.to_s) rescue nil
data = {}
return {"success" => false, "msg" => "Starting time cannot be greater than ending time."} if stime > etime
if property.is_available_for_hire?(stime, etime)
@ -31,78 +19,5 @@ module Admin::PropertyHiresHelper
end
return data
end
module HireMethod
extend ActionView::Helpers::UrlHelper
extend ActionView::Helpers::TagHelper
extend ActionView::Context
extend ActionView::Helpers::FormTagHelper
def self.set_input_name(input_name)
@input_name = input_name
end
def self.get_input_name
@input_name
end
def self.create_lang_panel(field)
tmp2 = content_tag(:div,:class => 'btn-group', :data=>{:toggle=>"buttons-radio"}) do
I18n.available_locales.collect do |key|
link_entry_ary = ["##{field}","_#{key}"]
link_entry = link_entry_ary.join
link_to(I18n.t(key),link_entry,:data=>{:toggle=>"tab"},:class=>"btn #{(key == I18n.locale ? "active" : nil)}",:for=>key)
end.join.html_safe
end
end
def self.multiple_lang_tag(index1,type_of_tag,field,value=nil,custom_options={},combine_element='',exteral_options={},panel_in_first=false)
content_tag(:div,{:class => "tab-panel"}.merge(exteral_options)) do
all_field = (get_input_name + "[#{index1}][#{field}][parant]").gsub(/\[/,'_').gsub(/\]/,'')
tmp = I18n.available_locales.collect do |locale|
active_flag = ((locale == I18n.locale) ? ' active' : '')
content_tag(:div,:class => "tab-content#{active_flag}",:id=>"#{all_field}_#{locale}") do
value_locale = ((value[locale] || value[locale.to_s]) rescue nil)
self.__send__("#{type_of_tag}_tag","#{get_input_name}[#{index1}][#{field}][#{locale}]",value_locale,custom_options)
end
end.join
if panel_in_first
tmp = create_lang_panel(all_field).html_safe + tmp.html_safe + combine_element
else
tmp = tmp.html_safe + create_lang_panel(all_field).html_safe + combine_element
end
tmp
end
end
def self.show_set_field(id,field_sets,key_field,key_index,field,markup='text_field',with_id=true)
end_block = with_id ? hidden_field_tag("property[#{key_field}][#{key_index}]"+"[id]",id) : ''
custom_options = markup == 'text_area' ? {:class => 'ckeditor'} : {}
a = multiple_lang_tag(key_field,markup,"#{key_index}][#{field}",field_sets,custom_options,end_block,{},markup=='text_area')
a.html_safe
end
def self.send_mail(field_name,email,property_id,send_date=nil,hire_id=nil,user_id=nil)
property = Property.where(id: property_id).first
if !property.nil?
email_set = property.hire_email_sets.select{|v| v.field_name == field_name}
title = property['title'].collect{|k,v| v}.select{|v| !v.to_s.empty?}.join('/')
note = property['note'].collect{|k,v| v}.select{|v| !v.to_s.empty?}.join('/')
content = "title:#{title}<br>note:#{note}"
if email_set.length==0
mail = Email.create(mail_to: Array(email),
module_app_key:"property_hire",
template:"email/#{field_name}_email.html.erb",
mail_sentdate: send_date || Time.current,
mail_subject: I18n.t("property_hire.email_#{field_name}_success"),
template_data:{'property_id'=>property_id,'content'=>content,'locale'=>I18n.locale.to_s,'hire_id'=>hire_id,'user_id'=>user_id})
elsif !(email_set[0].disabled)
mail = Email.create(mail_to: Array(email),
module_app_key:"property_hire",
template:"email/#{field_name}_email.html.erb",
mail_sentdate: send_date || Time.current,
mail_subject: email_set[0].title[I18n.locale],
template_data:{'property_id'=>property_id,'email_set_content'=>email_set[0].content.to_yaml,'content'=>content,'locale'=>I18n.locale.to_s,'hire_id'=>hire_id,'user_id'=>user_id})
end
begin
mail.deliver
rescue => e
puts ["email can't deliver",e]
end
end
end
end
end

View File

@ -1,10 +0,0 @@
class HireEmailSet
include Mongoid::Document
include Mongoid::Timestamps
field :field_name, type: String
field :title
field :content
field :disabled, type: Boolean, default: false
belongs_to :property
end

View File

@ -16,15 +16,7 @@ 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 = {})
@ -72,7 +64,7 @@ class PHire
@end_date += 7
end
if @start_date < re.recurring_end_date
@recurring << {:id => re.id.to_s, :hiring_person_name => re.hirer_name ,:title=>re.reason_for_hire, :note=>re.reason_for_hire, :start=>@start_date, :end => @end_date, :allDay => false, :recurring => re.recurring, :color => "#FC4040"}
@recurring << {:id => re.id.to_s, :title=>re.reason_for_hire, :note=>re.reason_for_hire, :start=>@start_date, :end => @end_date, :allDay => false, :recurring => re.recurring, :color => "#FC4040"}
end
end
when "month"

View File

@ -30,19 +30,10 @@ 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
accepts_nested_attributes_for :hire_email_sets, :allow_destroy => true
WEEKDAYS = [
"Sunday",
"Monday",
@ -91,72 +82,45 @@ class Property
end
def is_already_hired?(stime, etime, interval, recurring_end_date)
phires = self.p_hires
bookings_count = phires.where(:start_time.lte => stime,:end_time.gte => stime,:recurring => false).count
+ phires.where(:start_time.gte => stime,:end_time.lte => etime,:recurring => false).count
+phires.where(:start_time.lte => etime,:end_time.gte => etime,:recurring => false).count
bookings = self.p_hires.where(:end_time.gte => stime, :recurring => false)
available = true
if bookings_count != 0
available = false
bookings.each do |booking|
common_time = (booking.start_time..booking.end_time) & (stime..etime)
if !common_time.nil?
available = false
break
end
end
if available
bookings = phires.where(:recurring_end_date.gte => stime, :recurring => true) + phires.where(:recurring => false,:recurring_end_date => nil) + phires.where(:recurring => false,:recurring_end_date.gte => stime)
case interval
when 'week'
d_step = 1.week
when 'month'
d_step = 1.month
when "week"
stepu = 1.week
when "month"
stepu = 1.month
else
d_step = 0
stepu = 0
end
bookings = self.p_hires.where(:recurring_end_date.gte => stime, :recurring => true)
bookings.each do |booking|
stime_tp = stime
etime_tp = etime
b_interval = booking.recurring_interval
if (b_interval == 'month' || b_interval == 'week') && booking.recurring_end_date.nil?
b_interval = nil
end
while true
if b_interval == 'month'
diff_month = booking.end_time.month - booking.start_time.month
diff_month = diff_month + 12 if diff_month < 0
e_month = stime_tp.month + diff_month
e_year = stime_tp.year + (booking.end_time.year-booking.start_time.year)
e_month = e_month - 12 if e_month >12
b_sdata = Time.local(stime_tp.year,stime_tp.month,booking.start_time.day,booking.start_time.hour,booking.start_time.minute).to_datetime
b_edata = Time.local(e_year,e_month,booking.end_time.day,booking.end_time.hour,booking.end_time.minute).to_datetime
elsif b_interval == 'week'
diff_day = booking.end_time - booking.start_time
if (booking.end_time.wday <= booking.start_time.wday && diff_day>1) || diff_day > 7
over_one_week = true
end
b_sdata_tp = stime_tp - stime_tp.wday.day + booking.start_time.wday.day
b_sdata = Time.local(b_sdata_tp.year,b_sdata_tp.month,b_sdata_tp.day,booking.start_time.hour,booking.start_time.minute).to_datetime
if over_one_week && etime_tp.wday <= booking.start_time.wday
b_sdata = b_sdata - 7.day
end
now_diff_day = etime_tp - stime_tp
if (etime_tp.wday <= stime_tp.wday && now_diff_day>1) || now_diff_day > 7
b_sdata = b_sdata + 7.day
end
b_edata_tp = b_sdata + (booking.end_time - booking.start_time).to_i.day
b_edata = Time.local(b_edata_tp.year,b_edata_tp.month,b_edata_tp.day,booking.end_time.hour,booking.end_time.minute).to_datetime
booking.time_iterate do |st,et|
tst = stime
tet = etime
if stepu != 0
begin
common_time = (tst..tet) & (st..et)
available = false if !common_time.nil?
tet += stepu
break if !available
break if tst > st
end while (tst += stepu) <= recurring_end_date
else
b_sdata = booking.start_time
b_edata = booking.end_time
common_time = (tst..tet) & (st..et)
available = false if !common_time.nil?
break if !available
end
sdata = stime_tp
edata = etime_tp
if etime_tp > booking.start_time
if (sdata <= b_sdata && edata >= b_sdata) || (sdata >= b_sdata && edata <= b_edata) || (sdata <= b_edata && edata >= b_edata)
available = false
end
end
stime_tp = stime_tp + d_step
etime_tp = etime_tp + d_step
break if recurring_end_date.blank? || d_step==0 || recurring_end_date < stime_tp
break if !available
end
break if available == false
break if !available
end
end
return available
@ -168,4 +132,12 @@ class Property
end while (start_time += step) <= end_time
end
end
end

View File

@ -5,6 +5,6 @@ class PropertyHireSetting
field :auto_approve, type: Boolean, :default => false
def self.auto_approve_enabled?
self.first.auto_approve rescue false
self.first.auto_approve
end
end

View File

@ -1,19 +1,3 @@
<%
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" %>
@ -36,9 +20,7 @@
<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>
<li><a href="#settings" data-toggle="tab"><%= t('property_hire.settings') %></a></li>
<li><a href="#unavailability" data-toggle="tab"><%= t('property_hire.unavailability')%></a></li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
@ -155,66 +137,7 @@
</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">
@ -275,7 +198,7 @@
<%= 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">
<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" %>
@ -292,7 +215,7 @@
<% end %>
<% end %>
<% @site_in_use_locales.each do |locale| %>
<%= f.fields_for :unavailibility_note_translations do |f| %>
<%= 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">
@ -303,29 +226,6 @@
<% 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 -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
@ -368,12 +268,12 @@
</div>
<% end %>
</div>
</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>

View File

@ -23,7 +23,7 @@
<% end %>
</td>
<td>
<%= property.category.title rescue nil %>
<%= property.category.title %>
</td>
<td>
<%= property.get_location_name %>

View File

@ -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, :id=>'create_new_location', :class => "btn btn-primary", :data => {"toggle" => "modal", "target" => "#location-modal"} %>
<%= link_to t(:add), add_location_admin_property_hires_path, :class => "btn btn-primary", :data => {"toggle" => "modal", "target" => "#location-modal"} %>
</div>
</div>
@ -72,10 +72,4 @@
$("#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>

View File

@ -10,9 +10,6 @@
<tbody>
<% @bookings.each do |p_hire| %>
<tr>
<td>
<%= p_hire.property.title rescue nil %>
</td>
<td>
<%= p_hire.hirer_name %>
</td>

View File

@ -36,15 +36,6 @@
<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>

View File

@ -1,49 +0,0 @@
<% if !@data['email_set_content'].nil? %>
<% email_set_content = YAML.load(@data['email_set_content'])
now_locale = @data['locale'] %>
<%= email_set_content[now_locale].html_safe rescue nil %>
<% end %>
<br>
<%= @data['content'].html_safe %>
<% property = Property.where(id: @data['property_id']).first %>
<% if !property.nil? %>
<h3><%= property['title'].collect{|k,v| v}.uniq.join('/') rescue nil %></h3>
<% I18n.with_locale(@data['locale']) do %>
<table>
<thead>
<tr>
<td></td>
<td></td>
</tr>
</thead>
<tbody>
<% ['editor','property_usage','note','category','property_location','property_number','can_be_hired','purchase_date','owners','other_owner','owner_email','owner_phone','price'].each do |k| %>
<% v = property.send(k) rescue nil %>
<tr>
<td>
<%= k=='category' ? t('category') : t("property_hire.#{k}") %>:&nbsp;
</td>
<td>
<% if k == 'editor' %>
<%= User.find(user_id).name rescue nil %>
<% elsif ['purchase_date'].include?(k) %>
<%= v.strftime('%Y/%m/%d %H:%M') rescue nil %>
<% elsif ['property_usage','note'].include?(k) %>
<%= property[k].collect{|k,v| v}.uniq.join('/') rescue nil %>
<% elsif k=='owners' %>
<%= property.owner_profiles.collect{|v| v.name}.join(', ') %>
<% elsif ['category','property_location'].include?(k) %>
<%= v.title %>
<% elsif k == 'can_be_hired' %>
<%= v ? t('yes_') : t('no_') %>
<% else %>
<%= v %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% end %>

View File

@ -1,47 +0,0 @@
<% property = Property.where(id: @data['property_id']).first %>
<% email_set = property.hire_email_sets.select{|v| v.field_name == 'edit'} %>
<% 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_edit_success') %>
<% end %>
<h3><%= property['title'].collect{|k,v| v}.uniq.join('/') rescue nil %></h3>
<% I18n.with_locale(@data['locale']) do %>
<table>
<thead>
<tr>
<td></td>
<td></td>
</tr>
</thead>
<tbody>
<% ['editor','property_usage','note','category','property_location','property_number','can_be_hired','purchase_date','owners','other_owner','owner_email','owner_phone','price'].each do |k| %>
<% v = property.send(k) rescue nil %>
<tr>
<td>
<%= k=='category' ? t('category') : t("property_hire.#{k}") %>:&nbsp;
</td>
<td>
<% if k == 'editor' %>
<%= User.find(user_id).name rescue nil %>
<% elsif ['purchase_date'].include?(k) %>
<%= v.strftime('%Y/%m/%d %H:%M') rescue nil %>
<% elsif ['property_usage','note'].include?(k) %>
<%= property[k].collect{|k,v| v}.uniq.join('/') rescue nil %>
<% elsif k=='owners' %>
<%= property.owner_profiles.collect{|v| v.name}.join(', ') %>
<% elsif ['category','property_location'].include?(k) %>
<%= v.title %>
<% elsif k == 'can_be_hired' %>
<%= v ? t('yes_') : t('no_') %>
<% else %>
<%= v %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% end %>

View File

@ -1,53 +0,0 @@
<% 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 %>
<% end %>
<% else %>
<%= t('property_hire.email_p_hire_content') %>
<% end %>
<br>
<% 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 %>
<table>
<thead>
<tr>
<td></td>
<td></td>
</tr>
</thead>
<tbody>
<% 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>
<td>
<%= t("property_hire.#{k}") %>:&nbsp;
</td>
<td>
<% if ['start_time','end_time','recurring','recurring_interval','recurring_end_date','passed'].exclude?(k) %>
<%= v.to_s %>
<% 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 %>
<% end %>

View File

@ -28,34 +28,34 @@
<% 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_hires.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_hires.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>
</div>
<!-- ############# recurring ############# -->
<div class="form-group">
<%= f.label :recurring, t("property_hire.recurring"), :class => "col-sm-2 control-label" %>
<%= f.label :recurring, t("property_hires.recurring"), :class => "col-sm-2 control-label" %>
<div class="col-sm-1">
<%= f.check_box :recurring %>
</div>
</div>
<div id="recurring-block" <%= hire.recurring ? "" : "style=display:none;" %>>
<div class="form-group">
<%= f.label :recurring_interval, t("property_hire.recurring_interval"), :class => "col-sm-2 control-label" %>
<%= f.label :recurring_interval, t("property_hires.recurring_interval"), :class => "col-sm-2 control-label" %>
<div class="col-sm-1">
<%= f.select :recurring_interval, PHire::INTERVALS.collect{|int| [t("property_hire.recurring_interval_types.#{int}"), int] }, {:prompt => t('property_hire.select_interval')}, {:data => {"fv-validation" => "requiredifrecurring;" , "fv-messages" => "Cannot be empty;"}} %>
<%= f.select :recurring_interval, PHire::INTERVALS.collect{|int| [t("property_hire.recurring_interval_types.#{int}"), int] }, {:prompt => "Select interval"}, {:data => {"fv-validation" => "requiredifrecurring;" , "fv-messages" => "Cannot be empty;"}} %>
</div>
</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_hires.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><%= t("property_hire.Unavailibility_Schedule") %></b>
<b>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| %>
@ -89,57 +89,41 @@
<div class="form-group">
<label for="" class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<a href="/xhr/property_hires/check_availability" id="check-avail-btn" class="btn btn-primary"><%= t('property_hire.check_availibility') %></a>
<a href="/xhr/property_hires/check_availability" id="check-avail-btn" class="btn btn-primary">Check Availibility</a>
<img style="display: none;" width="40" src="/assets/spin.gif" id="spinner" />
</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_hires.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_hires.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_hires.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_hires.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>
</div>
<div class="form-group">
<%= f.label :note_for_hire, t("property_hire.note_for_hire"), :class => "col-sm-2 control-label" %>
<%= f.label :note_for_hire, t("property_hires.note_for_hire"), :class => "col-sm-2 control-label" %>
<div class="col-sm-5">
<%= 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" %>

View File

@ -1,17 +1,5 @@
en:
property_hire:
editor: Editor
email_p_hire_success: Hire Success
email_edit_success: 'Property Hire Module:Edit Success'
email_delete_success: 'Property Hire Module:Delete Success'
email_p_hire_content: Hire Success
email_edit_content: 'Property Hire Module:Edit Success'
email_delete_content: 'Property Hire Module:Delete Success'
edit: Edit
delete: Delete
auto_send_email_set: Auto Send Email Setting
email_title: Email Title
email_content: Email Content
recurring: Recurring
recurring_interval: Recurring Interval
recurring_interval_types:
@ -19,7 +7,7 @@ en:
week: Week
recurring_end_date: Recurring End Date
save: Save
property_hire: Manage of hire
property_hire: Property
my_bookings: My Bookings
settings: Settings
auto_approve: Auto approve
@ -62,20 +50,4 @@ en:
reason_for_hire: Reason For Hire
note_for_hire: Note For Hire
period: Period
passed: Accepted
'yes': 'Yes'
'no': 'No'
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
passed: Accepted

View File

@ -1,81 +1,53 @@
zh_tw:
property_hire:
editor: 編輯者
email_p_hire_success: 借用成功
email_edit_success: '租借模組:編輯成功'
email_delete_success: '租借模組:刪除成功'
email_p_hire_content: 借用成功
email_edit_content: '租借模組:編輯成功'
email_delete_content: '租借模組:刪除成功'
edit: 編輯
delete: 刪除
auto_send_email_set: 自動發信設定
email_title: 主旨
email_content: 內文
recurring: 週期性借用
recurring_interval: 借用週期
recurring: Recurring
recurring_interval: Recurring Interval
recurring_interval_types:
month:
week:
recurring_end_date: 週期結束時間
month: Month
week: Week
recurring_end_date: Recurring End Date
save: Save
my_bookings: My Bookings
settings: 設定
property_hire: 借用管理
settings: Settings
property_hire: Property
manage_locations: Manage Locations
location: 位置
location: Location
auto_approve: Auto approve
property_count: Property Count
edit_location: Edit Location
add_location: Add Location
unavailability: 不可借用
title: 名稱
select_interval: 選則週期
check_availibility: 檢查是否可借用
property_usage: 用途
note: 說明
property_number: 編號
can_be_hired: 可供借用
unavailability: Unavailability
title: Property Title
property_usage: Usage for property
note: Note
property_number: Property Number
can_be_hired: Available for hire
purchase_date: Purchase Date
owners: 管理人
other_owner: 其他管理人
owner_email: 管理人Email
owner_phone: 管理人聯絡電話
owners: Owners
other_owner: Other Owner
owner_email: Owner Email
owner_phone: Owner Phone
price: Price
set_unavailibility: 設定為不可借用
start_time: 借用開始時間
end_time: 借用結束時間
set_unavailibility: Set Unavailability
start_time: Start Time
end_time: End Time
weekdays: Weekdays
start_date: From Date
end_date: To Date
description: Unavailability Description
unavailibility_note: Unavailability Note
property_location: Property Location
available_for_hire: 可供借用
hire: 線上借用
view_calendar: 查詢目前借用狀況
available_for_hire: Available for hire
hire: Hire
view_calendar: Calendar
image: Property Image
actions: 操作
start_time: 借用開始時間
end_time: 借用結束時間
hiring_person_email: 借用人電子信箱
hiring_person_number: 借用人聯絡電話
hiring_person_name: 借用人姓名
reason_for_hire: 使用用途
note_for_hire: 備註
actions: Actions
start_time: Hire Start Time
end_time: Hire End Time
hiring_person_email: Hiring Person Email
hiring_person_number: Hiring Person Number
hiring_person_name: Hiring Person
reason_for_hire: Reason For Hire
note_for_hire: Note For Hire
period: Period
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: 聯絡人服務單位
passed: Accepted