diff --git a/app/controllers/admin/venue_management_bills_controller.rb b/app/controllers/admin/venue_management_bills_controller.rb index 70172d7..b4c0483 100644 --- a/app/controllers/admin/venue_management_bills_controller.rb +++ b/app/controllers/admin/venue_management_bills_controller.rb @@ -49,14 +49,31 @@ class Admin::VenueManagementBillsController < Admin::VenueAdminController (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')) %>") + '') + filter_bill + @venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue "" + if request.xhr? + render :partial => 'index' + end + end + + def filter_bill + if defined?(params).blank? + params = @params + end + @ext_filename = "" + @bills = nil + @categories = @module_app.categories.enabled + @filter_fields = filter_fields(@categories) filter_tags = params[:filters]["type"].to_a rescue [] @main_ids = nil if !filter_tags.blank? + @ext_filename += (I18n.t("vm_inviting.type") + ": #{Tag.where(:id.in=>filter_tags).map{|t| t.name}.join(',')}") @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? + @ext_filename += (I18n.t(:category) + ": #{Category.where(:id.in=>filters("category")).map{|t| t.title}.join(',')}") if @ext_filename.blank? @main_ids = VenueManagementMain.all.with_categories(filters("category")).pluck(:id) end if ( !params[:filters]["bill_typeA"].blank? rescue false) @@ -69,18 +86,24 @@ class Admin::VenueManagementBillsController < Admin::VenueAdminController end if @bills.nil? if accounting_month_start != 0 && accounting_month_end != 0 + @ext_filename += (I18n.t("vm_bill.accounting_month") + ": #{accounting_month_start}~#{accounting_month_end}") if @ext_filename.blank? @bills = VenueManagementBill.where(:accounting_month.gte=>accounting_month_start,:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10) elsif accounting_month_start != 0 + @ext_filename += (I18n.t("vm_bill.accounting_month") + ": #{accounting_month_start}~") if @ext_filename.blank? @bills = VenueManagementBill.where(:accounting_month.gte=>accounting_month_start).page(params[:page]).per(10) elsif accounting_month_end != 0 + @ext_filename += (I18n.t("vm_bill.accounting_month") + ": ~#{accounting_month_end}") if @ext_filename.blank? @bills = VenueManagementBill.where(:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10) end else 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) + @ext_filename += (I18n.t("vm_bill.accounting_month") + ": #{accounting_month_start}~#{accounting_month_end}") if @ext_filename.blank? + @bills = @bills.where(:accounting_month.gt=>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) + @ext_filename += (I18n.t("vm_bill.accounting_month") + ": #{accounting_month_start}~") if @ext_filename.blank? + @bills = @bills.where(:accounting_month.gt=>accounting_month_start).page(params[:page]).per(10) elsif accounting_month_end != 0 + @ext_filename += (I18n.t("vm_bill.accounting_month") + ": ~#{accounting_month_end}") if @ext_filename.blank? @bills = @bills.where(:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10) end end @@ -91,12 +114,24 @@ class Admin::VenueManagementBillsController < Admin::VenueAdminController @bills = @bills.where(:venue_management_main_id.in=>@main_ids).page(params[:page]).per(10) end end - if @bills.nil? + if @bills.nil? && params[:id].blank? @bills = VenueManagementBill.all.page(params[:page]).per(10) + elsif @bills.nil? + @bills = VenueManagementBill.where(:venue_management_main_id=>params[:id]) + elsif !params[:id].blank? + @bills = @bills.where(:venue_management_main_id=>params[:id]) end - @venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue "" - if request.xhr? - render '_index' + if params[:keywords].present? + @main_ids = @bills.pluck(:venue_management_main_id) + @venue_managements = VenueManagementMain.where(:id.in=>@main_ids) + if params[:keywords] == I18n.t(:empty) + ids = @bills.map{|bill| ((bill.contractor.display_contractors.blank?) rescue true) ? bill.id : nil } + else + ids = @bills.map{|bill| (bill.contractor.display_contractors.include?(params[:keywords]) rescue false) ? bill.id : nil } + end + @main_ids = search_data(@venue_managements,[:title]).pluck(:id) + ids1 = VenueManagementBill.where(:venue_management_main_id.in=>@main_ids).pluck(:id) + @bills = VenueManagementBill.where(:id.in=>(ids + ids1)).page(params[:page]).per(10) end end @@ -147,83 +182,23 @@ class Admin::VenueManagementBillsController < Admin::VenueAdminController render_to_string(:inline=>code,:locals=>pass_variables) end def export - filename = "" - @bills = nil - @categories = @module_app.categories.enabled - @filter_fields = filter_fields(@categories) - filter_tags = params[:filters]["type"].to_a rescue [] - @main_ids = nil - if !filter_tags.blank? - filename += (I18n.t("vm_inviting.type") + ": #{Tag.where(:id.in=>filter_tags).map{|t| t.name}.join(',')}") - @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? - filename += (I18n.t(:category) + ": #{Category.where(:id.in=>filters("category")).map{|t| t.title}.join(',')}") if filename.blank? - @main_ids = VenueManagementMain.all.with_categories(filters("category")).pluck(:id) - end - if ( !params[:filters]["bill_typeA"].blank? rescue false) - @bills = VenueManagementBill.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 @bills.nil? - if accounting_month_start != 0 && accounting_month_end != 0 - filename += (I18n.t("vm_bill.accounting_month") + ": #{accounting_month_start}~#{accounting_month_end}") if filename.blank? - @bills = VenueManagementBill.where(:accounting_month.gte=>accounting_month_start,:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10) - elsif accounting_month_start != 0 - filename += (I18n.t("vm_bill.accounting_month") + ": #{accounting_month_start}~") if filename.blank? - @bills = VenueManagementBill.where(:accounting_month.gte=>accounting_month_start).page(params[:page]).per(10) - elsif accounting_month_end != 0 - filename += (I18n.t("vm_bill.accounting_month") + ": ~#{accounting_month_end}") if filename.blank? - @bills = VenueManagementBill.where(:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10) - end - else - if accounting_month_start != 0 && accounting_month_end != 0 - filename += (I18n.t("vm_bill.accounting_month") + ": #{accounting_month_start}~#{accounting_month_end}") if filename.blank? - @bills = @bills.where(:accounting_month.gt=>accounting_month_start,:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10) - elsif accounting_month_start != 0 - filename += (I18n.t("vm_bill.accounting_month") + ": #{accounting_month_start}~") if filename.blank? - @bills = @bills.where(:accounting_month.gt=>accounting_month_start).page(params[:page]).per(10) - elsif accounting_month_end != 0 - filename += (I18n.t("vm_bill.accounting_month") + ": ~#{accounting_month_end}") if filename.blank? - @bills = @bills.where(:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10) - end - end - if !@main_ids.nil? - if @bills.nil? - @bills = VenueManagementBill.where(:venue_management_main_id.in=>@main_ids).page(params[:page]).per(10) - else - @bills = @bills.where(:venue_management_main_id.in=>@main_ids).page(params[:page]).per(10) - end - end - if @bills.nil? && params[:id].blank? - @bills = VenueManagementBill.all.page(params[:page]).per(10) - elsif @bills.nil? - @bills = VenueManagementBill.where(:venue_management_main_id=>params[:id]) - elsif !params[:id].blank? - @bills = @bills.where(:venue_management_main_id=>params[:id]) - end + filter_bill @bills = @bills.page(1).per(@bills.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 - filename = "export_bills" if filename.blank? - filename = filename + "_export.xlsx" + @ext_filename = "export_bills" if @ext_filename.blank? + @ext_filename = @ext_filename + "_export.xlsx" @id = params[:id] respond_to do |format| format.xlsx { response.headers['Content-Transfer-Encoding'] = 'binary' response.headers['Content-Type'] = 'binary/octet-stream' - response.headers['Content-Disposition'] = 'attachment; filename="' + filename + '"' + response.headers['Content-Disposition'] = 'attachment; filename="' + @ext_filename + '"' } end render :layout => false - # file_path = "tmp/cache/#{filename}" + # file_path = "tmp/cache/#{@ext_filename}" # File.open(file_path, 'w') do |f| # f.write render_to_string( handlers: [:axlsx], formats: [:xlsx] ,locals: {:@bills=>@bills,:@protocol=>@protocol,:@host=>@host,:@site_in_use_locales=>@site_in_use_locales}, :layout=>false ) # end diff --git a/app/controllers/admin/venue_management_contracts_controller.rb b/app/controllers/admin/venue_management_contracts_controller.rb index 083ff7c..bff17c0 100644 --- a/app/controllers/admin/venue_management_contracts_controller.rb +++ b/app/controllers/admin/venue_management_contracts_controller.rb @@ -48,31 +48,47 @@ class Admin::VenueManagementContractsController < Admin::VenueAdminController (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')) %>") + '') + filter_contract + @venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue "" + if request.xhr? + render :partial => 'index' + end + end + def filter_contract + @ext_filename = "" filter_tags = params[:filters]["type"].to_a rescue [] @main_ids = nil @inviting_ids = nil if !filter_tags.blank? + @ext_filename += (I18n.t("vm_bill.type") + ": #{Tag.where(:id.in=>filter_tags).map{|t| t.name}.join(',')}") @inviting_ids = VenueManagementInviting.with_tags(filter_tags).pluck(:id) end if !filters("category").blank? + @ext_filename += (I18n.t(:category) + ": #{Category.where(:id.in=>filters("category")).map{|t| t.title}.join(',')}") if @ext_filename.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 + @ext_filename += (I18n.t("vm_bill.accounting_month") + ": #{contract_start_date}~#{contract_end_date}") if @ext_filename.blank? @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 + @ext_filename += (I18n.t("vm_bill.accounting_month") + ": #{contract_start_date}~") if @ext_filename.blank? @contracts = VenueManagementContract.where(:contract_start_date.gte=>contract_start_date).page(params[:page]).per(10) elsif contract_end_date != 0 + @ext_filename += (I18n.t("vm_bill.accounting_month") + ": ~#{contract_end_date}") if @ext_filename.blank? @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 + @ext_filename += (I18n.t("vm_bill.accounting_month") + ": #{contract_start_date}~#{contract_end_date}") if @ext_filename.blank? @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 + @ext_filename += (I18n.t("vm_bill.accounting_month") + ": #{contract_start_date}~") if @ext_filename.blank? @contracts = @contracts.where(:contract_start_date.gte=>contract_start_date).page(params[:page]).per(10) elsif contract_end_date != 0 + @ext_filename += (I18n.t("vm_bill.accounting_month") + ": ~#{contract_end_date}") if @ext_filename.blank? @contracts = @contracts.where(:contract_end_date.lte=>contract_end_date).page(params[:page]).per(10) end end @@ -89,10 +105,25 @@ class Admin::VenueManagementContractsController < Admin::VenueAdminController if !@inviting_ids.nil? @contracts = @contracts.where(:venue_management_inviting_id.in=>@inviting_ids) end + if params[:id].present? + @ext_filename = "#{VenueManagementMain.find(params[:id]).title rescue ''}_export_invitings" if @ext_filename.blank? + @contracts = @contracts.and(:venue_management_main_id=>params[:id]) + end + if params[:keywords].present? + @main_ids = @contracts.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) + @contracts = @contracts.where(:case_no=>"") + else + @contracts = search_data(@contracts,[:case_no]) + end + ids = @contracts.pluck(:id) + ids1 = VenueManagementContract.where(:venue_management_main_id.in=>@main_ids).pluck(:id) + @contracts = VenueManagementContract.where(:id.in=>(ids + ids1)).page(params[:page]).per(10) + end @contracts = @contracts.order(updated_at: :desc).page(params[:page]).per(10) - @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 @@ -127,72 +158,19 @@ class Admin::VenueManagementContractsController < Admin::VenueAdminController redirect_to venue_management_contracts_admin_venue_management_path(@venue_management_main_id) end def export - filename = "" - filter_tags = params[:filters]["type"].to_a rescue [] - @main_ids = nil - @inviting_ids = nil - if !filter_tags.blank? - filename += (I18n.t("vm_bill.type") + ": #{Tag.where(:id.in=>filter_tags).map{|t| t.name}.join(',')}") - @inviting_ids = VenueManagementInviting.with_tags(filter_tags).pluck(:id) - end - if !filters("category").blank? - filename += (I18n.t(:category) + ": #{Category.where(:id.in=>filters("category")).map{|t| t.title}.join(',')}") if filename.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 - filename += (I18n.t("vm_bill.accounting_month") + ": #{contract_start_date}~#{contract_end_date}") if filename.blank? - @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 - filename += (I18n.t("vm_bill.accounting_month") + ": #{contract_start_date}~") if filename.blank? - @contracts = VenueManagementContract.where(:contract_start_date.gte=>contract_start_date).page(params[:page]).per(10) - elsif contract_end_date != 0 - filename += (I18n.t("vm_bill.accounting_month") + ": ~#{contract_end_date}") if filename.blank? - @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 - filename += (I18n.t("vm_bill.accounting_month") + ": #{contract_start_date}~#{contract_end_date}") if filename.blank? - @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 - filename += (I18n.t("vm_bill.accounting_month") + ": #{contract_start_date}~") if filename.blank? - @contracts = @contracts.where(:contract_start_date.gte=>contract_start_date).page(params[:page]).per(10) - elsif contract_end_date != 0 - filename += (I18n.t("vm_bill.accounting_month") + ": ~#{contract_end_date}") if filename.blank? - @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.where(: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 - if params[:id].present? - filename = "#{VenueManagementMain.find(params[:id]).title rescue ''}_export_invitings" if filename.blank? - @contracts = @contracts.and(:venue_management_main_id=>params[:id]) - end + filter_contract @contracts = @contracts.order(updated_at: :desc).page(1).per(@contracts.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 - filename = "export_contracts" if filename.blank? - filename = filename + "_export.xlsx" + @ext_filename = "export_contracts" if @ext_filename.blank? + @ext_filename = @ext_filename + "_export.xlsx" @id = params[:id] respond_to do |format| format.xlsx { response.headers['Content-Transfer-Encoding'] = 'binary' response.headers['Content-Type'] = 'binary/octet-stream' - response.headers['Content-Disposition'] = 'attachment; filename="' + filename + '"' + response.headers['Content-Disposition'] = 'attachment; filename="' + @ext_filename + '"' } end render :layout => false diff --git a/app/controllers/admin/venue_management_invitings_controller.rb b/app/controllers/admin/venue_management_invitings_controller.rb index 16fcd4a..2a2ef4b 100644 --- a/app/controllers/admin/venue_management_invitings_controller.rb +++ b/app/controllers/admin/venue_management_invitings_controller.rb @@ -33,33 +33,48 @@ class Admin::VenueManagementInvitingsController < Admin::VenueAdminController (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')) %>") + '') - filter_tags = params[:filters]["type"].to_a rescue [] - start_date = DateTime.parse(params[:filters]["start_date"]) rescue 0 - end_date = DateTime.parse(params[:filters]["end_date"]) rescue 0 - @invitings = VenueManagementInviting.with_tags(filter_tags).order(updated_at: :desc).page(params[:page]).per(10) - 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 + 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 = "" + filter_tags = params[:filters]["type"].to_a rescue [] + start_date = DateTime.parse(params[:filters]["start_date"]) rescue 0 + end_date = DateTime.parse(params[:filters]["end_date"]) rescue 0 + @invitings = VenueManagementInviting.with_tags(filter_tags).order(updated_at: :desc).page(params[:page]).per(10) + @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) + end + 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? + @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) + end + end def new @venue_management = VenueManagementMain.find(params[:id]) @venue_management_inviting = @venue_management.venue_management_invitings.build @@ -92,38 +107,19 @@ class Admin::VenueManagementInvitingsController < Admin::VenueAdminController render_to_string(:inline=>code,:locals=>pass_variables) end def export - filename = "" - filter_tags = params[:filters]["type"].to_a rescue [] - start_date = DateTime.parse(params[:filters]["start_date"]) rescue 0 - end_date = DateTime.parse(params[:filters]["end_date"]) rescue 0 - @invitings = VenueManagementInviting.with_tags(filter_tags).order(updated_at: :desc).page(params[:page]).per(10) - 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 - filename += (I18n.t("vm_inviting.start_end") + ": #{start_date}~#{end_date}") if filename.blank? - @invitings = @invitings.where(:start_date.gte=>start_date,:end_date.lte=>end_date).page(params[:page]).per(10) - elsif start_date != 0 - filename += (I18n.t("vm_inviting.start_end") + ": #{start_date}~") if filename.blank? - @invitings = @invitings.where(:start_date.gte=>start_date).page(params[:page]).per(10) - elsif end_date != 0 - filename += (I18n.t("vm_inviting.start_end") + ": ~#{end_date}") if filename.blank? - @invitings = @invitings.where(:end_date.lte=>end_date).page(params[:page]).per(10) - end - if params[:id].present? - filename = "#{VenueManagementMain.find(params[:id]).title rescue ''}_export_invitings" if filename.blank? - @invitings = @invitings.where(:venue_management_main_id=>params[:id]) - end + filter_inviting @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 - filename = "export_invitings" if filename.blank? - filename = filename + "_export.xlsx" + @ext_filename = "export_invitings" if @ext_filename.blank? + @ext_filename = @ext_filename + "_export.xlsx" @id = params[:id] respond_to do |format| format.xlsx { response.headers['Content-Transfer-Encoding'] = 'binary' response.headers['Content-Type'] = 'binary/octet-stream' - response.headers['Content-Disposition'] = 'attachment; filename="' + filename + '"' + response.headers['Content-Disposition'] = 'attachment; filename="' + @ext_filename + '"' } end render :layout => false diff --git a/app/controllers/admin/venue_management_memorabilias_controller.rb b/app/controllers/admin/venue_management_memorabilias_controller.rb index 39a1d72..c88cdf4 100644 --- a/app/controllers/admin/venue_management_memorabilias_controller.rb +++ b/app/controllers/admin/venue_management_memorabilias_controller.rb @@ -15,10 +15,32 @@ class Admin::VenueManagementMemorabiliasController < Admin::VenueAdminController 'vm_memorabilia.event_date', 'vm_memorabilia.details', ] - @memorabilias = VenueManagementMemorabilia.order(updated_at: :desc).page(params[:page]).per(10) + filter_memorabilia + @memorabilias = @memorabilias.order(updated_at: :desc).page(params[:page]).per(10) @venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue "" + if request.xhr? + render :partial => 'index' + end + end + def filter_memorabilia + @memorabilias = VenueManagementMemorabilia.all + @filter_fields = {} + if params[:keywords].present? + @main_ids = @memorabilias.pluck(:venue_management_main_id) + @invintings = VenueManagementInviting.where(:id.in => VenueManagementMemorabilia.all.pluck(:venue_management_inviting_id)) + @venue_managements = VenueManagementMain.where(:id.in=>@main_ids) + @main_ids = search_data(@venue_managements,[:title]).pluck(:id) + if params[:keywords] == I18n.t(:empty) + @invintings = @invintings.where(:case_no=>"") + else + @invintings = search_data(@invintings,[:case_no]) + end + ids = VenueManagementMemorabilia.where(:venue_management_inviting_id.in=>@invintings.pluck(:id)).pluck(:id) + ids1 = VenueManagementMemorabilia.where(:venue_management_main_id.in=>@main_ids).pluck(:id) + ids2 = VenueManagementMemorabilia.where(:venue_management_inviting_id =>nil ).pluck(:id) + @memorabilias = VenueManagementMemorabilia.where(:id.in=>(ids + ids1 + ids2)) + end end - def new @venue_management = VenueManagementMain.find(params[:id]) @venue_management_memorabilia = VenueManagementMemorabilia.new(venue_management_main_id: params[:id]) diff --git a/app/controllers/admin/venue_managements_controller.rb b/app/controllers/admin/venue_managements_controller.rb index c6b1b8f..300ea56 100644 --- a/app/controllers/admin/venue_managements_controller.rb +++ b/app/controllers/admin/venue_managements_controller.rb @@ -356,6 +356,7 @@ class Admin::VenueManagementsController < Admin::VenueAdminController 'vm_memorabilia.event_date', 'vm_memorabilia.details', ] + @filter_fields = {} @memorabilias = @venue_management.venue_management_memorabilias.page(params[:page]).per(10) @venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue "" end @@ -422,7 +423,7 @@ class Admin::VenueManagementsController < Admin::VenueAdminController end @venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue "" if request.xhr? - render 'admin/venue_management_bills/_index' + render :partial=> 'admin/venue_management_bills/index' end end def venue_management_contracts @@ -492,6 +493,9 @@ class Admin::VenueManagementsController < Admin::VenueAdminController @contracts = @contracts.order(updated_at: :desc) @venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue "" + if request.xhr? + render :partial=> 'admin/venue_management_contracts/index' + end end def render_html(code,pass_variables={}) render_to_string(:inline=>code,:locals=>pass_variables) diff --git a/app/views/admin/venue_management_bills/index.html.erb b/app/views/admin/venue_management_bills/index.html.erb index 5562654..d15e963 100644 --- a/app/views/admin/venue_management_bills/index.html.erb +++ b/app/views/admin/venue_management_bills/index.html.erb @@ -1,6 +1,4 @@ -
+<%= render_filter @filter_fields, "index_table" %> <%= render 'index' %> diff --git a/app/views/admin/venue_management_memorabilias/index.html.erb b/app/views/admin/venue_management_memorabilias/index.html.erb index be82942..858109c 100644 --- a/app/views/admin/venue_management_memorabilias/index.html.erb +++ b/app/views/admin/venue_management_memorabilias/index.html.erb @@ -1,4 +1,9 @@ +<%= render_filter @filter_fields, "index_table" %> <%= render 'index' %> <%= render 'layouts/delete_modal', delete_options: @delete_options %> + diff --git a/app/views/admin/venue_managements/export.xlsx.axlsx b/app/views/admin/venue_managements/export.xlsx.axlsx index 41f3f8b..bdaa812 100644 --- a/app/views/admin/venue_managements/export.xlsx.axlsx +++ b/app/views/admin/venue_managements/export.xlsx.axlsx @@ -3,7 +3,9 @@ wb = xlsx_package.workbook wb.add_worksheet(name: t('restful_actions.venue_management_contracts')) do |sheet| - row = [t('vm_contract.case_no')] + row = [] + row << t('venue_management.title') if @id.blank? + row << t('vm_contract.case_no') row << t('vm_inviting.type') row << t('venue_management.contractor') row << t('vm_inviting.rents') @@ -42,6 +44,7 @@ wb.add_worksheet(name: t('restful_actions.venue_management_contracts')) do |shee sheet.add_row row @venue_management.venue_management_contracts.each do |contract| row2 = [] + row2 << contract.venue_management_main.title if @id.blank? row2 << contract.case_no row2 << contract.display_tags row2 << contract.display_contractors @@ -85,6 +88,7 @@ wb.add_worksheet(name: t('restful_actions.venue_management_contracts')) do |shee end wb.add_worksheet(name: t('restful_actions.venue_management_invitings')) do |sheet| row = [] + row << t('venue_management.title') if @id.blank? row << t('vm_inviting.type') row << t('vm_inviting.case_no') row << t('vm_inviting.publish_times') @@ -110,6 +114,7 @@ wb.add_worksheet(name: t('restful_actions.venue_management_invitings')) do |shee sheet.add_row row @venue_management.venue_management_invitings.each do |inviting| row2 = [] + row2 << inviting.venue_management_main.title if @id.blank? row2 << inviting.tags.map{|t| t.name}.join(" , ") row2 << inviting.case_no row2 << inviting.publish_times @@ -137,6 +142,7 @@ wb.add_worksheet(name: t('restful_actions.venue_management_invitings')) do |shee end wb.add_worksheet(name: t('restful_actions.venue_management_memorabilias')) do |sheet| row = [] + row << t('venue_management.title') if @id.blank? row << t('vm_memorabilia.case_no') row << t('vm_memorabilia.event_date') @site_in_use_locales.each do |locale| @@ -156,6 +162,7 @@ wb.add_worksheet(name: t('restful_actions.venue_management_memorabilias')) do |s sheet.add_row row @venue_management.venue_management_memorabilias.each do |memorabilia| row2 = [] + row2 << memorabilia.venue_management_main.title if @id.blank? row2 << memorabilia.case_no row2 << memorabilia.event_date @site_in_use_locales.each do |locale| @@ -175,4 +182,43 @@ wb.add_worksheet(name: t('restful_actions.venue_management_memorabilias')) do |s sheet.add_row row2 end end +wb.add_worksheet(name: t('restful_actions.venue_management_bills')) do |sheet| + row = [] + row << t('venue_management.title') if @id.blank? + row << t('venue_management.contractor') + row << t('vm_bill.accounting_month') + row << t('vm_bill.bill_type') + row << t('vm_bill.caculation_basis') + row << t('vm_bill.total_amount') + row << t('vm_bill.pay_date') + row << t('vm_bill.reason') + row << t('vm_bill.pay_method') + row << t('vm_bill.note') + row << t("link") + row << t("link") + " " + t("url_alt") + row << t("file_") + row << t("file_") + " " + t("description") + row << t("file_") + " " + t("alternative") + sheet.add_row row + @venue_management.venue_management_bills.each do |bill| + row2 = [] + row2 << bill.venue_management_main.title if @id.blank? + row2 << (bill.contractor.display_contractors rescue "") + row2 << bill.display_accounting_month + row2 << "#{t("vm_bill.#{bill.bill_typeA}")}/#{t("vm_bill.#{bill.bill_typeB}")}" + row2 << bill.display_caculation_basis + row2 << bill.total_amount + row2 << bill.pay_date + row2 << bill.reason + row2 << bill.pay_method + row2 << bill.note + row2 << bill.venue_management_links.map{|l| l.url.to_s.strip}.join(";") + row2 << bill.venue_management_links.map{|l| l.title.to_s.strip}.join(";") + row2 << bill.venue_management_files.map{|f| @host + f.file.url rescue nil}.select{|s| !s.nil?}.join(";") + row2 << bill.venue_management_files.map{|f| f.description.to_s.strip}.join(";") + row2 << bill.venue_management_files.map{|f| f.title.to_s.strip}.join(";") + sheet.add_row row2 + end + +end \ No newline at end of file diff --git a/app/views/admin/venue_managements/venue_management_memorabilias.html.erb b/app/views/admin/venue_managements/venue_management_memorabilias.html.erb index 52ddb0e..51fc798 100644 --- a/app/views/admin/venue_managements/venue_management_memorabilias.html.erb +++ b/app/views/admin/venue_managements/venue_management_memorabilias.html.erb @@ -1,5 +1,10 @@ +<%= render_filter @filter_fields, "index_table" %> <%= render 'admin/venue_management_memorabilias/index' %> <%= render 'layouts/delete_modal', delete_options: @delete_options %> + \ No newline at end of file