diff --git a/app/controllers/admin/venue_management_bills_controller.rb b/app/controllers/admin/venue_management_bills_controller.rb index be5efab..f875f9d 100644 --- a/app/controllers/admin/venue_management_bills_controller.rb +++ b/app/controllers/admin/venue_management_bills_controller.rb @@ -64,19 +64,22 @@ class Admin::VenueManagementBillsController < Admin::VenueAdminController 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 - @bills = VenueManagementBill.where(:accounting_month.gt=>accounting_month_start,:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10) + @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 - @bills = VenueManagementBill.where(:accounting_month.gt=>accounting_month_start).page(params[:page]).per(10) + @bills = VenueManagementBill.where(:accounting_month.gte=>accounting_month_start).page(params[:page]).per(10) elsif accounting_month_end != 0 @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.gt=>accounting_month_start,:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10) + @bills = @bills.where(:accounting_month.gte=>accounting_month_start,:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10) elsif accounting_month_start != 0 - @bills = @bills.where(:accounting_month.gt=>accounting_month_start).page(params[:page]).per(10) + @bills = @bills.where(:accounting_month.gte=>accounting_month_start).page(params[:page]).per(10) elsif accounting_month_end != 0 @bills = @bills.where(:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10) end @@ -151,7 +154,7 @@ class Admin::VenueManagementBillsController < Admin::VenueAdminController filter_tags = params[:filters]["type"].to_a rescue [] @main_ids = nil if !filter_tags.blank? - filename += (I18n.t("vm_bill.type") + ": #{Tag.where(:id.in=>filter_tags).map{|t| t.name}.join(',')}") + 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) @@ -165,13 +168,16 @@ class Admin::VenueManagementBillsController < Admin::VenueAdminController 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.gt=>accounting_month_start,:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10) + @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.gt=>accounting_month_start).page(params[:page]).per(10) + @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) @@ -199,6 +205,8 @@ 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 + @bills = @bills.where(:venue_management_main_id=>params[:id]) end @bills = @bills.page(1).per(@bills.count) @protocol = (request.referer.blank? ? "http" : URI(request.referer).scheme) @@ -206,6 +214,7 @@ class Admin::VenueManagementBillsController < Admin::VenueAdminController @site_in_use_locales = Site.first.in_use_locales filename = "export_bills" if filename.blank? filename = filename + "_export.xlsx" + @id = params[:id] respond_to do |format| format.xlsx { response.headers['Content-Transfer-Encoding'] = 'binary' diff --git a/app/controllers/admin/venue_management_contracts_controller.rb b/app/controllers/admin/venue_management_contracts_controller.rb index 599b428..dfdb931 100644 --- a/app/controllers/admin/venue_management_contracts_controller.rb +++ b/app/controllers/admin/venue_management_contracts_controller.rb @@ -5,6 +5,11 @@ class Admin::VenueManagementContractsController < Admin::VenueAdminController before_action ->(module_app = @app_title) { set_variables module_app } before_action :set_venue_management_contract, only: [:edit, :update, :destroy] + def filter_fields(categories) + { + :category=>categories.map{|c| {:title=>(c.title.blank? ? " " : c.title), :id=>c.id}} + } + end def initialize super @app_title = 'venue_management' @@ -29,13 +34,69 @@ class Admin::VenueManagementContractsController < Admin::VenueAdminController 'vm_inviting.rents', 'vm_inviting.royalty', 'vm_contract.start_end', + 'vm_contract.deposit_amount_type_exp_date', 'vm_contract.renewal_permission', - 'vm_contract.note', + 'vm_contract.other_commitment', + 'vm_contract.note' ] - @contracts = VenueManagementContract.order(updated_at: :desc).page(params[:page]).per(10) + @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'] = ('
'+ + (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 + 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.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 + @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 + def new @venue_management = VenueManagementMain.find(params[:id]) @venue_management_contract = @venue_management.venue_management_contracts.build @@ -65,7 +126,77 @@ 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 + @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" + @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 + '"' + } + end + render :layout => false + end private def set_venue_management_contract diff --git a/app/controllers/admin/venue_management_invitings_controller.rb b/app/controllers/admin/venue_management_invitings_controller.rb index db9bc69..8e694ea 100644 --- a/app/controllers/admin/venue_management_invitings_controller.rb +++ b/app/controllers/admin/venue_management_invitings_controller.rb @@ -22,12 +22,38 @@ class Admin::VenueManagementInvitingsController < Admin::VenueAdminController 'vm_inviting.house_land_tax_payer', 'vm_inviting.contractor_manager', 'vm_inviting.bid_result', + 'vm_inviting.details' ] @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'] = ('
'+ + (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 @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 @venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue "" if request.xhr? render :partial => 'index' @@ -62,7 +88,46 @@ class Admin::VenueManagementInvitingsController < Admin::VenueAdminController redirect_to venue_management_invitings_admin_venue_management_path(@venue_management_main_id) end - + def render_html(code,pass_variables={}) + 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 + @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" + @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 + '"' + } + end + render :layout => false + end private def set_venue_management_inviting diff --git a/app/controllers/admin/venue_managements_controller.rb b/app/controllers/admin/venue_managements_controller.rb index b93fa50..afb5b62 100644 --- a/app/controllers/admin/venue_managements_controller.rb +++ b/app/controllers/admin/venue_managements_controller.rb @@ -312,12 +312,38 @@ class Admin::VenueManagementsController < Admin::VenueAdminController 'vm_inviting.house_land_tax_payer', 'vm_inviting.contractor_manager', 'vm_inviting.bid_result', + 'vm_inviting.details' ] filter_tags = params[:filters]["type"].to_a rescue [] @invitings = @venue_management.venue_management_invitings.with_tags(filter_tags).page(params[:page]).per(10) @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'] = ('
'+ + (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? + 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 @venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue "" if request.xhr? render :partial => 'admin/venue_management_invitings/index' @@ -381,10 +407,13 @@ class Admin::VenueManagementsController < Admin::VenueAdminController 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 accounting_month_start != 0 && accounting_month_end != 0 - @bills = @bills.where(:accounting_month.gt=>accounting_month_start,:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10) + @bills = @bills.where(:accounting_month.gte=>accounting_month_start,:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10) elsif accounting_month_start != 0 - @bills = @bills.where(:accounting_month.gt=>accounting_month_start).page(params[:page]).per(10) + @bills = @bills.where(:accounting_month.gte=>accounting_month_start).page(params[:page]).per(10) elsif accounting_month_end != 0 @bills = @bills.where(:accounting_month.lte=>accounting_month_end).page(params[:page]).per(10) end @@ -404,10 +433,64 @@ class Admin::VenueManagementsController < Admin::VenueAdminController 'vm_inviting.rents', 'vm_inviting.royalty', 'vm_contract.start_end', + 'vm_contract.deposit_amount_type_exp_date', 'vm_contract.renewal_permission', - 'vm_contract.note', + 'vm_contract.other_commitment', + 'vm_contract.note' ] + @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'] = ('
'+ + (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 @contracts = @venue_management.venue_management_contracts.page(params[:page]).per(10) + 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) + @venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue "" end def render_html(code,pass_variables={}) diff --git a/app/models/venue_management_bill.rb b/app/models/venue_management_bill.rb index 6f0e283..68b9741 100644 --- a/app/models/venue_management_bill.rb +++ b/app/models/venue_management_bill.rb @@ -181,6 +181,10 @@ class VenueManagementBill # venue_management_main.update(venue_management_main.venue_management_bill_ids.push(record.id)) # end # end + def display_note + html = self.note.to_s.split("\r\n").select{|s| !s.blank?}.first + return Nokogiri::HTML(html).css("body").text + end def display_caculation_basis caculation_basis_val = eval("#{self.class::CACULATIONBASIS[self.caculation_basis_type]}") return "#{I18n.t("vm_bill.#{self.class::CACULATIONBASIS[self.caculation_basis_type]}")}: #{caculation_basis_val}" diff --git a/app/models/venue_management_contract.rb b/app/models/venue_management_contract.rb index beaa164..b7e888d 100644 --- a/app/models/venue_management_contract.rb +++ b/app/models/venue_management_contract.rb @@ -62,6 +62,17 @@ class VenueManagementContract belongs_to :venue_management_main belongs_to :venue_management_inviting include VenueLinkFile + def deposit_amount_type_exp_date + return "#{self.deposit_amount}/#{self.deposit_type}/#{self.deposit_exp_date}" + end + def display_note + html = self.note.to_s.split("\r\n").select{|s| !s.blank?}.first + return Nokogiri::HTML(html).css("body").text + end + def display_other_commitment + html = self.other_commitment.to_s.split("\r\n").select{|s| !s.blank?}.first + return Nokogiri::HTML(html).css("body").text + end def display_royalty self.royalty.to_s.gsub("\r\n","
").html_safe end diff --git a/app/models/venue_management_inviting.rb b/app/models/venue_management_inviting.rb index dc5ee11..4824618 100644 --- a/app/models/venue_management_inviting.rb +++ b/app/models/venue_management_inviting.rb @@ -45,6 +45,10 @@ class VenueManagementInviting def display_case_no return (self.case_no.blank? ? I18n.t(:empty) : self.case_no) end + def display_details + html = self.details.to_s.split("\r\n").select{|s| !s.blank?}.first + return Nokogiri::HTML(html).css("body").text + end before_save do contracts = self.venue_management_contracts org_inviting = VenueManagementInviting.find(self.id) rescue nil diff --git a/app/models/venue_management_memorabilia.rb b/app/models/venue_management_memorabilia.rb index bd3fd22..befe29a 100644 --- a/app/models/venue_management_memorabilia.rb +++ b/app/models/venue_management_memorabilia.rb @@ -16,4 +16,8 @@ class VenueManagementMemorabilia belongs_to :venue_management_inviting belongs_to :venue_management_main include VenueLinkFile + def display_details + html = self.details.to_s.split("\r\n").select{|s| !s.blank?}.first + return Nokogiri::HTML(html).css("body").text + end end diff --git a/app/views/admin/venue_management_bills/_form.html.erb b/app/views/admin/venue_management_bills/_form.html.erb index 298ac0e..13b7c85 100644 --- a/app/views/admin/venue_management_bills/_form.html.erb +++ b/app/views/admin/venue_management_bills/_form.html.erb @@ -371,7 +371,7 @@ name = name.replace('venue_management_bill',''); if(name.split('[').length == 2){ name = name.replace('[','').replace(']',''); - eval.call(this,''+name+"="+Number(input.value).toString()) + window[name] = Number(input.value); }else{ var temp_arr = name.split("[").slice(1) field_name = temp_arr[0].replace(']',''); @@ -439,7 +439,7 @@ ' break;}').html_safe %> - eval.call(this,formula); + eval.call(window,formula); if($("#tax_excluded").prop("checked")){ $("#total_amount").val(Math.round(result*1.05)); $("#actual_amount").val(Math.round(result)); diff --git a/app/views/admin/venue_management_bills/_index.html.erb b/app/views/admin/venue_management_bills/_index.html.erb index 87b8917..413fe9a 100644 --- a/app/views/admin/venue_management_bills/_index.html.erb +++ b/app/views/admin/venue_management_bills/_index.html.erb @@ -46,7 +46,7 @@ <%= bill.total_amount %> <%= bill.pay_date %> <%= bill.pay_method %> - <%= bill.note %> + <%= bill.display_note %> <% end %> diff --git a/app/views/admin/venue_management_bills/export.xlsx.axlsx b/app/views/admin/venue_management_bills/export.xlsx.axlsx index 0d11f9b..27c1f9f 100644 --- a/app/views/admin/venue_management_bills/export.xlsx.axlsx +++ b/app/views/admin/venue_management_bills/export.xlsx.axlsx @@ -4,19 +4,16 @@ wb = xlsx_package.workbook 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') - @site_in_use_locales.each do |locale| - row << t('vm_bill.reason') + " - " + t(locale) - end - @site_in_use_locales.each do |locale| - row << t('vm_bill.pay_method') + " - " + t(locale) - end - @site_in_use_locales.each do |locale| - row << t('vm_bill.note') + " - " + t(locale) - end + 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") @site_in_use_locales.each do |locale| row << t("link") + " " + t("url_alt") + " - " + t(locale) @@ -31,19 +28,16 @@ wb.add_worksheet(name: t('restful_actions.venue_management_bills')) do |sheet| sheet.add_row row @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 - @site_in_use_locales.each do |locale| - row2 << bill.reason_translations[locale] - end - @site_in_use_locales.each do |locale| - row2 << bill.pay_method_translations[locale] - end - @site_in_use_locales.each do |locale| - row2 << bill.note_translations[locale] - end + 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(";") @site_in_use_locales.each do |locale| row2 << bill.venue_management_links.map{|l| l.title_translations[locale].to_s.strip}.join(";") diff --git a/app/views/admin/venue_management_contracts/_index.html.erb b/app/views/admin/venue_management_contracts/_index.html.erb index 9f7175c..ba0344e 100644 --- a/app/views/admin/venue_management_contracts/_index.html.erb +++ b/app/views/admin/venue_management_contracts/_index.html.erb @@ -39,29 +39,40 @@ <%= contract.display_royalty %> <%= "#{contract.contract_start_date} / #{contract.contract_end_date}" %> + <%= contract.deposit_amount_type_exp_date %> <%= contract.renewal_permission.present? ? t("vm_contract.renewal.#{contract.renewal_permission}") : t("vm_contract.renewal.false") %> - <%= contract.note %> + <%= contract.display_other_commitment %> + <%= contract.display_note %> <% end %> -<%= - content_tag :div, class: "bottomnav clearfix" do - content_tag :div, paginate(@contracts), class: "pagination pagination-centered" - end -%> +<% filter_url = request.fullpath.split("?")[1..-1].join("?") %> <% if @venue_management.present? %> + <% filter_url.blank? ? (filter_url += "id=#{@venue_management.id}") : (filter_url += "&id=#{@venue_management.id}") %>
- <%= content_tag :div, class: "pagination pagination-centered" do %> + <%= content_tag :div, class: "pagination-centered" do %> <%= paginate(@contracts) %>
+ <%= link_to content_tag(:i, nil, class: "fa fa-download") + " " + t('venue_management.export'), export_admin_venue_management_contracts_path(:format=>'xlsx')+"#{(filter_url.blank? ? '' : ('?'+filter_url))}", class: "btn btn-primary", target: '_blank' %> <%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), new_admin_venue_management_contract_path(id: @venue_management.id), class: "btn btn-primary" %>
<% end %>
+<% else %> + <%= + content_tag :div, class: "bottomnav clearfix" do + (content_tag(:div, class: "pagination-centered") do + paginate(@contracts) + end) + + ('
'.html_safe + + link_to(content_tag(:i, nil, class: "fa fa-download") + " " + t('venue_management.export'), export_admin_venue_management_contracts_path(:format=>'xlsx')+"#{(filter_url.blank? ? '' : ('?'+filter_url))}", class: "btn btn-primary", target: '_blank') + + '
'.html_safe) + end + %> <% end %>