gestion 1.9.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +48 -0
- data/.project +14 -0
- data/Binaries/adduser_to_buzz +15 -0
- data/Binaries/backup +7 -0
- data/Binaries/check_gestion +8 -0
- data/Binaries/gestion.gnumail +22 -0
- data/Binaries/gestion.logrotate +34 -0
- data/Binaries/gestion.service +12 -0
- data/Binaries/gestion_update.rb +183 -0
- data/Binaries/gestion_update.service +10 -0
- data/Binaries/get_compta +11 -0
- data/Binaries/kill_gestion +16 -0
- data/Binaries/ldap/add_indexes +51 -0
- data/Binaries/ldap/backup +2 -0
- data/Binaries/ldap/install_ldap +92 -0
- data/Binaries/ldap/restore +7 -0
- data/Binaries/lib_backup +5 -0
- data/Binaries/log_scan_errors +8 -0
- data/Binaries/loop_gestion +64 -0
- data/Binaries/onetimers/sync_courses_from_compta.rb +74 -0
- data/Binaries/onetimers/transfer_cash_from_ldap_to_csv +26 -0
- data/Binaries/reboot +5 -0
- data/Binaries/restore +3 -0
- data/Binaries/restore_do +22 -0
- data/Binaries/sort_events +31 -0
- data/Binaries/start_gestion +18 -0
- data/Binaries/swipe_gestion +18 -0
- data/Binaries/update_africompta +21 -0
- data/Binaries/update_users +3 -0
- data/Diplomas.src/accredited.odg +0 -0
- data/Diplomas.src/diploma.odg +0 -0
- data/Diplomas.src/label.odg +0 -0
- data/Diplomas.src/presence_sheet.ods +0 -0
- data/Diplomas.src/presence_sheet_small.ods +0 -0
- data/Diplomas.src/student_card.odg +0 -0
- data/Doc/130514-it-ideas.odt +0 -0
- data/Doc/Compta-cash.mm +179 -0
- data/Doc/General.odt +0 -0
- data/Entities/AccessGroups.rb +117 -0
- data/Entities/Activity.rb +178 -0
- data/Entities/ChatMsg.rb +142 -0
- data/Entities/Classroom.rb +11 -0
- data/Entities/Client.rb +19 -0
- data/Entities/Computer.rb +21 -0
- data/Entities/ConfigBase.rb +280 -0
- data/Entities/Course.rb +1588 -0
- data/Entities/CourseType.rb +171 -0
- data/Entities/DFiles.rb +466 -0
- data/Entities/FilesManage.rb +226 -0
- data/Entities/Grade.rb +186 -0
- data/Entities/Internet.rb +300 -0
- data/Entities/Netdev.rb +10 -0
- data/Entities/Person.rb +1175 -0
- data/Entities/Plug.rb +98 -0
- data/Entities/Quiz.rb +33 -0
- data/Entities/Recharges.rb +37 -0
- data/Entities/Report.rb +136 -0
- data/Entities/Room.rb +12 -0
- data/Entities/SMS.rb +30 -0
- data/Entities/ScheduleType.rb +33 -0
- data/Entities/Share.rb +120 -0
- data/Entities/Task.rb +51 -0
- data/Entities/Ticket.rb +72 -0
- data/Entities/Usage.rb +143 -0
- data/Entities/Worker.rb +29 -0
- data/Files/apache-profeda.conf +36 -0
- data/Files/label.erb +121 -0
- data/Files/label_notfound.erb +64 -0
- data/Files/label_notpassed.erb +84 -0
- data/Files/mobileinfo.erb +115 -0
- data/Files/smb.conf +333 -0
- data/Files/timetable.html +36 -0
- data/Files/timetable.js +239 -0
- data/Gemfile +12 -0
- data/Gemfile.dev +12 -0
- data/Gemfile.dev.lock +127 -0
- data/Gemfile.lock +127 -0
- data/Gemfile.prod +8 -0
- data/Gestion +35 -0
- data/Gestion.rb +220 -0
- data/INSTALL +40 -0
- data/Images/connection.xcf +0 -0
- data/Images/connection_no.png +0 -0
- data/Images/connection_wait.png +0 -0
- data/Images/connection_yes.png +0 -0
- data/Paths/Exas.rb +13 -0
- data/Paths/Files.rb +19 -0
- data/Paths/GetDiplomas.rb +20 -0
- data/Paths/Info.rb +114 -0
- data/Paths/Label.rb +187 -0
- data/Paths/MobileInfo.rb +19 -0
- data/Paths/internetCash.rb +34 -0
- data/Paths/internetWifi.rb +54 -0
- data/README.md +60 -0
- data/Rakefile +13 -0
- data/TODO +1391 -0
- data/Test/.gitignore +3 -0
- data/Test/Diplomas/base_gestion.odt +0 -0
- data/Test/Diplomas/base_report.odt +0 -0
- data/Test/Diplomas/carte_etudiant.odg +0 -0
- data/Test/Diplomas/exam_language.odt +0 -0
- data/Test/Diplomas/label.odg +0 -0
- data/Test/Diplomas/presence_sheet.ods +0 -0
- data/Test/Diplomas/presence_sheet_small.ods +0 -0
- data/Test/Diplomas/student_card.odg +0 -0
- data/Test/Manual/testMerge +18 -0
- data/Test/config_test.yaml +26 -0
- data/Test/db.testGestion +0 -0
- data/Test/dfiles/descs/avg-rescue.desc +10 -0
- data/Test/dfiles/descs/avg.desc +8 -0
- data/Test/dfiles/descs/driver.desc +8 -0
- data/Test/dfiles/descs/linuxmint.desc +7 -0
- data/Test/dfiles/files/avg-160203.exe +1 -0
- data/Test/dfiles/files/avg.iso +1 -0
- data/Test/dfiles/files/driver.exe +1 -0
- data/Test/dfiles/index_post.html +3 -0
- data/Test/dfiles/index_pre.html +8 -0
- data/Test/dfiles/priorities +5 -0
- data/Test/ge_activity.rb +124 -0
- data/Test/ge_chat.rb +106 -0
- data/Test/ge_compta.rb +67 -0
- data/Test/ge_configbase.rb +54 -0
- data/Test/ge_course.rb +1114 -0
- data/Test/ge_dfiles.rb +121 -0
- data/Test/ge_filesmanage.rb +180 -0
- data/Test/ge_info.rb +27 -0
- data/Test/ge_internet.rb +246 -0
- data/Test/ge_login.rb +55 -0
- data/Test/ge_person.rb +373 -0
- data/Test/ge_qvinfo.rb +28 -0
- data/Test/ge_report.rb +97 -0
- data/Test/ge_share.rb +27 -0
- data/Test/ge_sms.rb +34 -0
- data/Test/ge_tasks.rb +19 -0
- data/Test/ge_usage.rb +168 -0
- data/Test/ge_view.rb +46 -0
- data/Test/multiconf-captive +29 -0
- data/Test/test.conf +7 -0
- data/Test/test.rb +49 -0
- data/Test/test_bytes.png +0 -0
- data/VERSION +140 -0
- data/Views/Admin/Backup.rb +91 -0
- data/Views/Admin/Configuration.rb +44 -0
- data/Views/Admin/Credit.rb +32 -0
- data/Views/Admin/FilesManage.rb +219 -0
- data/Views/Admin/Function.rb +39 -0
- data/Views/Admin/Power.rb +49 -0
- data/Views/Admin/Printer.rb +37 -0
- data/Views/Admin/Server.rb +252 -0
- data/Views/Admin/Tabs.rb +5 -0
- data/Views/Admin/Update.rb +73 -0
- data/Views/Admin/UpdateSystem.rb +26 -0
- data/Views/Cashbox/Activity.rb +191 -0
- data/Views/Cashbox/Course.rb +141 -0
- data/Views/Cashbox/Credit.rb +79 -0
- data/Views/Cashbox/Report.rb +115 -0
- data/Views/Cashbox/Service.rb +105 -0
- data/Views/Cashbox/Tabs.rb +10 -0
- data/Views/Compta/Accounts.rb +36 -0
- data/Views/Compta/Course.rb +96 -0
- data/Views/Compta/Show.rb +6 -0
- data/Views/Compta/Transfer.rb +66 -0
- data/Views/Course/Diploma.rb +203 -0
- data/Views/Course/Grade.rb +401 -0
- data/Views/Course/Modify.rb +447 -0
- data/Views/Course/Print.rb +94 -0
- data/Views/Course/Responsible.rb +44 -0
- data/Views/Course/Stats.rb +76 -0
- data/Views/Course/Students.rb +92 -0
- data/Views/Course/Tabs.rb +220 -0
- data/Views/Internet/Access.rb +134 -0
- data/Views/Internet/ClassEdit.rb +24 -0
- data/Views/Internet/ClassUsers.rb +81 -0
- data/Views/Internet/Config.rb +32 -0
- data/Views/Internet/Mobile.rb +213 -0
- data/Views/Internet/Recharges.rb +49 -0
- data/Views/Internet/Tabs.rb +6 -0
- data/Views/Inventory/Computer.rb +24 -0
- data/Views/Inventory/Room.rb +18 -0
- data/Views/Inventory/Tabs.rb +9 -0
- data/Views/Inventory/TicketClosed.rb +7 -0
- data/Views/Inventory/TicketOpen.rb +23 -0
- data/Views/Library/Person.rb +36 -0
- data/Views/Library/Tabs.rb +7 -0
- data/Views/Network/Block.rb +87 -0
- data/Views/Network/Netdevs.rb +21 -0
- data/Views/Network/Restriction.rb +37 -0
- data/Views/Network/Share.rb +167 -0
- data/Views/Network/Tables.rb +28 -0
- data/Views/Network/Tabs.rb +6 -0
- data/Views/Person/Admin.rb +99 -0
- data/Views/Person/Center.rb +48 -0
- data/Views/Person/Course.rb +72 -0
- data/Views/Person/Modify.rb +153 -0
- data/Views/Person/Tabs.rb +162 -0
- data/Views/Report/ComptaExecutive.rb +221 -0
- data/Views/Report/ComptaFlat.rb +79 -0
- data/Views/Report/ReportCourse.rb +47 -0
- data/Views/Report/Tabs.rb +8 -0
- data/Views/Report/Usage.rb +52 -0
- data/Views/Report/UsageCases.rb +59 -0
- data/Views/Self/Cash.rb +67 -0
- data/Views/Self/Chat.rb +55 -0
- data/Views/Self/Concours.rb +109 -0
- data/Views/Self/Email.rb +34 -0
- data/Views/Self/Internet.rb +255 -0
- data/Views/Self/Results.rb +17 -0
- data/Views/Self/Services.rb +85 -0
- data/Views/Self/Show.rb +47 -0
- data/Views/Self/Tabs.rb +5 -0
- data/Views/Special/DFileEdit.rb +13 -0
- data/Views/Special/PlugEdit.rb +56 -0
- data/Views/Special/Tabs.rb +6 -0
- data/Views/Special/Vnc.rb +39 -0
- data/Views/Task/Client.rb +21 -0
- data/Views/Task/Edit.rb +33 -0
- data/Views/Task/List.rb +55 -0
- data/Views/Task/Tabs.rb +9 -0
- data/Views/Task/Worker.rb +30 -0
- data/Views/Template/Activity.rb +33 -0
- data/Views/Template/CourseType.rb +63 -0
- data/Views/Template/ScheduleType.rb +29 -0
- data/Views/Template/Tabs.rb +5 -0
- data/Views/Welcome.rb +121 -0
- data/config.yaml.default +36 -0
- data/po/Gestion-ar.po +2356 -0
- data/po/Gestion-en.mo +0 -0
- data/po/Gestion-en.po +4363 -0
- data/po/Gestion-fr.mo +0 -0
- data/po/Gestion-fr.po +4345 -0
- data/po/traduction-ar.rtf +76 -0
- metadata +381 -0
data/Views/Self/Chat.rb
ADDED
@@ -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
|
data/Views/Self/Email.rb
ADDED
@@ -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
|
data/Views/Self/Show.rb
ADDED
@@ -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
|
data/Views/Self/Tabs.rb
ADDED
@@ -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
|