diff --git a/app/assets/images/close.gif b/app/assets/images/close.gif
new file mode 100644
index 0000000..0fb8c83
Binary files /dev/null and b/app/assets/images/close.gif differ
diff --git a/app/assets/images/fhi.png b/app/assets/images/fhi.png
new file mode 100644
index 0000000..5d33e33
Binary files /dev/null and b/app/assets/images/fhi.png differ
diff --git a/app/assets/images/view.gif b/app/assets/images/view.gif
new file mode 100644
index 0000000..ad606f2
Binary files /dev/null and b/app/assets/images/view.gif differ
diff --git a/app/assets/javascripts/admin/olympiamanagement.js b/app/assets/javascripts/admin/olympiamanagement.js
index 14bc25e..000f6ac 100644
--- a/app/assets/javascripts/admin/olympiamanagement.js
+++ b/app/assets/javascripts/admin/olympiamanagement.js
@@ -1,11 +1,24 @@
$(document).ready(function(){
- $('.fieldset_block input[type="reset"]').off('click').on('click',function(){
+ $('.class_setting_block input[type="reset"]').off('click').on('click',function(){
$('.col_input').val('');
});
- $('.fieldset_block input[type="submit"]').off('click').on('click',function(){
+ $('.class_setting_block input[type="submit"]').off('click').on('click',function(){
var class_number_range = [];
- class_number_range.push($('.col_input input[name="MinClass"]').val());
- class_number_range.push($('.col_input input[name="MaxClass"]').val());
+ class_number_range.push(Number($('.class_setting_block .col_input[name="MinClass"]').val()));
+ class_number_range.push(Number($('.class_setting_block .col_input[name="MaxClass"]').val()));
+ var enrollment_available = $('.class_setting_block .col_input#Person').val();
class_number_range.sort();
+ var params_array = (window.location.search.substring(1)=="") ? [] : window.location.search.substring(1).split('&').map(function(el){return el.split('=')});
+ var params = {};
+ params_array.forEach(function(el){params[el[0]] = el[1]});
+ var params_to_send = {'type':'class_setting','class_number_range':class_number_range,'enrollment_available':enrollment_available};
+ params_to_send = Object.assign(params,params_to_send);
+ var post_data = $.post('/admin/olympiamanagements/update_school_data',params_to_send);
+ post_data.done(function(){
+ window.location.search="";
+ });
});
+ var $el = $('.fieldset_block select');
+ for(var i = 0 ; i < $el.length ; i++)
+ $el.eq(i).find('option[value='+$el.eq(i).attr('value')+']').attr('selected','selected');
});
\ No newline at end of file
diff --git a/app/assets/stylesheets/admin/olympiamanagement.scss b/app/assets/stylesheets/admin/olympiamanagement.scss
index 765bc1a..e8a7eab 100644
--- a/app/assets/stylesheets/admin/olympiamanagement.scss
+++ b/app/assets/stylesheets/admin/olympiamanagement.scss
@@ -16,8 +16,8 @@
.col {
float: left;
clear: both;
- width: 8.125em;
- margin: 0 0.625em 0px 0;
+ width: 9.125em;
+ margin: 0 0.625em 0em 0;
padding: 0.0625em 0 0.0625em 0;
}
.col_r {
@@ -43,22 +43,75 @@
color: #fff;
vertical-align: top;
background: #81ce25;
- border-bottom: 1px solid #67ac14;
+ border-bottom: 0.0625em solid #67ac14;
}
-.ts_rowsonly .even {
+.ts_rowsonly tbody tr:nth-child(odd){
+ background: #fff;
+}
+.ts_rowsonly tbody tr:nth-child(even){
background: #f5f6e2;
}
.ts_rowsonly td {
- border-bottom: 1px solid #e7eab9;
+ border-bottom: 0.0625em solid #e7eab9;
padding: 0.375em 0.625em;
text-align: left;
color: #111;
vertical-align: top;
}
.ts_rowsonly {
- margin: 0.625em 0 5px 0;
+ margin: 0.625em 0 0.3125em 0;
font-size: 1em;
}
+.PageDetails {
+ padding-top: 0.1875em;
+ padding-bottom: 0.1875em;
+ font-weight: bold;
+ font-size: 0.875em;
+ border-bottom: 0.0625em solid #ddd;
+ overflow: hidden;
+ text-align: right;
+ color: black;
+ font-size: 1.3em;
+}
+.PageList {
+ margin: 0em 0em 0 0.5em;
+ font-weight: bold;
+ font-size: 0.875em;
+ overflow: hidden;
+ list-style: none;
+ display: inline;
+ background: none;
+ color: #999;
+}
+ol {
+ margin: 0 0 0.5em 0;
+ min-height: 0.625em;
+ height: auto !important;
+ height: 0.625em;
+ padding: 0;
+ clear: both;
+ float: right;
+}
+.PageList li {
+ display: inline;
+}
+.wrap-inner{
+ font-size: 1.1em;
+}
+.field-hint-inactive {
+ color: #999;
+ margin-left: 0.3125em;
+ padding-left: 1em;
+ padding-right: 0.5em;
+ background-image: url(/assets/fhi.png);
+ background-repeat: no-repeat;
+ background-position: left center;
+ float: left;
+}
+.required {
+ font-weight: bold;
+ width: auto;
+}
li{
display: block;
}
\ No newline at end of file
diff --git a/app/controllers/admin/olympiamanagements_controller.rb b/app/controllers/admin/olympiamanagements_controller.rb
index 3391dc3..94c7667 100644
--- a/app/controllers/admin/olympiamanagements_controller.rb
+++ b/app/controllers/admin/olympiamanagements_controller.rb
@@ -1,11 +1,59 @@
class Admin::OlympiamanagementsController < OrbitAdminController
+ helper Admin::OlympiamanagementsHelper
def index
end
def add_school_data
+ SchoolDataFields.create if SchoolDataFields.all.count == 0
+ @SchoolDataField = SchoolDataFields.first
+ @olympia_school_data_field = (params[:id].nil? ? OlympiaSchoolDataFields.new : ((OlympiaSchoolDataFields.find(params[:id]).nil? rescue true) ? OlympiaSchoolDataFields.new : OlympiaSchoolDataFields.find(params[:id])))
+ end
+ def update_school_data
+ if params[:type] == 'class_setting'
+ @ClassSettingField = (params[:id].nil? ? ClassSettingFields.new : ((ClassSettingFields.find(params[:id]).nil? rescue true) ? ClassSettingFields.new : ClassSettingFields.find(params[:id])))
+ @ClassSettingField.class_number_range = params[:class_number_range].map{|num| num.to_i}
+ @ClassSettingField.enrollment_available = params[:enrollment_available].to_i
+ @ClassSettingField.save
+ render :json => {'success'=>true} and return
+ elsif params[:type] == 'delete_class_setting'
+ if !params[:id].to_s.blank?
+ begin
+ ClassSettingFields.find(params[:id]).destroy
+ rescue
+ puts 'not_found id='+params[:id]+' in ClassSettingFields'
+ end
+ redirect_to :back
+ end
+ elsif params[:type] == 'delete_school_data'
+ if !params[:id].to_s.blank?
+ begin
+ OlympiaSchoolDataFields.find(params[:id]).destroy
+ rescue
+ puts 'not_found id='+params[:id]+' in OlympiaSchoolDataFields'
+ end
+ redirect_to :back
+ end
+ elsif params[:type] == 'add_school_data'
+ @olympia_school_data_field = (params[:id].nil? ? OlympiaSchoolDataFields.new : ((OlympiaSchoolDataFields.find(params[:id]).nil? rescue true) ? OlympiaSchoolDataFields.new : OlympiaSchoolDataFields.find(params[:id])))
+ params['add_school_data'].keys.each do |field|
+ @olympia_school_data_field[field] = params['add_school_data'][field]
+ end
+ @olympia_school_data_field.save
+ redirect_to admin_olympiamanagements_school_data_list_path
+ end
end
def school_data_list
+ @SchoolDataField = SchoolDataFields.first
+ @SchoolDataname = @SchoolDataField.school_data_fields.map{|field| field.keys[0]}
+ page_num = params[:page] || 1
+ @OlympiaSchoolDataFields = OlympiaSchoolDataFields.all.asc(:id)
+ @OlympiaSchoolDataFields = @OlympiaSchoolDataFields.where("school_name" => /#{params[:school_name]}/) if !params[:school_name].to_s.blank?
+ @OlympiaSchoolDataFields = @OlympiaSchoolDataFields.where("school_code" => /#{params[:school_code]}/) if !params[:school_code].to_s.blank?
+ @OlympiaSchoolDataFields = @OlympiaSchoolDataFields.page(page_num).per(10)
end
def class_setting
+ page_num = params[:page] || 1
+ @class_setting_list = ClassSettingFields.all.asc(:enrollment_available).page(page_num).per(10)
+ @ClassSettingField = (params[:id].nil? ? nil : ((ClassSettingFields.find(params[:id]).nil? rescue true) ? nil : ClassSettingFields.find(params[:id])))
end
def sign_up_setting
end
diff --git a/app/helpers/admin/olympiamanagements_helper.rb b/app/helpers/admin/olympiamanagements_helper.rb
new file mode 100644
index 0000000..ff41f0f
--- /dev/null
+++ b/app/helpers/admin/olympiamanagements_helper.rb
@@ -0,0 +1,11 @@
+module Admin::OlympiamanagementsHelper
+ def create_pagination(page=1,fields=ClassSettingFields)
+ page = 1 if page == 0
+ per_page_num = 10
+ all_page_num = fields.all.count / per_page_num + 1
+ pagination = '
'+((I18n.locale.to_s == 'zh_tw') ? "第 #{page} 頁" : "page #{page}") +'/'+ ((I18n.locale.to_s == 'zh_tw') ? "共 #{all_page_num} 頁" : "Total #{all_page_num} page(s)")+'
'+
+ ((page == 1) ? '- ['+t('olympiamanagement.prev_page')+']
' : '- ['+t('olympiamanagement.prev_page')+']
')
+ (1..all_page_num).to_a.each{|page_num| pagination += ((page_num == page) ? '- '+page_num.to_s+'
' : '- '+page_num.to_s+'
')}
+ pagination += (((page==all_page_num) ? '- ['+t('olympiamanagement.next_page')+']
' : '- ['+t('olympiamanagement.next_page')+']
')+'
')
+ end
+end
\ No newline at end of file
diff --git a/app/models/class_setting_fields.rb b/app/models/class_setting_fields.rb
new file mode 100644
index 0000000..2dedee1
--- /dev/null
+++ b/app/models/class_setting_fields.rb
@@ -0,0 +1,11 @@
+class ClassSettingFields
+ include Mongoid::Document
+ include Mongoid::Timestamps
+ include OrbitModel::Status
+ include OrbitModel::Impression
+ # encoding: utf-8
+ include OrbitTag::Taggable
+ include OrbitCategory::Categorizable
+ field :class_number_range , type: Array , default: []
+ field :enrollment_available , type: Fixnum , default: 0
+end
\ No newline at end of file
diff --git a/app/models/olympia_school_data_fields.rb b/app/models/olympia_school_data_fields.rb
new file mode 100644
index 0000000..26be76e
--- /dev/null
+++ b/app/models/olympia_school_data_fields.rb
@@ -0,0 +1,22 @@
+class OlympiaSchoolDataFields
+ include Mongoid::Document
+ include Mongoid::Timestamps
+ include OrbitModel::Status
+ include OrbitModel::Impression
+ # encoding: utf-8
+ include OrbitTag::Taggable
+ include OrbitCategory::Categorizable
+ field :account_number , type: String , default: ''
+ field :password , type: String , default: ''
+ field :school_name , type: String , default: ''
+ field :school_code , type: String , default: ''
+ field :school_address , type: String , default: ''
+ field :class_number , type: Fixnum , default: 0
+ field :enrollment_limited , type: Fixnum , default: 0
+ field :school_contact_person_name , type: String , default: ''
+ field :department_job_title , type: String , default: ''
+ field :office_tel_number , type: String , default: ''
+ field :fax , type: String , default: ''
+ field :mobile_number , type: String , default: ''
+ field :email , type: String , default: ''
+end
\ No newline at end of file
diff --git a/app/models/school_data_fields.rb b/app/models/school_data_fields.rb
new file mode 100644
index 0000000..2656ae7
--- /dev/null
+++ b/app/models/school_data_fields.rb
@@ -0,0 +1,22 @@
+class SchoolDataFields
+ include Mongoid::Document
+ include Mongoid::Timestamps
+ include OrbitModel::Status
+ include OrbitModel::Impression
+ # encoding: utf-8
+ include OrbitTag::Taggable
+ include OrbitCategory::Categorizable
+ field :school_data_fields , type: Array , default: [{'account_number'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''}}},
+ {'password'=>{'type'=>'String','size'=>'','hint'=>{'zh_tw'=>'未修改即依照預設密碼','en'=>''}}},
+ {'school_name'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''}}},
+ {'school_code'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''}}},
+ {'school_address'=>{'type'=>'String','size'=>'40','hint'=>{'zh_tw'=>'','en'=>''}}},
+ {'class_number'=>{'type'=>'select','size'=>'','hint'=>{'zh_tw'=>'','en'=>''},'range'=>[1,200],'unit'=>{'zh_tw'=>'班','en'=>'class'}}},
+ {'enrollment_limited'=>{'type'=>'Fixnum','size'=>'5','hint'=>{'zh_tw'=>'未修改即依照班級設定','en'=>''}}},
+ {'school_contact_person_name'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''}}},
+ {'department_job_title'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''}}},
+ {'office_tel_number'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''}}},
+ {'fax'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''}}},
+ {'mobile_number'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''}}},
+ {'email'=>{'type'=>'String','size'=>'40','hint'=>{'zh_tw'=>'','en'=>''}}}]
+end
\ No newline at end of file
diff --git a/app/views/admin/olympiamanagements/add_school_data.html.erb b/app/views/admin/olympiamanagements/add_school_data.html.erb
index e69de29..830efdb 100644
--- a/app/views/admin/olympiamanagements/add_school_data.html.erb
+++ b/app/views/admin/olympiamanagements/add_school_data.html.erb
@@ -0,0 +1,29 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/olympiamanagements/class_setting.html.erb b/app/views/admin/olympiamanagements/class_setting.html.erb
index da9c36b..4e67302 100644
--- a/app/views/admin/olympiamanagements/class_setting.html.erb
+++ b/app/views/admin/olympiamanagements/class_setting.html.erb
@@ -1,16 +1,16 @@
-