class SelfServices
Public Class Methods
cash_msg( data )
click to toggle source
# File Views/Self/Services.rb, line 51 def self.cash_msg( data ) "{" + data.collect{|k,v| v.to_f > 0 and "\"#{k}\"=>\"#{v}\"" }.select{|m| m }.join(", ") + "}" end
Public Instance Methods
calc_total( values )
click to toggle source
# File Views/Self/Services.rb, line 30 def calc_total( values ) dputs( 5 ){ "#{values.inspect}" } services_total = 0 values.each{|k,v| dputs( 5 ){ "Searching for #{k}: #{v}" } case k when "copies_laser" services_total += v.to_i * 50 when "heures_groupe_petit" services_total += v.to_f * 1000 when "heures_groupe_grand" services_total += v.to_f * 2500 when "CDs" services_total += v.to_i * 500 when "autres_cfa" services_total += v.to_i end } services_total end
layout()
click to toggle source
# File Views/Self/Services.rb, line 2 def layout set_data_class :Persons @update = true @order = 30 @functions_need = [:accounting] @visible = false gui_hbox do gui_vbox do gui_vbox :nogroup do show_int :copies_laser, :callback => :calc #show_int :heures_groupe_petit, :callback => :calc show_int :heures_groupe_grand, :callback => :calc show_int :CDs, :callback => :calc end gui_vbox :nogroup do show_str :autres_text, :callback => :calc show_int :autres_cfa, :callback => :calc end gui_vbox :nogroup do show_int :services_total end show_button :add_cash end show_int_ro :account_total_due end end
rpc_callback( session, name, data )
click to toggle source
# File Views/Self/Services.rb, line 81 def rpc_callback( session, name, data ) rpc_update_with_values( session, data ) end
rpc_update( session )
click to toggle source
# File Views/Self/Services.rb, line 72 def rpc_update( session ) reply( :update, { :account_total_due => session.owner.account_total_due } ) end
rpc_update_with_values( session, values = nil )
click to toggle source
# File Views/Self/Services.rb, line 76 def rpc_update_with_values( session, values = nil ) dputs( 3 ){ "Got values: #{values.inspect}" } reply( :update, { :services_total => calc_total( values ) } ) end