完成了管理员界面学校列表

This commit is contained in:
linchun 2016-03-16 15:24:41 +08:00
parent 69ec475752
commit 34c9f54510
3 changed files with 58 additions and 26 deletions

View File

@ -24,7 +24,7 @@ class AdminController < ApplicationController
before_filter :require_admin
helper :sort
helper :Users
helper :Settings
helper :Settings,SchoolHelper
include SortHelper
def index
@ -390,7 +390,8 @@ class AdminController < ApplicationController
#组织
def organization
@organizations = Organization.find_by_sql("SELECT * FROM organizations ORDER BY created_at DESC")
#@organizations = Organization.find_by_sql("SELECT * FROM organizations ORDER BY created_at DESC")
@organizations = Organization.all.order("created_at desc")
respond_to do |format|
format.html
end
@ -398,17 +399,14 @@ class AdminController < ApplicationController
#学校列表
def schools
@school_name = params[:school_name]
if @school_name && @school_name != ''
@schools = School.where("name like '%#{@school_name}%'")
elsif @school_name.nil?
@schools = []
else @school_name && @school_name == ' '
@schools = School.where('1=1')
end
@schools = School.find_by_sql("SELECT * FROM schools ORDER BY created_at DESC")
@school_count = @schools.count
@school_pages = Paginator.new @school_count, 100, params['page'] || 1
@schools = paginateHelper @schools,100
@school_pages = Paginator.new @school_count, 50, params['page'] || 1
@schools = paginateHelper @schools,50
@page = (params['page'] || 1).to_i - 1
respond_to do |format|
format.html
end

View File

@ -1,2 +1,15 @@
module SchoolHelper
def schoolMember_num school
count = student_num(school) + teacher_num(school)
count.to_s
end
def student_num school
UserExtensions.find_by_sql("SELECT * FROM user_extensions WHERE occupation = '#{school.name}' AND identity = '1'").count
end
def teacher_num school
UserExtensions.find_by_sql("SELECT * FROM user_extensions AS ue, schools AS s WHERE ue.school_id = s.id AND s.name = '#{school.name}' AND ue.identity = '0'").count
end
end

View File

@ -1,43 +1,64 @@
<h3 style="float: left">
<%=l(:label_school_plural)%>
</h3>
<%= form_tag({:controller => 'admin', :action => 'schools' }, :method => :get,:id=>"search_course_form") do %>
<%= submit_tag "搜索",:style => "float: right;margin-right: 15px;"%>
<input style="float: right;margin-right: 10px;" id="v_subject" placeholder="学校名称" type="text" name="school_name" value="<%= @school_name%>">
<% end %>
<!--<!%= form_tag({:controller => 'admin', :action => 'schools' }, :method => :get,:id=>"search_course_form") do %>-->
<!-- <!%= submit_tag "搜索",:style => "float: right;margin-right: 15px;"%>-->
<!--<input style="float: right;margin-right: 10px;" id="v_subject" placeholder="学校名称" type="text" name="school_name" value="<%= @school_name%>">-->
<!% end %>
<div class="cl"></div>
<div class="autoscroll" style="margin-top: 40px;">
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 50px;">
<th style="width: 35px;">
序号
</th>
<th style="width: 100px;">
<th style="width: 60px;">
LOGO
</th>
<th>
<th style="width: 100px;">
学校名称
</th>
<th style="width: 100px;"></th>
<th style="width: 35px;">
用户数
</th>
<th style="width: 90px;">
创建时间
</th>
<th style="width: 80px;">
编辑高校信息
</th>
</tr>
</thead>
<tbody>
<% @schools.each do |school|%>
<% @count=@page * 30 %>
<% @schools.each do |school| %>
<tr class="<%= cycle("odd", "even") %>">
<td style="text-align:center;vertical-align: middle;">
<%= school.id %>
<!td style="text-align:center;vertical-align: middle;">
<!%= school.id %>
<% @count +=1 %>
<td align="center">
<%=@count %>
</td>
<td align="center">
<%= image_tag(school.logo_link,width:40,height:40) %>
<!%= school.name %>
</td>
<td style="text-align:center;vertical-align: middle;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=school.name%>'>
<span>
<%= link_to school.name,"http://#{Setting.host_course}/?school_id=#{school.id}" %>
<%= link_to school.name,"http://#{Setting.host_name}/?school_id=#{school.id}" %>
</span>
</td>
<td class="buttons" style="vertical-align: middle;">
<td style="vertical-align: middle;text-align:center">
<%= schoolMember_num(school) %>
</td>
<td style="vertical-align: middle;text-align:center">
<%= format_time(school.created_at) %>
</td>
<td class="buttons" style="vertical-align: middle;text-align:center">
<%= link_to("修改", upload_logo_school_path(school.id,:school_name => @school_name), :class => 'icon icon-copy') %>
<%#= link_to(l(:button_delete), organization_path(school.id), :method => :delete,:confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
</td>
@ -50,4 +71,4 @@
<%= pagination_links_full @school_pages, @school_count ,:per_page_links => true, :remote => false, :flag => true %>
</ul>
<% html_title(l(:label_project_plural)) -%>
<% html_title(l(:label_school_plural)) -%>