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

ouyangxuhua
linchun 10 years ago
parent 69ec475752
commit 34c9f54510

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

@ -1,2 +1,15 @@
module SchoolHelper 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 end

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

Loading…
Cancel
Save