Class: EducodeSales::HomeController
Instance Method Summary
collapse
#authenticate_admin, #authenticate_request, #current_user, #render_failure, #render_success
Instance Method Details
#index ⇒ Object
5
6
|
# File 'app/controllers/educode_sales/home_controller.rb', line 5
def index
end
|
#no_permission ⇒ Object
11
12
|
# File 'app/controllers/educode_sales/home_controller.rb', line 11
def no_permission
end
|
#sales_staff ⇒ Object
40
41
42
43
44
45
46
47
|
# File 'app/controllers/educode_sales/home_controller.rb', line 40
def sales_staff
common = Common.find_by(clazz: 'staff_type', name: '销售')
@staffs = Staff
if params[:q].present?
@staffs = @staffs.joins(user: :user_extension).where("concat(lastname, firstname) like :q", q: "%#{params[:q]}%")
end
@staffs = @staffs.where(is_admin: false).where.not(id: @current_admin.id).where(job_type: common.id).page(params[:page]).per(10)
end
|
#search ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/educode_sales/home_controller.rb', line 18
def search
if params[:type] == 'department'
@data = Department.joins(:school).where("schools.name like :q", q: "%#{params[:q]}%").limit(50)
unless @data.present?
@data = Department.where("name like ?", "%#{params[:q]}%").limit(50)
end
elsif params[:type] == "school"
data = School.where("name like ? ", "%#{params[:q]}%").limit(50)
end
end
|
#search_edu_teacher ⇒ Object
36
37
38
|
# File 'app/controllers/educode_sales/home_controller.rb', line 36
def search_edu_teacher
@data = User.joins(:user_extension).where("identity='teacher'").where("concat(lastname, firstname) like :q OR phone like :q OR mail like :q", q: "%#{params[:q]}%").limit(50)
end
|
#search_teacher ⇒ Object
30
31
32
33
34
|
# File 'app/controllers/educode_sales/home_controller.rb', line 30
def search_teacher
@data = Teacher.where("name like ? and is_key = false", "%#{params[:q]}%").limit(20)
user_ids = @data.pluck(:user_id).compact.uniq
@data += User.joins(:user_extension).where.not(id: user_ids).where("identity='teacher'", user_ids).where("lastname like ?", "%#{params[:q]}%").limit(50)
end
|
#search_users ⇒ Object
14
15
16
|
# File 'app/controllers/educode_sales/home_controller.rb', line 14
def search_users
@users = User.where("concat(lastname, firstname) like :q OR login like :q OR phone like :q or mail like :q", q: "%#{params[:q]}%").limit(50)
end
|
#statistics ⇒ Object
8
9
|
# File 'app/controllers/educode_sales/home_controller.rb', line 8
def statistics
end
|