@ -36,17 +36,18 @@ class CoursesController < ApplicationController
if!params[:name].nil?
condition="%#{params[:name].strip}%".gsub("","")
end
limit=15
course_org_ids=OrgCourse.find_by_sql("select distinct organization_id from org_courses where course_id = #{params[:id]}").map(&:organization_id)
ifcourse_org_ids.empty?
@orgs_not_in_course=Organization.where("(is_public or creator_id =?) and name like ?",User.current.id,condition).page((params[:page].to_i||1)).per(10)
@orgs_not_in_course=Organization.where("(is_public or creator_id =?) and name like ?",User.current.id,condition).page((params[:page].to_i||1)).per(limit)
@org_count=Organization.where("is_public = 1 or creator_id =?",User.current.id).where("name like ?",condition).count
else
course_org_ids="("+course_org_ids.join(',')+")"
@orgs_not_in_course=Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?",User.current.id,condition).page((params[:page].to_i||1)).per(10)
@orgs_not_in_course=Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?",User.current.id,condition).page((params[:page].to_i||1)).per(limit)
@org_count=Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?)",User.current.id).where("name like ?",condition).count
@ -144,6 +183,19 @@ class FilesController < ApplicationController
#resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC")
resultSet=Attachment.where("attachments.container_type = 'OrgSubfield' And attachments.container_id = '#{org_subfield.id}' AND filename LIKE :like ",like:"%#{keywords}%").
reorder(sort)
else
resultSet=Attachment.where("attachments.container_type = 'OrgSubfield' And attachments.container_id = '#{org_subfield.id}' ").reorder(sort)
end
#resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC")
end
deffind_project_attachekeywords,project,sort=""
ifsort==""
sort="created_on DESC"
@ -298,10 +350,52 @@ class FilesController < ApplicationController
@ -75,17 +75,18 @@ class ProjectsController < ApplicationController
if!params[:name].nil?
condition="%#{params[:name].strip}%".gsub("","")
end
limit=15
project_org_ids=OrgProject.find_by_sql("select distinct organization_id from org_projects where project_id = #{params[:id]}").map(&:organization_id)
ifproject_org_ids.empty?
@orgs_not_in_project=Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id,condition).page((params[:page].to_i||1)).per(10)
@orgs_not_in_project=Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id,condition).page((params[:page].to_i||1)).per(limit)
@org_count=Organization.where("is_public = 1 or creator_id =?",User.current.id).where("name like ?",condition).count
else
project_org_ids="("+project_org_ids.join(',')+")"
@orgs_not_in_project=Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?) and name like ?",User.current.id,condition).page((params[:page].to_i||1)).per(10)
@orgs_not_in_project=Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?) and name like ?",User.current.id,condition).page((params[:page].to_i||1)).per(limit)
@org_count=Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?)",User.current.id).where("name like ?",condition).count