educode_sales 1.10.49 → 1.10.59

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/educode_sales/modules/easyeditor/easyeditor.css +1 -1
  3. data/app/controllers/educode_sales/application_controller.rb +10 -0
  4. data/app/controllers/educode_sales/business_courses_controller.rb +58 -33
  5. data/app/controllers/educode_sales/businesses_controller.rb +43 -7
  6. data/app/controllers/educode_sales/contracts_controller.rb +6 -0
  7. data/app/controllers/educode_sales/money_plan_records_controller.rb +6 -2
  8. data/app/controllers/educode_sales/money_plans_controller.rb +3 -0
  9. data/app/controllers/educode_sales/plans_controller.rb +392 -9
  10. data/app/controllers/educode_sales/sale_trends_controller.rb +1 -1
  11. data/app/controllers/educode_sales/shixun_dectects_controller.rb +77 -16
  12. data/app/controllers/educode_sales/shixuns_controller.rb +65 -4
  13. data/app/controllers/educode_sales/subject_trends_controller.rb +99 -892
  14. data/app/controllers/educode_sales/subjects_controller.rb +29 -18
  15. data/app/helpers/educode_sales/application_helper.rb +3 -1
  16. data/app/helpers/educode_sales/business_courses_helper.rb +29 -6
  17. data/app/helpers/educode_sales/sale_trends_helper.rb +52 -52
  18. data/app/helpers/educode_sales/subject_helper.rb +5 -1
  19. data/app/models/educode_sales/business.rb +5 -5
  20. data/app/models/educode_sales/business_deliver_subject.rb +3 -2
  21. data/app/models/educode_sales/business_subject.rb +9 -3
  22. data/app/models/educode_sales/business_subject_shixun.rb +37 -8
  23. data/app/models/educode_sales/business_subject_staff.rb +1 -0
  24. data/app/models/educode_sales/permission.rb +7 -0
  25. data/app/models/educode_sales/sales_target_history.rb +11 -0
  26. data/app/views/educode_sales/business_courses/edit.html.erb +30 -4
  27. data/app/views/educode_sales/business_courses/index.html.erb +34 -12
  28. data/app/views/educode_sales/business_courses/index.json.jbuilder +2 -2
  29. data/app/views/educode_sales/business_courses/list_shixuns.html.erb +132 -64
  30. data/app/views/educode_sales/business_courses/list_shixuns.json.jbuilder +12 -6
  31. data/app/views/educode_sales/business_courses/list_subjects.html.erb +29 -34
  32. data/app/views/educode_sales/business_courses/list_subjects.json.jbuilder +7 -2
  33. data/app/views/educode_sales/business_courses/new.html.erb +45 -20
  34. data/app/views/educode_sales/businesses/index.html.erb +11 -9
  35. data/app/views/educode_sales/contracts/_list.html.erb +16 -1
  36. data/app/views/educode_sales/contracts/index.html.erb +5 -2
  37. data/app/views/educode_sales/contracts/list.js.erb +4 -1
  38. data/app/views/educode_sales/money_plan_records/_index.html.erb +21 -5
  39. data/app/views/educode_sales/money_plan_records/index.js.erb +4 -1
  40. data/app/views/educode_sales/money_plans/list.html.erb +6 -2
  41. data/app/views/educode_sales/plans/_year_execute.html.erb +293 -0
  42. data/app/views/educode_sales/plans/_year_target.html.erb +677 -0
  43. data/app/views/educode_sales/plans/index.html.erb +104 -81
  44. data/app/views/educode_sales/plans/year_execute.js.erb +1 -0
  45. data/app/views/educode_sales/plans/year_target.js.erb +1 -0
  46. data/app/views/educode_sales/plans/year_target.json.jbuilder +48 -0
  47. data/app/views/educode_sales/plans/years_all_target.json.jbuilder +53 -0
  48. data/app/views/educode_sales/sale_trends/_return_money_forecast.html.erb +1 -1
  49. data/app/views/educode_sales/sale_trends/_user_stat.html.erb +1 -1
  50. data/app/views/educode_sales/sale_trends/_visit_analysis.html.erb +1 -1
  51. data/app/views/educode_sales/sale_trends/return_money_forecast.js.erb +1 -1
  52. data/app/views/educode_sales/sale_trends/trends.html.erb +6 -6
  53. data/app/views/educode_sales/sale_trends/user_stat.js.erb +1 -1
  54. data/app/views/educode_sales/sale_trends/visit_analysis.js.erb +1 -1
  55. data/app/views/educode_sales/shixun_dectects/index.html.erb +97 -47
  56. data/app/views/educode_sales/shixun_dectects/index.json.jbuilder +4 -3
  57. data/app/views/educode_sales/shixun_dectects/markdown.html.erb +1 -1
  58. data/app/views/educode_sales/shixuns/edit.html.erb +35 -13
  59. data/app/views/educode_sales/shixuns/index.html.erb +348 -138
  60. data/app/views/educode_sales/shixuns/index.json.jbuilder +9 -5
  61. data/app/views/educode_sales/shixuns/new.html.erb +22 -12
  62. data/app/views/educode_sales/subject_trends/trends.html.erb +177 -575
  63. data/app/views/educode_sales/subjects/edit.html.erb +4 -4
  64. data/app/views/educode_sales/subjects/index.html.erb +50 -12
  65. data/app/views/educode_sales/subjects/index.json.jbuilder +3 -3
  66. data/app/views/educode_sales/subjects/list_shixuns.html.erb +143 -17
  67. data/app/views/educode_sales/subjects/list_shixuns.json.jbuilder +9 -4
  68. data/app/views/educode_sales/subjects/new.html.erb +4 -4
  69. data/app/views/layouts/educode_sales/application.html.erb +2 -2
  70. data/config/routes.rb +7 -2
  71. data/db/migrate/20230729085359_create_educode_sales_sales_target_histories.rb +45 -0
  72. data/lib/educode_sales/version.rb +1 -1
  73. metadata +10 -4
  74. data/app/views/educode_sales/plans/_target_track.html.erb +0 -178
  75. data/app/views/educode_sales/plans/target_track.js.erb +0 -1
@@ -1,16 +1,50 @@
1
- # frozen_string_literal: true
1
+ # frozen_string_literal: true
2
2
 
3
3
  # 实践项目管理
4
4
  module EducodeSales
5
5
  class ShixunsController < ApplicationController
6
- before_action :subject_members, :subject_staffs, :create_filter
6
+ before_action :subject_members, :subject_staffs, :create_filter, :subject_url
7
7
  def index
8
8
 
9
+ authorize! :shixun, BusinessDeliverSubject
10
+
9
11
  # 判断类型是否存在 1 管培 2 全职 3 专职 如果不存在就默认为1
10
12
  category = params[:q].present? ? params[:q][:category].to_i : BusinessSubjectShixun::CATEGORY_TYPE::TRAINING
11
- @shixuns = BusinessSubjectShixun.left_joins(:school, :shixun , business_subject: [:subject, business: :last_follow_up])
13
+ trends_category = params[:trends_category]
14
+
15
+ gon.category = trends_category.present? ? trends_category.to_i : 1
16
+ gon.is_admin = is_commissioner_above?
17
+
18
+ business_subject_shixuns = BusinessSubjectShixun
19
+
20
+ # 根据身份获取对应数据
21
+ business_subject_shixuns = if is_commissioner_above?
22
+ business_subject_shixuns
23
+ else
24
+ # 实训本身的成员
25
+ smembers_ids = business_subject_shixuns.joins(shixun_members: :staff).where("educode_sales_staffs.id = #{@current_admin.id} ")
26
+ .ids
27
+
28
+ # 父类课程经理
29
+ deliver_ids = business_subject_shixuns.joins(business_subject: [business_deliver_subject: [manages: :staff]])
30
+ .where("educode_sales_staffs.id = #{@current_admin.id} ")
31
+ .ids
32
+
33
+ subject_ids = business_subject_shixuns.joins(business_subject: [manages: :staff])
34
+ .where("educode_sales_business_subjects.business_id is null and educode_sales_staffs.id = #{@current_admin.id} ")
35
+ .ids
36
+
37
+ business_subject_shixuns.where(id: smembers_ids + deliver_ids + subject_ids)
38
+ end
39
+
40
+ @shixuns = business_subject_shixuns.left_joins(:last_dectect)
41
+ .left_joins(:school, :shixun , business_subject: [:subject, business: :last_follow_up])
12
42
  .where(category: category)
13
43
 
44
+ # if params[:q].present? && params[:q][:business_name].present?
45
+ # @shixuns = @shixuns.where("educode_sales_businesses.name like '%#{params[:q][:business_name]}%' ")
46
+ # end
47
+
14
48
  # 项目级别 0 全部
15
49
  if params[:q].present? && params[:q][:level].present? && params[:q][:level].to_i != 0
16
50
  @shixuns = @shixuns.where(level: params[:q][:level])
@@ -32,18 +66,42 @@ module EducodeSales
32
66
  if params[:q].present? && params[:q][:subject_name].present?
33
67
  @shixuns = @shixuns.where("subjects.name like '%#{params[:q][:subject_name]}%'")
34
68
  end
69
+
70
+
71
+ shixun_staffs = {}
72
+ BusinessSubjectShixun.includes(business_subject:[ business_deliver_subject: [:manages, business: [:school, last_follow_up: :assign_follow_ups]] ]).find_each do |d|
73
+ b_d_s = d.business_subject
74
+ if b_d_s.blank?
75
+ shixun_staffs.merge!({"#{d.id}": d.shixun_staff })
76
+ elsif b_d_s.present? && b_d_s.business_deliver_subject.present?
77
+ shixun_staffs.merge!({ "#{d.id}": b_d_s.business_deliver_subject.business.staff_name })
78
+ elsif b_d_s.present?
79
+ shixun_staffs.merge!({ "#{d.id}": b_d_s.staffs_name })
80
+ end
81
+ end
82
+ @shixun_staffs = shixun_staffs.stringify_keys
83
+ p @shixun_staffs
35
84
  @shixuns = @shixuns.select("educode_sales_business_subject_shixuns.*,
36
85
  educode_sales_follow_ups.reception_at,
37
86
  schools.name as school_name,
38
87
  subjects.name as subject_name,
88
+ subjects.identifier as subjects_identifier,
39
89
  shixuns.name as shixun_name,
90
+ shixuns.identifier as s_identifier,
91
+ educode_sales_shixun_dectects.created_at as shixun_dectects_time,
92
+ educode_sales_shixun_dectects.content as dectects_content,
40
93
  shixuns.identifier")
41
94
  .page(params[:page])
42
95
  .per(params[:limit])
43
96
  end
44
97
 
45
98
  def edit
99
+ authorize! :shixun, BusinessDeliverSubject
46
100
  @item = BusinessSubjectShixun.find(params[:id])
101
+ @last_dectect = ''
102
+ if @item.last_dectect.present?
103
+ @last_dectect = @item.last_dectect.dectect_type
104
+ end
47
105
  @producer_list = BusinessSubjectStaff.where(container_type: BusinessSubjectStaff::CONTAINER_TYPES::SHIXUN,
48
106
  container_id: params[:id],
49
107
  category: BusinessSubjectStaff::CATEGORY_TYPES::SHIXUN_PRODUCER)
@@ -60,6 +118,7 @@ module EducodeSales
60
118
  end
61
119
 
62
120
  def update
121
+ authorize! :shixun, BusinessDeliverSubject
63
122
  ActiveRecord::Base.transaction do
64
123
 
65
124
  if params[:id].present?
@@ -92,12 +151,14 @@ module EducodeSales
92
151
  end
93
152
 
94
153
  def new
154
+ authorize! :shixun, BusinessDeliverSubject
95
155
  gon.manage = @manages
96
156
  gon.staffs = @staffs
97
157
  render layout: false
98
158
  end
99
159
 
100
160
  def create
161
+ authorize! :shixun, BusinessDeliverSubject
101
162
  begin
102
163
  ActiveRecord::Base.transaction do
103
164
 
@@ -115,7 +176,7 @@ module EducodeSales
115
176
 
116
177
  if params[:shixun_type].to_i == 1
117
178
  # 目前支持名称关联实训
118
- origin_shixun = Shixun.unhidden.find_by_name(params[:name].to_s)
179
+ origin_shixun = Shixun.where(hidden: 0).find_by_name(params[:name].to_s)
119
180
  attr = origin_shixun.blank? ? attr : attr.merge({shixun_id: origin_shixun.id})
120
181
  end
121
182
  shixun = BusinessSubjectShixun.create!(attr)