From 2f076ab2cfca9916fca642d9958462ae8ffd9ce0 Mon Sep 17 00:00:00 2001 From: bohung Date: Wed, 17 Mar 2021 15:33:31 +0800 Subject: [PATCH] Add signup search feature. Add assign organizer to seminar events and assign signups to reviewers feature. --- .../admin/seminar_signups_controller.rb | 22 +- app/controllers/admin/seminars_controller.rb | 246 ++++++++++++++++-- app/controllers/seminars_controller.rb | 34 ++- app/helpers/admin/seminars_helper.rb | 13 +- app/models/seminar_main.rb | 87 ++++++- app/models/seminar_review.rb | 49 +++- app/models/seminar_signup.rb | 17 +- app/models/seminar_signup_admin_setting.rb | 7 + app/models/seminar_signup_value.rb | 93 ++++--- app/models/seminar_submission_value.rb | 97 +++---- app/models/seminar_user.rb | 13 + app/views/admin/seminars/_form.html.erb | 29 ++- .../seminars/_get_display_fields.html.erb | 119 +++++++++ app/views/admin/seminars/_index.html.erb | 18 +- .../_seminar_signup_dashboard.html.erb | 225 ++++++++++++++++ .../_seminar_signup_render_table.html.erb | 122 +++++++++ .../seminars/_seminar_signup_table.html.erb | 22 ++ .../seminars/enquiry_for_applicants.html.erb | 33 +++ app/views/admin/seminars/export.xlsx.axlsx | 2 +- .../admin/seminars/get_hide_reviewer.html.erb | 25 ++ .../seminars/get_reviewer_block.html.erb | 14 + .../admin/seminars/reviewer_setting.html.erb | 99 +++++++ .../admin/seminars/seminar_signup.html.erb | 230 ++-------------- .../seminar_signup_admin_setting.html.erb | 57 ++++ .../seminar_signup_render_table.html.erb | 103 ++++++++ config/locales/en.yml | 14 + config/locales/zh_tw.yml | 14 + config/routes.rb | 10 + lib/seminar/engine.rb | 9 +- 29 files changed, 1474 insertions(+), 349 deletions(-) create mode 100644 app/models/seminar_signup_admin_setting.rb create mode 100644 app/models/seminar_user.rb create mode 100644 app/views/admin/seminars/_get_display_fields.html.erb create mode 100644 app/views/admin/seminars/_seminar_signup_dashboard.html.erb create mode 100644 app/views/admin/seminars/_seminar_signup_render_table.html.erb create mode 100644 app/views/admin/seminars/_seminar_signup_table.html.erb create mode 100644 app/views/admin/seminars/enquiry_for_applicants.html.erb create mode 100644 app/views/admin/seminars/get_hide_reviewer.html.erb create mode 100644 app/views/admin/seminars/get_reviewer_block.html.erb create mode 100644 app/views/admin/seminars/reviewer_setting.html.erb create mode 100644 app/views/admin/seminars/seminar_signup_admin_setting.html.erb create mode 100644 app/views/admin/seminars/seminar_signup_render_table.html.erb diff --git a/app/controllers/admin/seminar_signups_controller.rb b/app/controllers/admin/seminar_signups_controller.rb index 5f1e989..c6a2e14 100644 --- a/app/controllers/admin/seminar_signups_controller.rb +++ b/app/controllers/admin/seminar_signups_controller.rb @@ -2,12 +2,21 @@ class Admin::SeminarSignupsController < OrbitAdminController include Admin::SeminarsHelper before_action ->(module_app = @app_title) { set_variables module_app } - + before_action :check_manager_for_seminar def initialize super @app_title = "seminar" end - + def check_manager_for_seminar + OrbitHelper.set_params(params,current_user) + access_level = OrbitHelper.user_access_level? + if (access_level.nil? || access_level == "user") + @seminar = SeminarSignup.find(params[:id]).seminar_main rescue nil + if (@seminar.organizer_id != current_user.member_profile_id rescue true) + render_401 + end + end + end def edit OrbitHelper.set_params(params,current_user) params[:controller] = "admin/seminars" @@ -29,6 +38,15 @@ class Admin::SeminarSignupsController < OrbitAdminController field_value = r.last[:id].present? @custom_field_value = SeminarSignupValue.put_field_values(@seminar_signup, r.last, r.last[:id], field_value) end + seminar_reviews = SeminarReview.where(:seminar_main_id=>@seminar_signup.seminar_main_id).to_a + seminar_reviews.each{|sr| sr.save} + @seminar = @seminar_signup.seminar_main + unassigned_seminar_signup_ids = @seminar.seminar_signup_ids.map{|s| s.to_s} + @seminar.seminar_reviews.each do |sr| + unassigned_seminar_signup_ids = unassigned_seminar_signup_ids - sr.all_seminar_signup_ids + end + @seminar.unassigned_seminar_signup_ids = unassigned_seminar_signup_ids + @seminar.save end redirect_to "/admin/seminars/#{@seminar_signup.seminar_main_id}/seminar_signup" diff --git a/app/controllers/admin/seminars_controller.rb b/app/controllers/admin/seminars_controller.rb index ad7f4c9..dbc4732 100644 --- a/app/controllers/admin/seminars_controller.rb +++ b/app/controllers/admin/seminars_controller.rb @@ -2,10 +2,13 @@ class Admin::SeminarsController < OrbitAdminController require 'axlsx' + include Admin::SeminarsHelper helper Admin::SeminarsFieldHelper before_action ->(module_app = @app_title) { set_variables module_app } - before_action :set_seminar, only: [:edit, :set_write_off, :seminar_signup, :destroy] - + before_action :set_seminar, only: [:edit, :set_write_off, :seminar_signup, :destroy,:seminar_signup_admin_setting,:update_seminar_signup_admin_setting,:get_reviewer_block,:update_seminar_review,:reviewer_setting,:update_reviewer_setting] + before_action :set_seminar_signup_admin_setting, only: [:seminar_signup,:seminar_signup_admin_setting,:update_seminar_signup_admin_setting,:get_reviewer_block] + before_action :check_permission_for_seminar, only: [:seminar_signup,:get_reviewer_block] + before_action :check_manager_for_seminar, only: [:seminar_signup_admin_setting,:update_seminar_signup_admin_setting,:update_seminar_review] def initialize super @app_title = "seminar" @@ -16,7 +19,152 @@ class Admin::SeminarsController < OrbitAdminController :category=>categories.map{|c| {:title=>(c.title.blank? ? " " : c.title), :id=>c.id}} } end + def check_manager_for_seminar + OrbitHelper.set_params(params,current_user) + access_level = OrbitHelper.user_access_level? + if (access_level.nil? || access_level == "user") && (@seminar.organizer_id != current_user.member_profile_id rescue true) + render_401 + end + end + def check_permission_for_seminar + OrbitHelper.set_params(params,current_user) + access_level = OrbitHelper.user_access_level? + if (access_level.nil? || access_level == "user") + unless (@seminar.reviewer_ids.include?(current_user.member_profile_id.to_s) rescue false) || (@seminar.organizer_id == current_user.member_profile_id rescue false) + render_401 + else + @user_authenticated_categories = ['all'] + end + end + end + def reviewer_setting + @seminar_reviews = @seminar.seminar_reviews + @fields = [] + @fields_translations = [] + access_markup = ["select","radio_button","checkbox"] + @fields_values = [] + @seminar.seminar_signup_fields.each do |f| + next if f.disabled + if access_markup.include?(f.markup) + @fields << "seminar_signup_fields.#{f.id}" + @fields_translations << f.title + @fields_values << f.option_list + end + end + @seminar.seminar_submission_fields.each do |f| + next if f.disabled + if access_markup.include?(f.markup) + @fields << "seminar_submission_fields.#{f.id}" + @fields_translations << f.title + @fields_values << f.option_list + end + end + @fields_values = @fields_values.collect.with_index{|fields_values,i| [i, fields_values.values.map{|v| v[I18n.locale]} ] }.to_h + end + def update_reviewer_setting + seminar_params[:seminar_reviews_attributes].keys.each do |i| + if seminar_params[:seminar_reviews_attributes][i][:default_topics].present? + seminar_params[:seminar_reviews_attributes][i][:default_topics] = [] if seminar_params[:seminar_reviews_attributes][i][:default_topics].nil? + default_topics_values = [] + (0...seminar_params[:seminar_reviews_attributes][i][:default_topics].count).each do |ii| + default_topics_values << (Array(seminar_params[:seminar_reviews_attributes][i][:default_topics_values][ii.to_s]) rescue []) + end + seminar_params[:seminar_reviews_attributes][i][:default_topics_values] = default_topics_values + else + seminar_params[:seminar_reviews_attributes][i][:default_topics] = [] + seminar_params[:seminar_reviews_attributes][i][:default_topics_values] = [] + end + end + #render :html => seminar_params and return + @seminar.update_attributes(seminar_params) + unassigned_seminar_signup_ids = @seminar.seminar_signup_ids.map{|s| s.to_s} + @seminar.seminar_reviews.each do |sr| + unassigned_seminar_signup_ids = unassigned_seminar_signup_ids - sr.all_seminar_signup_ids + end + @seminar.unassigned_seminar_signup_ids = unassigned_seminar_signup_ids + @seminar.save + redirect_to admin_seminars_path + end + def enquiry_for_applicants + OrbitHelper.set_params(params,current_user) + @access_level = OrbitHelper.user_access_level? + @can_edit = true + if @access_level == "user" || @access_level.nil? + @can_edit = false + end + reviewer_id = current_user.member_profile_id.to_s + if !@can_edit && SeminarMain.where(:reviewer_ids=>reviewer_id).count == 0 && SeminarMain.where(:organizer_id=>reviewer_id).count == 0 + render_401 and return + end + @seminar_signup_admin_setting = SeminarSignupAdminSetting.where(:seminar_main_id=>"enquiry_for_applicants").first + if @seminar_signup_admin_setting.nil? + @seminar_signup_admin_setting = SeminarSignupAdminSetting.create(:seminar_main_id=>"enquiry_for_applicants") + end + if params[:name].present? + @seminar_signups = SeminarSignup.where(:name => /#{params[:name]}/).page(params[:page]).per(10) + else + @seminar_signups = [] + end + unless @can_edit + if @seminar_signups.class != Array + seminar_signup_ids = SeminarReview.where(:reviewer_id=>reviewer_id).pluck(:seminar_signup_ids).flatten + remove_seminar_signup_ids = SeminarReview.where(:reviewer_id=>reviewer_id).pluck(:remove_seminar_signup_ids).flatten + default_seminar_signup_ids = SeminarReview.where(:reviewer_id=>reviewer_id).pluck(:default_seminar_signup_ids).flatten + all_seminar_signup_ids = seminar_signup_ids - remove_seminar_signup_ids + default_seminar_signup_ids + + ids2 = SeminarSignup.where(:seminar_main_id.in=> SeminarMain.where(:organizer_id=>current_user.member_profile_id).pluck(:id)).pluck(:id) + + @seminar_signups = @seminar_signups.where(:id.in=>all_seminar_signup_ids + ids2).page(params[:page]).per(10) + end + end + end + def get_hide_reviewer + seminar_main = SeminarMain.find(params[:id]) rescue nil + if seminar_main.nil? + render :nothing => true + else + @hide_reviewer_ids = Array(seminar_main.reviewer_ids) - Array(seminar_main.reviewer_show_ids) + @hide_reviewers = MemberProfile.where(:id.in=>@hide_reviewer_ids) + render :layout => false + end + end + def get_reviewer_block + @reviewer_id = params[:reviewer_id] + unless (@seminar.reviewer_show_ids.include?(@reviewer_id) rescue false) + @seminar.reviewer_show_ids << @reviewer_id + @seminar.save + end + render :layout => false + end + def update_seminar_review + if @seminar_review.nil? + render :json => {:success => false} + else + seminar_main = @seminar_review.seminar_main + if params[:mode] == "append" + @seminar_review.seminar_signup_ids << params[:signup_id] + @seminar_review.remove_seminar_signup_ids.delete(params[:signup_id]) + seminar_main.unassigned_seminar_signup_ids.delete(params[:signup_id]) + elsif params[:mode] == "remove" + @seminar_review.seminar_signup_ids.delete(params[:signup_id]) + @seminar_review.remove_seminar_signup_ids << params[:signup_id] + seminar_main.unassigned_seminar_signup_ids << params[:signup_id] + elsif params[:mode] == "hide" + if seminar_main.reviewer_show_ids.nil? + seminar_main.reviewer_show_ids = seminar_main.reviewer_ids[0..1] + end + seminar_main.reviewer_show_ids = seminar_main.reviewer_show_ids - Array(@seminar_review.reviewer_id).flatten + elsif params[:mode] == "show" + seminar_main.reviewer_show_ids = seminar_main.reviewer_show_ids.to_a + Array(@seminar_review.reviewer_id).flatten + else + render :json => {:success => false} and return + end + seminar_main.save + @seminar_review.save + render :json => {:success => true} + end + end def index @categories = @module_app.categories.enabled @filter_fields = filter_fields(@categories) @@ -37,7 +185,18 @@ class Admin::SeminarsController < OrbitAdminController @seminars = SeminarMain.all.order_by(sort).with_categories(filters("category")) @seminars = search_data(@seminars,[:title]).page(params[:page]).per(10) - + OrbitHelper.set_params(params,current_user) + @access_level = OrbitHelper.user_access_level? + @can_edit = true + if @access_level == "user" || @access_level.nil? + @can_edit = false + end + unless @can_edit + reviewer_id = current_user.member_profile_id.to_s + ids1 = @seminars.where(:reviewer_ids=>reviewer_id).pluck(:id) + ids2 = @seminars.where(:organizer_id=>current_user.member_profile_id).pluck(:id) + @seminars = @seminars.where(:id.in=>ids1+ids2) + end if request.xhr? render :partial => "index" end @@ -49,12 +208,19 @@ class Admin::SeminarsController < OrbitAdminController @seminar = SeminarMain.find(params[:id]) @seminar_signups = SeminarSignup.where(:seminar_main_id => params[:id]) filename = @seminar.title.parameterize.underscore + "_export.xlsx" - respond_to do |format| - format.xlsx { - response.headers['Content-Disposition'] = 'attachment; filename="' + filename + '"' - } + if can_see_seminar_signup(@seminar) + if !admin_for_seminar(@seminar) + @seminar_review = @seminar.seminar_reviews.where(:reviewer_id => current_user.member_profile_id.to_s).first + @seminar_signups = @seminar_signups.where(:id.in=>@seminar_review.all_seminar_signup_ids) rescue [] + end + respond_to do |format| + format.xlsx { + response.headers['Content-Disposition'] = 'attachment; filename="' + filename + '"' + } + end + else + render :nothing => true end - end def new @@ -121,22 +287,22 @@ class Admin::SeminarsController < OrbitAdminController @signup_sets = @seminar.seminar_signup_field_sets @submission_set = @seminar.seminar_submission_field_sets @custom_set = @seminar.seminar_signup_field_customs - if @seminar.seminar_reviews.first.nil? - @review = @seminar.seminar_reviews.new() + @member = MemberProfile.where(:id.in=>@seminar.reviewer_ids).to_a rescue [] + if (@seminar.organizer_id == current_user.member_profile_id rescue false) + @user_authorized_categories = @module_app.categories.enabled.to_a else - @review = @seminar.seminar_reviews.first + @user_authorized_categories = nil end - @member = MemberProfile.find(@review.reviewer_id) rescue nil end def update - params[:seminar_main][:registration_status] = (params[:seminar_main][:registration_status] ? params[:seminar_main][:registration_status] : []) uid = params[:id].split('-').last @seminar = SeminarMain.find_by(:uid=>uid) - + seminar_params["reviewer_ids"] = [] if seminar_params["reviewer_ids"].nil? + seminar_params["organizer_id"] = nil if seminar_params["organizer_id"].nil? if params[:seminar_main][:seminar_signup_fields] seminar_params[:seminar_signup_fields].each do |a| @field_name = 'seminar_main' @@ -209,15 +375,49 @@ class Admin::SeminarsController < OrbitAdminController end def seminar_signup - - if !params[:search].blank? - @seminar_signups = SeminarSignup.where(:seminar_main_id => @seminar.id, :name=>params[:search]).page(params[:page]).per(10) + @seminar_signups = [] + if params[:type] == "table" + @seminar_signups = @seminar.seminar_signups.where(:name=>/#{params[:search]}/) else - @seminar_signups = SeminarSignup.where(:seminar_main_id => @seminar.id).page(params[:page]).per(10) + @seminar_signups = SeminarSignup.where(:id.in => @seminar.unassigned_seminar_signup_ids, :name=>/#{params[:search]}/) + end + OrbitHelper.set_params(params,current_user) + @access_level = OrbitHelper.user_access_level? + @can_edit = true + if @access_level == "user" || @access_level.nil? + @can_edit = false + end + unless @can_edit + @can_edit = (@seminar.organizer_id == current_user.member_profile_id rescue false) + end + unless @can_edit + @seminar_review = @seminar.seminar_reviews.where(:reviewer_id => current_user.member_profile_id.to_s).first + @seminar_signups = @seminar.seminar_signups.where(:id.in=>@seminar_review.all_seminar_signup_ids) + end + @seminar_signups = @seminar_signups.page(params[:page]).per(10) + if request.xhr? + render :layout => false + end + end + def seminar_signup_admin_setting + if @seminar.nil? && params[:id] != "enquiry_for_applicants" + redirect_to admin_seminars_path + end + end + def update_seminar_signup_admin_setting + @seminar_signup_admin_setting.update_attributes(params.require(:seminar_signup_admin_setting).permit!) + if params[:id] != "enquiry_for_applicants" + redirect_to seminar_signup_admin_seminar_path(params[:id]) + else + redirect_to admin_seminar_enquiry_for_applicants_path + end + end + def set_seminar_signup_admin_setting + @seminar_signup_admin_setting = SeminarSignupAdminSetting.where(:seminar_main_id=>params[:id]).first + if @seminar_signup_admin_setting.nil? + @seminar_signup_admin_setting = SeminarSignupAdminSetting.create(:seminar_main_id=>params[:id]) end - end - def edit_seminar_signup @seminar_signup = SeminarSignup.find(params[:id]) @seminar = SeminarMain.find(@seminar_signup.seminar_main_id) @@ -237,7 +437,11 @@ class Admin::SeminarsController < OrbitAdminController private def set_seminar - @seminar = SeminarMain.find(params[:id]) + @seminar = SeminarMain.find(params[:id]) rescue nil + if params[:action] == "update_seminar_review" + @seminar_review = SeminarReview.find(params[:id]) rescue nil + @seminar = @seminar_review.seminar_main + end end def seminar_params diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb index 968a28d..e875a62 100644 --- a/app/controllers/seminars_controller.rb +++ b/app/controllers/seminars_controller.rb @@ -148,6 +148,11 @@ class SeminarsController < ApplicationController field_value = r.last[:id].present? @custom_field_value = SeminarSignupValue.put_field_values(@seminar_signup, r.last, r.last[:seminar_signup_field_id], field_value) end + seminar_reviews = SeminarReview.where(:seminar_main_id=>@seminar.id).to_a + seminar_reviews.each{|sr| sr.save} + else + @seminar.unassigned_seminar_signup_ids << @seminar_signup.id.to_s + @seminar.save end if params['seminar_signup']['status']=='C' status_param = '&status=' @@ -203,6 +208,15 @@ class SeminarsController < ApplicationController seminar_id = signup.seminar_main_id @seminar = SeminarMain.where(id:seminar_id).first send_mail('add_file',signup.email,seminar_id) + seminar_reviews = SeminarReview.where(:seminar_main_id=>signup.seminar_main_id).to_a + seminar_reviews.each{|sr| sr.save} + @seminar = signup.seminar_main + unassigned_seminar_signup_ids = @seminar.seminar_signup_ids.map{|s| s.to_s} + @seminar.seminar_reviews.each do |sr| + unassigned_seminar_signup_ids = unassigned_seminar_signup_ids - sr.all_seminar_signup_ids + end + @seminar.unassigned_seminar_signup_ids = unassigned_seminar_signup_ids + @seminar.save redirect_to "#{params[:referer_url]}/?method=con_upload" else redirect_to "#{params[:referer_url]}", :notice => t('recaptcha.errors.verification_failed') @@ -237,6 +251,15 @@ class SeminarsController < ApplicationController seminar_id = signup.seminar_main_id @seminar = SeminarMain.where(id:seminar_id).first send_mail('edit_file',signup.email,seminar_id) + seminar_reviews = SeminarReview.where(:seminar_main_id=>signup.seminar_main_id).to_a + seminar_reviews.each{|sr| sr.save} + @seminar = signup.seminar_main + unassigned_seminar_signup_ids = @seminar.seminar_signup_ids.map{|s| s.to_s} + @seminar.seminar_reviews.each do |sr| + unassigned_seminar_signup_ids = unassigned_seminar_signup_ids - sr.all_seminar_signup_ids + end + @seminar.unassigned_seminar_signup_ids = unassigned_seminar_signup_ids + @seminar.save redirect_to "#{params[:referer_url]}/?method=con_upload" else redirect_to "#{params[:referer_url]}", :notice => t('recaptcha.errors.verification_failed') @@ -250,9 +273,18 @@ class SeminarsController < ApplicationController # seminar_signup = SeminarSignup.find_by(_id: con.seminar_signup_id ) # seminar = SeminarMain.find_by(_id: seminar_signup.seminar_main_id ) - + signup = con.seminar_signup con.destroy + seminar_reviews = SeminarReview.where(:seminar_main_id=>signup.seminar_main_id).to_a + seminar_reviews.each{|sr| sr.save} + @seminar = SeminarMain.find(signup.seminar_main_id) + unassigned_seminar_signup_ids = @seminar.seminar_signup_ids.map{|s| s.to_s} + @seminar.seminar_reviews.each do |sr| + unassigned_seminar_signup_ids = unassigned_seminar_signup_ids - sr.all_seminar_signup_ids + end + @seminar.unassigned_seminar_signup_ids = unassigned_seminar_signup_ids + @seminar.save redirect_to "#{params[:referer_url]}/?method=con_upload" end diff --git a/app/helpers/admin/seminars_helper.rb b/app/helpers/admin/seminars_helper.rb index 3aeed66..bf3c72e 100644 --- a/app/helpers/admin/seminars_helper.rb +++ b/app/helpers/admin/seminars_helper.rb @@ -24,7 +24,18 @@ module Admin::SeminarsHelper ann_page = pages.first if ann_page.nil? request.protocol+(request.host_with_port+ann_page.url+'/'+seminar.to_param).gsub('//','/') rescue "/" end - + def can_see_seminar_signup(seminar) + if can_edit_or_delete?(seminar) + return true + elsif (seminar.organizer_id == current_user.member_profile_id rescue false) + return true + else + return seminar.reviewer_ids.to_a.include?(current_user.member_profile_id.to_s) + end + end + def admin_for_seminar(seminar) + return can_edit_or_delete?(seminar) || (seminar.organizer_id == current_user.member_profile_id rescue false) + end def page_for_seminar_url page = Pag.where(:module => 'seminar').first return request.protocol+(request.host_with_port+"/#{I18n.locale}#{page.url}").gsub('//','/') rescue "/" diff --git a/app/models/seminar_main.rb b/app/models/seminar_main.rb index 7626c28..a20e242 100644 --- a/app/models/seminar_main.rb +++ b/app/models/seminar_main.rb @@ -28,9 +28,13 @@ class SeminarMain field :create_user_id field :update_user_id - + field :reviewer_ids + field :reviewer_show_ids + field :unassigned_seminar_signup_ids + field :review_start_date, :type => Date + field :review_end_date, :type => Date belongs_to :seminar_item - + belongs_to :organizer , :class_name=>"MemberProfile", :foreign_key => :organizer_id has_many :seminar_links, :autosave => true, :dependent => :destroy has_many :seminar_files, :autosave => true, :dependent => :destroy has_many :seminar_item_contents, :autosave => true, :dependent => :destroy @@ -53,6 +57,85 @@ class SeminarMain accepts_nested_attributes_for :seminar_submission_field_sets, :allow_destroy => true accepts_nested_attributes_for :seminar_email_sets, :allow_destroy => true accepts_nested_attributes_for :seminar_signup_field_customs, :allow_destroy => true + before_save do + module_app_key = "seminar" + add_module_app_member_ids = [] + remove_module_app_member_ids = [] + if self.reviewer_ids_changed? + new_reviewer_ids = self.reviewer_ids.to_a - self.reviewer_ids_was.to_a + remove_reviewer_ids = self.reviewer_ids_was.to_a - self.reviewer_ids.to_a + new_reviewer_ids.each do |reviewer_id| + SeminarReview.create(:reviewer_id=>reviewer_id,:seminar_main=>self) + add_module_app_member_ids << reviewer_id + end + remove_reviewer_ids.each do |reviewer_id| + SeminarReview.where(:reviewer_id=>reviewer_id,:seminar_main=>self).destroy + remove_module_app_member_ids << reviewer_id + end + unassigned_seminar_signup_ids = self.seminar_signup_ids.map{|s| s.to_s} + seminar_reviews = self.seminar_reviews + seminar_reviews.each do |sr| + unassigned_seminar_signup_ids = unassigned_seminar_signup_ids - sr.all_seminar_signup_ids + end + self.unassigned_seminar_signup_ids = unassigned_seminar_signup_ids + end + if self.organizer_id_changed? + if self.organizer_id_was.present? + remove_module_app_member_ids << self.organizer_id_was + end + if self.organizer_id.present? + add_module_app_member_ids << self.organizer_id + end + end + remove_module_app_member_ids.delete(self.organizer_id) + self.reviewer_ids.each{|r| remove_module_app_member_ids.delete(r)} + remove_module_app_member_ids.each do |m_id| + user = User.where(:member_profile_id=>m_id).first + begin + user.extra_link_module_app_keys.delete(module_app_key) + user.save + rescue + next + end + end + add_module_app_member_ids.each do |m_id| + user = User.where(:member_profile_id=>m_id).first + begin + user.extra_link_module_app_keys << module_app_key + user.save + rescue + next + end + end + end + before_create do + self.unassigned_seminar_signup_ids = [] + end + after_initialize do + unless self.new_record? + save_flag = false + seminar_reviews = self.seminar_reviews + if seminar_reviews.present? + if self["reviewer_ids"].nil? + self["reviewer_ids"] = seminar_reviews.pluck(:reviewer_id).flatten.select{|s| !s.nil?}.to_a + save_flag = true + end + if seminar_reviews.count != 0 && self.review_start_date.nil? && self.review_end_date.nil? + seminar_review = seminar_reviews.first + self.review_start_date = seminar_review.review_start_date rescue nil + self.review_end_date = seminar_review.review_end_date rescue nil + unless (self.review_start_date.nil? && self.review_end_date.nil?) + save_flag = true + end + end + end + if self.unassigned_seminar_signup_ids.nil? + self.unassigned_seminar_signup_ids = self.seminar_signup_ids.map{|s| s.to_s} + save_flag = true + end + self.save if save_flag + end + end def self.time_range(date1 = null, date2 = null) if !date1.blank? diff --git a/app/models/seminar_review.rb b/app/models/seminar_review.rb index 8ed7aee..fb407d6 100644 --- a/app/models/seminar_review.rb +++ b/app/models/seminar_review.rb @@ -5,8 +5,53 @@ class SeminarReview include Mongoid::Document include Mongoid::Timestamps - field :review_start_date, :type => Date, :default => Time.now - field :review_end_date, :type => Date, :default => Time.now + field :review_start_date, :type => Date, :default => Time.now #Already move to seminar_main + field :review_end_date, :type => Date, :default => Time.now #Already move to seminar_main field :reviewer_id + field :seminar_signup_ids, :type => Array, :default => [] + field :remove_seminar_signup_ids, :type => Array, :default => [] + field :default_seminar_signup_ids, :type => Array, :default => [] + field :default_topics, :type => Array, :default => [] + field :default_topics_values, :type => Array, :default => [] belongs_to :seminar_main + after_initialize do + unless self.new_record? + if (self.reviewer_id.class == Array rescue false) + reviewer_ids = self.reviewer_id[1..-1] + reviewer_ids.each do |reviewer_id| + self.class.create(:reviewer_id=>reviewer_id,:seminar_main=>self.seminar_main) + end + self.reviewer_id = self.reviewer_id.first + self.save + end + end + end + before_save do + default_seminar_signup_ids = [] + self.default_topics.each_with_index do |topic,i| + fn,id = (topic.split(".") rescue []) + next if fn.nil? + if fn == "seminar_signup_fields" + default_seminar_signup_ids += SeminarSignupValue.where(:seminar_signup_field_id=>id,:val.in=>self.default_topics_values[i].to_a).pluck(:seminar_signup_id) + elsif "seminar_submission_fields" + seminar_signup_contribute_ids = SeminarSubmissionValue.where(:seminar_submission_field_id=>id,:val.in=>self.default_topics_values[i].to_a).pluck(:seminar_signup_contribute) + default_seminar_signup_ids += SeminarSignupContribute.where(:id.in=>seminar_signup_contribute_ids).pluck(:seminar_signup_id) + end + end + default_seminar_signup_ids.uniq! + default_seminar_signup_ids = default_seminar_signup_ids.map{|s| s.to_s} + self.default_seminar_signup_ids = default_seminar_signup_ids + end + def review + MemberProfile.find(self.reviewer_id) rescue nil + end + def all_seminar_signup_ids + seminar_signup_ids - remove_seminar_signup_ids + default_seminar_signup_ids + end + def append_default_signup_id(signup_id) + sid = signup_id.to_s + unless self.default_seminar_signup_ids.include?(sid) + self.default_seminar_signup_ids << sid + end + end end diff --git a/app/models/seminar_signup.rb b/app/models/seminar_signup.rb index 9f40877..cd08c32 100644 --- a/app/models/seminar_signup.rb +++ b/app/models/seminar_signup.rb @@ -22,6 +22,21 @@ class SeminarSignup accepts_nested_attributes_for :seminar_signup_values, allow_destroy: true accepts_nested_attributes_for :seminar_signup_contributes, allow_destroy: true - + after_destroy do + seminar_main = self.seminar_main + seminar_reviews = seminar_main.seminar_reviews + id = self.id.to_s + seminar_reviews.each do |sr| + if sr.all_seminar_signup_ids.include?(id) + sr.seminar_signup_ids.delete(id) + sr.remove_seminar_signup_ids.delete(id) + sr.default_seminar_signup_ids.delete(id) + sr.save + end + end + if seminar_main.unassigned_seminar_signup_ids.delete(id) + seminar_main.save + end + end end diff --git a/app/models/seminar_signup_admin_setting.rb b/app/models/seminar_signup_admin_setting.rb new file mode 100644 index 0000000..94b0864 --- /dev/null +++ b/app/models/seminar_signup_admin_setting.rb @@ -0,0 +1,7 @@ +# encoding: utf-8 +class SeminarSignupAdminSetting + include Mongoid::Document + include Mongoid::Timestamps + field :display_field , type: Array , default: [] + field :seminar_main_id +end \ No newline at end of file diff --git a/app/models/seminar_signup_value.rb b/app/models/seminar_signup_value.rb index f477f67..85b9da3 100644 --- a/app/models/seminar_signup_value.rb +++ b/app/models/seminar_signup_value.rb @@ -46,25 +46,30 @@ class SeminarSignupValue end def get_field_value - if (self.seminar_signup_field.markup.eql?("text_field") || self.seminar_signup_field.markup.eql?("text_area")) + seminar_signup_field = self.seminar_signup_field + if (seminar_signup_field.markup.eql?("text_field") || seminar_signup_field.markup.eql?("text_area")) + if self.value.class == String + field_value = self.value + else field_value = self.value[I18n.locale] - elsif (self.seminar_signup_field.markup.eql?("select") || self.seminar_signup_field.markup.eql?("radio_button")) - field_value = self.seminar_signup_field.markup_value["#{self.value}"][I18n.locale] rescue nil - elsif self.seminar_signup_field.markup.eql?("address") - field_value = rf[:address_key][I18n.locale].map{|k,v| v}.delete_if(&:blank?).join(', ') - elsif self.seminar_signup_field.markup.eql?("date") - case self.seminar_signup_field.typeC['format'] - when 'format1' - field_value = self.value.to_date.strftime("%Y/%m/%d") - when 'format2' - field_value = self.value.to_date.strftime("%Y/%m/%d") - when 'format3' - field_value = self.value.to_date.strftime("%Y/%m") - when 'format4' - field_value = self.value.to_date.strftime("%Y") - end - elsif self.seminar_signup_field.markup.eql?("checkbox") - field_value = self.value.map {|v| self.seminar_signup_field.markup_value["#{v}"][I18n.locale]}.join(', ') rescue nil + end + elsif (seminar_signup_field.markup.eql?("select") || seminar_signup_field.markup.eql?("radio_button")) + field_value = seminar_signup_field.markup_value["#{self.value}"][I18n.locale] rescue nil + elsif seminar_signup_field.markup.eql?("address") + field_value = rf[:address_key][I18n.locale].map{|k,v| v}.delete_if(&:blank?).join(', ') + elsif seminar_signup_field.markup.eql?("date") + case seminar_signup_field.typeC['format'] + when 'format1' + field_value = self.value.to_date.strftime("%Y/%m/%d") + when 'format2' + field_value = self.value.to_date.strftime("%Y/%m/%d") + when 'format3' + field_value = self.value.to_date.strftime("%Y/%m") + when 'format4' + field_value = self.value.to_date.strftime("%Y") + end + elsif seminar_signup_field.markup.eql?("checkbox") + field_value = self.value.map {|v| seminar_signup_field.markup_value["#{v}"][I18n.locale]}.join(', ') rescue nil end field_value = (field_value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "#{field_value}" : field_value @@ -72,15 +77,15 @@ class SeminarSignupValue if !field_value.blank? { - "key" => self.seminar_signup_field.key, - "title" => self.seminar_signup_field.title, + "key" => seminar_signup_field.key, + "title" => seminar_signup_field.title, "value" => field_value, "val" => field_value = self.value } else { - "key" => self.seminar_signup_field.key, - "title" => self.seminar_signup_field.title, + "key" => seminar_signup_field.key, + "title" => seminar_signup_field.title, "value" => "", "val" => field_value = self.value } @@ -88,29 +93,30 @@ class SeminarSignupValue end def get_value_by_locale(locale,add_more_index=nil) - case self.seminar_signup_field.markup + seminar_signup_field = self.seminar_signup_field + case seminar_signup_field.markup when "text_field" - case self.seminar_signup_field.add_more - when true - if self.seminar_signup_field.locale - add_more_index.nil? ? self.value.collect{|t| t[locale.to_s]}.join(",") : self.value(add_more_index)[locale] - else - add_more_index.nil? ? self.value.join(",") : self.value(add_more_index) - end - - when false - self.seminar_signup_field.locale ? self[locale.to_s] : self.value + case seminar_signup_field.add_more + when true + if seminar_signup_field.locale + add_more_index.nil? ? self.value.collect{|t| t[locale.to_s]}.join(",") : self.value(add_more_index)[locale] + else + add_more_index.nil? ? self.value.join(",") : self.value(add_more_index) + end + + when false + seminar_signup_field.locale ? self[locale.to_s] : self.value end when "select" - markup_values = self.seminar_signup_field.self_defined_markup_options? ? self.seminar_signup_field.markup_value : self.seminar_signup_field.markup_value + markup_values = seminar_signup_field.self_defined_markup_options? ? seminar_signup_field.markup_value : self.seminar_signup_field.markup_value markup_values[self.value][locale.to_s] rescue 'NoData' when "text_area" - self.seminar_signup_field.locale ? self[locale.to_s] : self.value + seminar_signup_field.locale ? self[locale.to_s] : self.value when "date" - if self.seminar_signup_field.date_is_range? + if seminar_signup_field.date_is_range? get_date_by_format(:from) + ' ~ ' + get_date_by_format(:to) # self.value["from"] + ' ~ ' + self.value["to"] else @@ -122,17 +128,17 @@ class SeminarSignupValue self.value[locale.to_s] when "radio_button" - markup_values = self.seminar_signup_field.markup_value + markup_values = seminar_signup_field.markup_value markup_values[self.value][locale.to_s] when "checkbox" - markup_values = self.seminar_signup_field.markup_value + markup_values = seminar_signup_field.markup_value self.value.collect{|key| markup_values["#{key}"][I18n.locale]}.join(",") when "date_durnation" self.value else - self.seminar_signup_field.locale ? self[locale.to_s] : self.value + seminar_signup_field.locale ? self[locale.to_s] : self.value end end @@ -174,18 +180,19 @@ def unset_all_lang_values end def data_proc + seminar_signup_field = self.seminar_signup_field unless self[:temp_data].nil? - case self.seminar_signup_field.markup + case seminar_signup_field.markup when "address" self["val"] = self["temp_data"] when 'text_field','text_area' - if self.seminar_signup_field.add_more + if seminar_signup_field.add_more self["val"] = self["temp_data"] else # if not add_more - if self.seminar_signup_field.can_muti_lang_input? + if seminar_signup_field.can_muti_lang_input? self[:temp_data].each do |key,val| self[key] = val - end if(!self.seminar_signup_field.get_data[:cross_lang]) + end if(!seminar_signup_field.get_data[:cross_lang]) else self["val"] = self[:temp_data] end diff --git a/app/models/seminar_submission_value.rb b/app/models/seminar_submission_value.rb index b04aea8..73accec 100644 --- a/app/models/seminar_submission_value.rb +++ b/app/models/seminar_submission_value.rb @@ -45,25 +45,30 @@ class SeminarSubmissionValue end def get_field_value - if (self.seminar_submission_field.markup.eql?("text_field") || self.seminar_submission_field.markup.eql?("text_area")) + seminar_submission_field = self.seminar_submission_field + if (seminar_submission_field.markup.eql?("text_field") || seminar_submission_field.markup.eql?("text_area")) + if self.value.class == String + field_value = self.value + else field_value = self.value[I18n.locale] - elsif (self.seminar_submission_field.markup.eql?("select") || self.seminar_submission_field.markup.eql?("radio_button")) - field_value = self.seminar_submission_field.markup_value["#{self.value}"][I18n.locale] rescue nil - elsif self.seminar_submission_field.markup.eql?("address") - field_value = rf[:address_key][I18n.locale].map{|k,v| v}.delete_if(&:blank?).join(', ') - elsif self.seminar_submission_field.markup.eql?("date") - case self.seminar_submission_field.typeC['format'] - when 'format1' - field_value = self.value.to_date.strftime("%Y/%m/%d") - when 'format2' - field_value = self.value.to_date.strftime("%Y/%m/%d") - when 'format3' - field_value = self.value.to_date.strftime("%Y/%m") - when 'format4' - field_value = self.value.to_date.strftime("%Y") - end - elsif self.seminar_submission_field.markup.eql?("checkbox") - field_value = self.value.map {|v| self.seminar_submission_field.markup_value["#{v}"][I18n.locale]}.join(', ') rescue nil + end + elsif (seminar_submission_field.markup.eql?("select") || seminar_submission_field.markup.eql?("radio_button")) + field_value = seminar_submission_field.markup_value["#{self.value}"][I18n.locale] rescue nil + elsif seminar_submission_field.markup.eql?("address") + field_value = rf[:address_key][I18n.locale].map{|k,v| v}.delete_if(&:blank?).join(', ') + elsif seminar_submission_field.markup.eql?("date") + case seminar_submission_field.typeC['format'] + when 'format1' + field_value = self.value.to_date.strftime("%Y/%m/%d") + when 'format2' + field_value = self.value.to_date.strftime("%Y/%m/%d") + when 'format3' + field_value = self.value.to_date.strftime("%Y/%m") + when 'format4' + field_value = self.value.to_date.strftime("%Y") + end + elsif seminar_submission_field.markup.eql?("checkbox") + field_value = self.value.map {|v| seminar_submission_field.markup_value["#{v}"][I18n.locale]}.join(', ') rescue nil end field_value = (field_value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "#{field_value}" : field_value @@ -71,15 +76,15 @@ class SeminarSubmissionValue if !field_value.blank? { - "key" => self.seminar_submission_field.key, - "title" => self.seminar_submission_field.title, + "key" => seminar_submission_field.key, + "title" => seminar_submission_field.title, "value" => field_value, "val" => field_value = self.value } else { - "key" => self.seminar_submission_field.key, - "title" => self.seminar_submission_field.title, + "key" => seminar_submission_field.key, + "title" => seminar_submission_field.title, "value" => "", "val" => field_value = self.value } @@ -87,29 +92,30 @@ class SeminarSubmissionValue end def get_value_by_locale(locale,add_more_index=nil) - case self.seminar_submission_field.markup + seminar_submission_field = self.seminar_submission_field + case seminar_submission_field.markup when "text_field" - case self.seminar_submission_field.add_more - when true - if self.seminar_submission_field.locale - add_more_index.nil? ? self.value.collect{|t| t[locale.to_s]}.join(",") : self.value(add_more_index)[locale] - else - add_more_index.nil? ? self.value.join(",") : self.value(add_more_index) - end - - when false - self.seminar_submission_field.locale ? self[locale.to_s] : self.value + case seminar_submission_field.add_more + when true + if seminar_submission_field.locale + add_more_index.nil? ? self.value.collect{|t| t[locale.to_s]}.join(",") : self.value(add_more_index)[locale] + else + add_more_index.nil? ? self.value.join(",") : self.value(add_more_index) + end + + when false + seminar_submission_field.locale ? self[locale.to_s] : self.value end when "select" - markup_values = self.seminar_submission_field.self_defined_markup_options? ? self.seminar_submission_field.markup_value : self.seminar_submission_field.markup_value + markup_values = seminar_submission_field.self_defined_markup_options? ? seminar_submission_field.markup_value : self.seminar_submission_field.markup_value markup_values[self.value][locale.to_s] rescue 'NoData' when "text_area" - self.seminar_submission_field.locale ? self[locale.to_s] : self.value + seminar_submission_field.locale ? self[locale.to_s] : self.value when "date" - if self.seminar_submission_field.date_is_range? + if seminar_submission_field.date_is_range? get_date_by_format(:from) + ' ~ ' + get_date_by_format(:to) # self.value["from"] + ' ~ ' + self.value["to"] else @@ -121,17 +127,17 @@ class SeminarSubmissionValue self.value[locale.to_s] when "radio_button" - markup_values = self.seminar_submission_field.markup_value + markup_values = seminar_submission_field.markup_value markup_values[self.value][locale.to_s] when "checkbox" - markup_values = self.seminar_submission_field.markup_value + markup_values = seminar_submission_field.markup_value self.value.collect{|key| markup_values["#{key}"][I18n.locale]}.join(",") when "date_durnation" self.value else - self.seminar_submission_field.locale ? self[locale.to_s] : self.value + seminar_submission_field.locale ? self[locale.to_s] : self.value end end @@ -167,22 +173,23 @@ class SeminarSubmissionValue protected def unset_all_lang_values - VALID_LOCALES.each{|t| self.unset t} - end + VALID_LOCALES.each{|t| self.unset t} +end def data_proc + seminar_submission_field = self.seminar_submission_field unless self[:temp_data].nil? - case self.seminar_submission_field.markup + case seminar_submission_field.markup when "address" self["val"] = self["temp_data"] when 'text_field','text_area' - if self.seminar_submission_field.add_more + if seminar_submission_field.add_more self["val"] = self["temp_data"] else # if not add_more - if self.seminar_submission_field.can_muti_lang_input? + if seminar_submission_field.can_muti_lang_input? self[:temp_data].each do |key,val| self[key] = val - end if(!self.seminar_submission_field.get_data[:cross_lang]) + end if(!seminar_submission_field.get_data[:cross_lang]) else self["val"] = self[:temp_data] end diff --git a/app/models/seminar_user.rb b/app/models/seminar_user.rb new file mode 100644 index 0000000..d130630 --- /dev/null +++ b/app/models/seminar_user.rb @@ -0,0 +1,13 @@ +class SeminarUser + include Mongoid::Document + include Mongoid::Timestamps + field :user_name + field :password + belongs_to :seminar_main + # belongs_to :user + # before_save do + # if self.new_record? + # self.user = User.find() + # end + # end +end \ No newline at end of file diff --git a/app/views/admin/seminars/_form.html.erb b/app/views/admin/seminars/_form.html.erb index 378188f..27d3a1c 100644 --- a/app/views/admin/seminars/_form.html.erb +++ b/app/views/admin/seminars/_form.html.erb @@ -64,7 +64,12 @@ <%= f.datetime_picker :seminar_end_date, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @seminar.new_record? %> - +
+ +
+ <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'seminar_main[organizer_id]', email_members:Array(f.object.organizer), index: "1", select_name: 'organizer_id'} %> +
+
@@ -131,30 +136,28 @@
- <%= f.fields_for :seminar_reviews,@review do |seminar_reviews_form| %>
<% if !@member.nil? %> - <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'seminar_main[seminar_reviews_attributes][0][reviewer_id][]', email_members:@member} %> + <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'seminar_main[reviewer_ids][]', email_members:@member, index: "2", select_name: 'reviewer_ids'} %> <% else %> - <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'seminar_main[seminar_reviews_attributes][0][reviewer_id][]', email_members:[]} %> + <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'seminar_main[reviewer_ids][]', email_members:[], index: "2", select_name: 'reviewer_ids'} %> <% end %>
-
+
- <%= seminar_reviews_form.datetime_picker :review_start_date, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @seminar.new_record? %> + <%= f.datetime_picker :review_start_date, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @seminar.new_record? %>
-
- -
- <%= seminar_reviews_form.datetime_picker :review_end_date, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @seminar.new_record? %> -
-
- <% end %> +
+ +
+ <%= f.datetime_picker :review_end_date, :no_label => true, :format=>"yyyy/MM/dd", :new_record => @seminar.new_record? %> +
+
diff --git a/app/views/admin/seminars/_get_display_fields.html.erb b/app/views/admin/seminars/_get_display_fields.html.erb new file mode 100644 index 0000000..5114ca2 --- /dev/null +++ b/app/views/admin/seminars/_get_display_fields.html.erb @@ -0,0 +1,119 @@ +<% @field_names = [] %> +<% @field_name_translations = [] %> +<% default_hidden = [] %> +<% if @seminar.present? %> + <% if @seminar.seminar_signup_field_sets.count != 0 %> + <% @seminar.seminar_signup_field_sets.each do |field_set| %> + <% default_hidden << "seminar_signup_field_set.#{field_set.field_name}" if (field_set.hidden) %> + <% @field_names << "seminar_signup_field_set.#{field_set.field_name}" %> + <% @field_name_translations << field_set.name[I18n.locale] %> + <% end %> + <% else %> + <% ['seminar_signup.name','seminar_signup.tel','seminar.registration_status'].each do |th| %> + <% @field_names << "default.#{th}" %> + <% @field_name_translations << t(th) %> + <% end %> + <% end %> + <% if @seminar.seminar_signup_field_customs.count != 0 %> + <% @seminar.seminar_signup_field_customs.each do |field_set| %> + <% s = SeminarSignupField.where(id:field_set.seminar_signup_field_id).first %> + <% title = s.title rescue '' %> + <% next if title.blank? %> + <% next if s.key.blank? %> + <% default_hidden << "seminar_signup_field_custom.#{s.key}" if (field_set.hidden) %> + <% @field_names << "seminar_signup_field_custom.#{s.key}" %> + <% @field_name_translations << (title)%> + <% end %> + <% end %> + <% @seminar.seminar_signup_fields.each do |s| %> + <% default_hidden << "seminar_signup_fields.#{s.key}" %> + <% @field_names << "seminar_signup_fields.#{s.key}" %> + <% @field_name_translations << s.title %> + <% end %> + <% if @seminar.seminar_submission_field_sets.count != 0 %> + <% show1 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='title'}[0].hidden) + show2 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='file'}[0].hidden) + show3 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='description'}[0].hidden) + %> + <% else %> + <% show1 = true + show2 = true + show3 = true + %> + <% end %> + <% default_hidden << "seminar_signup_contributes.title" if !show1 %> + <% @field_names << 'seminar_signup_contributes.title' %> + <% @field_name_translations << t('seminar_signup.title') %> + + <% default_hidden << "seminar_signup_contributes.file" if !show2 %> + <% @field_names << 'seminar_signup_contributes.file' %> + <% @field_name_translations << t('seminar_signup.file') %> + + <% default_hidden << "seminar_signup_contributes.description" if !show3 %> + <% @field_names << 'seminar_signup_contributes.description' %> + <% @field_name_translations << t('seminar_signup.description') %> + <% @seminar.seminar_submission_fields.each do |s| %> + <% @field_names << "seminar_submission_fields.#{s.key}" %> + <% @field_name_translations << s.title %> + <% end %> + <% @display_field = @seminar_signup_admin_setting.display_field %> + <% if @display_field.blank? + @display_field = @field_names - default_hidden + end %> +<% else %> + <% @field_names = [] %> + <% @field_name_translations = [] %> + <% default_show = [] %> + <% seminar_signup_field_sets = SeminarSignupFieldSet.all.uniq{|s| s.field_name} %> + <% if seminar_signup_field_sets.count != 0 %> + <% seminar_signup_field_sets.each do |field_set| %> + <% default_show << "seminar_signup_field_set.#{field_set.field_name}" if !(field_set.hidden) %> + <% @field_names << "seminar_signup_field_set.#{field_set.field_name}" %> + <% @field_name_translations << field_set.name[I18n.locale] %> + <% end %> + <% else %> + <% ['seminar_signup.name','seminar_signup.tel','seminar.registration_status'].each do |th| %> + <% @field_names << "default.#{th}" %> + <% @field_name_translations << t(th) %> + <% end %> + <% end %> + <% seminar_signup_field_customs = SeminarSignupFieldCustom.all.map{|field_set| SeminarSignupField.where(id: field_set.seminar_signup_field_id).first}.select{|s| !s.nil?}.uniq{|s| s.key } %> + <% if seminar_signup_field_customs.count != 0 %> + <% seminar_signup_field_customs.each do |s| %> + <% title = s.title rescue '' %> + <% next if title.blank? %> + <% next if s.key.blank? %> + <% @field_names << "seminar_signup_field_custom.#{s.key}" %> + <% @field_name_translations << (title)%> + <% end %> + <% end %> + <% seminar_signup_fields = SeminarSignupField.all.uniq{|s| s.key} %> + <% seminar_signup_fields.each do |s| %> + <% @field_names << "seminar_signup_fields.#{s.key}" %> + <% @field_name_translations << s.title %> + <% end %> + <% show1 = true + show2 = true + show3 = true + %> + <% default_show << "seminar_signup_contributes.title" if show1 %> + <% @field_names << 'seminar_signup_contributes.title' %> + <% @field_name_translations << t('seminar_signup.title') %> + + <% default_show << "seminar_signup_contributes.file" if show2 %> + <% @field_names << 'seminar_signup_contributes.file' %> + <% @field_name_translations << t('seminar_signup.file') %> + + <% default_show << "seminar_signup_contributes.description" if show3 %> + <% @field_names << 'seminar_signup_contributes.description' %> + <% @field_name_translations << t('seminar_signup.description') %> + <% seminar_submission_fields = SeminarSignupField.all.uniq{|s| s.key} %> + <% seminar_submission_fields.each do |s| %> + <% @field_names << "seminar_submission_fields.#{s.key}" %> + <% @field_name_translations << s.title %> + <% end %> + <% @display_field = @seminar_signup_admin_setting.display_field %> + <% if @display_field.blank? + @display_field = default_show + end %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/seminars/_index.html.erb b/app/views/admin/seminars/_index.html.erb index cb0b6b4..68b2f3f 100644 --- a/app/views/admin/seminars/_index.html.erb +++ b/app/views/admin/seminars/_index.html.erb @@ -22,11 +22,12 @@ <%= seminar.title %>
@@ -34,8 +35,19 @@ <%= SeminarMain.time_range(seminar.seminar_start_date, seminar.seminar_end_date) %> <%= SeminarMain.time_range(seminar.signup_start_date, seminar.signup_end_date) %> - <%= seminar.seminar_signups.count %> - <%= t('seminar.export') %> + + <% @seminar_review = seminar.seminar_reviews.where(:reviewer_id => current_user.member_profile_id.to_s).first %> + <% if @seminar_review.present? && !@can_edit %> + <%= @seminar_review.all_seminar_signup_ids.count %> + <% else %> + <%= seminar.seminar_signups.count %> + <% end %> + + + <% if can_see_seminar_signup(seminar) %> + <%= t('seminar.export') %> + <% end %> + <% end %> diff --git a/app/views/admin/seminars/_seminar_signup_dashboard.html.erb b/app/views/admin/seminars/_seminar_signup_dashboard.html.erb new file mode 100644 index 0000000..2f97dee --- /dev/null +++ b/app/views/admin/seminars/_seminar_signup_dashboard.html.erb @@ -0,0 +1,225 @@ +

<%= @seminar.title %>

+
+<% org_seminar_signups = @seminar_signups %> +
+

<%= t("seminar.reviewer") %>

+ <% reviewer_show_ids = @seminar.reviewer_show_ids %> + <% if reviewer_show_ids.nil? + reviewer_show_ids = @seminar.reviewer_ids[0..1] + @seminar.update(:reviewer_show_ids=>reviewer_show_ids) + end + %> + <% count = 0 %> + <% reviewer_show_ids.each do |reviewer_id| %> + <% seminar_review = @seminar.seminar_reviews.where(:reviewer_id => reviewer_id.to_s).first %> + <% next if seminar_review.nil? %> + <% count += 1 %> +
+
<%= MemberProfile.find(reviewer_id).name rescue "" %>
+ - + <% @seminar_signups = SeminarSignup.where(:id.in=>seminar_review.all_seminar_signup_ids) %> + <% @seminar_signups = @seminar_signups.page(params["page_no#{count}"]).per(5) %> + <% @seminar_signups = @seminar_signups.page(0) if @seminar_signups.to_a.count == 0 %> + <%= render :partial => "seminar_signup_render_table",:locals=>{:@seminar_signups=>@seminar_signups,:@drag => true,:@include_blank=>true,:@reviewer_id=>seminar_review.id.to_s} %> + <% + pagination_html = content_tag :div, class: "bottomnav clearfix", style: "position: static;" do + content_tag :div, paginate(@seminar_signups), class: "pagination pagination-centered" + end + %> + <%= pagination_html.gsub(/page_no#{count}=\d*/,"").gsub('&&','&').gsub(/page=(\d*)/m){|ff| ff.gsub("page=#{$1}","page=#{params[:page]}&page_no#{count}=#{$1}")}.html_safe %> +
+ <% end %> + <% if count != 2 && @seminar.seminar_reviews.count >= 2 %> + <% (0...(2-count)).each do |i| %> +
+ +
+ <% end %> + <% end %> +
+<% @seminar_signups = org_seminar_signups + @include_blank = false + @reviewer_id = nil +%> +
+
+ <%= render :partial => "seminar_signup_render_table" %> +
+<%= + content_tag :div, class: "bottomnav clearfix", style: "position: static;" do + content_tag :div, paginate(@seminar_signups), class: "pagination pagination-centered" + end +%> +
+<% unless request.xhr? %> +
" style="display: none;"> +
+
+ +
+
+
+
+ <%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t("seminar.field_display_setting"), seminar_signup_admin_setting_admin_seminar_path(params[:id]), :class => 'btn btn-primary' %> +
+
+ + +<% end %> \ No newline at end of file diff --git a/app/views/admin/seminars/_seminar_signup_render_table.html.erb b/app/views/admin/seminars/_seminar_signup_render_table.html.erb new file mode 100644 index 0000000..3034f37 --- /dev/null +++ b/app/views/admin/seminars/_seminar_signup_render_table.html.erb @@ -0,0 +1,122 @@ + + + + <% render :partial => "get_display_fields" %> + <% if @seminar.nil? %> + + <% end %> + <% if @drag%> + + <% end %> + <% @field_name_translations.each_with_index do |trans,i|%> + <% next unless @display_field.include?(@field_names[i]) %> + + <% end %> + + + > + <% @seminar_signups.each do |seminar_signup| %> + <% len = seminar_signup.seminar_signup_contributes.count %> + <% rowspan = "rowspan=#{len==0? 1 : len}" %> + <% vals = [] %> + + <% if @drag%> + + <% end %> + <% vals << seminar_signup.seminar_main.title if @seminar.nil? %> + <% @display_field.each_with_index do |fn,i|%> + <% names = fn.split(".") %> + <% val = "" %> + <% if names[0] == "seminar_signup_field_set" %> + <% if names[1] == "name" %> + <% val = seminar_signup.name + val += "
+ +
" + %> + <% elsif names[1] == 'status' %> + <% val = t("seminar.registration_status_#{seminar_signup.status}") if !seminar_signup.status.blank? %> + <% elsif names[1] != 'recaptcha' %> + <% val = seminar_signup.send("#{names[1]}") %> + <% end %> + <% elsif names[0] == "default" %> + <% if names[2] == "name" %> + <% val = seminar_signup.name + val += "
+ +
" + %> + <% elsif names[2] == "tel" %> + <% val = seminar_signup.tel %> + <% elsif names[2] == "registration_status" %> + <% val = t("seminar.registration_status_#{seminar_signup.status}") if !seminar_signup.status.blank? %> + <% end %> + <% elsif names[0] == "seminar_signup_field_custom" || names[0] == "seminar_signup_fields" %> + <% val = seminar_signup.seminar_signup_values.where(:key=>names[1]).first.get_value_by_locale(I18n.locale) rescue "" %> + <% elsif names[0] == "seminar_signup_contributes" %> + <% if names[1] == "file" %> + <% val = seminar_signup.seminar_signup_contributes.to_a %> + <% else %> + <% val = seminar_signup.seminar_signup_contributes.collect{|s| s.send(names[1])} %> + <% end %> + <% elsif names[0] == "seminar_submission_fields" %> + <% val = seminar_signup.seminar_signup_contributes.collect{|s| (s.seminar_submission_values.where(:key=>names[1]).first.get_value_by_locale(I18n.locale) rescue "")} %> + <% end %> + <% vals << val %> + <% end %> + <% count = 0 %> + <% indices = [] %> + <% vals.each_with_index do |val,i| %> + <% if val.class == Array %> + <% count = val.count - 1 %> + <% indices << i%> + + <% else %> + + <% end %> + <% end %> + <% (0...count).each do |i|%> + + <% indices.each do |index| %> + + <% end %> + + <% end %> + + <% end %> + <% if @include_blank && @seminar_signups.count == 0 %> + + <% if @drag %> + + <% end %> + <% (0...@display_field.count).each do |f| %> + + <% end %> + + <% end %> + +
<%= t('seminar.title') %><%= trans %>
> + <% if val[0].class == SeminarSignupContribute #File %> + <% seminar_signup_contribute = val[0] %> + <%= link_to (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(seminar_signup_contribute.description).text} if seminar_signup_contribute.file.file %> + <% else %> + <%= val[0].html_safe.to_s rescue "" %> + <% end %> + ><%= val.to_s.html_safe %>
+ <% if vals[index][i].class == SeminarSignupContribute #File %> + <% seminar_signup_contribute = vals[index][i] %> + <%= link_to (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(seminar_signup_contribute.description).text} if seminar_signup_contribute.file.file %> + <% else %> + <%= vals[index][i].html_safe.to_s rescue "" %> + <% end %> +
\ No newline at end of file diff --git a/app/views/admin/seminars/_seminar_signup_table.html.erb b/app/views/admin/seminars/_seminar_signup_table.html.erb new file mode 100644 index 0000000..bab8d13 --- /dev/null +++ b/app/views/admin/seminars/_seminar_signup_table.html.erb @@ -0,0 +1,22 @@ +
+
+ + +
+
+ + +

<%= @seminar.title %>

+ +<%= render :partial => "seminar_signup_render_table" %> + +
+ + <% if @can_edit %> +
+ <%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t("seminar.field_display_setting"), seminar_signup_admin_setting_admin_seminar_path(params[:id]), :class => 'btn btn-primary' %> +
+ <% end %> +
+ +<%= render 'layouts/delete_modal', delete_options: @delete_options %> \ No newline at end of file diff --git a/app/views/admin/seminars/enquiry_for_applicants.html.erb b/app/views/admin/seminars/enquiry_for_applicants.html.erb new file mode 100644 index 0000000..391eec0 --- /dev/null +++ b/app/views/admin/seminars/enquiry_for_applicants.html.erb @@ -0,0 +1,33 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> + <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> + <%= javascript_include_tag "lib/file-type" %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> +
+ 查詢報名人 +
+
+ +
+ + +
+
+
+
+<%= render :partial => "seminar_signup_render_table" %> +<% if @can_edit %> +
+ +
+ <%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t("seminar.field_display_setting"), seminar_signup_admin_setting_admin_seminar_path("enquiry_for_applicants"), :class => 'btn btn-primary' %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/admin/seminars/export.xlsx.axlsx b/app/views/admin/seminars/export.xlsx.axlsx index 340998f..38ba346 100644 --- a/app/views/admin/seminars/export.xlsx.axlsx +++ b/app/views/admin/seminars/export.xlsx.axlsx @@ -34,7 +34,7 @@ wb.add_worksheet(name: (@seminar.title.to_s[0..27]+'...')) do |sheet| sheet.add_row row - @seminar.seminar_signups.each do |signup| + @seminar_signups.each do |signup| row2 = [] diff --git a/app/views/admin/seminars/get_hide_reviewer.html.erb b/app/views/admin/seminars/get_hide_reviewer.html.erb new file mode 100644 index 0000000..ac43f9d --- /dev/null +++ b/app/views/admin/seminars/get_hide_reviewer.html.erb @@ -0,0 +1,25 @@ +
    + <% @hide_reviewers.each do |member|%> + <% member_name = member.name %> + <% member_id = member.id.to_s %> + <% member_pic_url = ((member.avatar.file.present? rescue false) ? member.avatar.url : "/assets/member-pic.png") %> +
  • + + +
  • + <% end %> +
+ \ No newline at end of file diff --git a/app/views/admin/seminars/get_reviewer_block.html.erb b/app/views/admin/seminars/get_reviewer_block.html.erb new file mode 100644 index 0000000..5400b54 --- /dev/null +++ b/app/views/admin/seminars/get_reviewer_block.html.erb @@ -0,0 +1,14 @@ +<% seminar_review = @seminar.seminar_reviews.where(:reviewer_id => @reviewer_id.to_s).first %> +<% unless seminar_review.nil? %> +
+
<%= MemberProfile.find(@reviewer_id).name rescue "" %>
+ - + <% @seminar_signups = SeminarSignup.where(:id.in=>seminar_review.all_seminar_signup_ids) %> + <%= render :partial => "seminar_signup_render_table",:locals=>{:@seminar_signups=>@seminar_signups.page(params[:page]).per(5),:@drag => true,:@include_blank=>true,:@reviewer_id=>seminar_review.id.to_s} %> + <%= + content_tag :div, class: "bottomnav clearfix", style: "position: static;" do + content_tag :div, paginate(@seminar_signups), class: "pagination pagination-centered" + end + %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admin/seminars/reviewer_setting.html.erb b/app/views/admin/seminars/reviewer_setting.html.erb new file mode 100644 index 0000000..fdd1334 --- /dev/null +++ b/app/views/admin/seminars/reviewer_setting.html.erb @@ -0,0 +1,99 @@ +<% select_keys = [] %> +<% fields_values = @fields_values.map{|i,fields_values| + "
" + fields_values.map.with_index{|v,ii| "" }.join("") + + "
" +} %> +<%= form_for @seminar, url: update_reviewer_setting_admin_seminar_path(@seminar.id), html: {class: "form-horizontal main-forms"} do |f| %> +
+ <% count = 0 %> + <% @seminar_reviews.each_with_index do |seminar_review,i| %> + <% next if seminar_review.review.nil? %> + <%= f.fields_for :seminar_reviews,seminar_review do |f| %> +

<%= seminar_review.review.name rescue "" %>

+
+ +
+ <% seminar_review.default_topics.each_with_index do |v,ii| %> +
+ X + <%= select_tag("seminar_main[seminar_reviews_attributes][#{count}][default_topics][]" , options_for_select(@fields_translations.zip(@fields),v),{:class=>"select_field_types","data-index"=>count}) %> + <% select_index = @fields.index(v) %> + <% checked_values = seminar_review.default_topics_values[ii] %> +
+ <% @fields_values[select_index].each_with_index do |v,iii| %> + <% checked = checked_values.include?(iii.to_s) rescue false %> + + <% end if select_index.present? %> +
+
+ <% end %> + <% select_keys << select_tag("seminar_main[seminar_reviews_attributes][#{count}][default_topics][]" , options_for_select(@fields_translations.zip(@fields)),{:class=>"select_field_types","data-index"=>count}) %> + +
+
+ <% end %> + <% count += 1 %> + <% end %> +
+ <%= f.submit t('submit'), class: 'btn btn-primary' %> + + <%= link_to t('cancel'), admin_seminars_path, :class=>"btn" %> +
+
+<% end %> + + \ No newline at end of file diff --git a/app/views/admin/seminars/seminar_signup.html.erb b/app/views/admin/seminars/seminar_signup.html.erb index d3bc449..d0a0bd8 100644 --- a/app/views/admin/seminars/seminar_signup.html.erb +++ b/app/views/admin/seminars/seminar_signup.html.erb @@ -1,215 +1,21 @@ - - + - - -
-
- -
-
- - -

<%= @seminar.title %>

- - - - - <% if @seminar.seminar_signup_field_sets.count != 0 %> - <% @seminar.seminar_signup_field_sets.each do |field_set| %> - <% if !(field_set.hidden) %> - - <% end %> - <% end %> - <% else %> - - - - <% end %> - <% if @seminar.seminar_signup_field_customs.count != 0 %> - <% @seminar.seminar_signup_field_customs.each do |field_set| %> - <% if !(field_set.hidden) %> - - <% end %> - <% end %> - <% end %> - <% if @seminar.seminar_submission_field_sets.count != 0 %> - <% show1 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='title'}[0].hidden) - show2 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='file'}[0].hidden) - show3 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='description'}[0].hidden) - %> - <% else %> - <% show1 = true - show2 = true - show3 = true - %> - <% end %> - <% if show1 %> - - <% end %> - <% if show2 %> - - <% end %> - <% if show3 %> - - <% end %> - <% @seminar.seminar_submission_fields.asc(:_id).each do |submission_field| %> - - <% end %> - - - - <% @seminar_signups.each do |seminar_signup| %> - <% len = seminar_signup.seminar_signup_contributes.count %> - - <% if @seminar.seminar_signup_field_sets.count != 0 %> - <% @seminar.seminar_signup_field_sets.each do |field_set| %> - <% if !(field_set.hidden) %> - - <% end %> - <% end %> - <% else %> - - - - <% end %> - <% if @seminar.seminar_signup_field_customs.count != 0 %> - <% @seminar.seminar_signup_field_customs.each do |field_set| %> - <% if !(field_set.hidden) %> - - <% end %> - <% end %> - <% end %> - <% count_set = 0 %> - <% if @seminar.seminar_submission_field_sets.count != 0 %> - <% show1 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='title'}[0].hidden) - show2 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='file'}[0].hidden) - show3 = !(@seminar.seminar_submission_field_sets.select{|v| v.field_name=='description'}[0].hidden) - %> - <% @seminar.seminar_submission_field_sets.each do |field_set| %> - <% if !(field_set.hidden) %> - <% count_set+=1 %> - <% end %> - <% end %> - <% else %> - <% show1 = true - show2 = true - show3 = true - %> - <% count_set = 2 %> - <% end %> - <% if len==0 %> - <% - count_field = @seminar.seminar_submission_fields.count - %> -
    - <% for i in 1..count_field+count_set %> -
- <% end %> - - - <% end %> -
    - <% seminar_signup.seminar_signup_contributes.collect do |seminar_signup_contribute| %> - <% if show1 %> -
- <% end %> - <% if show2 %> - - <% end %> - <% if show3 %> - - <% end %> - <% - count_value = seminar_signup_contribute.seminar_submission_values.count - count_field = @seminar.seminar_submission_fields.count - %> - <% if count_value == count_field %> - <% seminar_signup_contribute.seminar_submission_values.asc(:seminar_submission_field_id).each do |value| %> - - <% end %> - <% else %> - <% for i in 1..(count_field-count_value) %> - - <% end %> - <% end %> - - - <% end %> - - - <% end %> - -
<%= field_set.name[I18n.locale] %><%= t('seminar_signup.name')%><%= t('seminar_signup.tel')%><%= t('seminar.registration_status')%><%= SeminarSignupField.where(id:field_set.seminar_signup_field_id).first.title rescue '' %><%= t('seminar_signup.title')%><%= t('seminar_signup.file')%><%= t('seminar_signup.description')%><%= submission_field.title %>
- <% if field_set.field_name== 'name' %> - <%= seminar_signup.name %> -
- -
- <% elsif field_set.field_name== 'status' %> - <%= t("seminar.registration_status_#{seminar_signup.status}") if !seminar_signup.status.blank? %> - <% elsif field_set.field_name != 'recaptcha' %> - <%= seminar_signup.send("#{field_set.field_name}") %> - <% end %> -
- <%= seminar_signup.name %> -
- -
-
<%= seminar_signup.tel %><%= t("seminar.registration_status_#{seminar_signup.status}") if !seminar_signup.status.blank? %> - - <% seminar_signup.seminar_signup_values.each do |seminar_signup_values| %> - <% if seminar_signup_values.seminar_signup_field_id == field_set.seminar_signup_field_id %> - <% if seminar_signup_values.value.class == String || seminar_signup_values.value.nil? %> - <%= seminar_signup_values.get_value_by_locale(I18n.locale,seminar_signup_values) %> - <% else %> - <% seminar_signup_values.value.each do |key,v| %> - <%= "#{I18n.t(key)}:#{seminar_signup_values.get_value_by_locale(key,seminar_signup_values)}" %> -
- <% end %> - <% end %> - <% end %> - <% end %> -
-
-
  • <%= seminar_signup_contribute.title.to_s %>
  • -
    -
  • - <%= link_to (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(seminar_signup_contribute.description).text} if seminar_signup_contribute.file.file %> -
  • -
    -
  • <%= seminar_signup_contribute.description.to_s.html_safe %>
  • -
    - - <% if value.value.class == String || value.value.nil? %> - <%= value.get_value_by_locale(I18n.locale,value) %> - <% else %> - <% value.value.each do |key,v| %> - <%= "#{I18n.t(key)}:#{value.get_value_by_locale(key,value)}" %> -
    - <% end %> - <% end %> -
    -
    -
    - -<%= - content_tag :div, class: "bottomnav clearfix" do - content_tag :div, paginate(@seminar_signups), class: "pagination pagination-centered" - end -%> -
    - -<%= render 'layouts/delete_modal', delete_options: @delete_options %> +<% if @can_edit %> + +<% end %> +<% if params[:type] == "table" || (!@can_edit) %> +
    + <%= render :partial => 'seminar_signup_table' %> +<% else %> + <%= render :partial => 'seminar_signup_dashboard' %> +<% end %> + diff --git a/app/views/admin/seminars/seminar_signup_admin_setting.html.erb b/app/views/admin/seminars/seminar_signup_admin_setting.html.erb new file mode 100644 index 0000000..557beda --- /dev/null +++ b/app/views/admin/seminars/seminar_signup_admin_setting.html.erb @@ -0,0 +1,57 @@ +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/bootstrap-datetimepicker" %> + <%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %> + <%= javascript_include_tag "lib/file-type" %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> +<%= form_for @seminar_signup_admin_setting, url: update_seminar_signup_admin_setting_admin_seminar_path, html: {class: "form-horizontal main-forms"} do |f| %> +

    + <% if @seminar %> + <%= @seminar.title %> + <% else %> + <%= t("seminar.enquiry_for_applicants_display_fields_setting") %> + <% end %> +

    +
    + +
    +

    <%= t('seminar.display_field') %>

    + <% render :partial => "get_display_fields" %> + <% max_length = 10 %> + <% @field_name_translations.each_with_index do |trans,i|%> + <% if i % max_length == 0 %> + + + + + <% else %> + + <% end %> + <% if ((i % max_length) == (max_length - 1) || i == (@field_name_translations.count - 1)) %> + + + + <% @field_names[((i/max_length) *max_length) ..i].each do |fn|%> + + <% end %> + +
    <%= trans %><%= trans %>
    <%= check_box_tag "#{f.object_name}[display_field][]",fn , @display_field.include?(fn) %>
    + <% end %> + <% end %> + <%= hidden_field_tag :id, params[:id] %> +
    + + +
    + <%= f.submit t('submit'), class: 'btn btn-primary' %> + + <%= link_to t('cancel'), seminar_signup_admin_seminar_path(params[:id]), :class=>"btn" %> +
    +
    +<% end %> \ No newline at end of file diff --git a/app/views/admin/seminars/seminar_signup_render_table.html.erb b/app/views/admin/seminars/seminar_signup_render_table.html.erb new file mode 100644 index 0000000..79d184c --- /dev/null +++ b/app/views/admin/seminars/seminar_signup_render_table.html.erb @@ -0,0 +1,103 @@ + + + + <% render :partial => "get_display_fields" %> + <% @field_name_translations.each_with_index do |trans,i|%> + <% next unless @display_field.include?(@field_names[i]) %> + + <% end %> + + + + <% @seminar_signups.each do |seminar_signup| %> + <% len = seminar_signup.seminar_signup_contributes.count %> + <% rowspan = "rowspan=#{len==0? 1 : len}" %> + <% vals = [] %> + + <% @field_names.each_with_index do |fn,i|%> + <% next unless @display_field.include?(fn) %> + <% names = fn.split(".") %> + <% val = "" %> + <% if names[0] == "seminar_signup_field_set" %> + <% if names[1] == "name" %> + <% val = seminar_signup.name + val += "
    + +
    " + %> + <% elsif names[1] == 'status' %> + <% val = t("seminar.registration_status_#{seminar_signup.status}") if !seminar_signup.status.blank? %> + <% elsif names[1] != 'recaptcha' %> + <% val = seminar_signup.send("#{names[1]}") %> + <% end %> + <% elsif names[0] == "default" %> + <% if names[2] == "name" %> + <% val = seminar_signup.name + val += "
    + +
    " + %> + <% elsif names[2] == "tel" %> + <% val = seminar_signup.tel %> + <% elsif names[2] == "registration_status" %> + <% val = t("seminar.registration_status_#{seminar_signup.status}") if !seminar_signup.status.blank? %> + <% end %> + <% elsif names[0] == "seminar_signup_field_custom" || names[0] == "seminar_signup_fields" %> + <% val = seminar_signup.seminar_signup_values.where(:key=>names[1]).first.get_value_by_locale(I18n.locale) rescue "" %> + <% elsif names[0] == "seminar_signup_contributes" %> + <% if names[1] == "file" %> + <% val = seminar_signup.seminar_signup_contributes.to_a %> + <% else %> + <% val = seminar_signup.seminar_signup_contributes.collect{|s| s.send(names[1])} %> + <% end %> + <% elsif names[0] == "seminar_submission_fields" %> + <% val = seminar_signup.seminar_signup_contributes.collect{|s| (s.seminar_submission_values.where(:key=>names[1]).first.get_value_by_locale(I18n.locale) rescue "")} %> + <% end %> + <% vals << val %> + <% end %> + <% count = 0 %> + <% indices = [] %> + <% vals.each_with_index do |val,i| %> + <% if val.class == Array %> + <% count = val.count - 1 %> + <% indices << i%> + + <% else %> + + <% end %> + <% end %> + <% (0...count).each do |i|%> + + <% indices.each do |index| %> + + <% end %> + + <% end %> + + <% end %> + +
    <%= trans %>
    + <% if val[0].class == SeminarSignupContribute #File %> + <% seminar_signup_contribute = val[0] %> + <%= link_to (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(seminar_signup_contribute.description).text} if seminar_signup_contribute.file.file %> + <% else %> + <%= val[0].html_safe.to_s rescue "" %> + <% end %> + ><%= val.to_s.html_safe %>
    + <% if vals[index][i].class == SeminarSignupContribute #File %> + <% seminar_signup_contribute = vals[index][i] %> + <%= link_to (seminar_signup_contribute.title.blank? ? File.basename(seminar_signup_contribute.file.path) : seminar_signup_contribute.title) , seminar_signup_contribute.file.url, {:target => '_blank', :title => Nokogiri::HTML(seminar_signup_contribute.description).text} if seminar_signup_contribute.file.file %> + <% else %> + <%= vals[index][i].html_safe.to_s rescue "" %> + <% end %> +
    \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index bde6343..489952c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -9,6 +9,8 @@ en: seminar_submission_field: Seminar Submission Field seminar_signup_field: Seminar Signup Field seminar_signup: Signup Analyze + enquiry_for_applicants: Enquiry for applicants + reviewer_setting: Reviewer setting module_name: seminar: Seminar #研討會 @@ -17,6 +19,18 @@ en: verification_failed: Verification Failed #驗證碼錯誤 seminar: + are_you_want_to_remove: "Are you really want to remove?" + add_assign_fields: Add assign fields + assign_fields: Assign fields + organizer: Organizer + reviewer_setting: Reviewer setting + select_reviewer: Select reviewer + enquiry_for_applicants_display_fields_setting: Enquiry for applicants display fields setting + enquiry_for_applicants: Enquiry for applicants + field_display_setting: Field display setting + table: Table + dashboard: Dashboard + display_field: Display field note: Note email_signup_success: Signup success email_submission_success: Submission registration success diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index bf4891f..b3641af 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -9,6 +9,8 @@ zh_tw: seminar_submission_field: 上傳介面欄位 seminar_signup_field: 報名欄位 seminar_signup: 報名統計 + enquiry_for_applicants: 查詢報名人 + reviewer_setting: 審查委員設定 module_name: seminar: 研討會 @@ -17,6 +19,18 @@ zh_tw: verification_failed: 驗證碼錯誤 seminar: + are_you_want_to_remove: 你確定要刪除? + add_assign_fields: 新增分派欄位 + assign_fields: 分派欄位 + organizer: 主辦人 + reviewer_setting: 審查委員設定 + select_reviewer: 選擇審查委員 + enquiry_for_applicants_display_fields_setting: 查詢報名人顯示欄位設定 + enquiry_for_applicants: 查詢報名人 + field_display_setting: 欄位顯示設定 + table: 列表 + dashboard: 儀錶板 + display_field: 顯示的欄位 note: 附註 email_signup_success: 報名成功 email_submission_success: 投稿註冊成功 diff --git a/config/routes.rb b/config/routes.rb index 2b5c292..8263214 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,8 +12,18 @@ Rails.application.routes.draw do get 'seminar_item_content' get 'seminar_signup_field' get 'seminar_submission_field' + get 'seminar_signup_admin_setting' + post 'update_seminar_signup_admin_setting' + patch 'update_seminar_signup_admin_setting' + get 'get_hide_reviewer' + get 'get_reviewer_block' + get 'reviewer_setting' + post 'update_reviewer_setting' + patch 'update_reviewer_setting' end end + get 'seminar/enquiry_for_applicants' => "seminars#enquiry_for_applicants" + post 'seminar/update_seminar_review' => "seminars#update_seminar_review" resources :seminar_items do collection do post 'delete_items' diff --git a/lib/seminar/engine.rb b/lib/seminar/engine.rb index 6e026e0..113e4e1 100644 --- a/lib/seminar/engine.rb +++ b/lib/seminar/engine.rb @@ -11,7 +11,7 @@ module Seminar side_bar do head_label_i18n 'seminar.seminar', icon_class: "icon-globe" - available_for "managers" + available_for "users" active_for_controllers (['admin/seminars']) head_link_path "admin_seminars_path" @@ -19,7 +19,7 @@ module Seminar :link_path=>"admin_seminars_path" , :priority=>1, :active_for_action=>{'admin/seminars'=>'index'}, - :available_for => 'managers' + :available_for => 'users' context_link 'new_', :link_path=>"new_admin_seminar_path" , :priority=>2, @@ -42,6 +42,11 @@ module Seminar :priority=>3, :active_for_action=>{'admin/seminars'=>'seminar_agreements'}, :available_for => 'managers' + context_link 'seminar.enquiry_for_applicants', + :link_path=>"admin_seminar_enquiry_for_applicants_path" , + :priority=>3, + :active_for_action=>{'admin/seminars'=>'enquiry_for_applicants'}, + :available_for => 'users' end end