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
|
#search ⇒ Object
18
19
20
21
22
23
24
25
26
27
|
# File 'app/controllers/educode_sales/home_controller.rb', line 18
def search
if params[:type] == 'department'
@data = Department.where("name like ?", "%#{params[:q]}%").limit(20)
unless @data.present?
@data = Department.joins(:school).where("schools.name like ?", "%#{params[:q]}%").limit(20)
end
elsif params[:type] == "school"
data = School.where("name like ? ", "%#{params[:q]}%").limit(20)
end
end
|
#search_edu_teacher ⇒ Object
35
36
37
|
# File 'app/controllers/educode_sales/home_controller.rb', line 35
def search_edu_teacher
@data = User.joins(:user_extension).where("identity='teacher'").where("lastname like ? OR phone like ? OR mail like ?", "%#{params[:q]}%", "%#{params[:q]}%", "%#{params[:q]}%").limit(20)
end
|
#search_teacher ⇒ Object
29
30
31
32
33
|
# File 'app/controllers/educode_sales/home_controller.rb', line 29
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(20)
end
|
#search_users ⇒ Object
14
15
16
|
# File 'app/controllers/educode_sales/home_controller.rb', line 14
def search_users
@users = User.where("lastname like :q OR login like :q OR phone like :q or mail like :q", q: "%#{params[:q]}%").limit(20)
end
|
#statistics ⇒ Object
8
9
|
# File 'app/controllers/educode_sales/home_controller.rb', line 8
def statistics
end
|