educode_sales 0.4.4 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/educode_sales/indexLogo.png +0 -0
  3. data/app/controllers/educode_sales/businesses_controller.rb +6 -3
  4. data/app/controllers/educode_sales/home_controller.rb +4 -0
  5. data/app/controllers/educode_sales/operation_plans_controller.rb +6 -2
  6. data/app/controllers/educode_sales/operation_reports_controller.rb +9 -3
  7. data/app/controllers/educode_sales/operations_controller.rb +1 -1
  8. data/app/controllers/educode_sales/plans_controller.rb +19 -7
  9. data/app/controllers/educode_sales/sale_reports_controller.rb +9 -3
  10. data/app/controllers/educode_sales/sale_trends_controller.rb +8 -7
  11. data/app/controllers/educode_sales/sales_controller.rb +2 -2
  12. data/app/models/educode_sales/sale_plan.rb +1 -0
  13. data/app/models/educode_sales/teacher.rb +12 -19
  14. data/app/views/educode_sales/activities/index.html.erb +4 -0
  15. data/app/views/educode_sales/activities/index.json.jbuilder +6 -0
  16. data/app/views/educode_sales/activities/show_teachers.html.erb +16 -16
  17. data/app/views/educode_sales/businesses/index.html.erb +15 -10
  18. data/app/views/educode_sales/businesses/index.json.jbuilder +7 -1
  19. data/app/views/educode_sales/businesses/show_follow.html.erb +9 -4
  20. data/app/views/educode_sales/home/index.html.erb +1 -1
  21. data/app/views/educode_sales/home/search_operation_teacher.json.jbuilder +12 -0
  22. data/app/views/educode_sales/operation_plans/_monthPlan.html.erb +12 -8
  23. data/app/views/educode_sales/operation_plans/_monthly.html.erb +18 -4
  24. data/app/views/educode_sales/operation_plans/_weekPlan.html.erb +13 -9
  25. data/app/views/educode_sales/operation_plans/_weekly.html.erb +18 -4
  26. data/app/views/educode_sales/operation_plans/edit_month.html.erb +6 -6
  27. data/app/views/educode_sales/operation_plans/edit_week.html.erb +7 -7
  28. data/app/views/educode_sales/operation_plans/index.json.jbuilder +10 -2
  29. data/app/views/educode_sales/operation_plans/new_month.html.erb +36 -4
  30. data/app/views/educode_sales/operation_plans/new_monthly.html.erb +16 -2
  31. data/app/views/educode_sales/operation_plans/new_week.html.erb +33 -5
  32. data/app/views/educode_sales/operation_plans/new_weekly.html.erb +16 -2
  33. data/app/views/educode_sales/operation_reports/audit.html.erb +13 -1
  34. data/app/views/educode_sales/operation_reports/edit.html.erb +13 -1
  35. data/app/views/educode_sales/operation_reports/index.json.jbuilder +7 -0
  36. data/app/views/educode_sales/operation_reports/show.html.erb +13 -1
  37. data/app/views/educode_sales/places/index.html.erb +5 -0
  38. data/app/views/educode_sales/plans/_monthPlan.html.erb +11 -8
  39. data/app/views/educode_sales/plans/_monthly.html.erb +18 -3
  40. data/app/views/educode_sales/plans/_weekPlan.html.erb +10 -7
  41. data/app/views/educode_sales/plans/_weekly.html.erb +19 -3
  42. data/app/views/educode_sales/plans/edit_month.html.erb +7 -7
  43. data/app/views/educode_sales/plans/edit_week.html.erb +8 -8
  44. data/app/views/educode_sales/plans/index.json.jbuilder +4 -0
  45. data/app/views/educode_sales/plans/new_month.html.erb +2 -2
  46. data/app/views/educode_sales/plans/new_monthly.html.erb +16 -2
  47. data/app/views/educode_sales/plans/new_week.html.erb +2 -2
  48. data/app/views/educode_sales/plans/new_weekly.html.erb +16 -2
  49. data/app/views/educode_sales/sale_reports/audit.html.erb +13 -1
  50. data/app/views/educode_sales/sale_reports/edit.html.erb +13 -1
  51. data/app/views/educode_sales/sale_reports/index.json.jbuilder +7 -0
  52. data/app/views/educode_sales/sale_reports/show.html.erb +20 -9
  53. data/app/views/educode_sales/sales/index.html.erb +6 -0
  54. data/app/views/educode_sales/sales/index.json.jbuilder +20 -4
  55. data/app/views/educode_sales/sales/operations.html.erb +4 -4
  56. data/app/views/educode_sales/sales/operations.json.jbuilder +12 -3
  57. data/app/views/educode_sales/teachers/index.html.erb +19 -14
  58. data/app/views/educode_sales/teachers/index.json.jbuilder +12 -2
  59. data/app/views/educode_sales/teachers/show_follow.html.erb +10 -4
  60. data/app/views/layouts/educode_sales/application.html.erb +12 -4
  61. data/config/routes.rb +1 -0
  62. data/db/migrate/20211022085324_add_teacher_used_to_teachers.rb +7 -0
  63. data/lib/educode_sales/version.rb +1 -1
  64. metadata +5 -3
  65. data/app/assets/images/educode_sales/indexlogo.png +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbb707c74c7909b2a42a4cc3eaf395677a436c8a210db16ba31cfb5abb0c9cdd
4
- data.tar.gz: 7c08a37d777b84396fc415076c6fa768eb0bd9dc56d9e6307451832212141a71
3
+ metadata.gz: '09889c1d05306828a3d6dba9b149cdd6600ada4a043c545bfb6914521fdbfe43'
4
+ data.tar.gz: 9ee3dfb7975c1270ea5adfd43b3cc0bee417a0cb7c544628486465037afd4166
5
5
  SHA512:
6
- metadata.gz: d96671e32dfe8e9469c6f93927cf453d86861004d123bbbc01b1118295e7827fd37a1b039ac629a51803d1132341afed7b58fb630919387251253481377d7720
7
- data.tar.gz: '0628d9062d5c4b72851dc9cbb0f997169cb395713c3e20263c7b32df369ef323c79370955dffb428b88ff33d9cb297e0ebd3720b1c6bb1f04fdeeb198fbf49ad'
6
+ metadata.gz: 6acf74a3a544e7cc6fc44809976f549fe4f0ca55cc9e96e91044daf2a0b0acddf4807deda3967cb00310c8403fab92930f5f01fb7d17125ca904746a93b30e3d
7
+ data.tar.gz: 480ec2fc713a76af3cf6207805ee11c805cdeeaa50daefae6b148c70b976140b0ab01ba29aa4bc263b8b6fe9a6ef077c5dae8035acbbc219c5a32c2449cee336
@@ -47,8 +47,6 @@ module EducodeSales
47
47
  if params[:q].present? && params[:q][:mine].present?
48
48
  ids = AssignFollowUp.where(staff_id: @current_admin.id).pluck(:follow_up_id)
49
49
  ids1 = FollowUp.where(id: ids).pluck(:business_id)
50
- # ids2 = Business.where(staff_id: @current_admin.id).pluck(:id)
51
- # @businesses = Business.where(id: ids1+ids2)
52
50
  @businesses =@businesses.where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", ids1, @current_admin.id)
53
51
  end
54
52
 
@@ -61,7 +59,12 @@ module EducodeSales
61
59
  @businesses = @businesses.joins(:department).where("departments.id in (?)", departments_ids)
62
60
  end
63
61
  if params[:q].present? && params[:q][:staff_id].present?
64
- @businesses = @businesses.where(staff_id: params[:q][:staff_id])
62
+ part_a_ids = @businesses.where("educode_sales_businesses.last_follow_up_id is null AND staff_id = ?",params[:q][:staff_id]).ids
63
+ part_b_ids = @businesses.where("educode_sales_businesses.last_follow_up_id is not null").joins("
64
+ JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
65
+ ").where("educode_sales_follow_ups.staff_id = ?", params[:q][:staff_id]).pluck(:business_id)
66
+ business_ids = part_a_ids + part_b_ids
67
+ @businesses = EducodeSales::Business.where(id:business_ids)
65
68
  end
66
69
  if params[:q].present? && params[:q][:business_type].present?
67
70
  @businesses = @businesses.joins("
@@ -33,6 +33,10 @@ module EducodeSales
33
33
  @data += User.joins(:user_extension).where.not(id: user_ids).where("identity='teacher'", user_ids).where("lastname like ?", "%#{params[:q]}%").limit(50)
34
34
  end
35
35
 
36
+ def search_operation_teacher
37
+ @data = Teacher.where("name like ? and is_key = false", "%#{params[:q]}%").limit(20)
38
+ end
39
+
36
40
  def search_edu_teacher
37
41
  @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)
38
42
  end
@@ -21,7 +21,7 @@ module EducodeSales
21
21
  @sale_plans = OperationPlan.where(staff_id: @current_admin.id)
22
22
  when '区域'
23
23
  staff_ids = Staff.joins(user: [user_extension: [department: :school]]).where("schools.province in (?)", @current_admin.areas.pluck(:name)).pluck(:id)
24
- @sale_plans = OperationPlan.where("staff_id in (?)", staff_ids)
24
+ @sale_plans = OperationPlan.where("staff_id in (?) OR educode_sales_operation_plans.staff_id = ?", staff_ids, @current_admin.id)
25
25
  else
26
26
  @sale_plans = OperationPlan
27
27
  end
@@ -44,7 +44,7 @@ module EducodeSales
44
44
  if params[:sort].present? && params[:sort][:field]
45
45
  @sale_plans = @sale_plans.order("#{params[:sort][:field]} #{params[:sort][:order]}")
46
46
  else
47
- @sale_plans = @sale_plans.order("updated_at desc")
47
+ @sale_plans = @sale_plans.order("created_at desc")
48
48
  end
49
49
  @sale_plans = @sale_plans.page(params[:page]).per(params[:limit])
50
50
  end
@@ -77,6 +77,8 @@ module EducodeSales
77
77
  end
78
78
 
79
79
  def new_weekly
80
+ @area =@current_admin.areas.present? ? @current_admin.areas.pluck(:name).join("、") : ''
81
+ @name = @current_admin.user.real_name
80
82
  sale_plans = OperationPlan.where(month: Time.now.strftime("%Y-%m") + "-01 00:00:00", weekly: Time.now.strftime('%W').to_i, staff_id: @current_admin.id)
81
83
  @rate = sale_plans.present? ? (sale_plans.sum("finish_rate") / sale_plans.size) : 0
82
84
  @departments_count = sale_plans.joins(:teacher).count("distinct(department_id)")
@@ -92,6 +94,8 @@ module EducodeSales
92
94
  end
93
95
 
94
96
  def new_monthly
97
+ @area =@current_admin.areas.present? ? @current_admin.areas.pluck(:name).join("、") : ''
98
+ @name = @current_admin.user.real_name
95
99
  sale_plans = OperationPlan.where(month: Time.now.strftime("%Y-%m") + "-01 00:00:00", staff_id: @current_admin.id, weekly: nil)
96
100
  @rate = sale_plans.present? ? (sale_plans.sum("finish_rate") / sale_plans.size) : 0
97
101
  @departments_count = sale_plans.joins(:teacher).count("distinct(department_id)")
@@ -18,7 +18,7 @@ module EducodeSales
18
18
  @sale_reports = OperationReport.where(staff_id: @current_admin.id)
19
19
  when '区域'
20
20
  staff_ids = Staff.joins(user: [user_extension: [department: :school]]).where("schools.province in (?)", @current_admin.areas.pluck(:name)).pluck(:id)
21
- @sale_reports = OperationReport.where("staff_id in (?)", staff_ids)
21
+ @sale_reports = OperationReport.where("staff_id in (?) OR educode_sales_operation_reports.staff_id = ?", staff_ids, @current_admin.id)
22
22
  else
23
23
  @sale_reports = OperationReport
24
24
  end
@@ -40,7 +40,7 @@ module EducodeSales
40
40
  if params[:sort].present? && params[:sort][:field]
41
41
  @sale_reports = @sale_reports.order("#{params[:sort][:field]} #{params[:sort][:order]}")
42
42
  else
43
- @sale_reports = @sale_reports.order("updated_at desc")
43
+ @sale_reports = @sale_reports.order("created_at desc")
44
44
  end
45
45
  @sale_reports = @sale_reports.page(params[:page]).per(params[:limit])
46
46
  end
@@ -67,6 +67,8 @@ module EducodeSales
67
67
 
68
68
  def show
69
69
  @sale_report = OperationReport.find(params[:id])
70
+ @name = @sale_report.staff.user.real_name
71
+ @area = @sale_report.staff.areas.present? ? @sale_report.staff.areas.pluck(:name).join("、") : ''
70
72
  render layout: false
71
73
  end
72
74
 
@@ -78,6 +80,8 @@ module EducodeSales
78
80
 
79
81
  def edit
80
82
  @sale_report = OperationReport.find(params[:id])
83
+ @name = @sale_report.staff.user.real_name
84
+ @area = @sale_report.staff.areas.present? ? @sale_report.staff.areas.pluck(:name).join("、") : ''
81
85
  render layout: false
82
86
  end
83
87
 
@@ -113,6 +117,8 @@ module EducodeSales
113
117
 
114
118
  def audit
115
119
  @sale_report = OperationReport.find(params[:id])
120
+ @name = @sale_report.staff.user.real_name
121
+ @area = @sale_report.staff.areas.present? ? @sale_report.staff.areas.pluck(:name).join("、") : ''
116
122
  render layout: false
117
123
  end
118
124
 
@@ -126,6 +132,6 @@ module EducodeSales
126
132
  params.permit(:level1_opinion, :level2_opinion, :level3_opinion, :level1_score, :level2_score, :level3_score)
127
133
  end
128
134
 
129
-
135
+
130
136
  end
131
137
  end
@@ -4,7 +4,7 @@ module EducodeSales
4
4
  class OperationsController < ApplicationController
5
5
 
6
6
  def trends
7
- @years = (1..(Time.now.year - 2020)).map { |d| 2020 + d }
7
+ @years = (1..(Time.now.year - 2014)).map { |d| 2014 + d }
8
8
  @year = params[:year] ? params[:year] : Time.now.year
9
9
  @operation_trend = OperationTrend.find_or_create_by(year: @year)
10
10
  @inc_users_count = User.where("created_on > ? AND created_on <= ?", "#{@year}-01-01 00:00:00", "#{@year}-12-31 23:59:59").count
@@ -22,7 +22,7 @@ module EducodeSales
22
22
  @sale_plans = SalePlan.where(staff_id: @current_admin.id)
23
23
  when '区域'
24
24
  staff_ids = Staff.joins(user: [user_extension: [department: :school]]).where("schools.province in (?)", @current_admin.areas.pluck(:name)).pluck(:id)
25
- @sale_plans = SalePlan.where("staff_id in (?)", staff_ids)
25
+ @sale_plans = SalePlan.where("staff_id in (?) OR educode_sales_sale_plans.staff_id = ?", staff_ids, @current_admin.id)
26
26
  else
27
27
  @sale_plans = SalePlan
28
28
  end
@@ -44,7 +44,7 @@ module EducodeSales
44
44
  if params[:sort].present? && params[:sort][:field]
45
45
  @sale_plans = @sale_plans.order("#{params[:sort][:field]} #{params[:sort][:order]}")
46
46
  else
47
- @sale_plans = @sale_plans.order("updated_at desc")
47
+ @sale_plans = @sale_plans.order("created_at desc")
48
48
  end
49
49
 
50
50
  @sale_plans = @sale_plans.page(params[:page]).per(params[:limit])
@@ -59,7 +59,7 @@ module EducodeSales
59
59
  def create
60
60
  plan = @current_admin.sale_plans.build(plan_params)
61
61
  plan.month = params["month"] + "-1"
62
- plan.business = @current_admin.businesses.find_by(id: params[:business_id])
62
+ plan.business = Business.find_by(id: params[:business_id])
63
63
  if plan.save
64
64
  render_success
65
65
  else
@@ -78,11 +78,15 @@ module EducodeSales
78
78
  else
79
79
  @weeks = [week]
80
80
  end
81
- @businesses = @current_admin.businesses.pluck(:name, :id)
81
+ business_ids = EducodeSales::AssignFollowUp.joins(:follow_up).where(staff_id: @current_admin.id).pluck :business_id
82
+ @businesses = Business.includes(:department, :last_follow_up).where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", business_ids, @current_admin.id)
83
+ @businesses = @businesses.map { |b| [b.name + "(" + b.department.school.name + ")" + "---" + "最新跟进:" + (b.last_follow_up.present? ? b.last_follow_up.created_at.to_s : '无'), b.id] }
82
84
  render layout: false
83
85
  end
84
86
 
85
87
  def new_weekly
88
+ @area =@current_admin.areas.present? ? @current_admin.areas.pluck(:name).join("、") : ''
89
+ @name = @current_admin.user.real_name
86
90
  sale_plans = SalePlan.where(month: Time.now.strftime("%Y-%m") + "-01 00:00:00", weekly: Time.now.strftime('%W').to_i, staff_id: @current_admin.id)
87
91
  @rate = sale_plans.present? ? (sale_plans.sum("finish_rate") / sale_plans.size) : 0
88
92
  @departments_count = sale_plans.joins(:business).count("distinct(department_id)")
@@ -92,11 +96,15 @@ module EducodeSales
92
96
 
93
97
  def new_month
94
98
  @business = Business.find_by(id: params[:business_id])
95
- @businesses = @current_admin.businesses.pluck(:name, :id)
99
+ business_ids = EducodeSales::AssignFollowUp.joins(:follow_up).where(staff_id: @current_admin.id).pluck :business_id
100
+ @businesses =Business.includes(:department, :last_follow_up).where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", business_ids, @current_admin.id)
101
+ @businesses = @businesses.map { |b| [b.name + "(" + b.department.school.name + ")" + "---" + "最新跟进:" + (b.last_follow_up.present? ? b.last_follow_up.created_at.to_s : '无'), b.id] }
96
102
  render layout: false
97
103
  end
98
104
 
99
105
  def new_monthly
106
+ @area =@current_admin.areas.present? ? @current_admin.areas.pluck(:name).join("、") : ''
107
+ @name = @current_admin.user.real_name
100
108
  sale_plans = SalePlan.where(month: Time.now.strftime("%Y-%m") + "-01 00:00:00", staff_id: @current_admin.id, weekly: nil)
101
109
  @rate = sale_plans.present? ? (sale_plans.sum("finish_rate") / sale_plans.size) : 0
102
110
  @departments_count = sale_plans.joins(:business).count("distinct(department_id)")
@@ -123,7 +131,9 @@ module EducodeSales
123
131
  end
124
132
 
125
133
  def edit_week
126
- @businesses = @current_admin.businesses.pluck(:name, :id)
134
+ business_ids = EducodeSales::AssignFollowUp.joins(:follow_up).where(staff_id: @current_admin.id).pluck :business_id
135
+ @businesses = Business.includes(:department, :last_follow_up).where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", business_ids, @current_admin.id)
136
+ @businesses = @businesses.map { |b| [b.name + "(" + b.department.school.name + ")" + "---" + "最新跟进:" + (b.last_follow_up.present? ? b.last_follow_up.created_at.to_s : '无'), b.id] }
127
137
  @sale_plan = SalePlan.find(params[:id])
128
138
  if @sale_plan.weekly.present?
129
139
  week = Time.now.strftime('%W').to_i
@@ -169,7 +179,9 @@ module EducodeSales
169
179
  end
170
180
 
171
181
  def edit_month
172
- @businesses = @current_admin.businesses.pluck(:name, :id)
182
+ business_ids = EducodeSales::AssignFollowUp.joins(:follow_up).where(staff_id: @current_admin.id).pluck :business_id
183
+ @businesses = Business.includes(:department, :last_follow_up).where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", business_ids, @current_admin.id)
184
+ @businesses = @businesses.map { |b| [b.name + "(" + b.department.school.name + ")" + "---" + "最新跟进:" + (b.last_follow_up.present? ? b.last_follow_up.created_at.to_s : '无'), b.id] }
173
185
  @sale_plan = SalePlan.find(params[:id])
174
186
  @finish_rates = []
175
187
  11.times { |d| @finish_rates << ["#{d*10}%", d * 10]}
@@ -9,7 +9,7 @@ module EducodeSales
9
9
  else
10
10
  sale_report = @current_admin.sale_reports.build(month: Date.today.beginning_of_month, weekly: Time.now.strftime('%W').to_i)
11
11
  end
12
-
12
+
13
13
  sale_report.finish_rate = params[:finish_rate]
14
14
  sale_report.client = params[:client]
15
15
  sale_report.content = params[:content]
@@ -23,6 +23,8 @@ module EducodeSales
23
23
 
24
24
  def show
25
25
  @sale_report = SaleReport.find(params[:id])
26
+ @name = @sale_report.staff.user.real_name
27
+ @area = @sale_report.staff.areas.present? ? @sale_report.staff.areas.pluck(:name).join("、") : ''
26
28
  render layout: false
27
29
  end
28
30
 
@@ -51,7 +53,7 @@ module EducodeSales
51
53
  @sale_reports = SaleReport.where(staff_id: @current_admin.id)
52
54
  when '区域'
53
55
  staff_ids = Staff.joins(user: [user_extension: [department: :school]]).where("schools.province in (?)", @current_admin.areas.pluck(:name)).pluck(:id)
54
- @sale_reports = SaleReport.where("staff_id in (?)", staff_ids)
56
+ @sale_reports = SaleReport.where("staff_id in (?) OR educode_sales_sale_reports.staff_id = ?", staff_ids, @current_admin.id)
55
57
  else
56
58
  @sale_reports = SaleReport
57
59
  end
@@ -73,7 +75,7 @@ module EducodeSales
73
75
  if params[:sort].present? && params[:sort][:field]
74
76
  @sale_reports = @sale_reports.order("#{params[:sort][:field]} #{params[:sort][:order]}")
75
77
  else
76
- @sale_reports = @sale_reports.order("updated_at desc")
78
+ @sale_reports = @sale_reports.order("created_at desc")
77
79
  end
78
80
  @sale_reports = @sale_reports.page(params[:page]).per(params[:limit])
79
81
  end
@@ -83,6 +85,8 @@ module EducodeSales
83
85
 
84
86
  def edit
85
87
  @sale_report = SaleReport.find(params[:id])
88
+ @name = @sale_report.staff.user.real_name
89
+ @area = @sale_report.staff.areas.present? ? @sale_report.staff.areas.pluck(:name).join("、") : ''
86
90
  render layout: false
87
91
  end
88
92
 
@@ -118,6 +122,8 @@ module EducodeSales
118
122
 
119
123
  def audit
120
124
  @sale_report = SaleReport.find(params[:id])
125
+ @name = @sale_report.staff.user.real_name
126
+ @area = @sale_report.staff.areas.present? ? @sale_report.staff.areas.pluck(:name).join("、") : ''
121
127
  render layout: false
122
128
  end
123
129
 
@@ -7,20 +7,21 @@ module EducodeSales
7
7
  def trends
8
8
  # authorize! :trends, EducodeSales::SaleTrend
9
9
  @year = params[:year] ? params[:year] : Time.now.year
10
- @years = (1..(Time.now.year - 2020)).map { |d| 2020 + d }
10
+ @years = (1..(Time.now.year - 2014)).map { |d| 2014 + d }
11
11
  year_time = "#{@year}-01-01 00:00:00"
12
+ year_over_time = "#{@year}-12-31 23:59:59"
12
13
  x = Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
13
14
  o = Common.find_by(extras: EducodeSales::Common::OTYPE)&.id
14
15
  @sale_trend = SaleTrend.find_or_create_by(year: @year)
15
- @business_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ? AND educode_sales_follow_ups.clazz_id != ?", x, o).where("educode_sales_follow_ups.created_at >= ?", year_time).sum(:total_amount).round(2)
16
+ @business_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ? AND educode_sales_follow_ups.clazz_id != ?", x, o).sum(:total_amount).round(2)
16
17
  stage_ids = Common.where(clazz: '商机阶段', name: ['已中标','已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
17
- @goal_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.created_at >= ? AND educode_sales_follow_ups.stage_id IN (?)", year_time, stage_ids).sum(:total_amount).round(2)
18
+ @goal_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.created_at >= ? AND educode_sales_follow_ups.created_at <= ? AND educode_sales_follow_ups.stage_id IN (?)", year_time, year_over_time, stage_ids).sum(:total_amount).round(2)
18
19
  s_stage_ids = Common.where(clazz: '商机阶段', name: ['已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
19
- @service_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.created_at >= ? AND educode_sales_follow_ups.stage_id IN (?)", year_time, s_stage_ids).sum(:total_amount).round(2)
20
- @return_amount = Business.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x).where.not("educode_sales_money_plans.clazz!= ?", 1).where("educode_sales_money_plans.date_at >= ?", year_time).sum(:amount).round(2)
21
- a = Common.where(clazz: '商机类型', name: 'A').pluck(:id)
20
+ @service_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.created_at >= ? AND educode_sales_follow_ups.created_at <= ? AND educode_sales_follow_ups.stage_id IN (?)", year_time, year_over_time, s_stage_ids).sum(:total_amount).round(2)
21
+ @return_amount = Business.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x).where.not("educode_sales_money_plans.clazz!= ?", 1).where("educode_sales_money_plans.date_at >= ? AND educode_sales_money_plans.date_at <= ? ", year_time, year_over_time).sum(:amount).round(2)
22
+ a = Common.where(clazz: '商机类型', name: 'A类-有预算主推').pluck(:id)
22
23
  @a_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id IN (?)", a).sum(:total_amount).round(2)
23
- b = Common.where(clazz: '商机类型', name: 'B').pluck(:id)
24
+ b = Common.where(clazz: '商机类型', name: 'B类-有预算不主推').pluck(:id)
24
25
  @b_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id IN (?)", b).sum(:total_amount).round(2)
25
26
  end
26
27
 
@@ -12,8 +12,8 @@ module EducodeSales
12
12
  end
13
13
  format.json do
14
14
  common = Common.find_by(clazz: 'staff_type', name: '销售')
15
- @a_clazz = Common.find_by(clazz: 'business_type', name: 'A')
16
- @b_clazz = Common.find_by(clazz: 'business_type', name: 'B')
15
+ @a_clazz = Common.find_by(clazz: 'business_type', name: 'A类-有预算主推')
16
+ @b_clazz = Common.find_by(clazz: 'business_type', name: 'B类-有预算不主推')
17
17
  @x = Common.find_by(extras: EducodeSales::Common::XTYPE)
18
18
  @step_ids = Common.where(name: %w(已中标 已签单 已验收 回款中 服务中 已结束), clazz: 'business_step').pluck(:id)
19
19
 
@@ -2,6 +2,7 @@ module EducodeSales
2
2
  class SalePlan < ApplicationRecord
3
3
  belongs_to :business
4
4
  belongs_to :staff
5
+ validates :business_id, presence: true
5
6
 
6
7
  validates :month, presence: true
7
8
  end
@@ -13,29 +13,22 @@ module EducodeSales
13
13
  belongs_to :follow_up, class_name: 'TeacherFollow', optional: true
14
14
  validates :user_id, uniqueness: { allow_blank: true, message: '已存在老师列表'}
15
15
 
16
+ def cal_courses_count
17
+ if self.user_id.present?
18
+ Course.joins(:course_members).where(course_members: {user_id: self.user_id}).where("is_delete = 0 and role != 4 and excellent = 0 and is_hidden = 0").where("start_date is null or start_date <= '#{Date.today}'").distinct(:course_id).count
19
+ else
20
+ 0
21
+ end
22
+ end
16
23
 
17
- # def teacher_used_of_department
18
- # if user_id.present?
19
- # user_ids = User.joins(:user_extension).where(user_extensions: {department_id: self.department_id, identity: 0}).pluck(:id)
20
- # course_ids = CourseMember.where(role: "CREATOR", user_id: user_ids).pluck(:course_id)
21
- # if course_ids.present?
22
- # course_members = CourseMember.joins(course: :practice_homework_shixuns).where(course_id: course_ids).group("course_id").having("COUNT(homework_commons_shixuns.id) > 100 AND COUNT(course_members.user_id) > 20").select("COUNT(case when course_members.role !=4 then 1 END) AS count")
23
- # course_members.present? ? course_members[0]['count'] : 0
24
- # else
25
- # 0
26
- # end
27
- # else
28
- # 0
29
- # end
30
- # end
31
24
  def teacher_used_of_department
32
- user_ids = User.joins(:user_extension).where(user_extensions: {department_id: self.department_id, identity: 0}).pluck(:id)
33
- course_ids = CourseMember.where(role: "CREATOR", user_id: user_ids).pluck(:course_id)
34
- course_members = CourseMember.joins(course: :practice_homework_shixuns).where(course_id: course_ids).group("course_id").having("COUNT(homework_commons_shixuns.id) > 100 AND COUNT(course_members.user_id) > 20").select("COUNT(case when course_members.role !=4 then 1 END) AS count")
35
- course_members.present? ? course_members[0]['count'] : 0
25
+ user_ids = User.joins(:user_extension).where(user_extensions: {department_id: self.department_id, identity: 0}).pluck(:id)
26
+ course_ids = CourseMember.where(role: "CREATOR", user_id: user_ids).pluck(:course_id)
27
+ course_members = CourseMember.joins(course: :practice_homework_shixuns).where(course_id: course_ids).group("course_id").having("COUNT(homework_commons_shixuns.id) > 100 AND COUNT(course_members.user_id) > 20").select("COUNT(case when course_members.role !=4 then 1 END) AS count")
28
+ course_members.present? ? course_members[0]['count'] : 0
36
29
  end
37
30
 
38
- def students_count
31
+ def cal_students_count
39
32
  if user_id.present?
40
33
  course_ids = Course.joins(:course_members).where(course_members: {user_id: user_id}).where("is_delete = 0 and role != 4 and excellent = 0 and is_hidden = 0").where("start_date is null or start_date <= '#{Date.today}'").distinct("course_id").pluck(:course_id)
41
34
  CourseMember.where(course_id: course_ids, role: "STUDENT").count
@@ -39,12 +39,14 @@
39
39
  elem: '#activities_table',
40
40
  url: '/missions/activities',
41
41
  toolbar: '#activity_toolbar',
42
+ totalRow:true,
42
43
  defaultToolbar: [],
43
44
  cols: [
44
45
  [
45
46
  {
46
47
  field: 'id',
47
48
  title:'序号',type: 'numbers',
49
+ totalRowText:'合计',
48
50
  width: 60
49
51
  },
50
52
  {
@@ -68,11 +70,13 @@
68
70
  field: 'teachers_count',
69
71
  title: '教师数',
70
72
  width: 100,
73
+ totalRow:true,
71
74
  templet: '#teachers_count'
72
75
  },
73
76
  {
74
77
  field: 'students_count',
75
78
  title: '学生数',
79
+ totalRow:'{{ parseInt(d.TOTAL_NUMS) }}',
76
80
  width: 100
77
81
  },
78
82
  {
@@ -1,14 +1,20 @@
1
+ teachers_count = 0
1
2
  json.data do
2
3
  json.array! @activities do |d|
3
4
  json.id d.id
4
5
  json.name d.name
5
6
  json.days d.days
6
7
  json.teachers_count d.activity_teachers_count
8
+ teachers_count += d.activity_teachers_count
7
9
  json.return_rate d.return_rate
8
10
  json.students_count d.students_count || 0
9
11
  json.course_rate d.course_rate
10
12
  json.start_at d.start_at ? d.start_at.to_s(:date) : ''
11
13
  end
12
14
  end
15
+
16
+ json.totalRow do
17
+ json.teachers_count teachers_count.to_s
18
+ end
13
19
  json.code 0
14
20
  json.count @activities.total_count
@@ -1,3 +1,4 @@
1
+ <div class="min-height-table">
1
2
  <script type="text/html" id="teacher_toolbar">
2
3
  <div class="layui-btn-container">
3
4
  <span class="table-label">教师列表</span>
@@ -5,7 +6,6 @@
5
6
  </button>
6
7
  </div>
7
8
  </script>
8
- <div class="layuimini-main edit-table">
9
9
  <table class="layui-hide" id="show_teachers_table" style="min-height: 300px;" lay-filter="teachers_table"></table>
10
10
  </div>
11
11
  <script type="text/html" id="show_teachersTableBar">
@@ -53,84 +53,84 @@
53
53
  elem: '#show_teachers_table',
54
54
  url: '/missions/teachers?activity_id=' + parent.activity_id,
55
55
  toolbar: '#teacher_toolbar',
56
- defaultToolbar: [],
56
+ defaultToolbar: ['filter'],
57
57
  cols: [
58
58
  [
59
59
  {
60
60
  field: 'id',
61
- width: 120,
61
+ width: 60,
62
62
  title:'序号',type: 'numbers',
63
63
  },
64
64
  {
65
65
  field: 'name',
66
- width: 120,
66
+ width: 90,
67
67
  title: '姓名',
68
68
  templet: "#name"
69
69
  },
70
70
  {
71
71
  field: 'school',
72
- width: 190,
72
+ width: 120,
73
73
  title: '单位',
74
74
  },
75
75
  {
76
76
  field: 'department',
77
- width: 190,
77
+ width: 120,
78
78
  title: '部门'
79
79
  },
80
80
  {
81
81
  field: 'professional_title',
82
82
  title: '职称',
83
- width: 120,
83
+ width: 80,
84
84
  templet: '#show_follow'
85
85
  },
86
86
  {
87
87
  field: 'job',
88
- width: 120,
88
+ width: 80,
89
89
  title: '职务',
90
90
  templet: '#show_keys'
91
91
 
92
92
  },
93
93
  {
94
94
  field: 'source',
95
- width: 120,
95
+ width: 100,
96
96
  title: '来源',
97
97
  },
98
98
  {
99
99
  field: 'attitude',
100
- width: 120,
100
+ width: 80,
101
101
  title: '态度',
102
102
  },
103
103
  {
104
104
  field: 'course_subjects_count',
105
- width: 120,
105
+ width: 90,
106
106
  title: '课程方向',
107
107
  templet: "#courses"
108
108
  },
109
109
  {
110
110
  field: 'teacher_follows_count',
111
- width: 120,
111
+ width: 90,
112
112
  title: '跟进情况',
113
113
  templet: "#follow"
114
114
  },
115
115
  {
116
116
  field: 'teacher_used',
117
- width: 120,
117
+ width: 110,
118
118
  title: '学院渗透率',
119
119
  },
120
120
  {
121
121
  field: 'students',
122
- width: 120,
122
+ width: 60,
123
123
  title: '学生',
124
124
  },
125
125
  {
126
126
  field: 'courses_count',
127
- width: 120,
127
+ width: 60,
128
128
  title: '课堂',
129
129
  templet: "#class"
130
130
  },
131
131
  {
132
132
  field: 'activities_count',
133
- width: 120,
133
+ width: 100,
134
134
  title: '参与活动',
135
135
  templet: "#event"
136
136
  },
@@ -114,14 +114,16 @@
114
114
  elem: '#businesses_table',
115
115
  url: '/missions/businesses',
116
116
  where: {q: form.val('search_form')},
117
+ defaultToolbar: ['filter'],
117
118
  toolbar: '#bussinessBar',
118
- defaultToolbar: [],
119
+ totalRow: true,//开启合并行
119
120
  cols: [
120
121
  [
121
122
  {
122
123
  field: 'id',
123
124
  width: 60,
124
125
  title:'序号',type: 'numbers',
126
+ totalRowText: '合计',
125
127
  },
126
128
  {
127
129
  field: 'name',
@@ -130,19 +132,20 @@
130
132
  },
131
133
  {
132
134
  field: 'school',
133
- width: 200,
135
+ width: 150,
134
136
  title: '单位',
135
137
  },
136
138
  {
137
139
  field: 'department',
138
- width: 140,
140
+ width: 150,
139
141
  title: '部门'
140
142
  },
141
143
  {
142
144
  field: 'follow_ups_count',
143
145
  title: '跟进',
144
146
  width: 60,
145
- templet: '#show_follow'
147
+ templet: '#show_follow',
148
+ totalRow: true,
146
149
  },
147
150
  // {
148
151
  // field: 'teachers_count',
@@ -152,12 +155,12 @@
152
155
  // },
153
156
  {
154
157
  field: 'clazz',
155
- width: 120,
158
+ width: 80,
156
159
  title: '类型'
157
160
  },
158
161
  {
159
162
  field: 'stage',
160
- width: 100,
163
+ width: 90,
161
164
  title: '阶段'
162
165
  },
163
166
  {
@@ -176,27 +179,29 @@
176
179
  field: 'total_amount',
177
180
  width: 100,
178
181
  title: '总额',
182
+ totalRow: true,
179
183
  sort: true
180
184
  },
181
185
  {
182
186
  field: 'return_money',
183
187
  width: 100,
184
188
  title: '回款',
185
- sort: true
189
+ sort: true,
190
+ totalRow: true
186
191
  },
187
192
  {
188
193
  field: 'place',
189
- width: 110,
194
+ width: 80,
190
195
  title: '渠道'
191
196
  },
192
197
  {
193
198
  field: 'source',
194
- width: 110,
199
+ width: 90,
195
200
  title: '商机来源'
196
201
  },
197
202
  {
198
203
  field: 'last_follow_person',
199
- width: 120,
204
+ width: 100,
200
205
  title: '最新跟进人'
201
206
  },
202
207
  {