From 3a20974d9403877ffa9a720efd999df49a1733bf Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 10:33:28 +0100 Subject: list possible voicemail accounts --- app/controllers/call_forwards_controller.rb | 41 +++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-) (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 b30ee9e..858ed12 100644 --- a/app/controllers/call_forwards_controller.rb +++ b/app/controllers/call_forwards_controller.rb @@ -131,15 +131,46 @@ class CallForwardsController < ApplicationController phone_number_destination = CallForwardingDestination.new() phone_number_destination.id = ':PhoneNumber' phone_number_destination.label = 'Phone Number' - voice_mail_destination = CallForwardingDestination.new() - voice_mail_destination.id = ':Voicemail' - voice_mail_destination.label = 'Voice Mail' call_forwarding_destinations = [ phone_number_destination, - voice_mail_destination, ] + if @parent.try(:voicemail_accounts) + @parent.voicemail_accounts.each do |voicemail_account| + call_forwards_destination = CallForwardingDestination.new() + call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount" + call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}" + call_forwarding_destinations << call_forwards_destination + end + end + + if @parent.class == SipAccount + sip_account = @parent + if sip_account.sip_accountable.class == User || sip_account.sip_accountable.class == Tenant + sip_account.sip_accountable.voicemail_accounts.each do |voicemail_account| + call_forwards_destination = CallForwardingDestination.new() + call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount" + call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}" + call_forwarding_destinations << call_forwards_destination + end + end + end + + if @parent.class == PhoneNumber + if @parent.phone_numberable.class == SipAccount + sip_account = @parent.phone_numberable + if sip_account.sip_accountable.class == User || sip_account.sip_accountable.class == Tenant + sip_account.sip_accountable.voicemail_accounts.each do |voicemail_account| + call_forwards_destination = CallForwardingDestination.new() + call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount" + call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}" + call_forwarding_destinations << call_forwards_destination + end + end + end + end + if GuiFunction.display?('huntgroup_in_destination_field_in_call_forward_form', current_user) HuntGroup.all.each do |hunt_group| hunt_group_destination = CallForwardingDestination.new() @@ -149,7 +180,7 @@ class CallForwardsController < ApplicationController end end - return call_forwarding_destinations + return call_forwarding_destinations.uniq end end -- cgit v1.2.3 From e2b4088b25551316d373eae6a4e4cc2293801058 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 28 Mar 2013 09:12:05 +0100 Subject: parent accounts fixed --- app/controllers/call_forwards_controller.rb | 2 +- 1 file changed, 1 insertion(+), 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 858ed12..cdf6c06 100644 --- a/app/controllers/call_forwards_controller.rb +++ b/app/controllers/call_forwards_controller.rb @@ -136,7 +136,7 @@ class CallForwardsController < ApplicationController phone_number_destination, ] - if @parent.try(:voicemail_accounts) + if @parent.class == SipAccount || @parent.class == User || @parent.class == Tenant @parent.voicemail_accounts.each do |voicemail_account| call_forwards_destination = CallForwardingDestination.new() call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount" -- cgit v1.2.3 From 68ee69efeca95e6fa5fb063ca77274cffb053692 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 28 Mar 2013 14:27:22 +0100 Subject: call_forwarding_destinations method --- app/controllers/call_forwards_controller.rb | 43 +++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 9 deletions(-) (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 cdf6c06..917bee3 100644 --- a/app/controllers/call_forwards_controller.rb +++ b/app/controllers/call_forwards_controller.rb @@ -127,7 +127,7 @@ class CallForwardsController < ApplicationController end def call_forwarding_destination_types - + destinations_hash = {} phone_number_destination = CallForwardingDestination.new() phone_number_destination.id = ':PhoneNumber' phone_number_destination.label = 'Phone Number' @@ -140,18 +140,37 @@ class CallForwardsController < ApplicationController @parent.voicemail_accounts.each do |voicemail_account| call_forwards_destination = CallForwardingDestination.new() call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount" - call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}" - call_forwarding_destinations << call_forwards_destination + call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}" + if !destinations_hash[call_forwards_destination.id] + destinations_hash[call_forwards_destination.id] = true + call_forwarding_destinations << call_forwards_destination + end end end if @parent.class == SipAccount sip_account = @parent + group_ids = Group.target_group_ids_by_permission(:forward_to, sip_account.groups) + if sip_account.sip_accountable.class == User || sip_account.sip_accountable.class == Tenant + group_ids = group_ids + Group.target_group_ids_by_permission(:forward_to, sip_account.sip_accountable.groups) sip_account.sip_accountable.voicemail_accounts.each do |voicemail_account| call_forwards_destination = CallForwardingDestination.new() call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount" call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}" + if !destinations_hash[call_forwards_destination.id] + destinations_hash[call_forwards_destination.id] = true + call_forwarding_destinations << call_forwards_destination + end + end + end + + GroupMembership.where(:group_id => group_ids, :item_type => 'VoicemailAccount').each do |group_member| + call_forwards_destination = CallForwardingDestination.new() + call_forwards_destination.id = "#{group_member.item.id}:VoicemailAccount" + call_forwards_destination.label = "VoicemailAccount: #{group_member.item.to_s}" + if !destinations_hash[call_forwards_destination.id] + destinations_hash[call_forwards_destination.id] = true call_forwarding_destinations << call_forwards_destination end end @@ -165,7 +184,10 @@ class CallForwardsController < ApplicationController call_forwards_destination = CallForwardingDestination.new() call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount" call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}" - call_forwarding_destinations << call_forwards_destination + if !destinations_hash[call_forwards_destination.id] + destinations_hash[call_forwards_destination.id] = true + call_forwarding_destinations << call_forwards_destination + end end end end @@ -173,14 +195,17 @@ class CallForwardsController < ApplicationController if GuiFunction.display?('huntgroup_in_destination_field_in_call_forward_form', current_user) HuntGroup.all.each do |hunt_group| - hunt_group_destination = CallForwardingDestination.new() - hunt_group_destination.id = "#{hunt_group.id}:HuntGroup" - hunt_group_destination.label = "HuntGroup: #{hunt_group.to_s}" - call_forwarding_destinations.push(hunt_group_destination) + call_forwards_destination = CallForwardingDestination.new() + call_forwards_destination.id = "#{hunt_group.id}:HuntGroup" + call_forwards_destination.label = "HuntGroup: #{hunt_group.to_s}" + if !destinations_hash[call_forwards_destination.id] + destinations_hash[call_forwards_destination.id] = true + call_forwarding_destinations << call_forwards_destination + end end end - return call_forwarding_destinations.uniq + return call_forwarding_destinations end end -- cgit v1.2.3 From 82e76a100851ce62748d411c982f74c1a6366830 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 21 May 2013 14:39:25 +0200 Subject: breadcrumbs --- app/controllers/call_forwards_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (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 917bee3..fe54b55 100644 --- a/app/controllers/call_forwards_controller.rb +++ b/app/controllers/call_forwards_controller.rb @@ -92,6 +92,14 @@ class CallForwardsController < ApplicationController if @parent if @parent.class == PhoneNumber && @parent.phone_numberable_type == 'SipAccount' @sip_account = @parent.phone_numberable + elsif @parent.class == PhoneNumber && @parent.phone_numberable_type == 'HuntGroup' + add_breadcrumb t("hunt_groups.index.page_title"), tenant_hunt_groups_path(@parent.phone_numberable.tenant) + add_breadcrumb @parent.phone_numberable, tenant_hunt_group_path(@parent.phone_numberable.tenant, @parent.phone_numberable) + add_breadcrumb t("phone_numbers.index.page_title"), hunt_group_phone_numbers_path(@parent.phone_numberable) + add_breadcrumb @parent, hunt_group_phone_number_path(@parent.phone_numberable, @parent) + elsif @parent.class == HuntGroup + add_breadcrumb t("hunt_groups.index.page_title"), tenant_hunt_groups_path(@parent.tenant) + add_breadcrumb @parent, tenant_hunt_group_path(@parent.tenant, @parent) end if @sip_account -- cgit v1.2.3 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