603 lines
29 KiB
Ruby
603 lines
29 KiB
Ruby
# encoding: utf-8
|
|
class Admin::VenueManagementsController < Admin::VenueAdminController
|
|
include ActionView::Helpers::FormOptionsHelper
|
|
#include ActionView::Helpers::FormTagHelper #don't include this helper,or you will got an error when using redirect_to and url_for
|
|
#include ActionView::Helpers::FormHelper #don't include this helper,or you will got an error when using redirect_to and url_for
|
|
include VenueAdminHelper
|
|
include ActionView::Context
|
|
require 'axlsx'
|
|
helper Admin::VenueManagementsFieldHelper
|
|
before_action ->(module_app = @app_title) { set_variables module_app }
|
|
before_action :set_venue_management, only: [:edit, :set_write_off, :venue_management_signup, :destroy, :venue_management_invitings, :venue_management_memorabilias, :venue_management_bills, :venue_management_contracts]
|
|
def initialize
|
|
super
|
|
@app_title = "venue_management"
|
|
end
|
|
|
|
def filter_fields(categories)
|
|
{
|
|
:category=>categories.map{|c| {:title=>(c.title.blank? ? " " : c.title), :id=>c.id}}
|
|
}
|
|
end
|
|
|
|
def index
|
|
@categories = @module_app.categories.enabled
|
|
@filter_fields = filter_fields(@categories)
|
|
@table_fields = [ :category,
|
|
'vm_inviting.type',
|
|
'venue_management.title',
|
|
"venue_management.contractor",
|
|
'venue_management.event_during',
|
|
'venue_management.signup_during',
|
|
'venue_management.inviting_history',
|
|
'venue_management.contract_history',
|
|
'venue_management.memorabilia',
|
|
'venue_management.bills',
|
|
'venue_management.export'
|
|
]
|
|
@filter_fields["vm_inviting.type"] = @module_app.tags.map{|t| {:title => t.name,:id => t.id} }
|
|
if !params[:sort].blank?
|
|
if params[:sort] == 'event_during'
|
|
sort = {:venue_management_start_date.to_sym=>params[:order]}
|
|
elsif params[:sort] == 'signup_during'
|
|
sort = {:signup_start_date.to_sym=>params[:order]}
|
|
else
|
|
sort = {params[:sort].to_sym=>params[:order]}
|
|
end
|
|
else
|
|
sort = {:signup_start_date=>"desc"}
|
|
end
|
|
filter_tags = params[:filters][:type].to_a rescue []
|
|
if filter_tags.empty?
|
|
@venue_managements = VenueManagementMain.all.order_by(sort).with_categories(filters("category"))
|
|
@venue_managements = search_data(@venue_managements,[:title]).page(params[:page]).per(10)
|
|
else
|
|
@venue_managements = VenueManagementMain.all.order_by(sort).with_categories(filters("category"))
|
|
@venue_managements = search_data(@venue_managements,[:title])
|
|
@venue_management_inviting_ids = @venue_managements.map{|v| v.venue_management_invitings.desc(:id).first.id rescue ""}
|
|
@venue_management_ids = VenueManagementInviting.where(:id.in=>@venue_management_inviting_ids).with_tags(filter_tags).pluck(:venue_management_main_id)
|
|
@venue_managements = VenueManagementMain.where(:id.in=>@venue_management_ids).page(params[:page]).per(10)
|
|
end
|
|
|
|
if request.xhr?
|
|
render :partial => "index"
|
|
end
|
|
|
|
end
|
|
def print_pdf
|
|
time_now = Time.now
|
|
venue_management = VenueManagementMain.find(params[:id])
|
|
|
|
if !venue_management.registration_status.blank? && venue_management.signup_start_date <= time_now && ( venue_management.signup_end_date.nil? || venue_management.signup_end_date+1 >= time_now )
|
|
sign_up = ('<a href="'+ OrbitHelper.url_to_show(venue_management.to_param) + '" target="_blank">' + t('venue_management.signup') + '</a>').html_safe
|
|
elsif venue_management.registration_status.blank?
|
|
sign_up = t('venue_management.sign_up_not_open')
|
|
elsif venue_management.signup_start_date > time_now
|
|
sign_up = t('venue_management.sign_up_not_yet')
|
|
else
|
|
sign_up = t('venue_management.sign_up_overdue')
|
|
end
|
|
|
|
if !venue_management.registration_status.blank? && venue_management.registration_status.include?('C') && venue_management.contribute_start_date <= time_now && ( venue_management.contribute_end_date.nil? || venue_management.contribute_end_date+1 >= time_now )
|
|
if !@@session[:venue_management_signup_id].blank?
|
|
if @@session[:venue_management_main_id] == venue_management.id
|
|
contribute_action = ('<a href="'+ OrbitHelper.url_to_show(venue_management.to_param) + '?method=con_upload">' + t('venue_management_signup.uploads') + '</a>').html_safe
|
|
else
|
|
contribute_action = ('<a href="'+ OrbitHelper.url_to_show(venue_management.to_param) + '?method=con_login">' + t('venue_management_signup.con_login') + '</a>').html_safe
|
|
end
|
|
else
|
|
contribute_action = ('<a href="'+ OrbitHelper.url_to_show(venue_management.to_param) + '?method=con_login">' + t('venue_management_signup.con_login') + '</a>').html_safe
|
|
end
|
|
end
|
|
@venue_management = venue_management
|
|
@sign_up = sign_up
|
|
@contribute_action = contribute_action
|
|
@time_now = time_now
|
|
@contribute_time_range = VenueManagementMain.time_range(venue_management.contribute_start_date, venue_management.contribute_end_date)
|
|
@sign_up_time_range = venue_management.display_signup_during
|
|
@venue_management_time_range = venue_management.display_event_during
|
|
@params = params
|
|
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
|
|
if params[:type] == "print"
|
|
render "print_pdf" , :layout => false
|
|
end
|
|
end
|
|
def export
|
|
@protocol = (request.referer.blank? ? "http" : URI(request.referer).scheme)
|
|
@host = "#{@protocol}://#{request.host_with_port}"
|
|
@venue_management = VenueManagementMain.find(params[:id])
|
|
@venue_management_signups = VenueManagementSignup.where(:venue_management_main_id => params[:id])
|
|
@site_in_use_locales = Site.first.in_use_locales
|
|
filename = @venue_management.title.to_s.strip + "_export.xlsx"
|
|
respond_to do |format|
|
|
format.xlsx {
|
|
response.headers['Content-Disposition'] = 'attachment; filename="' + filename + '"'
|
|
}
|
|
end
|
|
|
|
end
|
|
|
|
def new
|
|
@member = nil
|
|
@managers = nil
|
|
@contractors = nil
|
|
@coordinators = nil
|
|
@venue_management = VenueManagementMain.new
|
|
create_set (false)
|
|
@signup_sets = @venue_management.venue_management_signup_field_sets
|
|
@submission_set = @venue_management.venue_management_submission_field_sets
|
|
@custom_set = @venue_management.venue_management_signup_field_customs
|
|
@venue_management_items = VenueManagementItem.all
|
|
@review = @venue_management.venue_management_reviews.new()
|
|
end
|
|
|
|
def create
|
|
|
|
venue_management_main_params = venue_management_params
|
|
if !venue_management_main_params['venue_management_links_attributes'].nil?
|
|
venue_management_main_params['venue_management_links_attributes'].each do |idx,link|
|
|
venue_management_main_params['venue_management_links_attributes'].delete(idx.to_s) if link['url'].blank?
|
|
end
|
|
end
|
|
venue_management_signup_set_params = venue_management_main_params['venue_management_signup_field_sets']
|
|
venue_management_submission_set_params = venue_management_main_params['venue_management_submission_field_sets']
|
|
venue_management_email_sets_params = venue_management_main_params['venue_management_email_sets']
|
|
venue_management_main_params.delete(:venue_management_signup_field_sets)
|
|
venue_management_main_params.delete(:venue_management_submission_field_sets)
|
|
venue_management_main_params.delete(:venue_management_email_sets)
|
|
venue_management = VenueManagementMain.new(venue_management_main_params)
|
|
venue_management.create_user_id = current_user.id
|
|
venue_management.update_user_id = current_user.id
|
|
venue_management.save
|
|
#venue_management_signup_set_params.each do |key,value|
|
|
# venue_management.venue_management_signup_field_sets.create(value)
|
|
#end
|
|
#venue_management_submission_set_params.each do |key,value|
|
|
# venue_management.venue_management_submission_field_sets.create(value)
|
|
#end
|
|
venue_management_email_sets_params.each do |key,value|
|
|
venue_management.venue_management_email_sets.create(value)
|
|
end
|
|
redirect_to params['referer_url']
|
|
|
|
end
|
|
|
|
def edit
|
|
@venue_management_items = VenueManagementItem.all
|
|
@venue_management = VenueManagementMain.where(id: params[:id]).first
|
|
@venue_management.venue_management_signup_field_sets.each do |signup_field_set|
|
|
if !(VenueManagementSignup.attribute_names.include? signup_field_set.field_name) && signup_field_set.field_name != 'recaptcha'
|
|
signup_field_set.delete
|
|
end
|
|
end
|
|
@venue_management.venue_management_submission_field_sets.each do |submission_field_set|
|
|
if !(VenueManagementSignupContribute.attribute_names.include? submission_field_set.field_name)
|
|
submission_field_set.delete
|
|
end
|
|
end
|
|
@venue_management.venue_management_signup_field_customs.each do |custom_set|
|
|
if !(@venue_management.venue_management_signup_fields.collect(&:id).include? custom_set.venue_management_signup_field_id)
|
|
custom_set.delete
|
|
end
|
|
end
|
|
create_set (true)
|
|
@signup_sets = @venue_management.venue_management_signup_field_sets
|
|
@submission_set = @venue_management.venue_management_submission_field_sets
|
|
@custom_set = @venue_management.venue_management_signup_field_customs
|
|
if @venue_management.venue_management_reviews.first.nil?
|
|
@review = @venue_management.venue_management_reviews.new()
|
|
else
|
|
@review = @venue_management.venue_management_reviews.first
|
|
end
|
|
@member = MemberProfile.find(@review.reviewer_id) rescue nil
|
|
@managers = MemberProfile.find(@venue_management.manager_ids) rescue nil
|
|
@contractors = MemberProfile.find(@venue_management.contractor_ids) rescue nil
|
|
@coordinators = MemberProfile.find(@venue_management.coordinator_ids) rescue nil
|
|
end
|
|
|
|
def update
|
|
|
|
|
|
params[:venue_management_main][:registration_status] = (params[:venue_management_main][:registration_status] ? params[:venue_management_main][:registration_status] : [])
|
|
|
|
uid = params[:id].split('-').last
|
|
@venue_management = VenueManagementMain.find_by(:uid=>uid)
|
|
|
|
if params[:venue_management_main][:venue_management_signup_fields]
|
|
venue_management_params[:venue_management_signup_fields].each do |a|
|
|
@field_name = 'venue_management_main'
|
|
field_status = a.last[:id].present?
|
|
@attribute_field = VenueManagementSignupField.add_venue_management_signup_field(@venue_management, a.last, a.last[:id], field_status)
|
|
@attribute = @venue_management
|
|
end
|
|
flash.now[:notice] = "Updated Fields"
|
|
@venue_management.venue_management_signup_fields.each{|t| t.destroy if t["to_delete"] == true}
|
|
|
|
redirect_to admin_venue_managements_path
|
|
elsif params[:venue_management_main][:venue_management_submission_fields]
|
|
params[:venue_management_main][:venue_management_submission_fields].each do |a|
|
|
@field_name = 'venue_management_main'
|
|
field_status = a.last[:id].present?
|
|
@attribute_field = VenueManagementSubmissionField.add_venue_management_signup_field(@venue_management, a.last, a.last[:id], field_status)
|
|
@attribute = @venue_management
|
|
end
|
|
flash.now[:notice] = "Updated Fields"
|
|
@venue_management.venue_management_submission_fields.each{|t| t.destroy if t["to_delete"] == true}
|
|
redirect_to admin_venue_managements_path
|
|
else
|
|
venue_management_main_params = venue_management_params
|
|
if !venue_management_main_params['venue_management_links_attributes'].nil?
|
|
venue_management_main_params['venue_management_links_attributes'].each do |idx,link|
|
|
venue_management_main_params['venue_management_links_attributes'].delete(idx.to_s) if link['url'].blank?
|
|
end
|
|
end
|
|
|
|
@venue_management.update_user_id = current_user.id
|
|
if @venue_management.update_attributes(venue_management_main_params)
|
|
@venue_management.venue_management_signup_fields.each{|t| t.destroy if t["to_delete"] == true}
|
|
redirect_to params['referer_url']
|
|
else
|
|
flash.now[:error] = t('update.error.category')
|
|
flash.keep
|
|
redirect_to action: :edit, :id =>@venue_management.id.to_s
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
def set_write_off
|
|
|
|
@venue_management.donation_write_off_status = true
|
|
@venue_management.save
|
|
|
|
redirect_to "/admin/venue_managements?page=#{params['page']}"
|
|
|
|
end
|
|
|
|
def destroy
|
|
|
|
@venue_management.destroy
|
|
redirect_to "/admin/venue_managements"
|
|
|
|
end
|
|
|
|
def venue_management_signup_field
|
|
@field_name = 'venue_management_main'
|
|
@attribute = VenueManagementMain.find(params[:id])
|
|
@attribute_type = 'venue_management'
|
|
@class = 'venue_managements'
|
|
end
|
|
|
|
def venue_management_submission_field
|
|
@field_name = 'venue_management_main'
|
|
@attribute = VenueManagementMain.find(params[:id])
|
|
@attribute_type = 'venue_management'
|
|
@class = 'venue_managements'
|
|
end
|
|
|
|
def venue_management_signup
|
|
|
|
if !params[:search].blank?
|
|
@venue_management_signups = VenueManagementSignup.where(:venue_management_main_id => @venue_management.id, :name=>params[:search]).page(params[:page]).per(10)
|
|
else
|
|
@venue_management_signups = VenueManagementSignup.where(:venue_management_main_id => @venue_management.id).page(params[:page]).per(10)
|
|
end
|
|
|
|
end
|
|
|
|
def edit_venue_management_signup
|
|
@venue_management_signup = VenueManagementSignup.find(params[:id])
|
|
@venue_management = VenueManagementMain.find(@venue_management_signup.venue_management_main_id)
|
|
end
|
|
|
|
def delete_venue_management_signup
|
|
|
|
@venue_management_signup = VenueManagementSignup.find(params[:id])
|
|
|
|
@venue_management_id = @venue_management_signup.venue_management_main_id
|
|
|
|
@venue_management_signup.destroy
|
|
|
|
redirect_to "/admin/venue_managements/@venue_management_id.to_s/venue_management_signup"
|
|
end
|
|
|
|
def venue_management_invitings
|
|
@table_fields = [
|
|
'vm_inviting.case_no',
|
|
'vm_inviting.type',
|
|
'vm_inviting.publish_times',
|
|
'vm_inviting.start_end',
|
|
'vm_inviting.rents',
|
|
'vm_inviting.royalty',
|
|
'vm_inviting.house_land_tax_payer',
|
|
'vm_inviting.contractor_manager',
|
|
'vm_inviting.bid_result',
|
|
'vm_inviting.details'
|
|
]
|
|
filter_tags = params[:filters]["type"].to_a rescue []
|
|
@invitings = @venue_management.venue_management_invitings.with_tags(filter_tags).page(params[:page]).per(10)
|
|
@tags = @module_app.tags
|
|
@filter_fields = {}
|
|
@filter_fields['vm_inviting.type'] = @tags.map{|t| {:title => t.name,:id => t.id} }
|
|
@filter_fields['vm_inviting.start_end'] = ('<div class="controls"><div style="float: left;">'+
|
|
(render_html('<%= org_datetime_picker("filters[start_date]", {:no_label => true, :format=>"yyyy/MM/dd", :new_record=>false, :value=>(DateTime.parse(params[:filters]["start_date"]) rescue nil)}) %>')) +
|
|
"</div><span style=\"float: left;\">~</span><div style=\"float: left;\">" +
|
|
(render_html('<%= org_datetime_picker("filters[end_date]", {:no_label => true, :format=>"yyyy/MM/dd", :new_record=>false, :value=>(DateTime.parse(params[:filters]["end_date"]) rescue nil)}) %>' ) ) +
|
|
render_html("<%= submit_tag(I18n.t('venue_management.search')) %>") +
|
|
'</div></div>')
|
|
start_date = DateTime.parse(params[:filters]["start_date"]) rescue 0
|
|
end_date = DateTime.parse(params[:filters]["end_date"]) rescue 0
|
|
if @invitings.nil?
|
|
if start_date != 0 && end_date != 0
|
|
@invitings = VenueManagementInviting.where(:start_date.gte=>start_date,:end_date.lte=>end_date).page(params[:page]).per(10)
|
|
elsif start_date != 0
|
|
@invitings = VenueManagementInviting.where(:start_date.gte=>start_date).page(params[:page]).per(10)
|
|
elsif end_date != 0
|
|
@invitings = VenueManagementInviting.where(:end_date.lte=>end_date).page(params[:page]).per(10)
|
|
end
|
|
else
|
|
if start_date != 0 && end_date != 0
|
|
@invitings = @invitings.where(:start_date.gte=>start_date,:end_date.lte=>end_date).page(params[:page]).per(10)
|
|
elsif start_date != 0
|
|
@invitings = @invitings.where(:start_date.gte=>start_date).page(params[:page]).per(10)
|
|
elsif end_date != 0
|
|
@invitings = @invitings.where(:end_date.lte=>end_date).page(params[:page]).per(10)
|
|
end
|
|
end
|
|
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
|
|
if request.xhr?
|
|
render :partial => 'admin/venue_management_invitings/index'
|
|
end
|
|
end
|
|
|
|
def venue_management_memorabilias
|
|
@table_fields = [
|
|
'vm_memorabilia.case_no',
|
|
'vm_memorabilia.event_date',
|
|
'vm_memorabilia.details',
|
|
]
|
|
@memorabilias = @venue_management.venue_management_memorabilias.page(params[:page]).per(10)
|
|
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
|
|
end
|
|
def venue_management_bills
|
|
@table_fields = [
|
|
"contractor",
|
|
"accounting_month",
|
|
"bill_type",
|
|
"caculation_basis",
|
|
"reason",
|
|
"total_amount",
|
|
"pay_date",
|
|
"pay_method",
|
|
"note"
|
|
]
|
|
@bills = @venue_management.venue_management_bills.page(params[:page]).per(10)
|
|
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
|
|
@categories = @module_app.categories.enabled
|
|
@filter_fields = filter_fields(@categories)
|
|
@tags = @module_app.tags
|
|
@filter_fields['vm_inviting.type'] = @tags.map{|t| {:title => t.name,:id => t.id} }
|
|
bill_type_select_str = "<div class=\"controls\">"
|
|
value_bill_typeA = params[:filters]["bill_typeA"] rescue "0"
|
|
value_bill_typeB = params[:filters]["bill_typeB"] rescue "0"
|
|
bill_type_select_str += render_html('<%= select_tag "filters[bill_typeA]", options_for_select(VenueManagementBill::BILLTYPE.keys.map { |k| [ I18n.t("vm_bill.#{k}"), k ] },value_bill_typeA) ,{:onchange=>"var $this=this;(function(){var obj=#{VenueManagementBill::BILLTYPE.map{|k,v| [k,v.map{|vv| [vv,I18n.t("vm_bill.#{vv}")]}.to_h]}.to_h.to_s.gsub(\'=>\',\':\')};$($this).siblings(\'select\').html($.map(obj[$this.value],function(v,k){return \'<option value=\"\'+k+\'\">\'+v+\'</option>\'}).join(\' \'))})()"} %>',{:value_bill_typeA=>value_bill_typeA})
|
|
bill_typeB = (params[:filters]["bill_typeA"].blank? rescue true) ? VenueManagementBill::BILLTYPE.values.first : VenueManagementBill::BILLTYPE[params[:filters]["bill_typeA"]]
|
|
bill_type_select_str += render_html('<%= select_tag "filters[bill_typeB]", options_for_select(bill_typeB.map { |v| [ I18n.t("vm_bill.#{v}"), v ] },value_bill_typeB) , {:onchange=> "var $this=this;(function(){if($this.value == \'other\') $(\'#bill_other_field\').removeClass(\'hidden\');else $(\'#bill_other_field\').addClass(\'hidden\');})()"} %>',{:bill_typeB=>bill_typeB,:value_bill_typeB=>value_bill_typeB})
|
|
bill_type_select_str += render_html('<%= submit_tag(I18n.t(\'venue_management.search\')) %>')
|
|
bill_type_select_str += "</div>"
|
|
@filter_fields['vm_bill.bill_type'] = bill_type_select_str
|
|
@filter_fields['vm_bill.accounting_month'] = ('<div class="controls"><div style="float: left;">'+
|
|
(render_html('<%= org_datetime_picker("filters[accounting_month_start]", {:no_label => true, :format=>"yyyy/MM", :new_record=>false, :value=>(DateTime.parse(params[:filters]["accounting_month_start"]) rescue nil)}) %>')) +
|
|
"</div><span style=\"float: left;\">~</span><div style=\"float: left;\">" +
|
|
(render_html('<%= org_datetime_picker("filters[accounting_month_end]", {:no_label => true, :format=>"yyyy/MM", :new_record=>false, :value=>(DateTime.parse(params[:filters]["accounting_month_end"]) rescue nil)}) %>' ) ) +
|
|
render_html("<%= submit_tag(I18n.t('venue_management.search')) %>") +
|
|
'</div></div>')
|
|
filter_tags = params[:filters]["type"].to_a rescue []
|
|
@main_ids = nil
|
|
if !filter_tags.blank?
|
|
@main_ids = VenueManagementInviting.with_tags(filter_tags).pluck(:venue_management_main_id)
|
|
if !filters("category").blank?
|
|
@main_ids = VenueManagementMain.where(:id.in=>@main_ids).with_categories(filters("category")).pluck(:id)
|
|
end
|
|
elsif !filters("category").blank?
|
|
@main_ids = VenueManagementMain.all.with_categories(filters("category")).pluck(:id)
|
|
end
|
|
if ( !params[:filters]["bill_typeA"].blank? rescue false)
|
|
@bills = @bills.where(:bill_typeA=>params[:filters]["bill_typeA"],:bill_typeB=>params[:filters]["bill_typeB"]).page(params[:page]).per(10)
|
|
end
|
|
accounting_month_start = DateTime.parse(params[:filters]["accounting_month_start"]) rescue 0
|
|
accounting_month_end = DateTime.parse(params[:filters]["accounting_month_end"]) rescue 0
|
|
if(accounting_month_end != 0)
|
|
accounting_month_end = accounting_month_end + 1.month - 1.day
|
|
end
|
|
if accounting_month_start != 0 && accounting_month_end != 0
|
|
@bills = @bills.where(:accounting_month.gte=>accounting_month_start,:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10)
|
|
elsif accounting_month_start != 0
|
|
@bills = @bills.where(:accounting_month.gte=>accounting_month_start).page(params[:page]).per(10)
|
|
elsif accounting_month_end != 0
|
|
@bills = @bills.where(:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10)
|
|
end
|
|
if !@main_ids.nil?
|
|
@bills = @bills.where(:venue_management_main_id.in=>@main_ids).page(params[:page]).per(10)
|
|
end
|
|
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
|
|
if request.xhr?
|
|
render 'admin/venue_management_bills/_index'
|
|
end
|
|
end
|
|
def venue_management_contracts
|
|
@table_fields = [
|
|
'vm_contract.case_no',
|
|
'vm_inviting.type',
|
|
'vm_contract.vendor',
|
|
'vm_inviting.rents',
|
|
'vm_inviting.royalty',
|
|
'vm_contract.start_end',
|
|
'vm_contract.deposit_amount_type_exp_date',
|
|
'vm_contract.renewal_permission',
|
|
'vm_contract.other_commitment',
|
|
'vm_contract.note'
|
|
]
|
|
@filter_fields = filter_fields(@categories)
|
|
@tags = @module_app.tags
|
|
@filter_fields['vm_inviting.type'] = @tags.map{|t| {:title => t.name,:id => t.id} }
|
|
@filter_fields['vm_contract.start_end'] = ('<div class="controls"><div style="float: left;">'+
|
|
(render_html('<%= org_datetime_picker("filters[contract_start_date]", {:no_label => true, :format=>"yyyy/MM/dd", :new_record=>false, :value=>(DateTime.parse(params[:filters]["contract_start_date"]) rescue nil)}) %>')) +
|
|
"</div><span style=\"float: left;\">~</span><div style=\"float: left;\">" +
|
|
(render_html('<%= org_datetime_picker("filters[contract_end_date]", {:no_label => true, :format=>"yyyy/MM/dd", :new_record=>false, :value=>(DateTime.parse(params[:filters]["contract_end_date"]) rescue nil)}) %>' ) ) +
|
|
render_html("<%= submit_tag(I18n.t('venue_management.search')) %>") +
|
|
'</div></div>')
|
|
filter_tags = params[:filters]["type"].to_a rescue []
|
|
@main_ids = nil
|
|
@inviting_ids = nil
|
|
@contracts = @venue_management.venue_management_contracts.page(params[:page]).per(10)
|
|
if !filter_tags.blank?
|
|
@inviting_ids = VenueManagementInviting.with_tags(filter_tags).pluck(:id)
|
|
end
|
|
if !filters("category").blank?
|
|
@main_ids = VenueManagementMain.all.with_categories(filters("category")).pluck(:id)
|
|
end
|
|
contract_start_date = DateTime.parse(params[:filters]["contract_start_date"]) rescue 0
|
|
contract_end_date = DateTime.parse(params[:filters]["contract_end_date"]) rescue 0
|
|
if @contracts.nil?
|
|
if contract_start_date != 0 && contract_end_date != 0
|
|
@contracts = VenueManagementContract.where(:contract_start_date.gte=>contract_start_date,:contract_end_date.lte=>contract_end_date).page(params[:page]).per(10)
|
|
elsif contract_start_date != 0
|
|
@contracts = VenueManagementContract.where(:contract_start_date.gte=>contract_start_date).page(params[:page]).per(10)
|
|
elsif contract_end_date != 0
|
|
@contracts = VenueManagementContract.where(:contract_end_date.lte=>contract_end_date).page(params[:page]).per(10)
|
|
end
|
|
else
|
|
if contract_start_date != 0 && contract_end_date != 0
|
|
@contracts = @contracts.where(:contract_start_date.gte=>contract_start_date,:contract_end_date.lte=>contract_end_date).page(params[:page]).per(10)
|
|
elsif contract_start_date != 0
|
|
@contracts = @contracts.where(:contract_start_date.gte=>contract_start_date).page(params[:page]).per(10)
|
|
elsif contract_end_date != 0
|
|
@contracts = @contracts.where(:contract_end_date.lte=>contract_end_date).page(params[:page]).per(10)
|
|
end
|
|
end
|
|
if !@main_ids.nil?
|
|
if @contracts.nil?
|
|
@contracts = VenueManagementContract.where(:venue_management_main_id.in=>@main_ids).page(params[:page]).per(10)
|
|
else
|
|
@contracts = @contracts.and(:venue_management_main_id.in=>@main_ids).page(params[:page]).per(10)
|
|
end
|
|
end
|
|
if @contracts.nil?
|
|
@contracts = VenueManagementContract.all.page(params[:page]).per(10)
|
|
end
|
|
if !@inviting_ids.nil?
|
|
@contracts = @contracts.where(:venue_management_inviting_id.in=>@inviting_ids)
|
|
end
|
|
@contracts = @contracts.order(updated_at: :desc)
|
|
|
|
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
|
|
end
|
|
def render_html(code,pass_variables={})
|
|
render_to_string(:inline=>code,:locals=>pass_variables)
|
|
end
|
|
private
|
|
|
|
def set_venue_management
|
|
@venue_management = VenueManagementMain.find(params[:id])
|
|
end
|
|
|
|
def venue_management_params
|
|
params.require(:venue_management_main).permit!
|
|
end
|
|
def create_set (save_flag)
|
|
VenueManagementSignup.attribute_names.each do |attr_signup|
|
|
if !(['_id', 'created_at', 'updated_at','venue_management_main_id'].include? attr_signup)
|
|
signup_set = @venue_management.venue_management_signup_field_sets.select{|v| v.field_name==attr_signup }
|
|
if signup_set.length==0
|
|
if ['status','name','tel','phone','email','password'].include? attr_signup
|
|
disabled = false
|
|
else
|
|
disabled = true
|
|
end
|
|
if ['status','name','tel'].include? attr_signup
|
|
hidden = false
|
|
else
|
|
hidden = true
|
|
end
|
|
name1 = Hash.new
|
|
now_locale = I18n.locale
|
|
I18n.available_locales.each do |locale|
|
|
I18n.locale = locale
|
|
name1[locale] = t("venue_management_signup.#{attr_signup}")
|
|
end
|
|
I18n.locale = now_locale
|
|
if save_flag
|
|
@venue_management.venue_management_signup_field_sets.create(field_name:attr_signup,disabled:disabled,hidden:hidden,name:name1,placeholder:name1)
|
|
else
|
|
@venue_management.venue_management_signup_field_sets.new(field_name:attr_signup,disabled:disabled,hidden:hidden,name:name1,placeholder:name1)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
signup_set = @venue_management.venue_management_signup_field_sets.select{|v| v.field_name== 'recaptcha' }
|
|
if signup_set.length==0
|
|
name1 = Hash.new
|
|
now_locale = I18n.locale
|
|
I18n.available_locales.each do |locale|
|
|
I18n.locale = locale
|
|
name1[locale] = t("venue_management_signup.recaptcha")
|
|
end
|
|
I18n.locale = now_locale
|
|
if save_flag
|
|
@venue_management.venue_management_signup_field_sets.create(field_name:'recaptcha',name:name1,placeholder:name1,hidden:true)
|
|
else
|
|
@venue_management.venue_management_signup_field_sets.new(field_name:'recaptcha',name:name1,placeholder:name1,hidden:true)
|
|
end
|
|
end
|
|
VenueManagementSignupContribute.attribute_names.each do |attr_submission|
|
|
if !(['_id', 'created_at', 'updated_at','venue_management_signup_id'].include? attr_submission)
|
|
signup_set = @venue_management.venue_management_submission_field_sets.select{|v| v.field_name==attr_submission }
|
|
if signup_set.length==0
|
|
name1 = Hash.new
|
|
now_locale = I18n.locale
|
|
I18n.available_locales.each do |locale|
|
|
I18n.locale = locale
|
|
name1[locale] = t("venue_management_signup.#{attr_submission}")
|
|
end
|
|
I18n.locale = now_locale
|
|
if save_flag
|
|
@venue_management.venue_management_submission_field_sets.create(field_name:attr_submission,name:name1,placeholder:name1)
|
|
else
|
|
@venue_management.venue_management_submission_field_sets.new(field_name:attr_submission,name:name1,placeholder:name1)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
@venue_management.venue_management_signup_fields.all.map{|v| v}.each do |field|
|
|
set = @venue_management.venue_management_signup_field_customs.select{|v| v.venue_management_signup_field_id==field.id}
|
|
if set.length == 0
|
|
@venue_management.venue_management_signup_field_customs.create(venue_management_signup_field_id:field.id)
|
|
end
|
|
end
|
|
@email_set = []
|
|
['signup','submission','add_file','edit_file'].each do |field_name|
|
|
email_set = @venue_management.venue_management_email_sets.select{|v| v.field_name==field_name}
|
|
if email_set.length==0
|
|
title = Hash.new
|
|
content = Hash.new
|
|
now_locale = I18n.locale
|
|
I18n.available_locales.each do |locale|
|
|
I18n.locale = locale
|
|
title[locale] = t("venue_management.email_#{field_name}_success")
|
|
content[locale] = t("venue_management.email_#{field_name}_content")
|
|
end
|
|
I18n.locale = now_locale
|
|
if save_flag
|
|
email_set = @venue_management.venue_management_email_sets.create(field_name:field_name,title:title,content:content)
|
|
else
|
|
email_set = @venue_management.venue_management_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
|