单位名称列表功能

This commit is contained in:
daiao 2016-07-29 16:11:26 +08:00
parent 6bd9f47222
commit 5b30036639
7 changed files with 58 additions and 15 deletions

View File

@ -154,6 +154,19 @@ class AdminController < ApplicationController
end
end
# 单位名称列表下的已审批按照名字排序
def apply_shcool_sort
@order = ""
@sort = ""
if params[:sort] && (params[:order] == 'name')
# courses = School.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) #{params[:sort]}, c.id desc")
school = School.find_by_sql(" SELECT aas.name FROM apply_add_schools aas where aas.status = '0' GROUP BY CONVERT(name USING gbk) #{params[:sort]}, aas.id desc ")
@order = params[:order]
@sort = params[:sort]
end
redirect_to unapplied_schools_url
end
#精品课程下的全部课程
def excellent_all_courses
name = params[:name]
@ -700,8 +713,10 @@ class AdminController < ApplicationController
user.update_column("school_id", nil)
end
applied_school.school.destroy
respond_to do |format|
format.html{ redirect_to unapplied_schools_url }
if params[:tip] == "unapplied"
redirect_to unapplied_schools_url
elsif params[:tip] == "applied"
redirect_to applied_schools_url
end
end

View File

@ -184,6 +184,9 @@ class SchoolController < ApplicationController
applyschool.user_id = User.current.id
if applyschool.save
data[:school_id] = school.id
user_extention= User.current.extensions
user_extention.school_id = school.id
user_extention.save!
else
data[:result] = 3
end

View File

@ -16,7 +16,7 @@
function school_submit() {
var checkboxs = $("input[name='school_id[]']:checked");
if(checkboxs.length == 0) {
$("#choose_courses_notice").text("请先选择班级");
$("#choose_courses_notice").text("请选择单位");
} else{
$("#choose_courses_notice").text("");
$("#schools_list_form").submit();

View File

@ -23,8 +23,11 @@
<th style="width: 20px;">
序号
</th>
<th style="width: 85px;">
单位名称
<th style="width: 85px;" class = "<%= @order == 'name' ? (@sort == 'desc' ? 'st_up' : (@sort == 'asc' ? 'st_down' : '')) : '' %>">
<%= link_to '单位名称', apply_shcool_sort_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'name', :tip=>'unapplied') %>
</th>
<th style="width: 30px;">
申请者
</th>
<th style="width: 75px;">
地区
@ -46,7 +49,7 @@
<tbody>
<% @apply_status.each do |apply| %>
<% if apply.status == 0 %>
<tr class="<%= cycle("odd", "even") %>">
<tr class="<%= cycle("odd", "even") %>">
<td style="text-align: center;">
<%= apply.id %>
</td>
@ -54,7 +57,13 @@
<%= apply.name %>
</td>
<td class="center">
<%= apply.province + apply.city %>
<% user = User.where("id=?", apply.user_id).first %>
<% unless user.nil? %>
<%= user.login %>
<% end %>
</td>
<td class="center">
<%= (apply.province.nil? ? "" : apply.province) + (apply.city.nil? ? "" : apply.city) %>
</td>
<td align="left" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<%= apply.address %>
@ -67,13 +76,13 @@
<%= format_date(apply.created_at) %>
</td>
<td class="center">
<%= link_to( l(:label_approve), { :controller => 'admin', :action => 'approve_applied_schools', :id => apply.id }, :class => 'icon-del') %>
<%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id },:method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon-del') %>
<%= link_to( l(:label_approve), { :controller => 'admin', :action => 'approve_applied_schools', :id => apply.id }) %>
<%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id, :tip => 'unapplied' },:method => :delete, :confirm => l(:text_are_you_sure)) %>
<%=link_to '更改', admin_all_schools_path(:school_id =>apply.id), :remote => true %>
</td>
</tr>
<% unless apply.remarks.empty? %>
<% unless apply.remarks.blank? %>
<tr class="odd">
<td>

View File

@ -26,6 +26,9 @@
<th style="width: 85px;">
单位名称
</th>
<th style="width: 30px;">
申请者
</th>
<th style="width: 75px;">
地区
</th>
@ -51,10 +54,22 @@
<%= apply.id %>
</td>
<td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=apply.name%>' id="apply_title_<%= apply.id %>">
<%= (School.find apply.school_id).name %>
<% unless apply.school_id.nil? %>
<% school_name = School.where("id=?", apply.school_id).first %>
<%= school_name.name %>
<% end %>
</td>
<td class="center">
<%= (School.find apply.school_id).province %>
<% user = User.where("id=?", apply.user_id).first %>
<% unless user.nil? %>
<%= user.login %>
<% end %>
</td>
<td class="center">
<% unless apply.school_id.nil? %>
<% school_province = School.where("id=?", apply.school_id).first %>
<%= school_province.province %>
<% end %>
</td>
<td align="left" style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis;">
<%= apply.address %>
@ -66,10 +81,10 @@
<%= format_date(apply.created_at) %>
</td>
<td class="center">
<%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id },:method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon-del') %>
<%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id, :tip => 'applied' },:method => :delete, :confirm => l(:text_are_you_sure) ) %>
</td>
</tr>
<% unless apply.remarks.empty? %>
<% unless apply.remarks.blank? %>
<tr class="odd">
<td>

View File

@ -369,7 +369,7 @@
function apply_add_school(){
var htmlvalue = "<%= escape_javascript( render :partial => 'my/apply_add_school' )%>";
pop_up_box(htmlvalue,580,20,48);
$("#schoolname").val($("input[name='province']").val());
}
function add_school(name){
$.ajax({

View File

@ -1074,6 +1074,7 @@ RedmineApp::Application.routes.draw do
get 'admin/approve_applied_schools'
post 'admin/edit_applied_schools'
get 'admin/all_schools'
get 'admin/apply_shcool_sort', as: :apply_shcool_sort
delete 'admin/delete_applied_schools'
get 'admin/leave_messages'