canada has same phone# rules as US
[freeside.git] / FS / FS / svc_domain.pm
index 3d011af..fce6cf2 100644 (file)
@@ -11,7 +11,7 @@ use Mail::Internet;
 use Mail::Header;
 use Date::Format;
 use Net::Whois 1.0;
-use FS::Record qw(fields qsearch qsearchs);
+use FS::Record qw(fields qsearch qsearchs dbh);
 use FS::Conf;
 use FS::svc_Common;
 use FS::cust_svc;
@@ -93,6 +93,8 @@ FS::svc_Common.  The following fields are currently supported:
 
 =item domain
 
+=item catchall - optional svcnum of an svc_acct record, designating an email catchall account.
+
 =back
 
 =head1 METHODS
@@ -186,7 +188,7 @@ sub insert {
       'reczone' => '@',
       'recaf'   => 'IN',
       'rectype' => 'SOA',
-      'recdata' => "$soamachine $soaemail ( ". time2str("%Y%m%e", time). "00 ".
+      'recdata' => "$soamachine $soaemail ( ". time2str("%Y%m%d", time). "00 ".
                    "$soarefresh $soaretry $soaexpire $soadefaultttl )"
     };
     $error = $soa->insert;
@@ -215,7 +217,7 @@ sub insert {
         'svcnum'  => $self->svcnum,
         'reczone' => '@',
         'recaf'   => 'IN',
-        'rectype' => 'mx',
+        'rectype' => 'MX',
         'recdata' => $mxmachine,
       };
       my $error = $mx->insert;
@@ -287,7 +289,11 @@ Sets any fixed values; see L<FS::part_svc>.
 
 sub check {
   my $self = shift;
-  my $error;
+  my $error =
+    $self->ut_numbern('svcnum')
+    || $self->ut_numbern('catchall')
+  ;
+  return $error if $error;
 
   my $x = $self->setfixed;
   return $x unless ref($x);
@@ -336,6 +342,9 @@ sub check {
   $recref->{action} =~ /^(M|N)$/ or return "Illegal action";
   $recref->{action} = $1;
 
+  my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $recref->{catchall} } );
+  return "Unknown catchall" unless $svc_acct || ! $recref->{catchall};
+
   $self->ut_textn('purpose');
 
 }
@@ -478,7 +487,7 @@ sub submit_internic {
 
 =head1 VERSION
 
-$Id: svc_domain.pm,v 1.8 2001-04-15 13:35:12 ivan Exp $
+$Id: svc_domain.pm,v 1.14 2001-08-17 10:57:23 ivan Exp $
 
 =head1 BUGS
 
@@ -495,7 +504,7 @@ The $recref stuff in sub check should be cleaned up.
 =head1 SEE ALSO
 
 L<FS::svc_Common>, L<FS::Record>, L<FS::Conf>, L<FS::cust_svc>,
-L<FS::part_svc>, L<FS::cust_pkg>, L<FS::SSH>, L<Net::Whois>, L<ssh>,
+L<FS::part_svc>, L<FS::cust_pkg>, L<Net::Whois>, L<ssh>,
 L<dot-qmail>, schema.html from the base documentation, config.html from the
 base documentation.