From 34c9f545101b42f771bb9580cd2d85a34db4381b Mon Sep 17 00:00:00 2001 From: linchun Date: Wed, 16 Mar 2016 15:24:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=86=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E7=95=8C=E9=9D=A2=E5=AD=A6=E6=A0=A1=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 22 ++++++------- app/helpers/school_helper.rb | 13 ++++++++ app/views/admin/schools.html.erb | 49 ++++++++++++++++++++--------- 3 files changed, 58 insertions(+), 26 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 8e0adffe2..66c35ed6b 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -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 diff --git a/app/helpers/school_helper.rb b/app/helpers/school_helper.rb index 0528cb7ac..075d2b039 100644 --- a/app/helpers/school_helper.rb +++ b/app/helpers/school_helper.rb @@ -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 diff --git a/app/views/admin/schools.html.erb b/app/views/admin/schools.html.erb index d19e9b3b9..f52d1f060 100644 --- a/app/views/admin/schools.html.erb +++ b/app/views/admin/schools.html.erb @@ -1,43 +1,64 @@

<%=l(:label_school_plural)%>

-<%= form_tag({:controller => 'admin', :action => 'schools' }, :method => :get,:id=>"search_course_form") do %> - <%= submit_tag "搜索",:style => "float: right;margin-right: 15px;"%> - -<% end %> + + + +
- - - - + + + - <% @schools.each do |school|%> + <% @count=@page * 30 %> + <% @schools.each do |school| %> "> - + + - + + @@ -50,4 +71,4 @@ <%= pagination_links_full @school_pages, @school_count ,:per_page_links => true, :remote => false, :flag => true %> -<% html_title(l(:label_project_plural)) -%> +<% html_title(l(:label_school_plural)) -%>
+ 序号 + LOGO + 学校名称 + 用户数 + + 创建时间 + + 编辑高校信息 +
- <%= school.id %> + + + <% @count +=1 %> + + <%=@count %> <%= image_tag(school.logo_link,width:40,height:40) %> + - <%= link_to school.name,"http://#{Setting.host_course}/?school_id=#{school.id}" %> + <%= link_to school.name,"http://#{Setting.host_name}/?school_id=#{school.id}" %> + + <%= schoolMember_num(school) %> + + <%= format_time(school.created_at) %> + <%= 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') %>