From 52c8593b0994cd4b911fe14c5f01bc0282abb754 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 11 May 2016 16:20:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=95=99=E5=B8=88=E5=88=97?= =?UTF-8?q?=E8=A1=A8sql=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 34 ++++++++++++- .../organizations/_org_teachers_list.html.erb | 35 +++++++++++++ .../organizations/_show_teachers.html.erb | 47 +++++------------- app/views/organizations/teacher_search.js.erb | 1 + config/routes.rb | 1 + public/images/search.png | Bin 0 -> 1658 bytes 6 files changed, 82 insertions(+), 36 deletions(-) create mode 100644 app/views/organizations/_org_teachers_list.html.erb create mode 100644 app/views/organizations/teacher_search.js.erb create mode 100644 public/images/search.png diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 07bd55321..71a39d7ac 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -102,8 +102,10 @@ class OrganizationsController < ApplicationController if params[:org_subfield_id] @org_subfield = OrgSubfield.find(params[:org_subfield_id]) if @org_subfield.field_type == "Comptec" || @org_subfield.field_type == "Compstu" - #@org_students = User.find_by_sql("SELECT * FROM users u, user_extensions ue where u.id = ue.user_id and ue.identity =1;") + # @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,( SELECT `courses`.* FROM `courses` INNER JOIN `members` ON `courses`.`id` = `members`.`course_id` WHERE `members`.`user_id` = u.id AND (courses.status<>9)) as course_count + # from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 order by course_count desc") @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 order by course_count desc") + # @org_resources = else @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 @org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10) @@ -148,6 +150,36 @@ class OrganizationsController < ApplicationController end + def teacher_search + "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_type in #{type_ids} and course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%' " + teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 order by course_count desc") + q = "#{params[:search].strip}" + @org_teachers = searchmember_by_name(teachers, q) + @is_remote = true + #@result_count = results.count + #@results = paginateHelper results, 10 + # @results = results + # @search_name = q + + end + + def searchmember_by_name members, name + #searchPeopleByRoles(project, StudentRoles) + mems = [] + if name != "" + name = name.to_s.downcase + members.each do |m| + username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase + if(m.user[:login].to_s.downcase.include?(name) || m.user.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name)) + mems << m + end + end + else + mems = members + end + mems + end + def get_project_message_activities_org org project_ids = org.projects.map{|project| project.id}.join(",") unless project_ids.blank? diff --git a/app/views/organizations/_org_teachers_list.html.erb b/app/views/organizations/_org_teachers_list.html.erb new file mode 100644 index 000000000..6397a9cb1 --- /dev/null +++ b/app/views/organizations/_org_teachers_list.html.erb @@ -0,0 +1,35 @@ +<% @org_teachers.each do |org_teacher| %> + <% school = School.where("id =?", org_teacher.school_id).first %> +
+
+
+ <%= link_to image_tag(url_to_avatar(org_teacher), :width => "90", :height => "90"), user_url_in_org(org_teacher), :alt => "用户头像" %> +
+
+
<%= org_teacher.try(:realname).nil? ? org_teacher.try(:login) : org_teacher.try(:realname) %> + <% unless school.nil? %> + <%= school.name %> + <% end %> + <% unless org_teacher.nil? %> + <%= org_teacher.technical_title %>
+ <% end %> +
+
<%= org_teacher_course_count(org_teacher) %>
+
课程数
+
+
+
+
<%= org_student_course_count(org_teacher) %>500
+
学生数
+
+
+
+
<%= org_teacher_resource_count(org_teacher) %>
+
资源数
+
+
+ 添加 +
+
+
+<% end %> \ No newline at end of file diff --git a/app/views/organizations/_show_teachers.html.erb b/app/views/organizations/_show_teachers.html.erb index cbaed9f74..3531b9a58 100644 --- a/app/views/organizations/_show_teachers.html.erb +++ b/app/views/organizations/_show_teachers.html.erb @@ -1,7 +1,14 @@
- - + <%= form_tag( url_for(:controller => 'organizations', :action => 'teacher_search'), + :remote => true , :method => 'get', :id => 'resource_search_form') do %> + + <%= submit_tag '', :class => 'homepageSearchIcon', :onfocus => 'this.blur();', :style => 'border-style:none', :class => "teacher-search-icon fl" %> + + <% end %> + + +
- <% @org_teachers.each do |org_teacher| %> - <% school = School.where("id =?", org_teacher.school_id).first %> -
-
-
-
-
<%= org_teacher.try(:realname).nil? ? org_teacher.try(:login) : org_teacher.try(:realname) %> - <% unless school.nil? %> - <%= school.name %> - <% end %> - <% unless org_teacher.nil? %> - <%= org_teacher.technical_title %>
- <% end %> -
-
<%= org_teacher_course_count(org_teacher) %>
-
课程数
-
-
-
-
<%= org_student_course_count(org_teacher) %>500
-
学生数
-
-
-
-
<%= org_teacher_resource_count(org_teacher) %>
-
资源数
-
-
- 添加 -
-
-
- <% end %> +
+ <%=render 'organizations/org_teachers_list' %> +
\ No newline at end of file diff --git a/app/views/organizations/teacher_search.js.erb b/app/views/organizations/teacher_search.js.erb new file mode 100644 index 000000000..6b27f0998 --- /dev/null +++ b/app/views/organizations/teacher_search.js.erb @@ -0,0 +1 @@ +$("#org_teachers_list").html('<%= escape_javascript( render :partial => 'organizations/org_teachers_list')%>'); diff --git a/config/routes.rb b/config/routes.rb index ffda033a6..9910cbe6c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -76,6 +76,7 @@ RedmineApp::Application.routes.draw do get 'more_org_projects' get 'more_org_courses' get 'search_courses' + get 'teacher_search' post 'join_course_menu' post 'join_courses' get 'search_projects' diff --git a/public/images/search.png b/public/images/search.png new file mode 100644 index 0000000000000000000000000000000000000000..97ce7bf5dd8ae75fde7d63b20abb63f0473ac6cc GIT binary patch literal 1658 zcmbVNX;2eq7+z>pv@&4usC2ArIK*o1WMNkjHd!K3E+J^N*s^3dWP{1Z%}N5T)UjSr zlrr85ULY06DjpQ0Gvd_>SghlL4p?XCg*H_{z)I254T9|t#~<$Oe&_o<@AJOj`^^?4 zC(iX96F3F{0AFn!mcsS^p3i3_*G}yoz`1TR8>?qiX(Q{v84^GVI+Fyo7CehgA#oyi zc>@^<0Ph$nou1Vv#3KgUBEmg3BB#a1p#dN=+G)cL*(3{Ql3A2BO3-n(P5@FwlwgrE zL6TrolO`%Ik0Dd@5_N{WYy(UPqUV5-PJ|<{kSq>5Ez7KS#2F4KiBt+gkVvXfLXdP8D3eHKVhQ&`La72#LWnFJ9C`$tH-<1G zDVS!+7dML%m{`_^h{XXsVss+#zH70Q>#%Wj48Mc2vZMZ zwN^WeTMgu}UyAcPgoWOSMbr$5voxcl>1D$ekZht^+HRt4pgI)-!xm9if_B(vc#h{~ zv>3@yIV7QBXbU))Uxa#%e+3H58&;__7z)8kiClrnA;A!qc$=JwIWb~S zas01XhL^Ys^bB8>J~w%Fc}OdFV;JsgNN?rE0f6^mEr#lxExOHDvs2OW-?!ht7aU9l zJ~?#IH~5TswU2p1VWAaUdU{;C&)PFp^U*sw<)=HN{n2~GbUn(pC6?$aHY_n@8 z%_dXW-`K9(!o6S3izx8HWV*B;Z zP8%}u%cb_SKV3c0!qYEa41as>+&_DOf%^LTfE`osK6>iw6^eRQ0&r@TZjY6wuN35J zXL#TB2g;h>Z!+FY>hxZ3=h6EvW0M}9(A>WG?Afy^yPGPL?Z?waN!rPWbbmKDH&4*_ z--`IL_RsFVH49!uUsjA=xxObjKX+Q>cXheO>Tx0an||1(Tn@&2XU;gE-q*39h2Ng_ z@WzhPhFb^IW?iP%k60BLTg~6;A4X02bY)R@9G_nl`u|g7*v~^xcfXV-e zYX4X9;*3ee-qNBiABMUwWOTYt@#M6(ETp&bw-f8OoN&3S9yBgJUmn)C_JAKhYa7tw zjsdGzmG7^qsmc26*u_8ipJ$v57$4jxoKMpqjyz5di*%CGNp>wuzWOw zlxdMCUl8GkuSxwrvaGcgFvi8=!cl=1g`e}?x!rxw)s1kHD(2}CK9C;LCFE_NwtL?i za^7CFDJvi*vfg;I(1H5^-8|WqxW}tX+Mv)E`2$HU;SC$(0e(Ak@KRf6j~DQ9xoewy z=A-hWI?E^j%!0-6E>A!B; R=kojww6TfUQB}t3e*v>ucjEv6 literal 0 HcmV?d00001