gestion 1.9.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +48 -0
  3. data/.project +14 -0
  4. data/Binaries/adduser_to_buzz +15 -0
  5. data/Binaries/backup +7 -0
  6. data/Binaries/check_gestion +8 -0
  7. data/Binaries/gestion.gnumail +22 -0
  8. data/Binaries/gestion.logrotate +34 -0
  9. data/Binaries/gestion.service +12 -0
  10. data/Binaries/gestion_update.rb +183 -0
  11. data/Binaries/gestion_update.service +10 -0
  12. data/Binaries/get_compta +11 -0
  13. data/Binaries/kill_gestion +16 -0
  14. data/Binaries/ldap/add_indexes +51 -0
  15. data/Binaries/ldap/backup +2 -0
  16. data/Binaries/ldap/install_ldap +92 -0
  17. data/Binaries/ldap/restore +7 -0
  18. data/Binaries/lib_backup +5 -0
  19. data/Binaries/log_scan_errors +8 -0
  20. data/Binaries/loop_gestion +64 -0
  21. data/Binaries/onetimers/sync_courses_from_compta.rb +74 -0
  22. data/Binaries/onetimers/transfer_cash_from_ldap_to_csv +26 -0
  23. data/Binaries/reboot +5 -0
  24. data/Binaries/restore +3 -0
  25. data/Binaries/restore_do +22 -0
  26. data/Binaries/sort_events +31 -0
  27. data/Binaries/start_gestion +18 -0
  28. data/Binaries/swipe_gestion +18 -0
  29. data/Binaries/update_africompta +21 -0
  30. data/Binaries/update_users +3 -0
  31. data/Diplomas.src/accredited.odg +0 -0
  32. data/Diplomas.src/diploma.odg +0 -0
  33. data/Diplomas.src/label.odg +0 -0
  34. data/Diplomas.src/presence_sheet.ods +0 -0
  35. data/Diplomas.src/presence_sheet_small.ods +0 -0
  36. data/Diplomas.src/student_card.odg +0 -0
  37. data/Doc/130514-it-ideas.odt +0 -0
  38. data/Doc/Compta-cash.mm +179 -0
  39. data/Doc/General.odt +0 -0
  40. data/Entities/AccessGroups.rb +117 -0
  41. data/Entities/Activity.rb +178 -0
  42. data/Entities/ChatMsg.rb +142 -0
  43. data/Entities/Classroom.rb +11 -0
  44. data/Entities/Client.rb +19 -0
  45. data/Entities/Computer.rb +21 -0
  46. data/Entities/ConfigBase.rb +280 -0
  47. data/Entities/Course.rb +1588 -0
  48. data/Entities/CourseType.rb +171 -0
  49. data/Entities/DFiles.rb +466 -0
  50. data/Entities/FilesManage.rb +226 -0
  51. data/Entities/Grade.rb +186 -0
  52. data/Entities/Internet.rb +300 -0
  53. data/Entities/Netdev.rb +10 -0
  54. data/Entities/Person.rb +1175 -0
  55. data/Entities/Plug.rb +98 -0
  56. data/Entities/Quiz.rb +33 -0
  57. data/Entities/Recharges.rb +37 -0
  58. data/Entities/Report.rb +136 -0
  59. data/Entities/Room.rb +12 -0
  60. data/Entities/SMS.rb +30 -0
  61. data/Entities/ScheduleType.rb +33 -0
  62. data/Entities/Share.rb +120 -0
  63. data/Entities/Task.rb +51 -0
  64. data/Entities/Ticket.rb +72 -0
  65. data/Entities/Usage.rb +143 -0
  66. data/Entities/Worker.rb +29 -0
  67. data/Files/apache-profeda.conf +36 -0
  68. data/Files/label.erb +121 -0
  69. data/Files/label_notfound.erb +64 -0
  70. data/Files/label_notpassed.erb +84 -0
  71. data/Files/mobileinfo.erb +115 -0
  72. data/Files/smb.conf +333 -0
  73. data/Files/timetable.html +36 -0
  74. data/Files/timetable.js +239 -0
  75. data/Gemfile +12 -0
  76. data/Gemfile.dev +12 -0
  77. data/Gemfile.dev.lock +127 -0
  78. data/Gemfile.lock +127 -0
  79. data/Gemfile.prod +8 -0
  80. data/Gestion +35 -0
  81. data/Gestion.rb +220 -0
  82. data/INSTALL +40 -0
  83. data/Images/connection.xcf +0 -0
  84. data/Images/connection_no.png +0 -0
  85. data/Images/connection_wait.png +0 -0
  86. data/Images/connection_yes.png +0 -0
  87. data/Paths/Exas.rb +13 -0
  88. data/Paths/Files.rb +19 -0
  89. data/Paths/GetDiplomas.rb +20 -0
  90. data/Paths/Info.rb +114 -0
  91. data/Paths/Label.rb +187 -0
  92. data/Paths/MobileInfo.rb +19 -0
  93. data/Paths/internetCash.rb +34 -0
  94. data/Paths/internetWifi.rb +54 -0
  95. data/README.md +60 -0
  96. data/Rakefile +13 -0
  97. data/TODO +1391 -0
  98. data/Test/.gitignore +3 -0
  99. data/Test/Diplomas/base_gestion.odt +0 -0
  100. data/Test/Diplomas/base_report.odt +0 -0
  101. data/Test/Diplomas/carte_etudiant.odg +0 -0
  102. data/Test/Diplomas/exam_language.odt +0 -0
  103. data/Test/Diplomas/label.odg +0 -0
  104. data/Test/Diplomas/presence_sheet.ods +0 -0
  105. data/Test/Diplomas/presence_sheet_small.ods +0 -0
  106. data/Test/Diplomas/student_card.odg +0 -0
  107. data/Test/Manual/testMerge +18 -0
  108. data/Test/config_test.yaml +26 -0
  109. data/Test/db.testGestion +0 -0
  110. data/Test/dfiles/descs/avg-rescue.desc +10 -0
  111. data/Test/dfiles/descs/avg.desc +8 -0
  112. data/Test/dfiles/descs/driver.desc +8 -0
  113. data/Test/dfiles/descs/linuxmint.desc +7 -0
  114. data/Test/dfiles/files/avg-160203.exe +1 -0
  115. data/Test/dfiles/files/avg.iso +1 -0
  116. data/Test/dfiles/files/driver.exe +1 -0
  117. data/Test/dfiles/index_post.html +3 -0
  118. data/Test/dfiles/index_pre.html +8 -0
  119. data/Test/dfiles/priorities +5 -0
  120. data/Test/ge_activity.rb +124 -0
  121. data/Test/ge_chat.rb +106 -0
  122. data/Test/ge_compta.rb +67 -0
  123. data/Test/ge_configbase.rb +54 -0
  124. data/Test/ge_course.rb +1114 -0
  125. data/Test/ge_dfiles.rb +121 -0
  126. data/Test/ge_filesmanage.rb +180 -0
  127. data/Test/ge_info.rb +27 -0
  128. data/Test/ge_internet.rb +246 -0
  129. data/Test/ge_login.rb +55 -0
  130. data/Test/ge_person.rb +373 -0
  131. data/Test/ge_qvinfo.rb +28 -0
  132. data/Test/ge_report.rb +97 -0
  133. data/Test/ge_share.rb +27 -0
  134. data/Test/ge_sms.rb +34 -0
  135. data/Test/ge_tasks.rb +19 -0
  136. data/Test/ge_usage.rb +168 -0
  137. data/Test/ge_view.rb +46 -0
  138. data/Test/multiconf-captive +29 -0
  139. data/Test/test.conf +7 -0
  140. data/Test/test.rb +49 -0
  141. data/Test/test_bytes.png +0 -0
  142. data/VERSION +140 -0
  143. data/Views/Admin/Backup.rb +91 -0
  144. data/Views/Admin/Configuration.rb +44 -0
  145. data/Views/Admin/Credit.rb +32 -0
  146. data/Views/Admin/FilesManage.rb +219 -0
  147. data/Views/Admin/Function.rb +39 -0
  148. data/Views/Admin/Power.rb +49 -0
  149. data/Views/Admin/Printer.rb +37 -0
  150. data/Views/Admin/Server.rb +252 -0
  151. data/Views/Admin/Tabs.rb +5 -0
  152. data/Views/Admin/Update.rb +73 -0
  153. data/Views/Admin/UpdateSystem.rb +26 -0
  154. data/Views/Cashbox/Activity.rb +191 -0
  155. data/Views/Cashbox/Course.rb +141 -0
  156. data/Views/Cashbox/Credit.rb +79 -0
  157. data/Views/Cashbox/Report.rb +115 -0
  158. data/Views/Cashbox/Service.rb +105 -0
  159. data/Views/Cashbox/Tabs.rb +10 -0
  160. data/Views/Compta/Accounts.rb +36 -0
  161. data/Views/Compta/Course.rb +96 -0
  162. data/Views/Compta/Show.rb +6 -0
  163. data/Views/Compta/Transfer.rb +66 -0
  164. data/Views/Course/Diploma.rb +203 -0
  165. data/Views/Course/Grade.rb +401 -0
  166. data/Views/Course/Modify.rb +447 -0
  167. data/Views/Course/Print.rb +94 -0
  168. data/Views/Course/Responsible.rb +44 -0
  169. data/Views/Course/Stats.rb +76 -0
  170. data/Views/Course/Students.rb +92 -0
  171. data/Views/Course/Tabs.rb +220 -0
  172. data/Views/Internet/Access.rb +134 -0
  173. data/Views/Internet/ClassEdit.rb +24 -0
  174. data/Views/Internet/ClassUsers.rb +81 -0
  175. data/Views/Internet/Config.rb +32 -0
  176. data/Views/Internet/Mobile.rb +213 -0
  177. data/Views/Internet/Recharges.rb +49 -0
  178. data/Views/Internet/Tabs.rb +6 -0
  179. data/Views/Inventory/Computer.rb +24 -0
  180. data/Views/Inventory/Room.rb +18 -0
  181. data/Views/Inventory/Tabs.rb +9 -0
  182. data/Views/Inventory/TicketClosed.rb +7 -0
  183. data/Views/Inventory/TicketOpen.rb +23 -0
  184. data/Views/Library/Person.rb +36 -0
  185. data/Views/Library/Tabs.rb +7 -0
  186. data/Views/Network/Block.rb +87 -0
  187. data/Views/Network/Netdevs.rb +21 -0
  188. data/Views/Network/Restriction.rb +37 -0
  189. data/Views/Network/Share.rb +167 -0
  190. data/Views/Network/Tables.rb +28 -0
  191. data/Views/Network/Tabs.rb +6 -0
  192. data/Views/Person/Admin.rb +99 -0
  193. data/Views/Person/Center.rb +48 -0
  194. data/Views/Person/Course.rb +72 -0
  195. data/Views/Person/Modify.rb +153 -0
  196. data/Views/Person/Tabs.rb +162 -0
  197. data/Views/Report/ComptaExecutive.rb +221 -0
  198. data/Views/Report/ComptaFlat.rb +79 -0
  199. data/Views/Report/ReportCourse.rb +47 -0
  200. data/Views/Report/Tabs.rb +8 -0
  201. data/Views/Report/Usage.rb +52 -0
  202. data/Views/Report/UsageCases.rb +59 -0
  203. data/Views/Self/Cash.rb +67 -0
  204. data/Views/Self/Chat.rb +55 -0
  205. data/Views/Self/Concours.rb +109 -0
  206. data/Views/Self/Email.rb +34 -0
  207. data/Views/Self/Internet.rb +255 -0
  208. data/Views/Self/Results.rb +17 -0
  209. data/Views/Self/Services.rb +85 -0
  210. data/Views/Self/Show.rb +47 -0
  211. data/Views/Self/Tabs.rb +5 -0
  212. data/Views/Special/DFileEdit.rb +13 -0
  213. data/Views/Special/PlugEdit.rb +56 -0
  214. data/Views/Special/Tabs.rb +6 -0
  215. data/Views/Special/Vnc.rb +39 -0
  216. data/Views/Task/Client.rb +21 -0
  217. data/Views/Task/Edit.rb +33 -0
  218. data/Views/Task/List.rb +55 -0
  219. data/Views/Task/Tabs.rb +9 -0
  220. data/Views/Task/Worker.rb +30 -0
  221. data/Views/Template/Activity.rb +33 -0
  222. data/Views/Template/CourseType.rb +63 -0
  223. data/Views/Template/ScheduleType.rb +29 -0
  224. data/Views/Template/Tabs.rb +5 -0
  225. data/Views/Welcome.rb +121 -0
  226. data/config.yaml.default +36 -0
  227. data/po/Gestion-ar.po +2356 -0
  228. data/po/Gestion-en.mo +0 -0
  229. data/po/Gestion-en.po +4363 -0
  230. data/po/Gestion-fr.mo +0 -0
  231. data/po/Gestion-fr.po +4345 -0
  232. data/po/traduction-ar.rtf +76 -0
  233. metadata +381 -0
@@ -0,0 +1,191 @@
1
+ class CashboxActivity < View
2
+ include PrintButton
3
+
4
+ def layout
5
+ @update = true
6
+ @order = 15
7
+
8
+ @functions_need = [:activities]
9
+
10
+ gui_hboxg do
11
+ gui_vboxg :nogroup do
12
+ show_entity_activity_all :activities, :single, :name, :flexheight => 1, :width => 200,
13
+ :callback => true
14
+ show_block_ro :show
15
+ end
16
+ gui_vboxg :nogroup do
17
+ gui_vboxg :nogroup do
18
+ show_entity_person :students, :single, :full_name,
19
+ :flexheight => 1, :callback => true, :width => 300
20
+ show_str :full_name
21
+ show_button :search_student, :new_student, :signed_up_students
22
+ # show_print :print_activity
23
+ end
24
+ end
25
+ gui_vboxg :nogroup do
26
+ gui_vbox :nogroup do
27
+ show_table :table_activities, :headings => %w( Start End )
28
+ show_date :date_start
29
+ end
30
+ show_button :pay_act, :delete
31
+ end
32
+
33
+ gui_window :printing do
34
+ show_html :msg_print
35
+ show_int_hidden :step
36
+ show_button :print_next, :close
37
+ end
38
+ end
39
+ end
40
+
41
+ def rpc_update(session)
42
+ # reply_print(session) +
43
+ reply(:update, :date_start => Date.today.to_web)
44
+ end
45
+
46
+ def rpc_button_pay_act(session, data)
47
+ return unless (data._activities and data._students)
48
+ # dp data._students
49
+ ActivityPayments.pay(data._activities, data._students, session.owner,
50
+ Date.from_web(data._date_start))
51
+ reply(:window_hide) +
52
+ rpc_list_choice_students(session, data)
53
+ end
54
+
55
+ def rpc_button_delete(session, data)
56
+ return unless (data._activities and data._students and
57
+ data._table_activities.length == 1)
58
+
59
+ act = ActivityPayments.match_by_activitypayment_id(data._table_activities.first)
60
+ if act.movement.account_src == act.person_cashed.account_due
61
+ act.movement.delete
62
+ act.delete
63
+ rpc_list_choice_students(session, data)
64
+ else
65
+ reply(:window_show, :printing)+
66
+ reply(:update, :msg_print => 'Ce mouvement est déjà comptabilisé')
67
+ end
68
+ end
69
+
70
+ def rpc_button_signed_up_students(session, data)
71
+ reply(:empty, :students) +
72
+ reply(:update, :students =>
73
+ ActivityPayments.search_by_activity(data._activities).collect { |ap|
74
+ ap.person_paid and ap.person_paid.to_list_id(session.owner)
75
+ }.compact.sort_by { |i| i[1] })
76
+ end
77
+
78
+ def rpc_button_new_student(session, data)
79
+ return unless (data._full_name || data._full_name.to_s.length > 0)
80
+ student = Persons.create({first_name: data._full_name})
81
+ student.permissions = %w(student internet)
82
+ data._full_name = student.login_name
83
+ rpc_button_search_student(session, data) +
84
+ reply(:update, students: [student.person_id])
85
+ end
86
+
87
+ def rpc_button_search_student(session, data)
88
+ return unless (data._full_name || data._full_name.to_s.length > 0)
89
+ reply(:empty_update, students: Persons.search_in(data._full_name).
90
+ collect { |p| p.to_list_id(session.owner) })
91
+ end
92
+
93
+ def rpc_list_choice_activities(session, data)
94
+ reply(:empty_nonlists_update, data._activities.to_hash) +
95
+ rpc_button_signed_up_students(session, data)
96
+ end
97
+
98
+ def rpc_list_choice_students(session, data)
99
+ return reply(:empty, %w(full_name table_activities)) unless data._students
100
+
101
+ act_table = ActivityPayments.for_user(data._students).collect { |act|
102
+ [act.activitypayment_id, [act.date_start, act.date_end]]
103
+ }.sort { |a, b| a[1] <=> b[1] }.reverse
104
+ reply(:empty_update, :table_activities => act_table) +
105
+ reply(:update, :date_start => Date.today.to_web)
106
+ end
107
+
108
+ def rpc_button_print_activity_steps(session, data)
109
+ ret = reply(:callback_button, :print_activity_steps)
110
+ var = session.s_data._print_activity
111
+ dputs(3) { "Doing with data #{var.inspect} step is #{var._step.inspect}" }
112
+ case var._step
113
+ when 1
114
+ dputs(3) { 'Showing prepare-window' }
115
+ var._students = var._activities.collect { |a| a.person_paid.login_name }
116
+ ret += reply(:window_show, :printing) +
117
+ reply(:update, :msg_print => 'Preparing students: <br><br>' +
118
+ var._students.each_slice(5).collect { |s| s.join(', ') }.
119
+ join(',<br>')) +
120
+ reply(:hide, :print_next)
121
+ when 2
122
+ dputs(3) { 'Printing pdfs' }
123
+ files = var._activities.collect { |act| act.print }
124
+ var._pages = OpenPrint.pdf_nup_duplex(files, 'activity_cards')
125
+ cmd = cmd_printer(session, :print_activity)
126
+ dputs(3) { "Command is #{cmd} with pages #{var._pages.inspect}" }
127
+ if not cmd
128
+ ret = reply(:window_show, :printing) +
129
+ reply(:update, :msg_print => 'Click on one of the links:<ul>' +
130
+ var._pages.collect { |r| "<li><a target='other' href=\"#{r}\">#{r}</a></li>" }.join('') +
131
+ '</ul>')
132
+ var._step = 9
133
+ elsif var._pages.length > 0
134
+ ret = reply(:window_show, :printing) +
135
+ reply(:update, :msg_print => 'Impression de la page face en cours pour<ul>' +
136
+ "<li>#{var._students.join('</li><li>')}</li></ul>" +
137
+ "<br>Cliquez sur 'suivant' pour imprimer les pages arrières") +
138
+ reply(:unhide, :print_next)
139
+ cmd += " #{var._pages[0]}"
140
+ dputs(3) { "Printing-cmd is #{cmd.inspect}" }
141
+ System.run_bool(cmd)
142
+ else
143
+ var._step = 9
144
+ end
145
+ when 3
146
+ cmd = cmd_printer(session, :print_activity)
147
+ dputs(3) { "Command is #{cmd} with pages #{var._pages.inspect}" }
148
+ ret = reply(:window_show, :printing) +
149
+ reply(:update, :msg_print => 'Impression de la page face arrière en cours<ul>' +
150
+ "<li>#{var._students.join('</li><li>')}</li></ul>") +
151
+ reply(:hide, :print_next)
152
+ cmd += " -o outputorder=reverse #{var._pages[1]}"
153
+ dputs(3) { "Printing-cmd is #{cmd.inspect}" }
154
+ System.run_bool(cmd)
155
+ when 4..10
156
+ dputs(3) { 'Hiding' }
157
+ ret = reply(:window_hide)
158
+ else
159
+ dputs(3) { "Oups - step is #{var._step.inspect}" }
160
+ end
161
+
162
+ var._step += 1
163
+ session.s_data[:print_activity] = var
164
+ dputs(3) { "Ret is #{ret.inspect}" }
165
+ return ret
166
+ end
167
+
168
+ def rpc_button_print_activity(session, data)
169
+ # dp "removed"
170
+ return nil
171
+ return unless data._students.length >= 1
172
+ acts = data._students.collect { |s|
173
+ if data._table_activities.length == 0
174
+ ActivityPayments.for_user(s).sort { |a, b| a.date_start <=> b.date_start }.
175
+ reverse.first
176
+ else
177
+ ActivityPayments.match_by_activitypayment_id(data._table_activities.first)
178
+ end
179
+ }
180
+
181
+ ret = rpc_print(session, :print_activity, data)
182
+ session.s_data._print_activity = {step: 1, activities: acts}
183
+ return ret + rpc_button_print_activity_steps(session, data)
184
+ end
185
+
186
+ def rpc_button_print_next(session, data)
187
+ rpc_button_print_activity_steps(session, data)
188
+ end
189
+
190
+ end
191
+
@@ -0,0 +1,141 @@
1
+ # Allows for adding cash to a specific course
2
+
3
+ class CashboxCourse < View
4
+ def layout
5
+ @order = 10
6
+ @update = true
7
+ @functions_need = [:cashbox, :accounting_courses]
8
+
9
+ gui_hboxg do
10
+ gui_vbox :nogroup do
11
+ show_entity_course :courses, :single, :name,
12
+ :flexheight => 1, :callback => true, :width => 100
13
+ end
14
+ gui_vbox :nogroup do
15
+ show_entity_person :students, :single, :full_name,
16
+ :flexheight => 1, :callback => true, :width => 300
17
+ show_str :full_name
18
+ show_button :add_student
19
+ end
20
+ gui_vbox :nogroup do
21
+ show_table :payments, :headings => [:Date, :Money, :Rest],
22
+ :widths => [100, 75, 75], :height => 200,
23
+ :columns => [0, :align_right, :align_right]
24
+ show_date :payment_date
25
+ show_int :cash
26
+ show_str :remark
27
+ show_str :receit_id
28
+ show_list_drop :old_cash, '%w( No Yes )'
29
+ show_button :pay, :delete, :move
30
+ end
31
+
32
+ gui_window :error do
33
+ show_html :msg
34
+ show_button :close
35
+ end
36
+
37
+ gui_window :win_move do
38
+ show_entity_person :move_students, :drop, :full_name, :width => 300
39
+ show_button :close, :do_move
40
+ end
41
+ end
42
+
43
+ @date_pay = Date.today
44
+ end
45
+
46
+ def rpc_list_choice_courses(session, data)
47
+ reply(:empty_nonlists, :students) +
48
+ reply(:update, :students => data._courses.list_students(true))
49
+ end
50
+
51
+ def rpc_list_choice_students(session, data)
52
+ reply(:empty, %w(cash remark receit_id)) +
53
+ reply(:update, :payment_date => @date_pay.strftime('%d.%m.%Y')) +
54
+ reply(:update, :payments =>
55
+ data._courses.student_payments(data._students.login_name))
56
+ end
57
+
58
+ def rpc_button_pay(session, data)
59
+ if data._payment_date
60
+ @date_pay = Date.parse(data._payment_date)
61
+ end
62
+
63
+ [[session.owner.account_due, "No account for #{session.owner.full_name}"],
64
+ [data._courses != [], 'Chose a course first'],
65
+ [data._students != [], 'Chose a student first'],
66
+ [data._courses.entries != [], 'Course has no account attached'],
67
+ [data._cash.to_i != 0, 'Enter an amount']].each { |t, msg|
68
+ dputs(3) { "Testing #{t.inspect} - #{msg}" }
69
+ t or return reply(:window_show, :error) +
70
+ reply(:update, :msg => msg)
71
+ }
72
+
73
+ dputs(3) { "Data is #{data.inspect}" }
74
+ if data._cash.to_i != 0
75
+ data._courses.payment(session.owner, data._students, data._cash, @date_pay,
76
+ session.owner.has_permission?(:admin) && data._old_cash.first == 'Yes',
77
+ remark: data._remark)
78
+ end
79
+ rpc_list_choice_students(session, data)
80
+ end
81
+
82
+ def rpc_button_add_student(session, data)
83
+ if (name = data._full_name).to_s.length > 0 &&
84
+ (course = data._courses)
85
+ Persons.create_add_course(data._full_name, session.owner, course)
86
+ rpc_list_choice_courses(session, data)
87
+ end
88
+ end
89
+
90
+ def rpc_button_move(session, data)
91
+ if data._students && data._courses
92
+ reply(:empty, :move_students) +
93
+ reply(:window_show, :win_move) +
94
+ reply(:update, :move_students => data._courses.list_students(true))
95
+ end
96
+ end
97
+
98
+ def rpc_button_do_move(session, data)
99
+ if (src = data._students) &&
100
+ (dst = data._move_students) &&
101
+ src != dst &&
102
+ data._courses
103
+ dputs(3) { "Moving student #{src.inspect}, #{dst.inspect}" }
104
+ data._courses.move_payment(src.login_name, dst.login_name)
105
+ end
106
+ reply(:window_hide) +
107
+ rpc_list_choice_students(session, data)
108
+ end
109
+
110
+ def rpc_update(session)
111
+ if owner = session.owner
112
+ reply_visible(owner.has_permission?(:admin), :old_cash)
113
+ else
114
+ []
115
+ end +
116
+ reply(:empty_nonlists, :students) +
117
+ reply(:empty_nonlists, :courses) +
118
+ reply(:update, :courses => Courses.list_courses_entries)
119
+ end
120
+
121
+ def rpc_button_delete(session, data)
122
+ if (gid = data._payments.first).to_s.length > 0
123
+ if mov = Movements.match_by_global_id(gid)
124
+ log_msg 'cashbox_course', "Deleting movement #{mov.inspect}"
125
+ date, value = mov.date, mov.value
126
+ mov.delete
127
+ user, id = gid.match(/(.*)-(.*)/)[1..2]
128
+ ngid = [user, (id.to_i + 1).to_s].join("-")
129
+ # If the next movement starts with "old_cash" and has same date
130
+ # and value, we suppose they go together
131
+ if mov = Movements.match_by_global_id(ngid) and
132
+ mov.desc =~ /^old_cash/ and mov.date == date and
133
+ mov.value == value
134
+ log_msg 'cashbox_course', "Found old_cash at #{mov.inspect}"
135
+ mov.delete
136
+ end
137
+ rpc_list_choice_students(session, data)
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,79 @@
1
+ =begin
2
+ This module allows for charging the internet-credit of a person. You can also
3
+ add a new person
4
+ =end
5
+
6
+ class CashboxCredit < View
7
+ def layout
8
+ set_data_class :Persons
9
+ @order = 30
10
+ @update = true
11
+ @functions_need = [:internet, :internet_cyber]
12
+
13
+ gui_hbox do
14
+ gui_vbox :nogroup do
15
+ show_str :search
16
+ show_entity_person :person, :single, :login_name, :callback => true
17
+ show_button :search_person, :add_person
18
+ end
19
+
20
+ gui_vbox :nogroup do
21
+ show_int :credit_add
22
+ show_str_ro :login_name
23
+ show_str_ro :full_name
24
+ show_int_ro :internet_credit
25
+ show_button :add_credit
26
+ end
27
+
28
+ gui_window :win_add do
29
+ show_str :full_name
30
+ show_button :win_add_person, :close
31
+ end
32
+
33
+ end
34
+ end
35
+
36
+ def rpc_button_add_person(session, data)
37
+ reply(:window_show, :win_add) +
38
+ reply(:empty, :full_name)
39
+ end
40
+
41
+ def rpc_button_win_add_person(session, data)
42
+ ret = reply(:window_hide)
43
+ person = if data._full_name.to_s.length > 0
44
+ Persons.create(complete_name: data._full_name)
45
+ end
46
+ person.permissions = %w(default internet)
47
+ ret + (person ? rpc_button_search_person(session, search: person.login_name) : [])
48
+ end
49
+
50
+ def rpc_button_search_person(session, data)
51
+ return reply(:empty, :person) unless data._search.length > 2
52
+ results = Persons.search_in(data._search, 20)
53
+ reply(:empty_update, :person => results.collect { |r| r.to_list_id(session.owner) } +
54
+ [results.first.person_id])
55
+ end
56
+
57
+ def rpc_button_add_credit(session, data)
58
+ dputs(3) { "Adding credit #{data.inspect}" }
59
+ rep = []
60
+ if person = Persons.add_internet_credit(session, data)
61
+ rep = reply(:update, :credit_add => '') +
62
+ reply(:update, :internet_credit => person.internet_credit)
63
+ end
64
+ rep + rpc_update(session)
65
+ end
66
+
67
+ def rpc_update(session)
68
+ super(session) +
69
+ reply(:parent, reply(:focus, :search))
70
+ end
71
+
72
+ def rpc_list_choice_person(session, data)
73
+ dputs(2) { "Got data: #{data.inspect}" }
74
+ if data._person
75
+ reply(:empty_update, data._person) +
76
+ reply(:focus, :credit_add)
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,115 @@
1
+ # Allows for adding cash to a specific course
2
+
3
+ class CashboxReport < View
4
+ include PrintButton
5
+
6
+ def layout
7
+ @order = 30
8
+ @update = true
9
+ @functions_need = [:cashbox]
10
+
11
+ gui_hbox do
12
+ gui_vbox :nogroup do
13
+ show_list_single :report_type, :callback => true, :maxheight => 160
14
+ show_date :report_start, :callback => :date
15
+ show_entity_course :course, :single, :name,
16
+ lambda{|c| c.entries}, :callback => true, :flexheight => 1
17
+ show_print :print
18
+ end
19
+ gui_vbox :nogroup do
20
+ show_table :report, :headings => [ :Date, :Desc, :Amount, :Sum ],
21
+ :widths => [ 100, 200, 75, 75 ], :height => 400, :width => 470,
22
+ :columns => [0, 0, :align_right, :align_right]
23
+ show_button :delete
24
+ end
25
+
26
+ gui_window :print_status do
27
+ gui_vbox :nogroup do
28
+ show_html :status
29
+ show_button :close
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ def rpc_show( session )
36
+ super( session )
37
+ end
38
+
39
+ def rpc_update( session )
40
+ super( session ) +
41
+ reply( :empty_nonlists, [ :course, :report_type ] ) +
42
+ reply( :update, :report_type =>
43
+ %w( Course Due_Daily Due_All Paid_All ).
44
+ map.with_index{|d,i|
45
+ [ i + 1, d ]} ) +
46
+ reply( :update, :course => Courses.list_courses_entries(session) ) +
47
+ reply( :hide, [:report_start, :course ] ) +
48
+ reply( :update, :report_start => Date.today.strftime( "%d.%m.%Y") ) +
49
+ reply_visible( session.owner.has_permission?( :accounting ), :delete ) +
50
+ reply_print( session )
51
+ end
52
+
53
+ def rpc_button_print( session, data )
54
+ ret = rpc_print( session, :print, data )
55
+ if data._report_type == []
56
+ return ret
57
+ end
58
+ date = Date.parse( data._report_start )
59
+
60
+ if ( report = data._report_type.first ) > 1
61
+ file = session.owner.report_pdf(
62
+ [ :daily, :all, :all_paid ][report - 2], date )
63
+ else
64
+ file = data._course.report_pdf
65
+ end
66
+
67
+ if printer = send_printer( session, :print, file )
68
+ ret + reply( :window_show, :print_status ) +
69
+ reply( :update, :status => "Printed to #{printer}")
70
+ else
71
+ ret + reply( :window_show, :print_status ) +
72
+ reply( :update, :status => "<a href='#{file}' target='other'>#{file}</a>")
73
+ end
74
+ end
75
+
76
+ def rpc_list_choice_report_type( session, data )
77
+ dputs(3){"report is #{data._report_start.inspect}"}
78
+ date = Date.parse( data._report_start.to_s )
79
+ ret = reply( :empty, :report )
80
+
81
+ case report = data._report_type.first
82
+ when 1
83
+ if data._course != []
84
+ ret += reply( :update, :report => data._course.report_list )
85
+ end
86
+ show = :course
87
+ when 2..4
88
+ ret += reply( :update, :report =>
89
+ session.owner.report_list(
90
+ [ :daily, :all, :all_paid ][report - 2], date ) )
91
+ show = :report_start
92
+ end
93
+
94
+ ret + reply( :unhide, show ) +
95
+ reply( :hide, show == :report_start ? :course : :report_start )
96
+ end
97
+
98
+ def rpc_list_choice_course( session, data )
99
+ rpc_list_choice_report_type( session, data )
100
+ end
101
+
102
+ def rpc_callback_date( session, data )
103
+ rpc_list_choice_report_type( session, data )
104
+ end
105
+
106
+ def rpc_button_delete( session, data )
107
+ if ( gid = data._report.first ).to_s.length > 0
108
+ if mov = Movements.match_by_global_id( gid )
109
+ log_msg "cashbox_report", "Deleting movement #{mov.inspect}"
110
+ mov.delete
111
+ rpc_list_choice_report_type( session, data )
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,105 @@
1
+ class CashboxService < View
2
+ def layout
3
+ set_data_class :Persons
4
+ @update = true
5
+ @order = 20
6
+
7
+ gui_hbox do
8
+ gui_vbox :nogroup do
9
+ gui_vbox :nogroup do
10
+ show_int :copies_intern, :callback => :calc
11
+ show_int :copies_extern, :callback => :calc
12
+ #show_int :heures_groupe_petit, :callback => :calc
13
+ show_int :heures_groupe_grand, :callback => :calc
14
+ show_int :CDs, :callback => :calc
15
+ end
16
+ gui_vbox :nogroup do
17
+ show_str :autres_text, :width => 200
18
+ show_int :autres_cfa, :callback => :calc
19
+ end
20
+ gui_vbox :nogroup do
21
+ show_int :services_total
22
+ end
23
+ show_date :date
24
+ show_button :add_cash
25
+ end
26
+ gui_vbox :nogroup do
27
+ gui_vbox :nogroup do
28
+ show_int_ro :account_total_due
29
+ end
30
+ gui_vbox :nogroup do
31
+ show_table :report, :headings => [:Date, :Desc, :Amount, :Sum],
32
+ :widths => [100, 300, 75, 75], :height => 400,
33
+ :columns => [0, 0, :align_right, :align_right]
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ def calc_total(values)
40
+ dputs(5) { "#{values.inspect}" }
41
+ services_total = 0
42
+ values.each { |k, v|
43
+ dputs(5) { "Searching for #{k}: #{v}" }
44
+ case k
45
+ when 'copies_intern'
46
+ services_total += v.to_i * 50
47
+ when 'copies_extern'
48
+ services_total += v.to_i * 100
49
+ when 'heures_groupe_grand'
50
+ services_total += v.to_f * 2500
51
+ when 'CDs'
52
+ services_total += v.to_i * 500
53
+ when 'autres_cfa'
54
+ services_total += v.to_i
55
+ end
56
+ }
57
+ services_total
58
+ end
59
+
60
+ def cash_msg(data)
61
+ '{' +
62
+ %w( copies_intern copies_extern heures_groupe_grand CDs autres_text ).select { |c|
63
+ data[c].to_s.length > 0
64
+ }.collect { |k|
65
+ "\"#{k}\"=>\"#{data[k]}\""
66
+ }.join(", ") +
67
+ '}'
68
+ end
69
+
70
+ # Adds the cash to the destination account, and puts the same amount into
71
+ # the AfriCompta-framework
72
+ def rpc_button_add_cash(session, data)
73
+ dputs(5) { "data is #{data.inspect}" }
74
+ services_total = calc_total(data)
75
+ dputs(5) { "which amounts to #{services_total} CFA" }
76
+ actor = session.owner
77
+ data.delete('services_total')
78
+ data.delete('account_total_due')
79
+ actor.pay_service(services_total, cash_msg(data),
80
+ data._date)
81
+ reply(:empty_nonlists) + rpc_update(session)
82
+ end
83
+
84
+ def rpc_update(session)
85
+ dputs(3) { 'Fetching total' }
86
+ ret = reply(:update, :account_total_due => session.owner.account_total_due)
87
+ dputs(3) { 'Updating time' }
88
+ ret += reply(:update, :date => Date.today.strftime('%d.%m.%Y'))
89
+ dputs(3) { 'Getting report_list' }
90
+ ret += reply(:update, :report => session.owner.report_list(:all))
91
+ dputs(3) { 'Done' }
92
+ ret
93
+ end
94
+
95
+ def rpc_update_with_values(session, values = nil)
96
+ dputs(3) { "Got values: #{values.inspect}" }
97
+ reply(:update, :services_total => calc_total(values))
98
+ end
99
+
100
+ def rpc_callback(session, name, data)
101
+ rpc_update_with_values(session, data)
102
+ end
103
+
104
+ end
105
+
@@ -0,0 +1,10 @@
1
+ # To change this template, choose Tools | Templates
2
+ # and open the template in the editor.
3
+
4
+ class CashboxTabs < View
5
+ def layout
6
+ @order = 90
7
+ @functions_need = [:cashbox]
8
+ end
9
+
10
+ end
@@ -0,0 +1,36 @@
1
+ class ComptaDefaults < View
2
+ def layout
3
+ @order = 300
4
+ @update = true
5
+ set_data_class(:ConfigBases)
6
+ @functions_need = [:accounting]
7
+
8
+ gui_vbox do
9
+ gui_hboxg :nogroup do
10
+ show_block :accounts
11
+ show_arg :account_cash, :width => 400
12
+ end
13
+ show_button :save
14
+ end
15
+ end
16
+
17
+ def rpc_update(session)
18
+ accounts_current = []
19
+ AccountRoot.current.get_tree_depth { |a|
20
+ accounts_current.push [a.id, a.get_path]
21
+ }
22
+ reply(:empty_nonlists) +
23
+ reply(:update, ConfigBases.get_block_fields(:accounts).collect { |acc|
24
+ [acc, accounts_current]
25
+ }.to_h) +
26
+ update_form_data(ConfigBases.singleton)
27
+
28
+ end
29
+
30
+ def rpc_button_save(session, data)
31
+ ConfigBase.store(data.to_sym)
32
+ dputs(3) { "Configuration is now #{ConfigBase.get_functions.inspect}" }
33
+
34
+ rpc_update(session)
35
+ end
36
+ end