From e5d047eaf6d4c9f138fce801f4d9b790e7e8a7e6 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 23 May 2013 11:47:23 +0200 Subject: JavaSctipt added to CallForward view --- app/controllers/call_forwards_controller.rb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'app/controllers/call_forwards_controller.rb') 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 @@ -81,7 +86,6 @@ class CallForwardsController < ApplicationController redirect_to m.( @parent ), :notice => t('call_forwards.controller.successfuly_destroyed') end - private private def set_and_authorize_parent @parent = @phone_number || @sip_account || @automatic_call_distributor || @hunt_group @@ -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 -- cgit v1.2.3