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/Entities/Plug.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
class Plugs < Entities
|
2
|
+
def setup_data
|
3
|
+
value_str :internal_id
|
4
|
+
value_str :fixed_id
|
5
|
+
value_str :center_name
|
6
|
+
value_str :center_id
|
7
|
+
value_str :center_city
|
8
|
+
value_str :ip_local
|
9
|
+
value_date :installation
|
10
|
+
value_str :telephone
|
11
|
+
value_str :credit
|
12
|
+
value_str :internet_left
|
13
|
+
value_list_drop :model, '%w(DreamPlug08 DreamPlug10 Smileplug
|
14
|
+
Cubox-i1 Cubox-i2x Cubox-i4)'
|
15
|
+
value_int :storage_size
|
16
|
+
|
17
|
+
Network::Device.add_observer(self)
|
18
|
+
update('add', Network::Device.search_dev({uevent: {driver: 'option'}}).first)
|
19
|
+
end
|
20
|
+
|
21
|
+
def update(op, dev = nil)
|
22
|
+
return unless ConfigBase.has_function?(:plug_admin)
|
23
|
+
dputs(2) { "Updating with operation #{op} and device #{dev}" }
|
24
|
+
if op =~ /add/ && dev && dev.instance_variable_defined?(:@serial_sms_new)
|
25
|
+
dev.serial_sms_new.push(Proc.new { |sms| new_sms(sms) })
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def new_sms(sms)
|
30
|
+
dputs_func
|
31
|
+
dputs(2) { "Found new sms #{sms.inspect}" }
|
32
|
+
search_all_.each { |p|
|
33
|
+
# Match for incomplete, but existing telephone number. Make sure that
|
34
|
+
# +235999999 matches 999999, in both ways
|
35
|
+
p1 = p.telephone.to_s.gsub(/[^0-9]/, '')
|
36
|
+
p2 = sms._number.gsub(/[^0-9]/, '')
|
37
|
+
dputs(3) { "Phone-numbers are _#{p1}_ and _#{p2}_" }
|
38
|
+
if p1.length > 0 && (p1 =~ /#{p2}$/ || p2 =~ /#{p1}$/)
|
39
|
+
p.new_sms(sms)
|
40
|
+
end
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def listp_center
|
45
|
+
Plugs.search_all_.collect{|p| [p.plug_id, p.center_name]}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class Plug < Entity
|
50
|
+
def send_cmd_sms(*cmds)
|
51
|
+
return unless telephone.to_s.length > 0 &&
|
52
|
+
!$MobileControl.operator_missing?
|
53
|
+
msg = "cmd: #{cmds.join('::')}"
|
54
|
+
add_stat(msg, :sms, :send)
|
55
|
+
$MobileControl.device.sms_send(telephone.to_s, msg)
|
56
|
+
end
|
57
|
+
|
58
|
+
def send_credit(amount)
|
59
|
+
return unless telephone.to_s.length > 0 &&
|
60
|
+
!$MobileControl.operator_missing?
|
61
|
+
add_stat(amount.to_s, :credit, :send)
|
62
|
+
$MobileControl.operator.credit_send(telephone.to_s, amount)
|
63
|
+
end
|
64
|
+
|
65
|
+
def new_sms(sms)
|
66
|
+
add_stat(sms._msg, :sms, :rcv)
|
67
|
+
log_msg :Plug, "Got new sms #{sms.inspect}"
|
68
|
+
case sms._msg
|
69
|
+
when /^stat: (.*): (.*) :: (.*) :: (.*)/
|
70
|
+
host, state, disk, time = $1, $2, $3, $4
|
71
|
+
_, _, _, internet, credit = state.split(':')
|
72
|
+
dputs(2) { "Host #{host} has state #{state}" }
|
73
|
+
self.internal_id = host
|
74
|
+
if internet != 'noop'
|
75
|
+
self.internet_left = internet.gsub(/[^0-9]/, '').to_i * 1_000_000
|
76
|
+
self.credit = credit
|
77
|
+
dputs(2) { "Host #{host} has #{internet} Bytes and #{self.credit} left" }
|
78
|
+
end
|
79
|
+
else
|
80
|
+
log_msg :Plut, "Unknown message from #{host}"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def add_stat(msg, type, dir)
|
85
|
+
PlugStats.create(time: Time.now, msg: msg, msg_type: [type],
|
86
|
+
msg_dir: [dir], plug: self)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class PlugStats < Entities
|
91
|
+
def setup_data
|
92
|
+
value_time :time
|
93
|
+
value_str :msg
|
94
|
+
value_list :msg_type, '%w( sms email rpc credit )'
|
95
|
+
value_list :msg_dir, '%w( send rcv )'
|
96
|
+
value_entity :plug
|
97
|
+
end
|
98
|
+
end
|
data/Entities/Quiz.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
class Quizs < Entities
|
2
|
+
def setup_data
|
3
|
+
value_str :email
|
4
|
+
value_str :full_name
|
5
|
+
value_str :reply
|
6
|
+
value_int :score
|
7
|
+
end
|
8
|
+
|
9
|
+
def create( a )
|
10
|
+
dputs( 4 ){ "Creating Quiz with #{a.inspect}" }
|
11
|
+
q = super( a )
|
12
|
+
q.score = q.evaluate
|
13
|
+
q
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.results
|
17
|
+
self.search_all.collect{|q| [ q.score, q.full_name ] }.
|
18
|
+
sort{ |a,b| b[0] <=> a[0] }.collect{|q| q.join( ":" ) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class Quiz < Entity
|
23
|
+
def evaluate
|
24
|
+
correct = %w( 1992 2007 faux route fai faux faux courriel www faux recherche ouvert
|
25
|
+
90 55000 ICANN IANA IAB NTIC isoc-chad.org )
|
26
|
+
s = 0
|
27
|
+
reply.split(",")[0..-2].each{|r|
|
28
|
+
r.to_s == correct.shift.to_s and s += 1
|
29
|
+
}
|
30
|
+
s
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class Recharges < Entities
|
2
|
+
def setup_data
|
3
|
+
value_str :time
|
4
|
+
value_int :volume
|
5
|
+
value_int :days_valid
|
6
|
+
value_int :days_goal
|
7
|
+
end
|
8
|
+
|
9
|
+
def enabled?
|
10
|
+
search_all_.length > 0
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Recharge < Entity
|
15
|
+
def left_today(left_total)
|
16
|
+
return -1 if days_goal.to_i <= 0
|
17
|
+
end_of_day = (days_goal.to_i - (Date.today - day) - 1) * volume.to_i / days_goal.to_i
|
18
|
+
(left_total - (end_of_day < 0 ? 0 : end_of_day)).to_i
|
19
|
+
end
|
20
|
+
|
21
|
+
def day
|
22
|
+
begin
|
23
|
+
year, month, day = time.scan(/../)
|
24
|
+
Date.new(2000 + year.to_i, month.to_i, day.to_i)
|
25
|
+
rescue ArgumentError => e
|
26
|
+
Date.today
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.left_today(left_total)
|
31
|
+
if (r = Recharges.search_all_).length > 0
|
32
|
+
r.sort { |a, b| a.time <=> b.time }.last.left_today(left_total)
|
33
|
+
else
|
34
|
+
-1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/Entities/Report.rb
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
class ReportAccounts < Entities
|
2
|
+
def setup_data
|
3
|
+
value_entity_account :root, :drop, :path
|
4
|
+
value_entity_account :account, :drop, :path
|
5
|
+
value_int :level
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
class Reports < Entities
|
11
|
+
def setup_data
|
12
|
+
value_str :name
|
13
|
+
value_list_entity_reportAccounts :accounts
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Report < Entity
|
18
|
+
attr_accessor :print_accounts, :print_movements, :print_account
|
19
|
+
|
20
|
+
def print_account_monthly(acc, start, months, counter)
|
21
|
+
stop = (start >> months) - 1
|
22
|
+
|
23
|
+
line = []
|
24
|
+
zeros = false
|
25
|
+
@print_account = ''
|
26
|
+
@print_accounts = counter.to_f / accounts.count
|
27
|
+
p_a = 0
|
28
|
+
acc.account.get_tree(acc.level.to_i) { |acc_sub, depth|
|
29
|
+
acc_sub.get_tree(depth > 0 ? 0 : -1) { p_a += accounts.count }
|
30
|
+
}
|
31
|
+
acc.account.get_tree(acc.level.to_i) { |acc_sub, depth|
|
32
|
+
dputs(2) { "Doing #{acc_sub.path} - #{depth.inspect}. Done: #{@print_accounts}" }
|
33
|
+
sum = Array.new(months) { 0 }
|
34
|
+
acc_sub.get_tree(depth > 0 ? 0 : -1) { |acc_sum|
|
35
|
+
@print_account = acc_sum.get_path
|
36
|
+
@print_accounts += 1.0 / p_a
|
37
|
+
p_m = 1.0 / acc_sum.movements.count
|
38
|
+
@print_movements = 0
|
39
|
+
acc_sum.movements.each { |m|
|
40
|
+
@print_movements += p_m
|
41
|
+
if (start..stop).include? m.date
|
42
|
+
sum[m.date.month - start.month] += m.get_value(acc_sum)
|
43
|
+
end
|
44
|
+
}
|
45
|
+
}
|
46
|
+
if sum.inject(false) { |m, o| m |= o != 0 } or line.size == 0
|
47
|
+
if line.size == 0
|
48
|
+
zeros = true
|
49
|
+
elsif zeros
|
50
|
+
line = []
|
51
|
+
zeros = false
|
52
|
+
end
|
53
|
+
line.push [acc_sub.path, sum + [sum.inject(:+)]]
|
54
|
+
end
|
55
|
+
}
|
56
|
+
line
|
57
|
+
end
|
58
|
+
|
59
|
+
def print_heading_monthly(start = Date.today, months = 12)
|
60
|
+
['Period', (0...months).collect { |m|
|
61
|
+
(start >> m).strftime('%Y/%m')
|
62
|
+
} + ['Sum']]
|
63
|
+
end
|
64
|
+
|
65
|
+
def print_list_monthly(start = Date.today, months = 12)
|
66
|
+
stop = start >> (months - 1)
|
67
|
+
acc_counter = -1
|
68
|
+
list = accounts.collect { |acc|
|
69
|
+
line = print_account_monthly(acc, start, months, acc_counter += 1)
|
70
|
+
if line.size > 1
|
71
|
+
line.push ['Sum', line.reduce(Array.new(months+1, 0)) { |memo, obj|
|
72
|
+
dputs(2) { "#{memo}, #{obj.inspect}" }
|
73
|
+
memo = memo.zip(obj[1]).map { |a, b| a + b }
|
74
|
+
}]
|
75
|
+
end
|
76
|
+
line
|
77
|
+
}
|
78
|
+
if list.size > 1
|
79
|
+
list + [[['Total', running = list.reduce(Array.new(months+1, 0)) { |memo, obj|
|
80
|
+
dputs(2) { "#{memo}, #{obj.inspect}" }
|
81
|
+
memo = memo.zip(obj.last.last).map { |a, b| a + b }
|
82
|
+
}],
|
83
|
+
['Running', running[0..-2].reduce([]) { |m, o| m + [(m.last || 0) + o] }]]]
|
84
|
+
else
|
85
|
+
list
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def print(start = Date.today, months = 12)
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
def listp_accounts
|
94
|
+
accounts.collect { |a|
|
95
|
+
[a.id, "#{a.level}: #{a.account.path}"]
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
def print_pdf_monthly(start = Date.today, months = 12)
|
100
|
+
stop = start >> (months - 1)
|
101
|
+
file = "/tmp/report_#{name}.pdf"
|
102
|
+
Prawn::Document.generate(file,
|
103
|
+
:page_size => 'A4',
|
104
|
+
:page_layout => :landscape,
|
105
|
+
:bottom_margin => 2.cm) do |pdf|
|
106
|
+
|
107
|
+
pdf.text "Report for #{name}",
|
108
|
+
:align => :center, :size => 20
|
109
|
+
pdf.font_size 7
|
110
|
+
pdf.text "From #{start.strftime('%Y/%m')} to #{stop.strftime('%Y/%m')}"
|
111
|
+
pdf.move_down 1.cm
|
112
|
+
|
113
|
+
pdf.table([print_heading_monthly(start, months).flatten.collect { |ch|
|
114
|
+
{:content => ch, :align => :center} }] +
|
115
|
+
print_list_monthly(start, months).collect { |acc|
|
116
|
+
acc.collect { |a, values|
|
117
|
+
[a] + values.collect { |v| Account.total_form(v) }
|
118
|
+
}
|
119
|
+
}.flatten(1).collect { |line|
|
120
|
+
a, s = (line[0] =~ /::/ ? [:left, :normal] : [:right, :bold])
|
121
|
+
[{:content => line.shift, :align => a, :font_style => s}] +
|
122
|
+
line.collect { |v|
|
123
|
+
{:content => v, :align => :right, :font_style => s} }
|
124
|
+
},
|
125
|
+
:header => true)
|
126
|
+
pdf.move_down(2.cm)
|
127
|
+
|
128
|
+
pdf.repeat(:all, :dynamic => true) do
|
129
|
+
pdf.draw_text "#{Date.today} - #{name}",
|
130
|
+
:at => [0, -20], :size => 10
|
131
|
+
pdf.draw_text pdf.page_number, :at => [18.cm, -20]
|
132
|
+
end
|
133
|
+
end
|
134
|
+
file
|
135
|
+
end
|
136
|
+
end
|
data/Entities/Room.rb
ADDED
data/Entities/SMS.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Holds SMS from Modem
|
2
|
+
|
3
|
+
class SMSs < Entities
|
4
|
+
def setup_data
|
5
|
+
value_date :date
|
6
|
+
value_phone :phone
|
7
|
+
value_txt :text
|
8
|
+
value_int :index
|
9
|
+
end
|
10
|
+
|
11
|
+
def last(count)
|
12
|
+
return [] if @data.length == 0 || count <= 0
|
13
|
+
|
14
|
+
msgs = [count, @data.length].min
|
15
|
+
dputs(3) { "Getting #{msgs} SMS for #{@data.inspect}" }
|
16
|
+
@data.keys.sort[-msgs..-1].collect { |d|
|
17
|
+
get_data_instance(d)
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def create(sms)
|
22
|
+
if !match_by_date(sms._date)
|
23
|
+
super({date: sms._date, phone: sms._number, text: sms._msg,
|
24
|
+
index: sms._id})
|
25
|
+
end
|
26
|
+
while @data.length > 50
|
27
|
+
get_data_instance(@data.first.first).delete
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class ScheduleTypes < Entities
|
2
|
+
def setup_data
|
3
|
+
value_str :name
|
4
|
+
value_str :schedule
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.get_script
|
8
|
+
return IO.read('Files/timetable.js')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.get_html(weeks: false)
|
12
|
+
return "<style type='text/css'>
|
13
|
+
td.select {
|
14
|
+
background-color: #00ffff
|
15
|
+
}</style>
|
16
|
+
<table width='80%' border=0 onload='add_weeks(16); add_days();add_hours();'> " +
|
17
|
+
(weeks ? "<tr id='tr_weeks'></tr>" : '') +
|
18
|
+
"<tr id='tr_days'></tr>
|
19
|
+
<tr id='tr_programs'></ tr>
|
20
|
+
<tr id='tr_hours'></tr>
|
21
|
+
</ table>"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class ScheduleType < Entity
|
26
|
+
def schedule_array
|
27
|
+
JSON.parse(schedule)
|
28
|
+
end
|
29
|
+
|
30
|
+
def schedule_array=(s)
|
31
|
+
schedule = s.to_json
|
32
|
+
end
|
33
|
+
end
|
data/Entities/Share.rb
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
# Holds share for samba
|
2
|
+
|
3
|
+
class Shares < Entities
|
4
|
+
def setup_data
|
5
|
+
value_block :config
|
6
|
+
value_str :name
|
7
|
+
value_str :path
|
8
|
+
value_str :comment
|
9
|
+
value_str :force_user
|
10
|
+
value_str :force_group
|
11
|
+
#value_text :args
|
12
|
+
value_list_drop :public, '%w( No Read ReadWrite )'
|
13
|
+
|
14
|
+
value_block :acl
|
15
|
+
value_str :acl
|
16
|
+
end
|
17
|
+
|
18
|
+
def migration_1(s)
|
19
|
+
s.public = [s.public.first == 'Yes' ? 'ReadWrite' : 'No']
|
20
|
+
end
|
21
|
+
|
22
|
+
def save_config(domain)
|
23
|
+
dputs_func
|
24
|
+
return unless Shares.is_active?
|
25
|
+
|
26
|
+
a = IO.read('Files/smb.conf')
|
27
|
+
a.gsub!(/WORKGROUP/, domain)
|
28
|
+
a.gsub!(/SERVER/, "Profeda-server on #{domain}")
|
29
|
+
a += "\n"
|
30
|
+
Shares.search_all_.each { |sh|
|
31
|
+
if !Dir.exists?(sh.path)
|
32
|
+
FileUtils.mkdir_p(sh.path)
|
33
|
+
end
|
34
|
+
begin
|
35
|
+
FileUtils.chmod 0777, sh.path
|
36
|
+
rescue Errno::EROFS => e
|
37
|
+
log_msg :Share, "Oups, couldn't chmod #{e.inspect}"
|
38
|
+
end
|
39
|
+
a += "\n\n[#{sh.name}]\n path = #{sh.path}\n comment = #{sh.comment}\n"
|
40
|
+
valid_users = []
|
41
|
+
if sh.force_user.to_s.length > 0
|
42
|
+
a += " force user = #{sh.force_user}\n"
|
43
|
+
valid_users.push sh.force_user
|
44
|
+
end
|
45
|
+
if sh.force_group.to_s.length > 0
|
46
|
+
a += " force group = #{sh.force_group}\n"
|
47
|
+
valid_users.push sh.force_group
|
48
|
+
end
|
49
|
+
case sh.public.first
|
50
|
+
when 'Read'
|
51
|
+
a += " guest ok = yes\n writeable = no\n"
|
52
|
+
when 'ReadWrite'
|
53
|
+
a += " guest ok = yes\n writeable = yes\n"
|
54
|
+
else
|
55
|
+
read = []
|
56
|
+
write = []
|
57
|
+
dputs(4) { "sh is #{sh.class}" }
|
58
|
+
sh.acl.class == Hash and sh.acl.each { |k, v|
|
59
|
+
dputs(4) { "Found #{k}: #{v}" }
|
60
|
+
case v
|
61
|
+
when /rw/
|
62
|
+
write.push k
|
63
|
+
when /ro/
|
64
|
+
read.push k
|
65
|
+
end
|
66
|
+
}
|
67
|
+
a += " read list = #{read.join(',')}\n write list = #{write.join(',')}\n" +
|
68
|
+
" valid users = #{ (read + write + valid_users).uniq.join(',')}\n"
|
69
|
+
end
|
70
|
+
a += " directory mask = 0775\n create mask = 0664\n"
|
71
|
+
#a += " hide files = /~$*/*.tmp/\n blocking locks = no\n"
|
72
|
+
#a += " create mask = 741\n map archive = yes\n map system = yes\n" +
|
73
|
+
# " map hidden = yes\n"
|
74
|
+
}
|
75
|
+
file_smb = "#{ConfigBase.samba_config}/smb.conf"
|
76
|
+
File.open(file_smb, 'w') { |f|
|
77
|
+
f.write(a)
|
78
|
+
}
|
79
|
+
|
80
|
+
Platform.restart('samba')
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.is_active?
|
84
|
+
ConfigBase.samba_simul == %w(false) &&
|
85
|
+
!get_config(false, :Entities, :Share, :simulation)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
class Share < Entity
|
90
|
+
def setup_instance
|
91
|
+
if not self.acl
|
92
|
+
self.acl = {}
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def add_htaccess
|
97
|
+
if File.exists? path
|
98
|
+
File.open("#{path}/.htaccess", "w") { |f|
|
99
|
+
f << "AuthType Basic
|
100
|
+
AuthName 'Restricted Access'
|
101
|
+
AuthUserFile '#{path}/.htpasswd'
|
102
|
+
Require valid-user
|
103
|
+
"
|
104
|
+
}
|
105
|
+
File.exists? passfile = "#{path}/.htpasswd" and
|
106
|
+
FileUtils.rm passfile
|
107
|
+
if acl.class == Hash
|
108
|
+
acl.each { |k, v|
|
109
|
+
dputs(4) { "Adding #{k} to htpasswd" }
|
110
|
+
case v
|
111
|
+
when /rw|ro/
|
112
|
+
dputs(4) { "Really adding #{k} to #{passfile}" }
|
113
|
+
user = Persons.find_by_login_name(k)
|
114
|
+
System.run_str("/usr/bin/htpasswd -bnd #{user.login_name} '#{user.password_plain }' >> #{passfile}")
|
115
|
+
end
|
116
|
+
}
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
data/Entities/Task.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
class Tasks < Entities
|
2
|
+
def setup_data
|
3
|
+
value_str :date_name
|
4
|
+
|
5
|
+
value_block :who
|
6
|
+
value_str :client
|
7
|
+
value_str :person
|
8
|
+
value_entity_person :worker, :drop, :full_name
|
9
|
+
|
10
|
+
value_block :work
|
11
|
+
value_date :date
|
12
|
+
value_list_drop :time, "22.times.collect{|t| sprintf( '%02i.%02i', 7 + ( t / 2 ).floor, 30 * ( t % 2 ) )}"
|
13
|
+
value_int :duration_hours
|
14
|
+
value_text :work
|
15
|
+
|
16
|
+
value_block :other
|
17
|
+
value_int :transport_length
|
18
|
+
value_list_single :transport_type, "%w( moto voiture taxi )"
|
19
|
+
value_int :cost
|
20
|
+
value_str :cost_description
|
21
|
+
value_int :gain
|
22
|
+
value_str :gain_description
|
23
|
+
end
|
24
|
+
|
25
|
+
def data_to_time( d )
|
26
|
+
dputs( 3 ){ d.inspect }
|
27
|
+
t = d[:date].split('.').values_at( 2, 1, 0 ) +
|
28
|
+
d[:time].to_s.split('.')
|
29
|
+
Time.utc( *t )
|
30
|
+
end
|
31
|
+
|
32
|
+
def listp_tasks
|
33
|
+
@data.values.sort{|a,b|
|
34
|
+
data_to_time(a) <=> data_to_time(b)
|
35
|
+
}.reverse.collect{ |d|
|
36
|
+
[ d[:task_id], data_to_time(d).strftime("%d.%m.%y") + " - " + d[:person].to_s]
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def list_task_month( worker, year, month, client )
|
41
|
+
@data.values.select{|d|
|
42
|
+
dputs( 3 ){ "Data is: #{d.inspect}" }
|
43
|
+
date = data_to_time( d )
|
44
|
+
dputs( 3 ){ [ date.inspect, year, month, worker, d[:person] ].inspect }
|
45
|
+
date.year == year.to_i and
|
46
|
+
date.month == month.to_i and
|
47
|
+
worker == Entities.Workers.find_full_name( d[:person][0] ) and
|
48
|
+
client.name == d[:client][0]
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
data/Entities/Ticket.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# A ticket is opened for computers only
|
2
|
+
|
3
|
+
class Tickets < Entities
|
4
|
+
def setup_data
|
5
|
+
value_block :date
|
6
|
+
value_date :opened
|
7
|
+
value_date :closed
|
8
|
+
value_list_drop :severity, "%w( critique grave moyen optionnel )"
|
9
|
+
value_str_ro :created_by
|
10
|
+
value_entity_person_empty :assigned, :drop, :full_name,
|
11
|
+
lambda{|p| p.permissions.index("maintenance")}
|
12
|
+
value_entity_computer_empty :computer, :drop, :name_service
|
13
|
+
value_str :other
|
14
|
+
|
15
|
+
value_block :detail
|
16
|
+
value_text :todo
|
17
|
+
value_text :verification
|
18
|
+
value_text :work
|
19
|
+
end
|
20
|
+
|
21
|
+
def listp_opened( closed = false )
|
22
|
+
search_all.select{|k|
|
23
|
+
( not k.closed ) ^ closed
|
24
|
+
}.collect{|k|
|
25
|
+
dputs( 4 ){ "k is #{k.inspect}" }
|
26
|
+
comp = k.computer != 0 ? k.computer.name_service : "---"
|
27
|
+
[k.ticket_id, "#{k.opened} - #{comp}" ]
|
28
|
+
}.sort{|a,b|
|
29
|
+
a[1] <=> b[1]
|
30
|
+
}.reverse
|
31
|
+
end
|
32
|
+
|
33
|
+
def listp_closed
|
34
|
+
listp_opened( true )
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
module TicketLayout
|
40
|
+
def t_layout( method )
|
41
|
+
set_data_class :Tickets
|
42
|
+
@update = true
|
43
|
+
@order = method == :opened ? 150 : 200
|
44
|
+
|
45
|
+
gui_hbox do
|
46
|
+
gui_vbox :nogroup do
|
47
|
+
vtlp_list :ticket_list, method, :width => 150
|
48
|
+
if method == :opened
|
49
|
+
show_button :new_ticket, :delete
|
50
|
+
else
|
51
|
+
show_button :delete
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
gui_vbox :nogroup do
|
56
|
+
gui_hbox :nogroup do
|
57
|
+
gui_vbox :nogroup do
|
58
|
+
show_block :date
|
59
|
+
end
|
60
|
+
gui_vbox :nogroup do
|
61
|
+
show_block :detail, :width => 150
|
62
|
+
end
|
63
|
+
end
|
64
|
+
if method == :opened
|
65
|
+
show_button :save_ticket
|
66
|
+
else
|
67
|
+
show_button :save
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|