gestion 1.9.12

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 (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,55 @@
1
+ # To change this template, choose Tools | Templates
2
+ # and open the template in the editor.
3
+
4
+ class SelfChat < View
5
+ def layout
6
+ @@box_length = 40
7
+ @order = 100
8
+ @update = true
9
+ @auto_update_async = 5
10
+ @auto_update_send_values = false
11
+
12
+ gui_vboxg do
13
+ gui_vbox :nogroup do
14
+ show_html :replace
15
+ show_str :email
16
+ show_str :talk, :flexwidth => 1
17
+ show_button :send
18
+ end
19
+ gui_vboxg :nogroup do
20
+ show_text :discussion, :flexheight => 1, :flexwidth => 1
21
+ end
22
+ end
23
+
24
+ ChatMsgs.wait_max = 3
25
+ end
26
+
27
+ def rpc_update_view(session, args = nil)
28
+ super(session, args) +
29
+ if get_config(false, :multilogin)
30
+ reply(:update, :email => 'anonyme@profeda.org') +
31
+ reply(:update, :replace => '<h1>Ajoutez votre courriel!</h1>')
32
+ else
33
+ reply(:hide, [:replace, :email])
34
+ end
35
+ end
36
+
37
+ def rpc_update(session)
38
+ ChatMsgs.wait_counter_add
39
+ reply(:update, discussion: ChatMsgs.show_list) +
40
+ reply(:focus, :talk)
41
+ end
42
+
43
+ def rpc_button_send(session, data)
44
+ name, ret = if get_config(false, :multilogin)
45
+ [data._email, if data._email != 'anonyme@profeda.org'
46
+ reply(:hide, :replace)
47
+ end.to_a]
48
+ else
49
+ [session.owner.login_name, []]
50
+ end
51
+ ChatMsgs.new_msg_send(name, data._talk)
52
+ ret + reply(:empty, [:talk]) +
53
+ rpc_update(session)
54
+ end
55
+ end
@@ -0,0 +1,109 @@
1
+ class SelfConcours < View
2
+ def layout
3
+ @order = 10
4
+ @visible = true
5
+ @functions_need = [:quiz]
6
+
7
+ gui_vbox do
8
+ gui_vbox :nogroup do
9
+ show_html :welcome
10
+ end
11
+ gui_vbox :nogroup do
12
+ show_str :email, :width => 300
13
+ show_str :full_name, :width => 300
14
+ end
15
+ gui_hbox :nogroup do
16
+ gui_vbox :nogroup do
17
+ show_list_drop :q01_isoc_start, "%w( répondez 1980 1992 2000 )"
18
+ show_list_drop :q02_isoc_chad_start, "%w( répondez 2000 2003 2007 )"
19
+ show_list_drop :q03_internet_sat, "%w( répondez vrai faux )"
20
+ show_list_drop :q04_internet_like, "%w( répondez route avion eau )"
21
+ show_list_drop :q05_internet_needs, "%w( répondez portable fai disque_dur )"
22
+ show_list_drop :q06_fai_only_one, "%w( répondez vrai faux )"
23
+ show_list_drop :q07_price_free, "%w( répondez vrai faux )"
24
+ show_list_drop :q08_email_generic, "%w( répondez courriel yahoo gmail )"
25
+ show_list_drop :q09_service_surf, "%w( répondez ftp www e-mail )"
26
+ show_list_drop :q10_is_central, "%w( répondez vrai faux )"
27
+ end
28
+ gui_vbox :nogroup do
29
+ show_list_drop :q11_internet_start, "%w( répondez recherche commercial )"
30
+ show_list_drop :q12_what_standards, "%w( répondez ouvert payants )"
31
+ show_list_drop :q13_chapters_count, "%w( répondez 80 90 100 )"
32
+ show_list_drop :q14_isoc_members, "%w( répondez 57000 60000 55000 )"
33
+ show_list_drop :q15_domain_names, "%w( répondez IANA IAB ICANN )"
34
+ show_list_drop :q16_gives_ips, "%w( répondez IANA IAB ICANN )"
35
+ show_list_drop :q17_does_standards, "%w( répondez IANA IAB ICANN )"
36
+ show_list_drop :q18_we_work_with, "%w( répondez NTIC NPIC IPNT )"
37
+ show_list_drop :q19_website_chad, "%w( répondez isoc-tchad.org isoc-chad.org isoc.td )"
38
+ show_list_drop :q20_best_fai, "%w( répondez tigo airtel sotel prestabist tawali vsat )"
39
+ end
40
+ end
41
+ gui_vbox :nogroup do
42
+ show_button :send_replies
43
+ end
44
+ gui_window :error do
45
+ show_html :txt_error
46
+ show_button :ok
47
+ end
48
+ gui_window :finish do
49
+ show_html :txt_finish
50
+ show_button :yes, :no
51
+ end
52
+ gui_window :result do
53
+ show_html :txt
54
+ show_button :close
55
+ end
56
+ end
57
+ end
58
+
59
+ def rpc_show( session )
60
+ super( session ) +
61
+ reply( :update, :welcome => "<h1>مسابقة جمعية الانترنت التشادية</h1>" )
62
+ #reply( :update, :welcome => "<h1>ISOC-concours</h1>" )
63
+ end
64
+
65
+ def rpc_button_send_replies( session, data )
66
+ if not data['email'] or not data['full_name'] then
67
+ return reply( :window_show, :error ) +
68
+ reply( :update, :txt_error => "لم تدخل اسمك<br>أو البريدك الالكتروني" )
69
+ #reply( :update, :txt_error => "Vous n'avez pas entré un nom<br>ou un courriel" )
70
+ end
71
+ reply( :window_show, :finish ) +
72
+ reply( :update, :txt_finish => "هل تريد انهاء المسابقة<br>لو انهيتها لا تستطيع التعديل" )
73
+ #reply( :update, :txt_finish => "Voulez vous terminer votre essai?<br>Vous ne pourriez plus rien changer" )
74
+ end
75
+
76
+ def rpc_button_ok( session, data )
77
+ reply( :window_hide )
78
+ end
79
+
80
+ def rpc_button_no( session, data )
81
+ reply( :window_hide )
82
+ end
83
+
84
+ def rpc_button_yes( session, data )
85
+ replies = []
86
+ data.sort{|a,b| a[0] <=> b[0] }.each{|d|
87
+ dputs( 5 ){ "Data is #{d.inspect}" }
88
+ d[0] =~ /^q.._/ and replies.push d[1][0]
89
+ }
90
+ dputs( 2 ){ "replies is #{replies}" }
91
+ quiz = Quizs.create( :email => data['email'], :full_name => data['full_name'],
92
+ :reply => replies.join(",") )
93
+ greeting = case quiz.score
94
+ when 0..5 then "Oups"
95
+ when 6..10 then "Ca va"
96
+ when 11..15 then "Bien"
97
+ when 16..18 then "Très bien"
98
+ when 19 then "Excellent"
99
+ end
100
+ reply( :window_hide ) +
101
+ reply( :window_show, :result ) +
102
+ reply( :update, :txt => "<h2>#{greeting}, votre score est de</h2><br><div align='center'><h1>#{quiz.score}/19</h1>" )
103
+ end
104
+
105
+ def rpc_button_close( session, data )
106
+ reply( :window_hide ) +
107
+ rpc_show( session )
108
+ end
109
+ end
@@ -0,0 +1,34 @@
1
+ class SelfEmail < View
2
+ def layout
3
+ set_data_class :Persons
4
+ @update = true
5
+ @order = 100
6
+ @functions_need = [:network, :email]
7
+ @elements = %w( email acc_remote acc_pass acc_proto acc_port acc_supp )
8
+
9
+ gui_vbox do
10
+ show_str_ro :login_name
11
+ show_str :email, :width => 300
12
+ show_block :email_account
13
+ show_button :save
14
+ end
15
+ end
16
+
17
+ def rpc_update(session, client = nil)
18
+ person = session.owner
19
+ reply(:empty_nonlists) +
20
+ reply(:update, :login_name => person.login_name) +
21
+ reply(:update, Hash[*@elements.collect { |e|
22
+ [e.to_sym, person.data_get(e)] }.flatten(1)])
23
+ end
24
+
25
+
26
+ def rpc_button_save(session, data)
27
+ person = session.owner
28
+ @elements.each { |d|
29
+ person.data_set(d, data[d])
30
+ }
31
+ Persons.update_fetchmailrc
32
+ end
33
+
34
+ end
@@ -0,0 +1,255 @@
1
+ class SelfInternet < View
2
+ include Network
3
+
4
+ def layout
5
+ set_data_class :Persons
6
+ @order = 10
7
+ @update = true
8
+ @auto_update_async = 5
9
+ @auto_update_send_values = false
10
+ @functions_need = [:internet, :internet_captive]
11
+ @functions_reject = [:internet_simple]
12
+
13
+ gui_hbox do
14
+ gui_vbox :nogroup do
15
+ show_html :connection_status
16
+ show_int_ro :internet_credit
17
+ show_int_ro :users_connected
18
+ show_int_ro :bytes_left
19
+ show_int_ro :bytes_left_today
20
+ show_html :connection, :width => 100
21
+ show_html :auto_connection
22
+ show_button :connect, :disconnect
23
+ end
24
+ gui_vbox :nogroup do
25
+ show_table :traffic, headings: %w(Name Day-2 Day-1 Today),
26
+ widths: [100, 75, 75, 75]
27
+ show_button :disconnect_user
28
+ end
29
+ end
30
+ end
31
+
32
+ # 0 - yes
33
+ # 1 - no money left
34
+ # 2 - restrictions
35
+ # 3 - AccessGroups-rules
36
+ # 4 - no internet available
37
+ def can_connect(session)
38
+ noop = Internet.operator == nil
39
+ return 4 if noop
40
+ if not (ag = AccessGroups.allow_user_now(session.owner))[0]
41
+ return ag[1]
42
+ elsif Captive.restricted
43
+ return 2
44
+ elsif Internet.free(session.owner)
45
+ return 0
46
+ else
47
+ if session.owner and session.owner.internet_credit
48
+ cost_max = 20
49
+ if Internet.operator
50
+ cost_max = Internet.operator.user_cost_max
51
+ end
52
+ return (session.owner.internet_credit.to_i >= cost_max) ?
53
+ 0 : 1
54
+ else
55
+ dputs(0) { "Error: Called with session.owner == nil! #{session.inspect}" }
56
+ return 1
57
+ end
58
+ end
59
+ end
60
+
61
+ def update_connection_status(session)
62
+ #dputs_func
63
+ return reply(:hide, :connection_status) unless session.owner.has_role(:cybermanager)
64
+ ret = []
65
+ cc = can_connect(session)
66
+ dputs(3) { "CanConnect is #{cc}" }
67
+ case cc
68
+ when 0
69
+ status, status_str = Internet.connection_status
70
+ dputs(3) { "Connection-status is #{status.inspect}" }
71
+ status = status.to_i
72
+ if (0..4).include? status.to_i
73
+ status_color = %w( ff0000 ff2200 ff5500 ffff88 88ff88 )
74
+ status_width = %w( 25 30 35 100 150 )
75
+ connection_status = "<td width='#{status_width[status]}" +
76
+ "' bgcolor='" +
77
+ status_color[status] + "'>" +
78
+ status_str + "</td><td bgcolor='ffffff'></td>"
79
+ else
80
+ dputs(0) { "Error: connection-status was #{status.inspect}" }
81
+ connection_status = 'Comm-error'
82
+ end
83
+
84
+ ret += reply(:update, :connection_status =>
85
+ 'Etat de la connexion:<br>' +
86
+ "<table width='150px'><tr>" +
87
+ connection_status +
88
+ '</tr></table>')
89
+ when 1
90
+ ret += reply(:update, :connection_status => 'Not enough money in account')
91
+ when 2
92
+ ret += reply(:update, :connection_status => 'Restricted access due to teaching')
93
+ when 3
94
+ ret += reply(:update, :connection_status => cc)
95
+ when 4
96
+ ret += reply(:update, :connection_status => 'No internet connection available')
97
+ end
98
+ return ret
99
+ end
100
+
101
+ def update_button(session, nobutton = false)
102
+ #dputs_func
103
+ if nobutton
104
+ return reply(:hide, :connect) +
105
+ reply(:hide, :disconnect) +
106
+ reply(:update, :connection =>
107
+ "<img src='/Images/connection_wait.png' height='50'>")
108
+
109
+ end
110
+ if not session.owner
111
+ dputs(0) { "Error: no owner for session #{session.inspect}" }
112
+ return
113
+ end
114
+ show_button = :connect
115
+ connected = Captive.user_connected session.owner.login_name
116
+ dputs(3) { "User #{session.owner.login_name} is connected: #{connected} " +
117
+ "and can_connect = #{can_connect(session)}" }
118
+ if can_connect(session) == 0
119
+ dputs(3) { "User_connected #{session.owner.login_name}: #{connected.inspect}" }
120
+ if connected
121
+ dputs(4) { "Showing disconnect because we're connected" }
122
+ show_button = :disconnect
123
+ elsif Internet.operator &&
124
+ Internet.operator.has_promo && Internet.operator.internet_left <= 100_000
125
+ dputs(4) { 'Showing disconnect because there is no promotion left' }
126
+ show_button = :disconnect
127
+ end
128
+ else
129
+ dputs(3) { "User #{session.owner.login_name} has connected-status: #{connected.inspect}" }
130
+ show_button = :disconnect
131
+ end
132
+ if show_button == :disconnect && !connected
133
+ reply(:hide, [:connect, :disconnect])
134
+ else
135
+ reply_one_two(show_button == :connect, :connect, :disconnect)
136
+ end +
137
+ reply(:update, :connection =>
138
+ "<img src='/Images/connection_#{connected ? 'yes' : 'no'}.png' height='50'>") +
139
+ reply_visible(session.owner.is_responsible?, :disconnect_user)
140
+ end
141
+
142
+ def update_isp(session)
143
+ promo = (Internet.operator && Internet.operator.has_promo)
144
+ dputs(3) { "promo is #{promo}: #{Internet.operator} - #{Internet.operator.has_promo.inspect}" }
145
+ reply_visible(promo && session.owner.is_staff?, :bytes_left) +
146
+ reply(:unhide, :connection_status)
147
+ end
148
+
149
+ def self.make_users_str(users)
150
+ users_str = [[]]
151
+ users.split.sort.each { |u|
152
+ if users_str.last.count > 3
153
+ users_str[-1] = users_str.last.join(', ')
154
+ users_str.push []
155
+ end
156
+ users_str.last.push u
157
+ }
158
+ users_str[-1] = users_str.last.join(', ')
159
+ users_str.join(',<br>')
160
+ end
161
+
162
+ def rpc_update_async(session)
163
+ rpc_update(session)
164
+ end
165
+
166
+ def traffic_rxtx(t)
167
+ t.collect { |r, t| r+t }.join('-')
168
+ end
169
+
170
+ def get_traffic(user)
171
+ return reply(:hide, :traffic) unless (t = Captive.traffic) && user.is_staff?
172
+ list = t.traffic.collect { |h, _k|
173
+ traffic = t.get_day(h, -3).collect { |r, t| ((r+t)/1000)/1000.0 }
174
+ [h, [h] + traffic]
175
+ }.select { |t| t[1][1..3].inject(:+) > 0
176
+ }.sort_by { |t| t[1][3] }.reverse
177
+ #list = [[:ineiti], [20, 30, 40]]
178
+ reply(:unhide, :traffic) +
179
+ reply(:update, traffic: list)
180
+ end
181
+
182
+ def rpc_update(session, nobutton = false)
183
+ if nobutton
184
+ nobutton = Internet.operator &&
185
+ Internet.operator.connection_type == Operator::CONNECTION_ONDEMAND
186
+ end
187
+ o = session.owner
188
+
189
+ users = Captive.users_connected
190
+ users_str = SelfInternet.make_users_str(users)
191
+ dputs(4) { "session is #{session.inspect}" }
192
+ if session.class != Session
193
+ dputs(0) { "Called rpc_update without a session! #{caller.inspect}" }
194
+ end
195
+ ret = reply(:update, update(session)) +
196
+ update_button(session, nobutton) +
197
+ update_connection_status(session) +
198
+ update_isp(session) +
199
+ reply(:update, :internet_credit => o.internet_credit.to_i) +
200
+ reply(:update, :users_connected => "#{users.count}: #{users_str}") +
201
+ reply_visible(!Internet.free(session.owner), :internet_credit)
202
+ if Internet.operator && Internet.operator.has_promo && o.is_staff?
203
+ left = Internet.operator.internet_left
204
+ ret += reply(:unhide, :bytes_left) +
205
+ reply(:update, :bytes_left => left.to_MB('Mo'))
206
+ if Recharges.enabled?
207
+ ret += reply(:unhide, :bytes_left_today) +
208
+ reply(:update, bytes_left_today: Recharge.left_today(left).to_MB('Mo'))
209
+ else
210
+ ret += reply(:hide, :bytes_left_today)
211
+ end
212
+ else
213
+ ret += reply(:hide, %w(bytes_left bytes_left_today))
214
+ end
215
+
216
+ Captive.user_keep o.login_name, ConfigBase.keep_idle_free.to_i, true
217
+ url = 'Bookmark for<br>'+ "<a href='http://#{session.web_req.header._host.first}/" +
218
+ "?user=#{o.login_name}&pass=#{o.password}'>" +
219
+ 'Internet-connection</a>'
220
+
221
+ ret + reply(:update, auto_connection: url) +
222
+ get_traffic(o)
223
+ end
224
+
225
+ def rpc_show(session)
226
+ super(session) +
227
+ rpc_update(session)
228
+ end
229
+
230
+ def rpc_button_connect(session, data)
231
+ if session.web_req
232
+ log_msg :internet, "#{session.owner.login_name} connects with #{session.inspect}"
233
+ Internet.user_connect session.owner.login_name, session.client_ip
234
+ rpc_update(session, true)
235
+ end
236
+ end
237
+
238
+ def rpc_button_disconnect(session, data)
239
+ if session.web_req
240
+ log_msg :internet, "#{session.owner.login_name} disconnects"
241
+ Internet.user_disconnect session.owner.login_name
242
+ rpc_update(session, true)
243
+ end
244
+ end
245
+
246
+ def rpc_button_disconnect_user(session, data)
247
+ return unless session.owner.is_responsible?
248
+ data._traffic.each { |u|
249
+ log_msg :internet, "#{session.owner.login_name} disconnects #{u}"
250
+ Internet.user_disconnect u
251
+ rpc_update(session, true)
252
+ }
253
+ end
254
+
255
+ end
@@ -0,0 +1,17 @@
1
+ class SelfResults < View
2
+ def layout
3
+ @order = 10
4
+ @visible = true
5
+ @functions_need = [:quiz]
6
+
7
+ gui_vbox do
8
+ show_list :results, 'Quizs.results', :flexheight => 1
9
+ show_button :update
10
+ end
11
+ end
12
+
13
+ def rpc_button_update( session, data )
14
+ reply( :empty_nonlists, [ :results ] ) +
15
+ reply( :update, :results => Quizs.results )
16
+ end
17
+ end
@@ -0,0 +1,85 @@
1
+ class SelfServices < View
2
+ def layout
3
+ set_data_class :Persons
4
+ @update = true
5
+ @order = 30
6
+ @functions_need = [:accounting]
7
+ @visible = false
8
+
9
+ gui_hbox do
10
+ gui_vbox do
11
+ gui_vbox :nogroup do
12
+ show_int :copies_laser, :callback => :calc
13
+ #show_int :heures_groupe_petit, :callback => :calc
14
+ show_int :heures_groupe_grand, :callback => :calc
15
+ show_int :CDs, :callback => :calc
16
+ end
17
+ gui_vbox :nogroup do
18
+ show_str :autres_text, :callback => :calc
19
+ show_int :autres_cfa, :callback => :calc
20
+ end
21
+ gui_vbox :nogroup do
22
+ show_int :services_total
23
+ end
24
+ show_button :add_cash
25
+ end
26
+ show_int_ro :account_total_due
27
+ end
28
+ end
29
+
30
+ def calc_total( values )
31
+ dputs( 5 ){ "#{values.inspect}" }
32
+ services_total = 0
33
+ values.each{|k,v|
34
+ dputs( 5 ){ "Searching for #{k}: #{v}" }
35
+ case k
36
+ when "copies_laser"
37
+ services_total += v.to_i * 50
38
+ when "heures_groupe_petit"
39
+ services_total += v.to_f * 1000
40
+ when "heures_groupe_grand"
41
+ services_total += v.to_f * 2500
42
+ when "CDs"
43
+ services_total += v.to_i * 500
44
+ when "autres_cfa"
45
+ services_total += v.to_i
46
+ end
47
+ }
48
+ services_total
49
+ end
50
+
51
+ def self.cash_msg( data )
52
+ "{" +
53
+ data.collect{|k,v|
54
+ v.to_f > 0 and "\"#{k}\"=>\"#{v}\""
55
+ }.select{|m| m }.join(", ") +
56
+ "}"
57
+ end
58
+
59
+ # Adds the cash to the destination account, and puts the same amount into
60
+ # the AfriCompta-framework
61
+ def rpc_button_add_cash( session, data )
62
+ dputs( 5 ){ "data is #{data.inspect}" }
63
+ services_total = calc_total( data )
64
+ dputs( 5 ){ "which amounts to #{services_total} CFA" }
65
+ actor = session.owner
66
+ data.delete( "services_total" )
67
+ data.delete( "account_total_due" )
68
+ actor.pay_service( services_total, SelfServices.cash_msg( data ) )
69
+ reply( :empty_nonlists, nil ) + rpc_update( session )
70
+ end
71
+
72
+ def rpc_update( session )
73
+ reply( :update, { :account_total_due => session.owner.account_total_due } )
74
+ end
75
+
76
+ def rpc_update_with_values( session, values = nil )
77
+ dputs( 3 ){ "Got values: #{values.inspect}" }
78
+ reply( :update, { :services_total => calc_total( values ) } )
79
+ end
80
+
81
+ def rpc_callback( session, name, data )
82
+ rpc_update_with_values( session, data )
83
+ end
84
+
85
+ end
@@ -0,0 +1,47 @@
1
+ # Allows to add, modify and delete persons
2
+
3
+ class SelfShow < View
4
+ def layout
5
+ set_data_class :Persons
6
+ @order = 20
7
+ @update = true
8
+
9
+ gui_hbox do
10
+ show_block :address, :width => 150
11
+ show_button :save
12
+
13
+ gui_vbox :nogroup do
14
+ show_str :new_password
15
+ show_button :change_password
16
+
17
+ show_button :logout
18
+ end
19
+ end
20
+
21
+ dputs(5) { "#{@layout.inspect}" }
22
+ end
23
+
24
+ def rpc_button(session, name, data)
25
+ dputs(3) { "Pressed button #{name} with #{data.inspect}" }
26
+ person = session.owner
27
+ case name
28
+ when 'change_password'
29
+ person.password = data['new_password']
30
+ when 'save'
31
+ person.data_set_hash(data)
32
+ when 'logout'
33
+ return reply('reload')
34
+ end
35
+ return nil
36
+ end
37
+
38
+ def rpc_update(session)
39
+ if session.owner
40
+ reply(:empty_nonlists) +
41
+ reply(:update, session.owner.to_hash)
42
+ else
43
+ log_msg :SelfShow, 'Got empty session.owner, reloading'
44
+ reply(:reload)
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,5 @@
1
+ class SelfTabs < View
2
+ def layout
3
+ @order = 100
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ class SpecialDFileEdit < View
2
+ def layout
3
+ @order = 100
4
+ @functions_need = [:files_manage]
5
+
6
+ gui_hbox do
7
+ gui_vbox do
8
+ show_button :mount_harddisk
9
+ show_button :contact_url
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,56 @@
1
+ class SpecialPlug < View
2
+ include VTListPane
3
+
4
+ def layout
5
+ @order = 150
6
+ set_data_class :Plugs
7
+ @update = true
8
+
9
+ gui_hbox do
10
+ gui_vbox :nogroup do
11
+ vtlp_list :plugs, :center_name
12
+ show_button :delete, :new
13
+ end
14
+ gui_vbox :nogroup do
15
+ show_block :default
16
+ show_arg :internal_id, :width => 150
17
+ show_button :save
18
+ end
19
+ gui_vbox :nogroup do
20
+ show_text :stats, height: 300, width: 250
21
+ show_int_ro :operator
22
+ show_int_ro :credit_left
23
+ show_int :recharge_credit
24
+ show_str :cmd_str
25
+ show_button :recharge, :charge, :cmd
26
+ end
27
+ end
28
+ end
29
+
30
+ def rpc_update(session)
31
+ op, cl = if $MobileControl
32
+ [$MobileControl.operator_name,
33
+ $MobileControl.operator_missing? ? -1 : $MobileControl.operator.credit_left]
34
+ else
35
+ ['None', -1]
36
+ end
37
+ reply(:update, operator: op,
38
+ credit_left: cl)
39
+ end
40
+
41
+ def plugs(data)
42
+ Plugs.match_by_plug_id(data._plugs.first)
43
+ end
44
+
45
+ def rpc_button_recharge(session, data)
46
+ # dp data._plugs
47
+ end
48
+
49
+ def rpc_button_charge(session, data )
50
+ plugs(data).send_cmd_sms(:charge)
51
+ end
52
+
53
+ def rpc_button_cmd(session, data)
54
+ plugs(data).send_cmd_sms(data._cmd_str.split(/,\s*/))
55
+ end
56
+ end
@@ -0,0 +1,6 @@
1
+ class SpecialTabs < View
2
+ def layout
3
+ @order = 200
4
+ @functions_need = [:special]
5
+ end
6
+ end