Class: EducodeSales::RecyclesController
Instance Method Summary
collapse
#authenticate_admin, #authenticate_request, #current_user, #filter, #is_commissioner_above?, #paginate, #render_failure, #render_success, #subject_members, #subject_staffs, #subject_url
#add_businesses_score, #base_url, #collection_amount_score, #completion_rate, #current?, #disk_filename, #get_businesses_chart, #handled_data, #handled_time_data, #handled_time_data_accurate, #relative_path, #signed_amount_score, #storage_path, #url_to_avatar, #visits_score
Instance Method Details
#business ⇒ Object
51
52
53
54
55
56
57
58
59
|
# File 'app/controllers/educode_sales/recycles_controller.rb', line 51
def business
@businesses = Recycle.where(source_type:"EducodeSales::Business")
if params[:sort].present? && params[:sort][:field]
@businesses = @businesses.order("created_at #{params[:sort][:order]}")
else
@businesses = @businesses.order("educode_sales_recycles.created_at desc")
end
@businesses = @businesses.page(params[:page]).per(params[:limit])
end
|
#destroy ⇒ Object
6
7
8
9
10
|
# File 'app/controllers/educode_sales/recycles_controller.rb', line 6
def destroy
@recycle = Recycle.find(params[:id])
@recycle.destroy
render_success
end
|
#follow_up ⇒ Object
61
62
63
64
65
66
67
68
69
|
# File 'app/controllers/educode_sales/recycles_controller.rb', line 61
def follow_up
@data = Recycle.where(source_type:"EducodeSales::FollowUp")
if params[:sort].present? && params[:sort][:field]
@data = @data.order("created_at #{params[:sort][:order]}")
else
@data = @data.order("educode_sales_recycles.created_at desc")
end
@data = @data.page(params[:page]).per(params[:limit])
end
|
#monthly ⇒ Object
81
82
83
84
85
86
87
88
89
|
# File 'app/controllers/educode_sales/recycles_controller.rb', line 81
def monthly
@monthly = Recycle.where(source_type:"EducodeSales::SaleReport")
if params[:sort].present? && params[:sort][:field]
@monthly = @monthly.order("created_at #{params[:sort][:order]}")
else
@monthly = @monthly.order("educode_sales_recycles.created_at desc")
end
@monthly = @monthly.page(params[:page]).per(params[:limit])
end
|
#monthPlan ⇒ Object
101
102
103
104
105
106
107
108
109
|
# File 'app/controllers/educode_sales/recycles_controller.rb', line 101
def monthPlan
@monthPlans = Recycle.joins("JOIN educode_sales_sale_plans ON educode_sales_sale_plans.id = educode_sales_recycles.source_id AND educode_sales_sale_plans.month IS NOT NULL AND educode_sales_sale_plans.weekly IS NULL").where(source_type:"EducodeSales::SalePlan")
if params[:sort].present? && params[:sort][:field]
@monthPlans = @monthPlans.order("created_at #{params[:sort][:order]}")
else
@monthPlans = @monthPlans.order("educode_sales_recycles.created_at desc")
end
@monthPlans = @monthPlans.page(params[:page]).per(params[:limit])
end
|
#restore_businesses ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'app/controllers/educode_sales/recycles_controller.rb', line 41
def restore_businesses
@recycle = Recycle.find(params[:id])
business_id = @recycle.source_id
EducodeSales::Business.unscoped.find(business_id).update(deleted_at: nil)
follow_ups = EducodeSales::FollowUp.unscoped.where(business_id: business_id)
follow_ups.update_all(deleted_at: nil)
@recycle.destroy
render_success
end
|
#restore_follow_up ⇒ Object
12
13
14
15
16
17
18
|
# File 'app/controllers/educode_sales/recycles_controller.rb', line 12
def restore_follow_up
@recycle = Recycle.find(params[:id])
report_id = @recycle.source_id
EducodeSales::FollowUp.unscoped.find(report_id).update(deleted_at: nil)
@recycle.destroy
render_success
end
|
#restore_plans ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/educode_sales/recycles_controller.rb', line 28
def restore_plans
@recycle = Recycle.find(params[:id])
plan = EducodeSales::SalePlan.unscoped.find(@recycle.source_id)
business = EducodeSales::Business.unscoped.find(plan.business_id)
Recycle.find_by(source_id: business.id).destroy if Recycle.find_by(source_id: business.id).present?
business.update(deleted_at: nil)
follow_ups = EducodeSales::FollowUp.unscoped.where(business_id: business.id)
follow_ups.update_all(deleted_at: nil)
plan.update(deleted_at: nil)
@recycle.destroy
render_success
end
|
#restore_reports ⇒ Object
20
21
22
23
24
25
26
|
# File 'app/controllers/educode_sales/recycles_controller.rb', line 20
def restore_reports
@recycle = Recycle.find(params[:id])
report_id = @recycle.source_id
EducodeSales::SaleReport.unscoped.find(report_id).update(deleted_at: nil)
@recycle.destroy
render_success
end
|
#weekly ⇒ Object
71
72
73
74
75
76
77
78
79
|
# File 'app/controllers/educode_sales/recycles_controller.rb', line 71
def weekly
@weekly = Recycle.where(source_type:"EducodeSales::SaleReport").order(created_at: :desc).page(params[:page]).per(params[:limit])
if params[:sort].present? && params[:sort][:field]
@weekly = @weekly.order("created_at #{params[:sort][:order]}")
else
@weekly = @weekly.order("educode_sales_recycles.created_at desc")
end
@weekly = @weekly.page(params[:page]).per(params[:limit])
end
|
#weekPlan ⇒ Object
91
92
93
94
95
96
97
98
99
|
# File 'app/controllers/educode_sales/recycles_controller.rb', line 91
def weekPlan
@weekPlans = Recycle.where(source_type:"EducodeSales::SalePlan")
if params[:sort].present? && params[:sort][:field]
@weekPlans = @weekPlans.order("created_at #{params[:sort][:order]}")
else
@weekPlans = @weekPlans.order("educode_sales_recycles.created_at desc")
end
@weekPlans = @weekPlans.page(params[:page]).per(params[:limit])
end
|
#yearPlan ⇒ Object
111
112
113
114
115
116
117
118
119
|
# File 'app/controllers/educode_sales/recycles_controller.rb', line 111
def yearPlan
@plans = Recycle.joins("JOIN educode_sales_sale_plans ON educode_sales_sale_plans.id = educode_sales_recycles.source_id AND educode_sales_sale_plans.year IS NOT NULL").where(source_type:"EducodeSales::SalePlan")
if params[:sort].present? && params[:sort][:field]
@plans = @plans.order("created_at #{params[:sort][:order]}")
else
@plans = @plans.order("educode_sales_recycles.created_at desc")
end
@plans = @plans.page(params[:page]).per(params[:limit])
end
|