Fix bugs.

This commit is contained in:
BoHung Chiu 2020-11-23 19:58:12 +08:00
parent 8a4dd5b253
commit 3195214d08
4 changed files with 20 additions and 10 deletions

View File

@ -110,17 +110,25 @@ class Admin::VenueManagementContractsController < Admin::VenueAdminController
@contracts = @contracts.and(:venue_management_main_id=>params[:id])
end
if params[:keywords].present?
@contracts = @contracts.page(nil).per(@contracts.count)
@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)
ids = []
if params[:keywords] == I18n.t(:empty)
@contracts = @contracts.where(:case_no=>"")
ids = @contracts.where(:case_no.in=>["",nil]).pluck(:id)
else
@contracts = search_data(@contracts,[:case_no])
ids = search_data(@contracts,[:case_no]).pluck(:id)
end
ids2 = [] #ids for search contractors
if params[:keywords] == I18n.t(:empty)
ids2 = @contracts.map{|contract| ((contract.display_contractors.blank?) rescue true) ? contract.id : nil }
else
ids2 = @contracts.map{|contract| (contract.display_contractors.include?(params[:keywords]) rescue false) ? contract.id : nil }
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)
@contracts = VenueManagementContract.where(:id.in=>(ids + ids1 + ids2)).page(params[:page]).per(10)
#render :html => ids and return
end
@contracts = @contracts.order(updated_at: :desc).page(params[:page]).per(10)
end

View File

@ -62,6 +62,7 @@ class Admin::VenueManagementInvitingsController < Admin::VenueAdminController
@invitings = @invitings.where(:venue_management_main_id=>params[:id])
end
if params[:keywords].present?
@invitings = @invitings.page(nil).per(@invitings.count)
@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)

View File

@ -30,14 +30,15 @@ class Admin::VenueManagementMemorabiliasController < Admin::VenueAdminController
@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)
ids2 = []
if params[:keywords] == I18n.t(:empty)
@invintings = @invintings.where(:case_no=>"")
ids2 = VenueManagementMemorabilia.where(:venue_management_inviting_id =>nil ).pluck(:id)
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

View File

@ -46,12 +46,12 @@
<div class="bottomnav clearfix">
<%= content_tag :div, class: "pagination pagination-centered" do %>
<%= paginate(@memorabilias) %>
<% end %>
<% if can_edit_or_delete?(@venue_management) %>
<div class="action pull-right">
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), new_admin_venue_management_memorabilia_path(id: @venue_management.id), class: "btn btn-primary" %>
</div>
<% end %>
<% end %>
</div>
<!-- footer:end -->
<% end %>