summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-05-23 11:47:23 +0200
committerPeter Kozak <spag@golwen.net>2013-05-23 11:47:23 +0200
commite5d047eaf6d4c9f138fce801f4d9b790e7e8a7e6 (patch)
tree8d501fafbbab40ee40deb0ef68d742c057be48e6 /app/controllers
parent6d53887d83c00b187c297ad5dd74ef8fd19ff87c (diff)
JavaSctipt added to CallForward view
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/call_forwards_controller.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb
index fe54b55..1721aa3 100644
--- a/app/controllers/call_forwards_controller.rb
+++ b/app/controllers/call_forwards_controller.rb
@@ -30,6 +30,7 @@ class CallForwardsController < ApplicationController
@call_forward.active = true
@call_forwarding_destinations = call_forwarding_destination_types()
@call_forward.destination = GsParameter.get('CALLFORWARD_DESTINATION_DEFAULT').to_s if defined?(GsParameter.get('CALLFORWARD_DESTINATION_DEFAULT'))
+ @destination_phone_number = @call_forward.destination
@available_call_forward_cases = []
CallForwardCase.all.each do |available_call_forward_case|
@@ -45,6 +46,8 @@ class CallForwardsController < ApplicationController
@call_forward.call_forward_case_id = CallForwardCase.find_by_value('noanswer').id
@call_forward.timeout = 45
end
+
+ @available_greetings = available_greetings()
end
def create
@@ -62,6 +65,8 @@ class CallForwardsController < ApplicationController
def edit
@available_call_forward_cases = CallForwardCase.all
@call_forwarding_destinations = call_forwarding_destination_types()
+ @available_greetings = available_greetings()
+ @destination_phone_number = @call_forward.destination if @call_forward.call_forwarding_destination == ':PhoneNumber'
end
def update
@@ -82,7 +87,6 @@ class CallForwardsController < ApplicationController
end
private
- private
def set_and_authorize_parent
@parent = @phone_number || @sip_account || @automatic_call_distributor || @hunt_group
authorize! :read, @parent
@@ -216,4 +220,20 @@ class CallForwardsController < ApplicationController
return call_forwarding_destinations
end
+ def available_greetings
+ if @parent.class == PhoneNumber
+ owner = @parent.phone_numberable
+ else
+ owner = @parent
+ end
+
+ if owner.class == SipAccount
+ owner = owner.sip_accountable
+ elsif owner.class == FaxAccount
+ owner = owner.fax_accountable
+ end
+
+ return GenericFile.where(:category => 'greeting', :owner_type => owner.class.to_s, :owner_id => owner.id).map {|x| [x.to_s, x.name] }
+ end
+
end