From e3e2c37f128a16d104f6090e985e96050e1373ad Mon Sep 17 00:00:00 2001 From: cxt Date: Fri, 26 Feb 2016 16:26:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E7=9A=84=E6=9C=80=E8=BF=91=E7=99=BB=E5=BD=95=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=B7=BB=E5=8A=A0=E8=80=81=E5=B8=88=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admin_controller.rb | 17 ++++ app/views/admin/_tab_users.erb | 7 ++ .../admin/latest_login_teachers.html.erb | 84 +++++++++++++++++++ app/views/admin/latest_login_users.html.erb | 5 +- config/routes.rb | 3 +- 5 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 app/views/admin/_tab_users.erb create mode 100644 app/views/admin/latest_login_teachers.html.erb diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 68386de44..01703f679 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -469,6 +469,23 @@ class AdminController < ApplicationController end end + #最近登录老师列表 + def latest_login_teachers + scope = User.find_by_sql("SELECT * FROM users,user_extensions WHERE users.id = user_extensions.user_id AND user_extensions.identity=0 ORDER BY last_login_on DESC") + if params[:startdate].present? + scope = User.find_by_sql("SELECT * FROM users,user_extensions WHERE users.id = user_extensions.user_id AND user_extensions.identity=0 and last_login_on>= '#{params[:startdate]} 00:00:00' ORDER BY last_login_on DESC") + end + if params[:enddate].present? + scope = User.find_by_sql("SELECT * FROM users,user_extensions WHERE users.id = user_extensions.user_id AND user_extensions.identity=0 and last_login_on <= '#{params[:enddate]} 23:59:59' ORDER BY last_login_on DESC") + end + @teachers = scope + @teachers = paginateHelper @teachers,30 + @page = (params['page'] || 1).to_i - 1 + respond_to do |format| + format.html + end + end + #作业 def homework @homework = HomeworkCommon.order('end_time desc') diff --git a/app/views/admin/_tab_users.erb b/app/views/admin/_tab_users.erb new file mode 100644 index 000000000..2cda0c61c --- /dev/null +++ b/app/views/admin/_tab_users.erb @@ -0,0 +1,7 @@ +
+ +
\ No newline at end of file diff --git a/app/views/admin/latest_login_teachers.html.erb b/app/views/admin/latest_login_teachers.html.erb new file mode 100644 index 000000000..06c0386f5 --- /dev/null +++ b/app/views/admin/latest_login_teachers.html.erb @@ -0,0 +1,84 @@ +<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %> +

+ <%=l(:label_latest_login_user_list)%> +

+<%= render 'tab_users' %> + +

+ 最近登录老师列表 +

+<%= form_tag({}, :method => :get) do %> +
+ + <%= l(:label_filter_plural) %> + + + <%= text_field_tag 'startdate', params[:startdate], :size => 15, :onchange=>"$('#ui-datepicker-div').hide()", :style=>"float:left"%> + <%= calendar_for('startdate')%>    + + <%= text_field_tag 'enddate', params[:enddate], :size => 15, :onchange =>"$('#ui-datepicker-div').hide()", :style=>"float:left"%> + <%= calendar_for('enddate')%>   + <%= submit_tag l(:button_apply), :class => "small", :name => nil %> + <%= link_to l(:button_clear), {:controller => 'admin', :action => 'latest_login_teachers'}, :class => 'icon icon-reload' %> +
+<% end %> +  +
+ + + + + + + + + + + + + <% @count=@page * 30 %> + <% for teacher in @teachers do %> + + <% @count +=1 %> + + + + + + + + <% end %> + +
+ 序号 + + 登录时间 + + 用户id + + 用户姓名 + + 用户登录名 + + 用户身份 +
+ <%=@count %> + + <%=format_time(teacher.last_login_on) %> + + <%=teacher.id %> + <%= teacher.login%><% else %><%=teacher.try(:realname) %><% end %>'> + <% if teacher.try(:realname) == ' '%> + <%= link_to(teacher.login, user_path(teacher)) %> + <% else %> + <%= link_to(teacher.try(:realname), user_path(teacher)) %> + <% end %> + + <%=link_to(teacher.login, user_path(teacher)) %> + + 老师 +
+
+ diff --git a/app/views/admin/latest_login_users.html.erb b/app/views/admin/latest_login_users.html.erb index 594f554b4..17680a8c8 100644 --- a/app/views/admin/latest_login_users.html.erb +++ b/app/views/admin/latest_login_users.html.erb @@ -2,7 +2,10 @@

<%=l(:label_latest_login_user_list)%>

- +<%= render 'tab_users' %> +

+ <%=l(:label_latest_login_user_list)%> +

<%= form_tag({}, :method => :get) do %>
diff --git a/config/routes.rb b/config/routes.rb index 562fb8157..248b21a60 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -954,7 +954,8 @@ RedmineApp::Application.routes.draw do match 'admin/project_messages', as: :project_messages match'admin/course_messages', as: :course_messages get 'admin/notices' - get 'admin/latest_login_users' + match 'admin/latest_login_users', as: :latest_login_users + match 'admin/latest_login_teachers', as: :latest_login_teachers get 'admin/homework' resources :auth_sources do