From 0dd51846f6279fcdf3b4a7749b70d3b2fad8b0a5 Mon Sep 17 00:00:00 2001
From: "C.J. Adams-Collier" <cjac@colliertech.org>
Date: Thu, 18 Sep 2014 11:56:02 -0700
Subject: [PATCH] FS RT #30831 - passing the ISO 3166-1 alpha-2 country code to
 ut_phonen

---
 FS/FS/Record.pm    | 4 ++--
 FS/FS/svc_alarm.pm | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index 3e50b11a7..6e4f973df 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -2487,8 +2487,8 @@ sub ut_alpha_lower {
 Check/untaint phone numbers.  May be null.  If there is an error, returns
 the error, otherwise returns false.
 
-Takes an optional two-letter ISO country code; without it or with unsupported
-countries, ut_phonen simply calls ut_alphan.
+Takes an optional two-letter ISO 3166-1 alpha-2 country code; without
+it or with unsupported countries, ut_phonen simply calls ut_alphan.
 
 =cut
 
diff --git a/FS/FS/svc_alarm.pm b/FS/FS/svc_alarm.pm
index bb9338c7f..bfdb6bda1 100644
--- a/FS/FS/svc_alarm.pm
+++ b/FS/FS/svc_alarm.pm
@@ -198,13 +198,15 @@ sub check {
   my $x = $self->setfixed;
   return $x unless ref $x;
 
+  my $iso3166 = $self->cust_main->ship_location->country();
+
   my $error =
     $self->ut_numbern('svcnum')
     || $self->ut_text('acctnum')
     || $self->ut_alphan('_password')
     || $self->ut_textn('location')
     || $self->ut_numbern('cs_receiver')
-    || $self->ut_phonen('cs_phonenum')
+    || $self->ut_phonen('cs_phonenum', $iso3166)
     || $self->ut_alphan('serialnum')
     || $self->ut_foreign_key('alarmsystemnum',  'alarm_system',  'systemnum')
     || $self->ut_foreign_key('alarmtypenum',    'alarm_type',    'typenum')
-- 
2.20.1