diff --git a/app/assets/stylesheets/admin/venue_print.scss b/app/assets/stylesheets/admin/venue_print.scss new file mode 100644 index 0000000..0869c62 --- /dev/null +++ b/app/assets/stylesheets/admin/venue_print.scss @@ -0,0 +1,6 @@ +*{ + display: none; +} +.print_text{ + display: block; +} \ No newline at end of file diff --git a/app/controllers/admin/venue_managements_controller.rb b/app/controllers/admin/venue_managements_controller.rb index 17fa1b9..7560d95 100644 --- a/app/controllers/admin/venue_managements_controller.rb +++ b/app/controllers/admin/venue_managements_controller.rb @@ -60,13 +60,51 @@ class Admin::VenueManagementsController < Admin::VenueAdminController end end + def print_pdf + time_now = Time.now + venue_management = VenueManagementMain.find(params[:id]) + if !venue_management.registration_status.blank? && venue_management.signup_start_date <= time_now && ( venue_management.signup_end_date.nil? || venue_management.signup_end_date+1 >= time_now ) + sign_up = ('' + t('venue_management.signup') + '').html_safe + elsif venue_management.registration_status.blank? + sign_up = t('venue_management.sign_up_not_open') + elsif venue_management.signup_start_date > time_now + sign_up = t('venue_management.sign_up_not_yet') + else + sign_up = t('venue_management.sign_up_overdue') + end + + if !venue_management.registration_status.blank? && venue_management.registration_status.include?('C') && venue_management.contribute_start_date <= time_now && ( venue_management.contribute_end_date.nil? || venue_management.contribute_end_date+1 >= time_now ) + if !@@session[:venue_management_signup_id].blank? + if @@session[:venue_management_main_id] == venue_management.id + contribute_action = ('' + t('venue_management_signup.uploads') + '').html_safe + else + contribute_action = ('' + t('venue_management_signup.con_login') + '').html_safe + end + else + contribute_action = ('' + t('venue_management_signup.con_login') + '').html_safe + end + end + @venue_management = venue_management + @sign_up = sign_up + @contribute_action = contribute_action + @time_now = time_now + @contribute_time_range = VenueManagementMain.time_range(venue_management.contribute_start_date, venue_management.contribute_end_date) + @sign_up_time_range = venue_management.display_signup_during + @venue_management_time_range = venue_management.display_event_during + @params = params + @venue_management_page_url = Page.where(:module =>"venue_management").last.url rescue "" + if params[:type] == "print" + render "print_pdf" , :layout => false + end + end def export - + @protocol = (request.referer.blank? ? "http" : URI(request.referer).scheme) + @host = "#{@protocol}://#{request.host_with_port}" @venue_management = VenueManagementMain.find(params[:id]) @venue_management_signups = VenueManagementSignup.where(:venue_management_main_id => params[:id]) @site_in_use_locales = Site.first.in_use_locales - filename = @venue_management.title.parameterize.underscore + "_export.xlsx" + filename = @venue_management.title.to_s.strip + "_export.xlsx" respond_to do |format| format.xlsx { response.headers['Content-Disposition'] = 'attachment; filename="' + filename + '"' diff --git a/app/views/admin/venue_managements/_index.html.erb b/app/views/admin/venue_managements/_index.html.erb index 5dcff70..f118d53 100644 --- a/app/views/admin/venue_managements/_index.html.erb +++ b/app/views/admin/venue_managements/_index.html.erb @@ -33,6 +33,7 @@ -->
  • <%= t(:delete_) %>
  • <% end %> +
  • <%= t("venue_management.print_pdf") %>
  • diff --git a/app/views/admin/venue_managements/export.xlsx.axlsx b/app/views/admin/venue_managements/export.xlsx.axlsx index 493a51b..f08b012 100644 --- a/app/views/admin/venue_managements/export.xlsx.axlsx +++ b/app/views/admin/venue_managements/export.xlsx.axlsx @@ -2,78 +2,177 @@ wb = xlsx_package.workbook -wb.add_worksheet(name: (@venue_management.title.to_s[0..27]+'...')) do |sheet| - - row = [t(:category)] - - row << t('venue_management.manager') - - row << t('venue_management.contractor') - - row << t('venue_management.venue_management_start_date') - - row << t('venue_management.venue_management_end_date') - - row << t('venue_management.title') - - row << t('venue_management_signup.address') - - row << t('venue_management.land_number') - - row << t('venue_management.area') - row << t('venue_management.land_zoning') - row << t('venue_management.content') - row << t('venue_management.act_place') - row << t("link") # Seperate with ';' - @site_in_use_locales.each do |locale| - row << t("link") + " " + t("url_alt") + " - " + t(locale) - end - row << t("file_") # Seperate with ';' Example: http://www.example.com/images/example.png; http://www.example.com/images/example2.png" - @site_in_use_locales.each do |locale| - row << t("file_") + " " + t("description") + " - " + t(locale) #"Seperate with ';' with respective to the links in the link columns. Example : Great view; Nice potrait" - end - @site_in_use_locales.each do |locale| - row << t("file_") + " " + t("alternative") + " - " + t(locale) #"Seperate with ';' with respective to the links in the link columns. Example : example1; example2" - end - @venue_management.venue_management_signup_fields.asc(:_id).each do |rf| - if rf.can_muti_lang_input? - @site_in_use_locales.each do |l| - row << rf.title + " (#{t(l.to_s)})" - end - else - row << rf.title +wb.add_worksheet(name: t('restful_actions.venue_management_contracts')) do |sheet| + row = [t('vm_contract.case_no')] + row << t('vm_inviting.type') + row << t('venue_management.contractor') + row << t('vm_inviting.rents') + row << t('vm_inviting.royalty') + row << t('vm_inviting.house_land_tax_payer') + row << t('vm_contract.renewal_permission') + row << t('vm_contract.start_end') + row << t('vm_contract.construction_start_end') + row << t('vm_contract.operation_start_end') + row << t('vm_contract.free_period_start_end') + row << t('vm_contract.sign_date') + row << t('vm_contract.handover_date') + row << t('vm_contract.deposit_payment_date') + row << t('vm_contract.deposit_type') + row << t('vm_contract.deposit_exp_date') + row << t('vm_contract.insurance_type') + row << t('vm_contract.insurance_payment_deadline') + row << t('vm_contract.insurance_payment_date') + @site_in_use_locales.each do |locale| + row << t('vm_contract.other_commitment') + " - " + t(locale) end - end - - sheet.add_row row - - @venue_management.venue_management_signups.each do |signup| - - row2 = [] - - row2 << "#{signup.created_at} " - row2 << "#{signup[:name]} " - row2 << "#{signup.unit} " - row2 << "#{signup[:tel]} " - row2 << "#{signup[:phone]} " - row2 << "#{signup[:fax]} " - row2 << "#{signup.address} " - row2 << "#{signup[:email]} " - row2 << "#{signup.note} " - - @venue_management.venue_management_signup_fields.asc(:_id).each do |rf| - if rf.can_muti_lang_input? - @site_in_use_locales.each do |l| - row2 << nl2br(show_attribute_value(@venue_management.get_attribute_value(rf,signup.id).get_value_by_locale(l))) rescue ' ' + @site_in_use_locales.each do |locale| + row << t('vm_contract.note') + " - " + t(locale) + end + row << t("link") + @site_in_use_locales.each do |locale| + row << t("link") + " " + t("url_alt") + " - " + t(locale) + end + 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 + sheet.add_row row + @venue_management.venue_management_contracts.each do |contract| + row2 = [] + row2 << contract.venue_management_inviting.case_no + row2 << contract.display_tags + row2 << contract.display_contractors + row2 << "#{contract.early_rent} / #{contract.operation_rent}" + row2 << contract.royalty + row2 << t("vm_inviting.enums.#{contract.house_tax_payer}")+"/"+t("vm_inviting.enums.#{contract.land_tax_payer}") + row2 << contract.renewal_permission.present? ? t("vm_contract.renewal.#{contract.renewal_permission}") : t("vm_contract.renewal.false") + row2 << "#{contract.contract_start_date} ~ #{contract.contract_end_date}" + row2 << "#{contract.construction_start_date} ~ #{contract.construction_end_date}" + row2 << "#{contract.operation_start_date} ~ #{contract.operation_end_date}" + row2 << "#{contract.free_period_start_date} ~ #{contract.free_period_end_date}" + row2 << contract.sign_date + row2 << contract.handover_date + row2 << contract.deposit_payment_date + row2 << contract.deposit_type + row2 << contract.deposit_exp_date + row2 << contract.insurance_type + row2 << contract.insurance_payment_deadline + row2 << contract.insurance_payment_date + @site_in_use_locales.each do |locale| + row2 << contract.other_commitment_translations[locale] end - else - row2 << nl2br(show_attribute_value(@venue_management.get_attribute_value(rf,signup.id).get_value_by_locale(I18n.locale))) rescue ' ' - end + @site_in_use_locales.each do |locale| + row2 << contract.note_translations[locale] + end + row2 << contract.venue_management_links.map{|l| l.url.to_s.strip}.join(";") + @site_in_use_locales.each do |locale| + row2 << contract.venue_management_links.map{|l| l.title_translations[locale].to_s.strip}.join(";") + end + row2 << contract.venue_management_files.map{|f| @host + f.file.url rescue nil}.select{|s| !s.nil?}.join(";") + @site_in_use_locales.each do |locale| + row2 << contract.venue_management_files.map{|f| f.description_translations[locale].to_s.strip}.join(";") + end + @site_in_use_locales.each do |locale| + row2 << contract.venue_management_files.map{|f| f.title_translations[locale].to_s.strip}.join(";") + end + sheet.add_row row2 end - - sheet.add_row row2 - end end +wb.add_worksheet(name: t('restful_actions.venue_management_invitings')) do |sheet| + row = [] + row << t('vm_inviting.type') + row << t('vm_inviting.case_no') + row << t('vm_inviting.publish_times') + row << t('vm_inviting.rents') + row << t('vm_inviting.royalty') + row << t('vm_inviting.house_land_tax_payer') + row << t('vm_inviting.contractor_manager') + row << t('vm_inviting.bid_result') + @site_in_use_locales.each do |locale| + row << t('vm_inviting.details') + "-" + t(locale) + end + row << t("link") + @site_in_use_locales.each do |locale| + row << t("link") + " " + t("url_alt") + " - " + t(locale) + end + 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 + sheet.add_row row + @venue_management.venue_management_invitings.each do |inviting| + row2 = [] + row2 << inviting.tags.map{|t| t.name}.join(" , ") + row2 << inviting.case_no + row2 << inviting.publish_times + row2 << "#{inviting.early_rent} / #{inviting.operation_rent}" + row2 << inviting.royalty + row2 << t("vm_inviting.enums.#{inviting.house_tax_payer}")+"/"+t("vm_inviting.enums.#{inviting.land_tax_payer}") + row2 << inviting.contractor_manager + row2 << t("vm_inviting.enums.bid_result.#{inviting.bid_result}") + @site_in_use_locales.each do |locale| + row2 << inviting.details_translations[locale] + end + row2 << inviting.venue_management_links.map{|l| l.url.to_s.strip}.join(";") + @site_in_use_locales.each do |locale| + row2 << inviting.venue_management_links.map{|l| l.title_translations[locale].to_s.strip}.join(";") + end + row2 << inviting.venue_management_files.map{|f| @host + f.file.url rescue nil}.select{|s| !s.nil?}.join(";") + @site_in_use_locales.each do |locale| + row2 << inviting.venue_management_files.map{|f| f.description_translations[locale].to_s.strip}.join(";") + end + @site_in_use_locales.each do |locale| + row2 << inviting.venue_management_files.map{|f| f.title_translations[locale].to_s.strip}.join(";") + end + sheet.add_row row2 + end +end +wb.add_worksheet(name: t('restful_actions.venue_management_memorabilias')) do |sheet| + row = [] + row << t('vm_memorabilia.case_no') + row << t('vm_memorabilia.event_date') + @site_in_use_locales.each do |locale| + row << t('vm_memorabilia.details') + "-" + t(locale) + end + row << t("link") + @site_in_use_locales.each do |locale| + row << t("link") + " " + t("url_alt") + " - " + t(locale) + end + 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 + sheet.add_row row + @venue_management.venue_management_memorabilias.each do |memorabilia| + row2 = [] + row2 << memorabilia.case_no + row2 << memorabilia.event_date + @site_in_use_locales.each do |locale| + row2 << memorabilia.details_translations[locale] + end + row2 << memorabilia.venue_management_links.map{|l| l.url.to_s.strip}.join(";") + @site_in_use_locales.each do |locale| + row2 << memorabilia.venue_management_links.map{|l| l.title_translations[locale].to_s.strip}.join(";") + end + row2 << memorabilia.venue_management_files.map{|f| @host + f.file.url rescue nil}.select{|s| !s.nil?}.join(";") + @site_in_use_locales.each do |locale| + row2 << memorabilia.venue_management_files.map{|f| f.description_translations[locale].to_s.strip}.join(";") + end + @site_in_use_locales.each do |locale| + row2 << memorabilia.venue_management_files.map{|f| f.title_translations[locale].to_s.strip}.join(";") + end + sheet.add_row row2 + end +end diff --git a/app/views/admin/venue_managements/print_pdf.html.erb b/app/views/admin/venue_managements/print_pdf.html.erb new file mode 100644 index 0000000..31c8239 --- /dev/null +++ b/app/views/admin/venue_managements/print_pdf.html.erb @@ -0,0 +1,386 @@ +<% # encoding: utf-8 %> +<% if params[:type] == "print" %> + + + + <%= @venue_management.title %> + + <%= stylesheet_link_tag "bootstrap/bootstrap.min.css" ,:media => "all" %> + + + + +<% end %> + +<%= javascript_include_tag "jspdf.min" %> + +<% @save_name = @venue_management.title %> +
    + <%= I18n.t('venue_management.print_pdf') %> +
    + +<% if params[:type] == "print" %> + + + +<% end %> \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index bc70c71..fab3131 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -5,6 +5,7 @@ en: label: "" empty: none restful_actions: + print_pdf: Print act_signup: Sign Up Info #報名資料 venue_management_submission_field: VenueManagement Submission Field venue_management_signup_field: VenueManagement Signup Field @@ -20,6 +21,7 @@ en: verification_failed: Verification Failed #驗證碼錯誤 venue_management: + print_pdf: Print send_email_reminder: Send email reminder before: Before day_send_email: day send email diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index aadf6ae..5098ab2 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -5,6 +5,7 @@ zh_tw: label: "" empty: 無 restful_actions: + print_pdf: 列印 act_signup: 報名資料 venue_management_submission_field: 上傳介面欄位 venue_management_signup_field: 報名欄位 @@ -20,6 +21,7 @@ zh_tw: verification_failed: 驗證碼錯誤 venue_management: + print_pdf: 列印 send_email_reminder: 寄送Email提醒 before: 提前 day_send_email: 天寄送 diff --git a/config/routes.rb b/config/routes.rb index db4c654..ae11a7a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -15,6 +15,7 @@ Rails.application.routes.draw do get 'venue_management_invitings' get 'venue_management_memorabilias' get 'venue_management_contracts' + get 'print_pdf' end end resources :venue_management_items do