2020-07-27 16:34:33 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-08-04 09:04:04 +00:00
|
|
|
class Admin::VenueManagementInvitingsController < Admin::VenueAdminController
|
2020-07-27 16:34:33 +00:00
|
|
|
include Admin::VenueManagementsHelper
|
|
|
|
before_action ->(module_app = @app_title) { set_variables module_app }
|
|
|
|
before_action :set_venue_management_inviting, only: [:edit, :update, :destroy]
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super
|
|
|
|
@app_title = 'venue_management'
|
|
|
|
end
|
|
|
|
|
|
|
|
def index
|
|
|
|
@table_fields = [
|
|
|
|
'venue_management.title',
|
|
|
|
'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 02:50:11 +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-11-03 03:03:27 +00:00
|
|
|
filter_inviting
|
|
|
|
@venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue ""
|
|
|
|
if request.xhr?
|
|
|
|
render :partial => 'index'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def filter_inviting
|
|
|
|
@ext_filename = ""
|
2020-08-09 13:47:41 +00:00
|
|
|
filter_tags = params[:filters]["type"].to_a rescue []
|
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
|
2020-08-09 13:47:41 +00:00
|
|
|
@invitings = VenueManagementInviting.with_tags(filter_tags).order(updated_at: :desc).page(params[:page]).per(10)
|
2020-11-03 03:03:27 +00:00
|
|
|
@ext_filename += (I18n.t("vm_inviting.type") + ": #{Tag.where(:id.in=>filter_tags).map{|t| t.name}.join(',')}") if !filter_tags.blank?
|
|
|
|
if start_date != 0 && end_date != 0
|
|
|
|
@ext_filename += (I18n.t("vm_inviting.start_end") + ": #{start_date}~#{end_date}") if @ext_filename.blank?
|
|
|
|
@invitings = @invitings.where(:start_date.gte=>start_date,:end_date.lte=>end_date).page(params[:page]).per(10)
|
|
|
|
elsif start_date != 0
|
|
|
|
@ext_filename += (I18n.t("vm_inviting.start_end") + ": #{start_date}~") if @ext_filename.blank?
|
|
|
|
@invitings = @invitings.where(:start_date.gte=>start_date).page(params[:page]).per(10)
|
|
|
|
elsif end_date != 0
|
|
|
|
@ext_filename += (I18n.t("vm_inviting.start_end") + ": ~#{end_date}") if @ext_filename.blank?
|
|
|
|
@invitings = @invitings.where(:end_date.lte=>end_date).page(params[:page]).per(10)
|
2020-10-27 02:41:08 +00:00
|
|
|
end
|
2020-11-03 03:03:27 +00:00
|
|
|
if params[:id].present?
|
|
|
|
@ext_filename = "#{VenueManagementMain.find(params[:id]).title rescue ''}_export_invitings" if @ext_filename.blank?
|
|
|
|
@invitings = @invitings.where(:venue_management_main_id=>params[:id])
|
|
|
|
end
|
|
|
|
if params[:keywords].present?
|
2020-11-23 11:58:55 +00:00
|
|
|
@invitings = @invitings.page(nil).per(@invitings.count)
|
2020-11-03 03:03:27 +00:00
|
|
|
@main_ids = @invitings.pluck(:venue_management_main_id)
|
|
|
|
@venue_managements = VenueManagementMain.where(:id.in=>@main_ids)
|
|
|
|
@main_ids = search_data(@venue_managements,[:title]).pluck(:id)
|
|
|
|
if params[:keywords] == I18n.t(:empty)
|
|
|
|
@invitings = @invitings.where(:case_no=>"")
|
|
|
|
else
|
|
|
|
@invitings = search_data(@invitings,[:case_no])
|
|
|
|
end
|
|
|
|
ids = @invitings.pluck(:id)
|
|
|
|
ids1 = VenueManagementInviting.where(:venue_management_main_id.in=>@main_ids).pluck(:id)
|
|
|
|
@invitings = VenueManagementInviting.where(:id.in=>(ids + ids1)).page(params[:page]).per(10)
|
2020-08-09 02:50:11 +00:00
|
|
|
end
|
2020-07-27 16:34:33 +00:00
|
|
|
end
|
|
|
|
def new
|
|
|
|
@venue_management = VenueManagementMain.find(params[:id])
|
|
|
|
@venue_management_inviting = @venue_management.venue_management_invitings.build
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@venue_management_inviting = VenueManagementInviting.new(venue_management_inviting_params)
|
|
|
|
@venue_management_inviting.save
|
|
|
|
|
|
|
|
redirect_to params['referer_url']
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@venue_management = VenueManagementMain.find(@venue_management_inviting.venue_management_main_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@venue_management_inviting.update_attributes(venue_management_inviting_params)
|
|
|
|
|
|
|
|
redirect_to venue_management_invitings_admin_venue_management_path(@venue_management_inviting.venue_management_main_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@venue_management_main_id = @venue_management_inviting.venue_management_main_id
|
|
|
|
@venue_management_inviting.destroy
|
|
|
|
|
|
|
|
redirect_to venue_management_invitings_admin_venue_management_path(@venue_management_main_id)
|
|
|
|
end
|
2020-10-27 02:41:08 +00:00
|
|
|
def render_html(code,pass_variables={})
|
|
|
|
render_to_string(:inline=>code,:locals=>pass_variables)
|
|
|
|
end
|
|
|
|
def export
|
2020-11-03 03:03:27 +00:00
|
|
|
filter_inviting
|
2020-10-27 02:41:08 +00:00
|
|
|
@invitings = @invitings.page(1).per(@invitings.count)
|
|
|
|
@protocol = (request.referer.blank? ? "http" : URI(request.referer).scheme)
|
|
|
|
@host = "#{@protocol}://#{request.host_with_port}"
|
|
|
|
@site_in_use_locales = Site.first.in_use_locales
|
2020-11-03 03:03:27 +00:00
|
|
|
@ext_filename = "export_invitings" if @ext_filename.blank?
|
|
|
|
@ext_filename = @ext_filename + "_export.xlsx"
|
2020-10-27 02:41:08 +00:00
|
|
|
@id = params[:id]
|
|
|
|
respond_to do |format|
|
|
|
|
format.xlsx {
|
|
|
|
response.headers['Content-Transfer-Encoding'] = 'binary'
|
|
|
|
response.headers['Content-Type'] = 'binary/octet-stream'
|
2020-11-03 03:03:27 +00:00
|
|
|
response.headers['Content-Disposition'] = 'attachment; filename="' + @ext_filename + '"'
|
2020-10-27 02:41:08 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
render :layout => false
|
|
|
|
end
|
2020-07-27 16:34:33 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def set_venue_management_inviting
|
|
|
|
@venue_management_inviting = VenueManagementInviting.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def venue_management_inviting_params
|
2020-08-09 13:47:41 +00:00
|
|
|
inviting_params = params.require(:venue_management_inviting).permit!
|
|
|
|
inviting_params["tags"] = [] if inviting_params["tags"].nil?
|
|
|
|
return inviting_params
|
2020-07-27 16:34:33 +00:00
|
|
|
end
|
|
|
|
end
|