diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index 037fdd411..3f53df113 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -216,4 +216,61 @@ class SchoolController < ApplicationController render :json =>status end + + def edit_apply_name + name = params[:name] || "" + status = -1 + + if name != "" + applyschool = ApplyAddSchools.where("id=?",params[:id]).first + + applyschool.name = name.strip + + if applyschool.school + applyschool.school.name = name + applyschool.school.pinyin = Pinyin.t(name.strip, splitter: '') + applyschool.school.save! + end + applyschool.save! + status = 0 + end + + render :json=>{:status=>status,:id=>params[:id],:name=>name} + end + + def edit_apply_address + address = params[:address] || "" + + status = -1 + + if address != "" + applyschool = ApplyAddSchools.where("id=?",params[:id]).first + applyschool.address = address + applyschool.save! + status = 0 + end + + render :json=>{:status=>status,:id=>params[:id],:address=>address} + end + + def edit_apply_province + province = params[:province] || "" + city = params[:city] || "" + status = -1 + + if(province != "") &&(city != "") + applyschool = ApplyAddSchools.where("id=?",params[:id]).first + applyschool.province = province + applyschool.city = city + + if applyschool.school + applyschool.school.province = province + applyschool.school.save! + end + applyschool.save! + status = 0 + end + + render :json=>{:status=>status,:id=>params[:id],:province=>province,:city=>city} + end end diff --git a/app/views/admin/applied_schools.html.erb b/app/views/admin/applied_schools.html.erb index 518624b5f..c9ebdfb66 100644 --- a/app/views/admin/applied_schools.html.erb +++ b/app/views/admin/applied_schools.html.erb @@ -53,8 +53,9 @@ <%= apply.id %> - - <%= apply.name %> + + <%= apply.name %> + <% user = User.where("id=?", apply.user_id).first %> @@ -63,10 +64,51 @@ <% end %> + <%= (apply.province.nil? ? "" : apply.province) + (apply.city.nil? ? "" : apply.city) %> + + + - <%= apply.address %> + <%= apply.address %> + <% count = UserExtensions.where("school_id = #{apply.school_id}").count %> @@ -82,6 +124,9 @@ + <% unless apply.remarks.blank? %> diff --git a/app/views/admin/has_applied_schools.html.erb b/app/views/admin/has_applied_schools.html.erb index 286edbd19..9289a1574 100644 --- a/app/views/admin/has_applied_schools.html.erb +++ b/app/views/admin/has_applied_schools.html.erb @@ -59,7 +59,8 @@ <% unless apply.school_id.nil? %> <% school_name = School.where("id=?", apply.school_id).first %> - <%= school_name.name %> + <%= school_name %> + <% end %> @@ -69,13 +70,51 @@ <% end %> - <% unless apply.school_id.nil? %> - <% school_province = School.where("id=?", apply.school_id).first %> - <%= school_province.province %> - <% end %> + + <%= (apply.province.nil? ? "" : apply.province) + (apply.city.nil? ? "" : apply.city) %> + + + - <%= apply.address %> + <%= apply.address %> + <%= apply.name %> @@ -91,7 +130,9 @@ <%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id, :tip => 'applied' },:method => :delete, :confirm => l(:text_are_you_sure) ) %> - <% end %> + <% end %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index b1dc57c0f..27b87a048 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -226,6 +226,9 @@ RedmineApp::Application.routes.draw do member do get 'upload_logo' post 'upload' + get 'edit_apply_name' + get 'edit_apply_address' + get 'edit_apply_province' end end diff --git a/public/javascripts/application.js b/public/javascripts/application.js index b4ccd1533..9841a20a7 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1899,3 +1899,124 @@ function updateCourseName(){ } } } + +function edit_school_name(url,id){ + if($("#school_name_edit_"+id).val() == ""){ + $("#apply_title_"+id).show(); + $("#school_name_edit_"+id).hide(); + return; + } + $.get( + url, + {id: id ,name: $("#school_name_edit_"+id).val() }, + function (data) { + if(data.status == 0){ + $("#apply_title_"+data.id).show(); + $("#school_name_edit_"+data.id).hide(); + $("#apply_title_"+data.id).text(data.name); + } + else{ + $("#apply_title_"+data.id).show(); + $("#school_name_edit_"+data.id).hide(); + } + + } + ); +} + +function show_edit_school_name(id){ + $("#apply_title_"+id).hide(); + $("#school_name_edit_"+id).val($("#apply_title_"+id).text()); + $("#school_name_edit_"+id).show(); + $("#school_name_edit_"+id).focus(); + + +} + +function edit_school_address(url,id){ + if($("#school_address_edit_"+id).val() == ""){ + $("#apply_address_"+id).show(); + $("#school_address_edit_"+id).hide(); + return; + } + $.get( + url, + {id: id ,address: $("#school_address_edit_"+id).val() }, + function (data) { + if(data.status == 0){ + $("#apply_address_"+data.id).show(); + $("#school_address_edit_"+data.id).hide(); + $("#apply_address_"+data.id).text(data.address); + } + else{ + $("#apply_address_"+data.id).show(); + $("#school_address_edit_"+data.id).hide(); + } + + + } + ); +} + +function show_edit_school_address(id){ + $("#apply_address_"+id).hide(); + $("#school_address_edit_"+id).val($("#apply_address_"+id).text()); + $("#school_address_edit_"+id).show(); + $("#school_address_edit_"+id).focus(); +} + +function edit_school_province(url,id){ + + var province = $("#school_province_edit_"+id).val(); + var city = $("#schoolCity_"+id).val(); + + if((province == "")||(city == "")){ + $("#apply_province_"+id).show(); + $("#school_province_edit_"+id).hide(); + $("#schoolCity_"+id).hide(); + return; + } + + $.get( + url, + {id: id ,province: province,city:city }, + function (data) { + if(data.status == 0){ + $("#apply_province_"+data.id).show(); + $("#school_province_edit_"+data.id).hide(); + $("#schoolCity_"+data.id).hide(); + init_province_and_city(document.getElementById('school_province_edit_'+data.id), data.province, document.getElementById('schoolCity_'+data.id), data.city); + $("#apply_province_"+data.id).text(data.province+data.city); + + } + else{ + $("#apply_province_"+data.id).show(); + $("#school_province_edit_"+data.id).hide(); + $("#schoolCity_"+data.id).hide(); + } + + } + ); +} + +function init_province_and_city(pField, province, cField, city) { + for (var i = 0; i < pField.options.length; i++) { + if (pField.options[i].value == province) { + pField.selectedIndex = i; + } + } + showcity(province, cField); + for (var i = 0; i < cField.options.length; i++) { + if (cField.options[i].value == city) { + cField.selectedIndex = i; + } + } +} + +function show_edit_school_province(id){ + $("#apply_province_"+id).hide(); + $("#school_province_edit_"+id).show(); + $("#schoolCity_"+id).show(); + +} +