2020-05-07 15:26:34 +00:00
|
|
|
# encoding: utf-8
|
2020-08-04 09:04:04 +00:00
|
|
|
class Admin::VenueManagementsController < Admin::VenueAdminController
|
2020-10-14 01:48:38 +00:00
|
|
|
include ActionView::Helpers::FormOptionsHelper
|
2020-10-15 06:51:17 +00:00
|
|
|
#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
|
2020-10-14 01:48:38 +00:00
|
|
|
include VenueAdminHelper
|
|
|
|
include ActionView::Context
|
2020-05-07 15:26:34 +00:00
|
|
|
require 'axlsx'
|
|
|
|
helper Admin::VenueManagementsFieldHelper
|
|
|
|
before_action ->(module_app = @app_title) { set_variables module_app }
|
2020-09-08 06:12:14 +00:00
|
|
|
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]
|
2020-05-07 15:26:34 +00:00
|
|
|
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)
|
2020-07-30 17:30:14 +00:00
|
|
|
@table_fields = [ :category,
|
2020-08-09 13:47:41 +00:00
|
|
|
'vm_inviting.type',
|
2020-07-30 17:30:14 +00:00
|
|
|
'venue_management.title',
|
2020-08-09 13:47:41 +00:00
|
|
|
"venue_management.contractor",
|
2020-07-30 17:30:14 +00:00
|
|
|
'venue_management.event_during',
|
|
|
|
'venue_management.signup_during',
|
|
|
|
'venue_management.inviting_history',
|
2020-09-22 15:19:59 +00:00
|
|
|
'venue_management.contract_history',
|
2020-07-30 17:30:14 +00:00
|
|
|
'venue_management.memorabilia',
|
2020-09-08 06:12:14 +00:00
|
|
|
'venue_management.bills',
|
2020-07-30 17:30:14 +00:00
|
|
|
'venue_management.export'
|
|
|
|
]
|
2020-08-09 13:47:41 +00:00
|
|
|
@filter_fields["vm_inviting.type"] = @module_app.tags.map{|t| {:title => t.name,:id => t.id} }
|
2020-07-27 16:34:33 +00:00
|
|
|
if !params[:sort].blank?
|
2020-05-07 15:26:34 +00:00
|
|
|
if params[:sort] == 'event_during'
|
2020-07-27 16:34:33 +00:00
|
|
|
sort = {:venue_management_start_date.to_sym=>params[:order]}
|
2020-05-07 15:26:34 +00:00
|
|
|
elsif params[:sort] == 'signup_during'
|
2020-07-27 16:34:33 +00:00
|
|
|
sort = {:signup_start_date.to_sym=>params[:order]}
|
2020-05-07 15:26:34 +00:00
|
|
|
else
|
2020-07-27 16:34:33 +00:00
|
|
|
sort = {params[:sort].to_sym=>params[:order]}
|
2020-05-07 15:26:34 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
sort = {:signup_start_date=>"desc"}
|
|
|
|
end
|
2020-08-09 13:47:41 +00:00
|
|
|
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 ""}
|
2020-10-14 01:48:38 +00:00
|
|
|
@venue_management_ids = VenueManagementInviting.where(:id.in=>@venue_management_inviting_ids).with_tags(filter_tags).pluck(:venue_management_main_id)
|
2020-08-09 13:47:41 +00:00
|
|
|
@venue_managements = VenueManagementMain.where(:id.in=>@venue_management_ids).page(params[:page]).per(10)
|
|
|
|
end
|
2020-07-27 16:34:33 +00:00
|
|
|
|
2020-05-07 15:26:34 +00:00
|
|
|
if request.xhr?
|
|
|
|
render :partial => "index"
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2020-08-10 07:35:02 +00:00
|
|
|
def print_pdf
|
|
|
|
time_now = Time.now
|
|
|
|
venue_management = VenueManagementMain.find(params[:id])
|
2020-05-07 15:26:34 +00:00
|
|
|
|
2020-08-10 07:35:02 +00:00
|
|
|
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
|
2020-05-07 15:26:34 +00:00
|
|
|
|
2020-08-10 07:35:02 +00:00
|
|
|
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}"
|
2020-05-07 15:26:34 +00:00
|
|
|
@venue_management = VenueManagementMain.find(params[:id])
|
|
|
|
@venue_management_signups = VenueManagementSignup.where(:venue_management_main_id => params[:id])
|
2020-08-09 02:50:11 +00:00
|
|
|
@site_in_use_locales = Site.first.in_use_locales
|
2020-08-10 07:35:02 +00:00
|
|
|
filename = @venue_management.title.to_s.strip + "_export.xlsx"
|
2020-05-07 15:26:34 +00:00
|
|
|
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
|
2020-07-27 16:34:33 +00:00
|
|
|
|
2020-08-02 13:33:41 +00:00
|
|
|
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?
|
2020-05-07 15:26:34 +00:00
|
|
|
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] : [])
|
2020-07-27 16:34:33 +00:00
|
|
|
|
2020-05-07 15:26:34 +00:00
|
|
|
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
|
2020-08-02 13:33:41 +00:00
|
|
|
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?
|
2020-05-07 15:26:34 +00:00
|
|
|
end
|
|
|
|
end
|
2020-07-27 16:34:33 +00:00
|
|
|
|
2020-05-07 15:26:34 +00:00
|
|
|
@venue_management.update_user_id = current_user.id
|
2020-08-02 13:33:41 +00:00
|
|
|
if @venue_management.update_attributes(venue_management_main_params)
|
2020-05-07 15:26:34 +00:00
|
|
|
@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')
|
2020-08-02 13:33:41 +00:00
|
|
|
flash.keep
|
|
|
|
redirect_to action: :edit, :id =>@venue_management.id.to_s
|
2020-05-07 15:26:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2020-07-27 16:34:33 +00:00
|
|
|
|
2020-05-07 15:26:34 +00:00
|
|
|
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'
|
2020-07-27 16:34:33 +00:00
|
|
|
@attribute = VenueManagementMain.find(params[:id])
|
2020-05-07 15:26:34 +00:00
|
|
|
@attribute_type = 'venue_management'
|
|
|
|
@class = 'venue_managements'
|
|
|
|
end
|
|
|
|
|
|
|
|
def venue_management_submission_field
|
|
|
|
@field_name = 'venue_management_main'
|
2020-07-27 16:34:33 +00:00
|
|
|
@attribute = VenueManagementMain.find(params[:id])
|
2020-05-07 15:26:34 +00:00
|
|
|
@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
|
2020-07-27 16:34:33 +00:00
|
|
|
|
2020-05-07 15:26:34 +00:00
|
|
|
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
|
2020-07-27 16:34:33 +00:00
|
|
|
|
2020-05-07 15:26:34 +00:00
|
|
|
@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
|
|
|
|
|
2020-07-27 16:34:33 +00:00
|
|
|
def venue_management_invitings
|
|
|
|
@table_fields = [
|
|
|
|
'vm_inviting.case_no',
|
2020-08-09 13:47:41 +00:00
|
|
|
'vm_inviting.type',
|
2020-07-27 16:34:33 +00:00
|
|
|
'vm_inviting.publish_times',
|
2020-08-09 13:47:41 +00:00
|
|
|
'vm_inviting.start_end',
|
2020-07-27 16:34:33 +00:00
|
|
|
'vm_inviting.rents',
|
|
|
|
'vm_inviting.royalty',
|
2020-08-09 13:47:41 +00:00
|
|
|
'vm_inviting.house_land_tax_payer',
|
2020-07-27 16:34:33 +00:00
|
|
|
'vm_inviting.contractor_manager',
|
|
|
|
'vm_inviting.bid_result',
|
2020-10-27 02:41:08 +00:00
|
|
|
'vm_inviting.details'
|
2020-07-27 16:34:33 +00:00
|
|
|
]
|
2020-08-09 13:47:41 +00:00
|
|
|
filter_tags = params[:filters]["type"].to_a rescue []
|
|
|
|
@invitings = @venue_management.venue_management_invitings.with_tags(filter_tags).page(params[:page]).per(10)
|
2020-08-09 03:28:13 +00:00
|
|
|
@tags = @module_app.tags
|
|
|
|
@filter_fields = {}
|
|
|
|
@filter_fields['vm_inviting.type'] = @tags.map{|t| {:title => t.name,:id => t.id} }
|
2020-10-27 04:44:10 +00:00
|
|
|
@filter_fields['vm_inviting.start_end'] = ('<div class="controls"><div style="float: left;">'+
|
2020-10-27 02:41:08 +00:00
|
|
|
(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')) %>") +
|
2020-10-27 04:44:10 +00:00
|
|
|
'</div></div>')
|
2020-10-27 02:41:08 +00:00
|
|
|
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
|
2020-08-09 03:28:13 +00:00
|
|
|
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
|
|
|
|
if request.xhr?
|
|
|
|
render :partial => 'admin/venue_management_invitings/index'
|
|
|
|
end
|
2020-07-27 16:34:33 +00:00
|
|
|
end
|
|
|
|
|
2020-07-30 14:28:57 +00:00
|
|
|
def venue_management_memorabilias
|
|
|
|
@table_fields = [
|
|
|
|
'vm_memorabilia.case_no',
|
|
|
|
'vm_memorabilia.event_date',
|
|
|
|
'vm_memorabilia.details',
|
|
|
|
]
|
2020-11-03 03:03:27 +00:00
|
|
|
@filter_fields = {}
|
2020-07-30 14:28:57 +00:00
|
|
|
@memorabilias = @venue_management.venue_management_memorabilias.page(params[:page]).per(10)
|
2020-08-09 13:47:41 +00:00
|
|
|
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
|
2020-07-30 14:28:57 +00:00
|
|
|
end
|
2020-09-08 06:12:14 +00:00
|
|
|
def venue_management_bills
|
|
|
|
@table_fields = [
|
|
|
|
"contractor",
|
|
|
|
"accounting_month",
|
|
|
|
"bill_type",
|
|
|
|
"caculation_basis",
|
|
|
|
"reason",
|
2020-10-05 16:09:17 +00:00
|
|
|
"total_amount",
|
2020-09-08 06:12:14 +00:00
|
|
|
"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 ""
|
2020-10-14 01:48:38 +00:00
|
|
|
@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} }
|
2020-10-27 04:44:10 +00:00
|
|
|
bill_type_select_str = "<div class=\"controls\">"
|
2020-10-14 01:48:38 +00:00
|
|
|
value_bill_typeA = params[:filters]["bill_typeA"] rescue "0"
|
|
|
|
value_bill_typeB = params[:filters]["bill_typeB"] rescue "0"
|
2020-10-15 06:51:17 +00:00
|
|
|
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})
|
2020-10-14 01:48:38 +00:00
|
|
|
bill_typeB = (params[:filters]["bill_typeA"].blank? rescue true) ? VenueManagementBill::BILLTYPE.values.first : VenueManagementBill::BILLTYPE[params[:filters]["bill_typeA"]]
|
2020-10-15 06:51:17 +00:00
|
|
|
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\')) %>')
|
2020-10-27 04:44:10 +00:00
|
|
|
bill_type_select_str += "</div>"
|
2020-10-14 01:48:38 +00:00
|
|
|
@filter_fields['vm_bill.bill_type'] = bill_type_select_str
|
2020-10-27 04:44:10 +00:00
|
|
|
@filter_fields['vm_bill.accounting_month'] = ('<div class="controls"><div style="float: left;">'+
|
2020-10-15 06:51:17 +00:00
|
|
|
(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)}) %>')) +
|
2020-10-14 01:48:38 +00:00
|
|
|
"</div><span style=\"float: left;\">~</span><div style=\"float: left;\">" +
|
2020-10-15 06:51:17 +00:00
|
|
|
(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)}) %>' ) ) +
|
2020-10-16 04:03:26 +00:00
|
|
|
render_html("<%= submit_tag(I18n.t('venue_management.search')) %>") +
|
2020-10-27 04:44:10 +00:00
|
|
|
'</div></div>')
|
2020-10-14 01:48:38 +00:00
|
|
|
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
|
2020-10-27 02:41:08 +00:00
|
|
|
if(accounting_month_end != 0)
|
|
|
|
accounting_month_end = accounting_month_end + 1.month - 1.day
|
|
|
|
end
|
2020-10-14 01:48:38 +00:00
|
|
|
if accounting_month_start != 0 && accounting_month_end != 0
|
2020-10-27 02:41:08 +00:00
|
|
|
@bills = @bills.where(:accounting_month.gte=>accounting_month_start,:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10)
|
2020-10-14 01:48:38 +00:00
|
|
|
elsif accounting_month_start != 0
|
2020-10-27 02:41:08 +00:00
|
|
|
@bills = @bills.where(:accounting_month.gte=>accounting_month_start).page(params[:page]).per(10)
|
2020-10-14 01:48:38 +00:00
|
|
|
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?
|
2020-11-03 03:03:27 +00:00
|
|
|
render :partial=> 'admin/venue_management_bills/index'
|
2020-10-14 01:48:38 +00:00
|
|
|
end
|
2020-09-08 06:12:14 +00:00
|
|
|
end
|
2020-07-30 17:30:14 +00:00
|
|
|
def venue_management_contracts
|
|
|
|
@table_fields = [
|
|
|
|
'vm_contract.case_no',
|
2020-08-09 13:47:41 +00:00
|
|
|
'vm_inviting.type',
|
2020-07-30 17:30:14 +00:00
|
|
|
'vm_contract.vendor',
|
2020-08-09 13:47:41 +00:00
|
|
|
'vm_inviting.rents',
|
|
|
|
'vm_inviting.royalty',
|
2020-07-30 17:30:14 +00:00
|
|
|
'vm_contract.start_end',
|
2020-10-27 02:41:08 +00:00
|
|
|
'vm_contract.deposit_amount_type_exp_date',
|
2020-07-30 17:30:14 +00:00
|
|
|
'vm_contract.renewal_permission',
|
2020-10-27 02:41:08 +00:00
|
|
|
'vm_contract.other_commitment',
|
|
|
|
'vm_contract.note'
|
2020-07-30 17:30:14 +00:00
|
|
|
]
|
2020-10-27 02:41:08 +00:00
|
|
|
@filter_fields = filter_fields(@categories)
|
|
|
|
@tags = @module_app.tags
|
|
|
|
@filter_fields['vm_inviting.type'] = @tags.map{|t| {:title => t.name,:id => t.id} }
|
2020-10-27 04:44:10 +00:00
|
|
|
@filter_fields['vm_contract.start_end'] = ('<div class="controls"><div style="float: left;">'+
|
2020-10-27 02:41:08 +00:00
|
|
|
(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')) %>") +
|
2020-10-27 04:44:10 +00:00
|
|
|
'</div></div>')
|
2020-10-27 02:41:08 +00:00
|
|
|
filter_tags = params[:filters]["type"].to_a rescue []
|
|
|
|
@main_ids = nil
|
|
|
|
@inviting_ids = nil
|
2020-07-30 17:30:14 +00:00
|
|
|
@contracts = @venue_management.venue_management_contracts.page(params[:page]).per(10)
|
2020-10-27 02:41:08 +00:00
|
|
|
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)
|
|
|
|
|
2020-08-09 03:28:13 +00:00
|
|
|
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
|
2020-11-03 03:03:27 +00:00
|
|
|
if request.xhr?
|
|
|
|
render :partial=> 'admin/venue_management_contracts/index'
|
|
|
|
end
|
2020-07-30 17:30:14 +00:00
|
|
|
end
|
2020-10-15 06:51:17 +00:00
|
|
|
def render_html(code,pass_variables={})
|
|
|
|
render_to_string(:inline=>code,:locals=>pass_variables)
|
|
|
|
end
|
2020-05-07 15:26:34 +00:00
|
|
|
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|
|
2020-07-27 16:34:33 +00:00
|
|
|
if !(['_id', 'created_at', 'updated_at','venue_management_main_id'].include? attr_signup)
|
2020-05-07 15:26:34 +00:00
|
|
|
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|
|
2020-07-27 16:34:33 +00:00
|
|
|
if !(['_id', 'created_at', 'updated_at','venue_management_signup_id'].include? attr_submission)
|
2020-05-07 15:26:34 +00:00
|
|
|
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
|