summaryrefslogtreecommitdiff
path: root/app/controllers/phones_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/phones_controller.rb')
-rw-r--r--app/controllers/phones_controller.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/app/controllers/phones_controller.rb b/app/controllers/phones_controller.rb
index 2698465..14735e6 100644
--- a/app/controllers/phones_controller.rb
+++ b/app/controllers/phones_controller.rb
@@ -78,11 +78,11 @@ class PhonesController < ApplicationController
end
def set_fallback_sip_accounts
- used_sip_account_ids = Phone.where(:fallback_sip_account_id => SipAccount.pluck(:id)).pluck(:fallback_sip_account_id)
- @fallback_sip_accounts = SipAccount.where(:sip_accountable_type => 'Tenant').where(:hotdeskable => true) - SipAccount.where(:id => used_sip_account_ids)
- if @phone && !@phone.fallback_sip_account_id.blank? && SipAccount.exists?(@phone.fallback_sip_account_id)
- @fallback_sip_accounts << SipAccount.where(:id => @phone.fallback_sip_account_id).first
+ used_sip_account_ids = Phone.pluck(:fallback_sip_account_id) + PhoneSipAccount.pluck(:sip_account_id)
+ if @phone
+ used_sip_account_ids = used_sip_account_ids - [ @phone.fallback_sip_account_id ]
end
+ @fallback_sip_accounts = SipAccount.where(:sip_accountable_type => 'Tenant') - SipAccount.where(:id => used_sip_account_ids)
end
end