This commit is contained in:
BoHung Chiu 2020-10-27 12:44:10 +08:00
parent 1a18f73780
commit bd1d8f5c5c
11 changed files with 52 additions and 36 deletions

View File

@ -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 = "<div class=\"controls\"><form>"
bill_type_select_str = "<div class=\"controls\">"
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 \'<option value=\"\'+k+\'\">\'+v+\'</option>\'}).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 += "</form></div>"
bill_type_select_str += "</div>"
@filter_fields['vm_bill.bill_type'] = bill_type_select_str
@filter_fields['vm_bill.accounting_month'] = ('<form><div class="controls"><div style="float: left;">'+
@filter_fields['vm_bill.accounting_month'] = ('<div class="controls"><div style="float: left;">'+
(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)}) %>')) +
"</div><span style=\"float: left;\">~</span><div style=\"float: left;\">" +
(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')) %>") +
'</div></div></form>')
'</div></div>')
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)

View File

@ -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'] = ('<form><div class="controls"><div style="float: left;">'+
@filter_fields['vm_contract.start_end'] = ('<div class="controls"><div style="float: left;">'+
(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)}) %>')) +
"</div><span style=\"float: left;\">~</span><div style=\"float: left;\">" +
(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')) %>") +
'</div></div></form>')
'</div></div>')
filter_tags = params[:filters]["type"].to_a rescue []
@main_ids = nil
@inviting_ids = nil

View File

@ -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'] = ('<form><div class="controls"><div style="float: left;">'+
@filter_fields['vm_inviting.start_end'] = ('<div class="controls"><div style="float: left;">'+
(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')) %>") +
'</div></div></form>')
'</div></div>')
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

View File

@ -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'] = ('<form><div class="controls"><div style="float: left;">'+
@filter_fields['vm_inviting.start_end'] = ('<div class="controls"><div style="float: left;">'+
(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')) %>") +
'</div></div></form>')
'</div></div>')
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 = "<div class=\"controls\"><form>"
bill_type_select_str = "<div class=\"controls\">"
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 \'<option value=\"\'+k+\'\">\'+v+\'</option>\'}).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 += "</form></div>"
bill_type_select_str += "</div>"
@filter_fields['vm_bill.bill_type'] = bill_type_select_str
@filter_fields['vm_bill.accounting_month'] = ('<form><div class="controls"><div style="float: left;">'+
@filter_fields['vm_bill.accounting_month'] = ('<div class="controls"><div style="float: left;">'+
(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)}) %>')) +
"</div><span style=\"float: left;\">~</span><div style=\"float: left;\">" +
(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')) %>") +
'</div></div></form>')
'</div></div>')
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'] = ('<form><div class="controls"><div style="float: left;">'+
@filter_fields['vm_contract.start_end'] = ('<div class="controls"><div style="float: left;">'+
(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)}) %>')) +
"</div><span style=\"float: left;\">~</span><div style=\"float: left;\">" +
(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')) %>") +
'</div></div></form>')
'</div></div>')
filter_tags = params[:filters]["type"].to_a rescue []
@main_ids = nil
@inviting_ids = nil

View File

@ -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

View File

@ -1,5 +1,11 @@
<form>
<%= render_filter @filter_fields, "index_table" %>
</form>
<span id="index_table">
<%= render 'index' %>
</span>
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
<script type="text/javascript">
var $form = $("<form><form>");
$(".filter-group.accordion-group").before($form).appendTo($form);
</script>

View File

@ -3,3 +3,7 @@
<%= render 'index' %>
</span>
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
<script type="text/javascript">
var $form = $("<form><form>");
$(".filter-group.accordion-group").before($form).appendTo($form);
</script>

View File

@ -3,3 +3,7 @@
<%= render 'index' %>
</span>
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
<script type="text/javascript">
var $form = $("<form><form>");
$(".filter-group.accordion-group").before($form).appendTo($form);
</script>

View File

@ -1,6 +1,12 @@
<form>
<%= render_filter @filter_fields, "index_table" %>
</form>
<span id="index_table">
<%= render 'admin/venue_management_bills/index' %>
</span>
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
<script type="text/javascript">
var $form = $("<form><form>");
$(".filter-group.accordion-group").before($form).appendTo($form);
</script>

View File

@ -4,3 +4,7 @@
</span>
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
<script type="text/javascript">
var $form = $("<form><form>");
$(".filter-group.accordion-group").before($form).appendTo($form);
</script>

View File

@ -4,3 +4,7 @@
</span>
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
<script type="text/javascript">
var $form = $("<form><form>");
$(".filter-group.accordion-group").before($form).appendTo($form);
</script>