rails_attend 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +20 -0
  3. data/README.md +22 -0
  4. data/Rakefile +32 -0
  5. data/app/controllers/attend/admin/absence_stats_controller.rb +60 -0
  6. data/app/controllers/attend/admin/absences_controller.rb +77 -0
  7. data/app/controllers/attend/admin/attendance_logs_controller.rb +103 -0
  8. data/app/controllers/attend/admin/attendance_settings_controller.rb +86 -0
  9. data/app/controllers/attend/admin/attendance_stats_controller.rb +58 -0
  10. data/app/controllers/attend/admin/attendances_controller.rb +57 -0
  11. data/app/controllers/attend/admin/base_controller.rb +4 -0
  12. data/app/controllers/attend/admin/extra_days_controller.rb +63 -0
  13. data/app/controllers/attend/admin/financial_months_controller.rb +69 -0
  14. data/app/controllers/attend/admin/overtimes_controller.rb +59 -0
  15. data/app/controllers/attend/me/absences_controller.rb +71 -0
  16. data/app/controllers/attend/me/attendance_logs_controller.rb +74 -0
  17. data/app/controllers/attend/me/attendance_settings_controller.rb +52 -0
  18. data/app/controllers/attend/me/attendance_stats_controller.rb +27 -0
  19. data/app/controllers/attend/me/attendances_controller.rb +43 -0
  20. data/app/controllers/attend/me/base_controller.rb +4 -0
  21. data/app/controllers/attend/me/calendars_controller.rb +33 -0
  22. data/app/controllers/attend/me/overtimes_controller.rb +65 -0
  23. data/app/javascript/packs/controllers/attend/admin/attendance_logs/index.js +1 -0
  24. data/app/javascript/packs/controllers/attend/admin/attendance_logs/my.js +14 -0
  25. data/app/javascript/packs/controllers/attend/admin/attendance_settings/create.js +1 -0
  26. data/app/javascript/packs/controllers/attend/admin/attendance_settings/index.js +1 -0
  27. data/app/javascript/packs/controllers/attend/admin/attendance_settings/my.js +13 -0
  28. data/app/javascript/packs/controllers/attend/admin/attendance_settings/new.js +11 -0
  29. data/app/javascript/packs/controllers/attend/me/absences/new.js +16 -0
  30. data/app/javascript/packs/controllers/attend/me/absences/update.js +3 -0
  31. data/app/javascript/packs/controllers/attend/me/attendance_settings/create.js +1 -0
  32. data/app/javascript/packs/controllers/attend/me/attendance_settings/edit.js +1 -0
  33. data/app/javascript/packs/controllers/attend/me/attendance_settings/new.js +2 -0
  34. data/app/javascript/packs/controllers/attend/me/calendars/show.js +48 -0
  35. data/app/jobs/attendance_job.rb +14 -0
  36. data/app/models/absence/attend/annual_leave.rb +5 -0
  37. data/app/models/absence/attend/bereavement_leave.rb +5 -0
  38. data/app/models/absence/attend/business_trip.rb +5 -0
  39. data/app/models/absence/attend/children_day_leave.rb +5 -0
  40. data/app/models/absence/attend/compensatory_leave.rb +5 -0
  41. data/app/models/absence/attend/marriage_leave.rb +4 -0
  42. data/app/models/absence/attend/maternity_leave.rb +5 -0
  43. data/app/models/absence/attend/parental_leave.rb +5 -0
  44. data/app/models/absence/attend/personal_leave.rb +5 -0
  45. data/app/models/absence/attend/prenatal_leave.rb +4 -0
  46. data/app/models/absence/attend/sick_leave.rb +5 -0
  47. data/app/models/absence/attend/vacation_leave.rb +5 -0
  48. data/app/models/absence/attend/welfare_leave.rb +5 -0
  49. data/app/models/attend/absence.rb +5 -0
  50. data/app/models/attend/absence_stat.rb +5 -0
  51. data/app/models/attend/application_record.rb +5 -0
  52. data/app/models/attend/attendance.rb +5 -0
  53. data/app/models/attend/attendance_log.rb +5 -0
  54. data/app/models/attend/attendance_setting.rb +5 -0
  55. data/app/models/attend/attendance_stat.rb +5 -0
  56. data/app/models/attend/ext/member.rb +33 -0
  57. data/app/models/attend/extra_day.rb +5 -0
  58. data/app/models/attend/financial_month.rb +5 -0
  59. data/app/models/attend/model/absence/business_trip.rb +10 -0
  60. data/app/models/attend/model/absence/compensatory_leave.rb +5 -0
  61. data/app/models/attend/model/absence/personal_leave.rb +5 -0
  62. data/app/models/attend/model/absence/welfare_leave/annual_leave.rb +16 -0
  63. data/app/models/attend/model/absence/welfare_leave/vacation_leave.rb +16 -0
  64. data/app/models/attend/model/absence/welfare_leave.rb +5 -0
  65. data/app/models/attend/model/absence.rb +208 -0
  66. data/app/models/attend/model/absence_stat.rb +17 -0
  67. data/app/models/attend/model/attendance.rb +314 -0
  68. data/app/models/attend/model/attendance_log.rb +165 -0
  69. data/app/models/attend/model/attendance_setting.rb +61 -0
  70. data/app/models/attend/model/attendance_stat.rb +104 -0
  71. data/app/models/attend/model/extra_day.rb +21 -0
  72. data/app/models/attend/model/financial_month.rb +114 -0
  73. data/app/models/attend/model/overtime.rb +93 -0
  74. data/app/models/attend/overtime.rb +5 -0
  75. data/app/models/attend.rb +11 -0
  76. data/app/models/concerns/absent.rb +103 -0
  77. data/app/views/admin/_attend_nav.html.erb +15 -0
  78. data/app/views/attend/admin/absence_stats/_filter_form.html.erb +9 -0
  79. data/app/views/attend/admin/absence_stats/_form.html.erb +12 -0
  80. data/app/views/attend/admin/absence_stats/_index_tbody.html.erb +3 -0
  81. data/app/views/attend/admin/absence_stats/_index_thead.html.erb +4 -0
  82. data/app/views/attend/admin/absence_stats/index.html.erb +5 -0
  83. data/app/views/attend/admin/absences/_absence.html.erb +38 -0
  84. data/app/views/attend/admin/absences/_edit_form.html.erb +3 -0
  85. data/app/views/attend/admin/absences/_filter_form.html.erb +8 -0
  86. data/app/views/attend/admin/absences/_form.html.erb +5 -0
  87. data/app/views/attend/admin/absences/_index_tbody.html.erb +18 -0
  88. data/app/views/attend/admin/absences/_index_thead.html.erb +10 -0
  89. data/app/views/attend/admin/absences/_new_form.html.erb +3 -0
  90. data/app/views/attend/admin/absences/_show.html.erb +11 -0
  91. data/app/views/attend/admin/absences/index.html.erb +5 -0
  92. data/app/views/attend/admin/absences/my.html.erb +5 -0
  93. data/app/views/attend/admin/attendance_logs/_edit_form.html.erb +5 -0
  94. data/app/views/attend/admin/attendance_logs/_filter_form.html.erb +11 -0
  95. data/app/views/attend/admin/attendance_logs/_form.html.erb +6 -0
  96. data/app/views/attend/admin/attendance_logs/_index_thead.html.erb +19 -0
  97. data/app/views/attend/admin/attendance_logs/_list.html.erb +61 -0
  98. data/app/views/attend/admin/attendance_logs/_new_form.html.erb +3 -0
  99. data/app/views/attend/admin/attendance_logs/index.html.erb +5 -0
  100. data/app/views/attend/admin/attendance_logs/my.html.erb +5 -0
  101. data/app/views/attend/admin/attendance_settings/_button.html.erb +4 -0
  102. data/app/views/attend/admin/attendance_settings/_filter_form.html.erb +11 -0
  103. data/app/views/attend/admin/attendance_settings/_form.html.erb +7 -0
  104. data/app/views/attend/admin/attendance_settings/_index_tbody.html.erb +15 -0
  105. data/app/views/attend/admin/attendance_settings/_index_thead.html.erb +10 -0
  106. data/app/views/attend/admin/attendance_settings/_new_form.html.erb +8 -0
  107. data/app/views/attend/admin/attendance_settings/_show_table.html.erb +12 -0
  108. data/app/views/attend/admin/attendance_settings/index.html.erb +5 -0
  109. data/app/views/attend/admin/attendance_settings/my.html.erb +5 -0
  110. data/app/views/attend/admin/attendance_stats/_filter_form.html.erb +10 -0
  111. data/app/views/attend/admin/attendance_stats/_form.html.erb +6 -0
  112. data/app/views/attend/admin/attendance_stats/_index_thead.html.erb +10 -0
  113. data/app/views/attend/admin/attendance_stats/index.html.erb +44 -0
  114. data/app/views/attend/admin/attendances/_button.html.erb +2 -0
  115. data/app/views/attend/admin/attendances/_filter_form.html.erb +10 -0
  116. data/app/views/attend/admin/attendances/_form.html.erb +23 -0
  117. data/app/views/attend/admin/attendances/_index_tbody.html.erb +61 -0
  118. data/app/views/attend/admin/attendances/_index_thead.html.erb +22 -0
  119. data/app/views/attend/admin/attendances/_new_form.html.erb +4 -0
  120. data/app/views/attend/admin/attendances/index.html.erb +7 -0
  121. data/app/views/attend/admin/base/_financial_month_menu.html.erb +10 -0
  122. data/app/views/attend/admin/base/_nav.html.erb +3 -0
  123. data/app/views/attend/admin/base/_nav_attendances.html.erb +7 -0
  124. data/app/views/attend/admin/extra_days/_breadcrumb.html.erb +0 -0
  125. data/app/views/attend/admin/extra_days/_edit_form.html.erb +4 -0
  126. data/app/views/attend/admin/extra_days/_filter_form.html.erb +5 -0
  127. data/app/views/attend/admin/extra_days/_form.html.erb +4 -0
  128. data/app/views/attend/admin/extra_days/_index_tbody.html.erb +3 -0
  129. data/app/views/attend/admin/extra_days/_index_thead.html.erb +4 -0
  130. data/app/views/attend/admin/extra_days/_new_form.html.erb +4 -0
  131. data/app/views/attend/admin/extra_days/index.html.erb +7 -0
  132. data/app/views/attend/admin/financial_months/_breadcrumb.html.erb +0 -0
  133. data/app/views/attend/admin/financial_months/_edit_form.html.erb +4 -0
  134. data/app/views/attend/admin/financial_months/_filter_form.html.erb +9 -0
  135. data/app/views/attend/admin/financial_months/_form.html.erb +4 -0
  136. data/app/views/attend/admin/financial_months/_index_tbody.html.erb +9 -0
  137. data/app/views/attend/admin/financial_months/_index_thead.html.erb +6 -0
  138. data/app/views/attend/admin/financial_months/_new_form.html.erb +4 -0
  139. data/app/views/attend/admin/financial_months/events.json.jbuilder +9 -0
  140. data/app/views/attend/admin/financial_months/index.html.erb +7 -0
  141. data/app/views/attend/admin/financial_months/index.js +60 -0
  142. data/app/views/attend/admin/financial_months/show.html.erb +10 -0
  143. data/app/views/attend/admin/overtimes/_button.html.erb +0 -0
  144. data/app/views/attend/admin/overtimes/_edit_form.html.erb +4 -0
  145. data/app/views/attend/admin/overtimes/_filter_form.html.erb +8 -0
  146. data/app/views/attend/admin/overtimes/_form.html.erb +3 -0
  147. data/app/views/attend/admin/overtimes/_index_tbody.html.erb +22 -0
  148. data/app/views/attend/admin/overtimes/_index_thead.html.erb +9 -0
  149. data/app/views/attend/admin/overtimes/_new_form.html.erb +4 -0
  150. data/app/views/attend/admin/overtimes/index.html.erb +5 -0
  151. data/app/views/attend/admin/overtimes/my.html.erb +8 -0
  152. data/app/views/attend/me/absences/_absence.html.erb +34 -0
  153. data/app/views/attend/me/absences/_edit_form.html.erb +3 -0
  154. data/app/views/attend/me/absences/_filter_form.html.erb +11 -0
  155. data/app/views/attend/me/absences/_form.html.erb +33 -0
  156. data/app/views/attend/me/absences/_index_tbody.html.erb +24 -0
  157. data/app/views/attend/me/absences/_index_thead.html.erb +8 -0
  158. data/app/views/attend/me/absences/_new_form.html.erb +3 -0
  159. data/app/views/attend/me/absences/_redeeming_form.html.erb +5 -0
  160. data/app/views/attend/me/absences/_show.html.erb +11 -0
  161. data/app/views/attend/me/absences/dashboard.html.erb +44 -0
  162. data/app/views/attend/me/absences/index.html.erb +7 -0
  163. data/app/views/attend/me/absences/redeeming.js.erb +6 -0
  164. data/app/views/attend/me/absences/show.html.erb +1 -0
  165. data/app/views/attend/me/attendance_logs/_edit_form.html.erb +4 -0
  166. data/app/views/attend/me/attendance_logs/_filter_form.html.erb +11 -0
  167. data/app/views/attend/me/attendance_logs/_form.html.erb +11 -0
  168. data/app/views/attend/me/attendance_logs/_index_thead.html.erb +9 -0
  169. data/app/views/attend/me/attendance_logs/_new_form.html.erb +4 -0
  170. data/app/views/attend/me/attendance_logs/index.html.erb +42 -0
  171. data/app/views/attend/me/attendance_settings/_edit_form.html.erb +6 -0
  172. data/app/views/attend/me/attendance_settings/_index_tbody.html.erb +15 -0
  173. data/app/views/attend/me/attendance_settings/_index_thead.html.erb +12 -0
  174. data/app/views/attend/me/attendance_settings/_new_form.html.erb +8 -0
  175. data/app/views/attend/me/attendance_settings/index.html.erb +5 -0
  176. data/app/views/attend/me/attendance_stats/_form.html.erb +6 -0
  177. data/app/views/attend/me/attendance_stats/_search_form.html.erb +5 -0
  178. data/app/views/attend/me/attendance_stats/edit.html.erb +9 -0
  179. data/app/views/attend/me/attendance_stats/index.html.erb +49 -0
  180. data/app/views/attend/me/attendance_stats/new.html.erb +9 -0
  181. data/app/views/attend/me/attendance_stats/show.html.erb +28 -0
  182. data/app/views/attend/me/attendances/_button.html.erb +3 -0
  183. data/app/views/attend/me/attendances/_filter_form.html.erb +9 -0
  184. data/app/views/attend/me/attendances/_form.html.erb +22 -0
  185. data/app/views/attend/me/attendances/_index_tbody.html.erb +49 -0
  186. data/app/views/attend/me/attendances/_index_thead.html.erb +19 -0
  187. data/app/views/attend/me/attendances/index.html.erb +7 -0
  188. data/app/views/attend/me/base/_menu.html.erb +8 -0
  189. data/app/views/attend/me/base/_nav_absences.html.erb +9 -0
  190. data/app/views/attend/me/base/_nav_attendances.html.erb +10 -0
  191. data/app/views/attend/me/calendars/events.json.jbuilder +19 -0
  192. data/app/views/attend/me/calendars/show.html.erb +12 -0
  193. data/app/views/attend/me/overtimes/_edit_form.html.erb +4 -0
  194. data/app/views/attend/me/overtimes/_filter_form.html.erb +9 -0
  195. data/app/views/attend/me/overtimes/_form.html.erb +16 -0
  196. data/app/views/attend/me/overtimes/_index_tbody.html.erb +23 -0
  197. data/app/views/attend/me/overtimes/_index_thead.html.erb +6 -0
  198. data/app/views/attend/me/overtimes/_new_form.html.erb +4 -0
  199. data/app/views/attend/me/overtimes/index.html.erb +7 -0
  200. data/app/views/me/_attend_nav.html.erb +12 -0
  201. data/app/views/me/_nav_attendance_settings.html.erb +8 -0
  202. data/config/locales/en.attributes.yml +34 -0
  203. data/config/locales/en.controller.yml +18 -0
  204. data/config/locales/en.enum.yml +43 -0
  205. data/config/locales/en.notify.yml +38 -0
  206. data/config/locales/zh.attributes.yml +34 -0
  207. data/config/locales/zh.controller.yml +40 -0
  208. data/config/locales/zh.enum.yml +43 -0
  209. data/config/locales/zh.notify.yml +38 -0
  210. data/config/routes.rb +70 -0
  211. data/lib/rails_attend/config.rb +11 -0
  212. data/lib/rails_attend/engine.rb +25 -0
  213. data/lib/rails_attend.rb +2 -0
  214. metadata +269 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6a35f587114cfe832757c93bfc3e1e365aa6aea2e6f43d0a832640abf130e414
4
+ data.tar.gz: dfbec0e4f014f36ebc3a013b6255adc28f40ff5a950d27cf94a87d872c4b803e
5
+ SHA512:
6
+ metadata.gz: 60cde8c045811789596533b653064bd619091aa17df8d10b1786b86fdd433784b767a35f74cab858ebaaabc403bf83ce6b2c31c7c5abf57f36ca34bbd449faa7
7
+ data.tar.gz: 2ca3becbc36db395f045d1c875f98b1b8477b47dacc4ee574e5acf7de27583428f51801c43c36e4135701498deb2f48e6d75684c504690c944671cc9459d6848
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2019-Present Mingyuan Qin <mingyuan0715@foxmail.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # RailsAttend
2
+
3
+ [![测试](https://github.com/work-design/rails_dingtalk/actions/workflows/test.yml/badge.svg)](https://github.com/work-design/rails_dingtalk/actions/workflows/test.yml)
4
+ [![Docker构建](https://github.com/work-design/rails_dingtalk/actions/workflows/cd.yml/badge.svg)](https://github.com/work-design/rails_dingtalk/actions/workflows/cd.yml)
5
+ [![Gem](https://github.com/work-design/rails_dingtalk/actions/workflows/gempush.yml/badge.svg)](https://github.com/work-design/rails_dingtalk/actions/workflows/gempush.yml)
6
+
7
+ 人员出勤,签到管理
8
+
9
+ ## Usage
10
+ How to use my plugin.
11
+
12
+ ## Installation
13
+ ```
14
+ yarn add @fullcalendar/core
15
+ yarn add @fullcalendar/daygrid
16
+ ```
17
+
18
+ ## Contributing
19
+ Contribution directions go here.
20
+
21
+ ## 许可证
22
+ 遵循 [MIT](https://opensource.org/licenses/MIT) 协议
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'RailsAttend'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ load 'rails/tasks/statistics.rake'
21
+
22
+ require 'bundler/gem_tasks'
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'test'
28
+ t.pattern = 'test/**/*_test.rb'
29
+ t.verbose = false
30
+ end
31
+
32
+ task default: :test
@@ -0,0 +1,60 @@
1
+ module Attend
2
+ class Admin::AbsenceStatsController < Admin::BaseController
3
+ before_action :set_absence_stat, only: [:show, :edit, :update, :destroy]
4
+
5
+ def index
6
+ q_params = {}
7
+ q_params.merge! params.permit()
8
+
9
+ @absence_stats = AbsenceStat.default_where(q_params).page(params[:page])
10
+ end
11
+
12
+ def new
13
+ @absence_stat = AbsenceStat.new
14
+ end
15
+
16
+ def create
17
+ @absence_stat = AbsenceStat.new(absence_stat_params)
18
+
19
+ if @absence_stat.save
20
+ redirect_to admin_absence_stats_url
21
+ else
22
+ render :new
23
+ end
24
+ end
25
+
26
+ def show
27
+ end
28
+
29
+ def edit
30
+ end
31
+
32
+ def update
33
+ if @absence_stat.update(absence_stat_params)
34
+ redirect_to admin_absence_stats_url
35
+ else
36
+ render :edit
37
+ end
38
+ end
39
+
40
+ def destroy
41
+ @absence_stat.destroy
42
+ redirect_to admin_absence_stats_url
43
+ end
44
+
45
+ private
46
+ def set_absence_stat
47
+ @absence_stat = AbsenceStat.find(params[:id])
48
+ end
49
+
50
+ def absence_stat_params
51
+ params.fetch(:absence_stat, {}).permit(
52
+ :member_id,
53
+ :annual_days,
54
+ :annual_add,
55
+ :year
56
+ )
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,77 @@
1
+ module Attend
2
+ class Admin::AbsencesController < Admin::BaseController
3
+ before_action :set_absence, only: [:show, :trigger, :edit, :update, :destroy]
4
+
5
+ def index
6
+ q_params = params.fetch(:q, {}).permit('member.name')
7
+ q_params.merge! params.permit(:member_id, :id)
8
+
9
+ @absences = Absence.default_where(q_params).order(id: :desc).page(params[:page])
10
+ end
11
+
12
+ def my
13
+ q_params = {
14
+ member_id: current_member.child_ids
15
+ }.with_indifferent_access
16
+ q_params.merge! params.fetch(:q, {}).permit('member.name')
17
+ q_params.merge! params.permit(:member_id, :id)
18
+
19
+ @absences = Absence.default_where(q_params).order(id: :desc).page(params[:page])
20
+
21
+ render :my, layout: 'my'
22
+ end
23
+
24
+ def new
25
+ @absence = Absence.new
26
+ end
27
+
28
+ def create
29
+ @absence = Absence.new(absence_params)
30
+
31
+ if @absence.save
32
+ redirect_to admin_absences_url
33
+ else
34
+ render :new
35
+ end
36
+ end
37
+
38
+ def show
39
+ end
40
+
41
+ def trigger
42
+ @absence.do_trigger(state: params[:state], auditor_id: current_member.id)
43
+ redirect_to admin_absences_url(member_id: @absence.member_id)
44
+ end
45
+
46
+ def edit
47
+ end
48
+
49
+ def update
50
+ if @absence.update(absence_params)
51
+ redirect_to admin_absences_url
52
+ else
53
+ render :edit
54
+ end
55
+ end
56
+
57
+ def destroy
58
+ @absence.destroy
59
+ redirect_to admin_absences_url
60
+ end
61
+
62
+ private
63
+ def set_absence
64
+ @absence = Absence.find(params[:id])
65
+ end
66
+
67
+ def absence_params
68
+ params.fetch(:absence, {}).permit(
69
+ :state,
70
+ :start_at,
71
+ :finish_at,
72
+ :note
73
+ )
74
+ end
75
+
76
+ end
77
+ end
@@ -0,0 +1,103 @@
1
+ module Attend
2
+ class Admin::AttendanceLogsController < Admin::BaseController
3
+ before_action :set_attendance_log, only: [:show, :edit, :update, :analyze, :destroy]
4
+
5
+ def index
6
+ q_params = {}.with_indifferent_access
7
+ q_params.merge! params.permit(:attendance_id, :id)
8
+ q_params.merge! params.fetch(:q, {}).permit!
9
+ @attendance_logs = AttendanceLog.default_where(q_params).order(record_at: :desc).page(params[:page])
10
+ end
11
+
12
+ def my
13
+ q_params = {
14
+ member_id: current_member.child_ids
15
+ }.with_indifferent_access
16
+ q_params.merge! params.fetch(:q, {}).permit('member.name')
17
+ q_params.merge! params.permit(:member_id, :id)
18
+
19
+ @attendance_logs = AttendanceLog.pending.default_where(q_params).order(id: :desc).page(params[:page])
20
+
21
+ render :my, layout: 'my'
22
+ end
23
+
24
+ def check
25
+ add_ids = params[:add_ids].split(',')
26
+ if add_ids.present?
27
+ als = AttendanceLog.where(id: add_ids)
28
+ als.each do |al|
29
+ al.do_trigger(state: 'valid')
30
+ end
31
+ end
32
+
33
+ redirect_to my_admin_attendance_logs_url
34
+ end
35
+
36
+ def new
37
+ if params[:attendance_id]
38
+ @attendance = Attendance.find params[:attendance_id]
39
+ attrs = { record_at: @attendance.attend_on, member_id: @attendance.member_id, attendance_id: @attendance.id }
40
+ else
41
+ attrs = {}
42
+ end
43
+
44
+ @attendance_log = AttendanceLog.new attrs
45
+ end
46
+
47
+ def create
48
+ @attendance_log = AttendanceLog.new(attendance_log_params)
49
+
50
+ respond_to do |format|
51
+ if @attendance_log.save
52
+ format.html { redirect_to admin_attendance_logs_url(attendance_id: @attendance_log.attendance_id) }
53
+ format.js do
54
+ @attendance_log.compute
55
+ end
56
+ else
57
+ format.html { render :new }
58
+ format.js
59
+ end
60
+ end
61
+ end
62
+
63
+ def show
64
+ end
65
+
66
+ def edit
67
+ end
68
+
69
+ def update
70
+ if @attendance_log.update(attendance_log_params)
71
+ redirect_to admin_attendance_logs_url(attendance_id: @attendance_log.attendance_id)
72
+ else
73
+ render :edit
74
+ end
75
+ end
76
+
77
+ def analyze
78
+ @attendance_log.analyze
79
+ redirect_to admin_attendance_logs_url(attendance_id: @attendance_log.attendance_id)
80
+ end
81
+
82
+ def destroy
83
+ @attendance_log.destroy
84
+ redirect_to admin_attendance_logs_url(attendance_id: @attendance_log.attendance_id)
85
+ end
86
+
87
+ private
88
+ def set_attendance_log
89
+ @attendance_log = AttendanceLog.find(params[:id])
90
+ end
91
+
92
+ def attendance_log_params
93
+ q = params.fetch(:attendance_log, {}).permit(
94
+ :record_at,
95
+ :note,
96
+ :member_id,
97
+ :attendance_id
98
+ )
99
+ q.merge! source: 'admin'
100
+ end
101
+
102
+ end
103
+ end
@@ -0,0 +1,86 @@
1
+ module Attend
2
+ class Admin::AttendanceSettingsController < Admin::BaseController
3
+ before_action :set_attendance_setting, only: [:show, :edit, :update, :destroy]
4
+
5
+ def index
6
+ q_params = {}.with_indifferent_access
7
+ q_params.merge! params.fetch(:q, {}).permit('member.name', 'member.email')
8
+ q_params.merge! params.permit(:member_id, :id)
9
+
10
+ @attendance_settings = AttendanceSetting.includes(:member, :financial_month).default_where(q_params).order(id: :desc).page(params[:page])
11
+ end
12
+
13
+ def my
14
+ q_params = {
15
+ member_id: current_member.child_ids
16
+ }.with_indifferent_access
17
+ q_params.merge! params.fetch(:q, {}).permit('member.name', 'member.email')
18
+ q_params.merge! params.permit(:member_id, :id)
19
+
20
+ @attendance_settings = AttendanceSetting.includes(:member, :financial_month).default_where(q_params).order(id: :desc).page(params[:page])
21
+
22
+ render :my, layout: 'my'
23
+ end
24
+
25
+ def check
26
+ add_ids = params[:add_ids].split(',')
27
+ if add_ids.present?
28
+ als = AttendanceSetting.where(id: add_ids)
29
+ als.each do |al|
30
+ al.do_trigger(state: 'approved')
31
+ end
32
+ end
33
+
34
+ redirect_back fallback_location: my_admin_attendance_settings_url
35
+ end
36
+
37
+ def new
38
+ @attendance_setting = AttendanceSetting.new
39
+ end
40
+
41
+ def create
42
+ @attendance_setting = AttendanceSetting.new(attendance_setting_params)
43
+
44
+ if @attendance_setting.save
45
+ redirect_to admin_attendance_settings_url(member_id: @attendance_setting.member_id)
46
+ else
47
+ render :new
48
+ end
49
+ end
50
+
51
+ def show
52
+ end
53
+
54
+ def edit
55
+ end
56
+
57
+ def update
58
+ if @attendance_setting.update(attendance_setting_params)
59
+ redirect_to admin_attendance_settings_url
60
+ else
61
+ render :edit
62
+ end
63
+ end
64
+
65
+ def destroy
66
+ @attendance_setting.destroy
67
+ redirect_to admin_attendance_settings_url
68
+ end
69
+
70
+ private
71
+ def set_attendance_setting
72
+ @attendance_setting = AttendanceSetting.find(params[:id])
73
+ end
74
+
75
+ def attendance_setting_params
76
+ params.fetch(:attendance_setting, {}).permit(
77
+ :member_id,
78
+ :financial_month_id,
79
+ :on_time,
80
+ :state,
81
+ :note
82
+ )
83
+ end
84
+
85
+ end
86
+ end
@@ -0,0 +1,58 @@
1
+ module Attend
2
+ class Admin::AttendanceStatsController < Admin::BaseController
3
+ before_action :set_attendance_stat, only: [:show, :edit, :update, :destroy]
4
+
5
+ def index
6
+ q_params = {}
7
+ q_params.merge! params.permit!
8
+
9
+ @attendance_stats = AttendanceStat.includes(:member).default_where(q_params).page(params[:page])
10
+ end
11
+
12
+ def new
13
+ @attendance_stat = AttendanceStat.new
14
+ end
15
+
16
+ def create
17
+ @attendance_stat = AttendanceStat.new(attendance_stat_params)
18
+
19
+ if @attendance_stat.save
20
+ redirect_to admin_attendance_stats_url
21
+ else
22
+ render :new
23
+ end
24
+ end
25
+
26
+ def show
27
+ end
28
+
29
+ def edit
30
+ end
31
+
32
+ def update
33
+ if @attendance_stat.update(attendance_stat_params)
34
+ redirect_to admin_attendance_stats_url
35
+ else
36
+ render :edit
37
+ end
38
+ end
39
+
40
+ def destroy
41
+ @attendance_stat.destroy
42
+ redirect_to admin_attendance_stats_url
43
+ end
44
+
45
+ private
46
+ def set_attendance_stat
47
+ @attendance_stat = AttendanceStat.find(params[:id])
48
+ end
49
+
50
+ def attendance_stat_params
51
+ params.fetch(:attendance_stat, {}).permit(
52
+ :member_id,
53
+ :financial_month_id
54
+ )
55
+ end
56
+
57
+ end
58
+ end