From bd1d8f5c5c40a9f5d0f0537dc89a6e98f21fdf2d Mon Sep 17 00:00:00 2001 From: bohung Date: Tue, 27 Oct 2020 12:44:10 +0800 Subject: [PATCH] Fix bug. --- .../venue_management_bills_controller.rb | 10 ++++---- .../venue_management_contracts_controller.rb | 4 ++-- .../venue_management_invitings_controller.rb | 4 ++-- .../admin/venue_managements_controller.rb | 16 ++++++------- .../venue_management_bills/export.xlsx.axlsx | 24 +++++-------------- .../venue_management_bills/index.html.erb | 8 ++++++- .../venue_management_contracts/index.html.erb | 4 ++++ .../venue_management_invitings/index.html.erb | 4 ++++ .../venue_management_bills.html.erb | 6 +++++ .../venue_management_contracts.html.erb | 4 ++++ .../venue_management_invitings.html.erb | 4 ++++ 11 files changed, 52 insertions(+), 36 deletions(-) diff --git a/app/controllers/admin/venue_management_bills_controller.rb b/app/controllers/admin/venue_management_bills_controller.rb index f875f9d..70172d7 100644 --- a/app/controllers/admin/venue_management_bills_controller.rb +++ b/app/controllers/admin/venue_management_bills_controller.rb @@ -34,21 +34,21 @@ class Admin::VenueManagementBillsController < Admin::VenueAdminController @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 = "
" + bill_type_select_str = "
" 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 \'\'}).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 += "
" + bill_type_select_str += "
" @filter_fields['vm_bill.bill_type'] = bill_type_select_str - @filter_fields['vm_bill.accounting_month'] = ('
'+ + @filter_fields['vm_bill.accounting_month'] = ('
'+ (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)}) %>')) + "
~
" + (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_tags = params[:filters]["type"].to_a rescue [] @main_ids = nil if !filter_tags.blank? @@ -205,7 +205,7 @@ class Admin::VenueManagementBillsController < Admin::VenueAdminController @bills = VenueManagementBill.all.page(params[:page]).per(10) elsif @bills.nil? @bills = VenueManagementBill.where(:venue_management_main_id=>params[:id]) - else + elsif !params[:id].blank? @bills = @bills.where(:venue_management_main_id=>params[:id]) end @bills = @bills.page(1).per(@bills.count) diff --git a/app/controllers/admin/venue_management_contracts_controller.rb b/app/controllers/admin/venue_management_contracts_controller.rb index dfdb931..083ff7c 100644 --- a/app/controllers/admin/venue_management_contracts_controller.rb +++ b/app/controllers/admin/venue_management_contracts_controller.rb @@ -42,12 +42,12 @@ class Admin::VenueManagementContractsController < Admin::VenueAdminController @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'] = ('
'+ + @filter_fields['vm_contract.start_end'] = ('
'+ (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)}) %>')) + "
~
" + (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_tags = params[:filters]["type"].to_a rescue [] @main_ids = nil @inviting_ids = nil diff --git a/app/controllers/admin/venue_management_invitings_controller.rb b/app/controllers/admin/venue_management_invitings_controller.rb index 8e694ea..16fcd4a 100644 --- a/app/controllers/admin/venue_management_invitings_controller.rb +++ b/app/controllers/admin/venue_management_invitings_controller.rb @@ -27,12 +27,12 @@ class Admin::VenueManagementInvitingsController < Admin::VenueAdminController @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'] = ('
'+ + @filter_fields['vm_inviting.start_end'] = ('
'+ (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)}) %>')) + "
~
" + (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 diff --git a/app/controllers/admin/venue_managements_controller.rb b/app/controllers/admin/venue_managements_controller.rb index afb5b62..c6b1b8f 100644 --- a/app/controllers/admin/venue_managements_controller.rb +++ b/app/controllers/admin/venue_managements_controller.rb @@ -319,12 +319,12 @@ class Admin::VenueManagementsController < Admin::VenueAdminController @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'] = ('
'+ + @filter_fields['vm_inviting.start_end'] = ('
'+ (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)}) %>')) + "
~
" + (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')) %>") + - '
') + '
') start_date = DateTime.parse(params[:filters]["start_date"]) rescue 0 end_date = DateTime.parse(params[:filters]["end_date"]) rescue 0 if @invitings.nil? @@ -377,21 +377,21 @@ class Admin::VenueManagementsController < Admin::VenueAdminController @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 = "
" + bill_type_select_str = "
" 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 \'\'}).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 += "
" + bill_type_select_str += "
" @filter_fields['vm_bill.bill_type'] = bill_type_select_str - @filter_fields['vm_bill.accounting_month'] = ('
'+ + @filter_fields['vm_bill.accounting_month'] = ('
'+ (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)}) %>')) + "
~
" + (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_tags = params[:filters]["type"].to_a rescue [] @main_ids = nil if !filter_tags.blank? @@ -441,12 +441,12 @@ class Admin::VenueManagementsController < Admin::VenueAdminController @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'] = ('
'+ + @filter_fields['vm_contract.start_end'] = ('
'+ (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)}) %>')) + "
~
" + (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_tags = params[:filters]["type"].to_a rescue [] @main_ids = nil @inviting_ids = nil diff --git a/app/views/admin/venue_management_bills/export.xlsx.axlsx b/app/views/admin/venue_management_bills/export.xlsx.axlsx index 27c1f9f..e202a6e 100644 --- a/app/views/admin/venue_management_bills/export.xlsx.axlsx +++ b/app/views/admin/venue_management_bills/export.xlsx.axlsx @@ -15,16 +15,10 @@ wb.add_worksheet(name: t('restful_actions.venue_management_bills')) do |sheet| row << t('vm_bill.pay_method') row << t('vm_bill.note') row << t("link") - @site_in_use_locales.each do |locale| - row << t("link") + " " + t("url_alt") + " - " + t(locale) - end + row << t("link") + " " + t("url_alt") row << t("file_") - @site_in_use_locales.each do |locale| - row << t("file_") + " " + t("description") + " - " + t(locale) - end - @site_in_use_locales.each do |locale| - row << t("file_") + " " + t("alternative") + " - " + t(locale) - end + row << t("file_") + " " + t("description") + row << t("file_") + " " + t("alternative") sheet.add_row row @bills.each do |bill| row2 = [] @@ -39,16 +33,10 @@ wb.add_worksheet(name: t('restful_actions.venue_management_bills')) do |sheet| row2 << bill.pay_method row2 << bill.note row2 << bill.venue_management_links.map{|l| l.url.to_s.strip}.join(";") - @site_in_use_locales.each do |locale| - row2 << bill.venue_management_links.map{|l| l.title_translations[locale].to_s.strip}.join(";") - end + 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(";") - @site_in_use_locales.each do |locale| - row2 << bill.venue_management_files.map{|f| f.description_translations[locale].to_s.strip}.join(";") - end - @site_in_use_locales.each do |locale| - row2 << bill.venue_management_files.map{|f| f.title_translations[locale].to_s.strip}.join(";") - end + 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 diff --git a/app/views/admin/venue_management_bills/index.html.erb b/app/views/admin/venue_management_bills/index.html.erb index ce7e858..5562654 100644 --- a/app/views/admin/venue_management_bills/index.html.erb +++ b/app/views/admin/venue_management_bills/index.html.erb @@ -1,5 +1,11 @@ -<%= render_filter @filter_fields, "index_table" %> +
+ <%= render_filter @filter_fields, "index_table" %> +
<%= render 'index' %> <%= render 'layouts/delete_modal', delete_options: @delete_options %> + \ No newline at end of file diff --git a/app/views/admin/venue_management_contracts/index.html.erb b/app/views/admin/venue_management_contracts/index.html.erb index ce7e858..d15e963 100644 --- a/app/views/admin/venue_management_contracts/index.html.erb +++ b/app/views/admin/venue_management_contracts/index.html.erb @@ -3,3 +3,7 @@ <%= render 'index' %> <%= render 'layouts/delete_modal', delete_options: @delete_options %> + \ No newline at end of file diff --git a/app/views/admin/venue_management_invitings/index.html.erb b/app/views/admin/venue_management_invitings/index.html.erb index ce7e858..d15e963 100644 --- a/app/views/admin/venue_management_invitings/index.html.erb +++ b/app/views/admin/venue_management_invitings/index.html.erb @@ -3,3 +3,7 @@ <%= render 'index' %> <%= render 'layouts/delete_modal', delete_options: @delete_options %> + \ No newline at end of file diff --git a/app/views/admin/venue_managements/venue_management_bills.html.erb b/app/views/admin/venue_managements/venue_management_bills.html.erb index 92a7595..e7d58e0 100644 --- a/app/views/admin/venue_managements/venue_management_bills.html.erb +++ b/app/views/admin/venue_managements/venue_management_bills.html.erb @@ -1,6 +1,12 @@ +
<%= render_filter @filter_fields, "index_table" %> +
<%= render 'admin/venue_management_bills/index' %> <%= render 'layouts/delete_modal', delete_options: @delete_options %> + diff --git a/app/views/admin/venue_managements/venue_management_contracts.html.erb b/app/views/admin/venue_managements/venue_management_contracts.html.erb index 1b0e6d8..e218120 100644 --- a/app/views/admin/venue_managements/venue_management_contracts.html.erb +++ b/app/views/admin/venue_managements/venue_management_contracts.html.erb @@ -4,3 +4,7 @@ <%= render 'layouts/delete_modal', delete_options: @delete_options %> + \ No newline at end of file diff --git a/app/views/admin/venue_managements/venue_management_invitings.html.erb b/app/views/admin/venue_managements/venue_management_invitings.html.erb index 339e520..d6a5e9b 100644 --- a/app/views/admin/venue_managements/venue_management_invitings.html.erb +++ b/app/views/admin/venue_managements/venue_management_invitings.html.erb @@ -4,3 +4,7 @@ <%= render 'layouts/delete_modal', delete_options: @delete_options %> + \ No newline at end of file