- $svc_acct = new FS::svc_acct ( {
- 'svcpart' => $svcpart,
- 'username' => $cgi->param('username'),
- '_password' => $cgi->param('_password'),
- 'popnum' => $cgi->param('popnum'),
- } );
-
- my $y = $svc_acct->setdefault; # arguably should be in new method
- $error ||= $y unless ref($y);
- #and just in case you were silly
- $svc_acct->svcpart($svcpart);
- $svc_acct->username($cgi->param('username'));
- $svc_acct->_password($cgi->param('_password'));
- $svc_acct->popnum($cgi->param('popnum'));
-
- $error ||= $svc_acct->check;
-
- } elsif ( $cgi->param('username') ) { #good thing to catch
- $error = "Can't assign username without a package!";
+ my $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } );
+ my $svcdb = $part_svc->svcdb;
+
+ if ( $svcdb eq 'svc_acct' ) {
+
+ my %svc_acct = (
+ 'svcpart' => $svcpart,
+ 'username' => scalar($cgi->param('username')),
+ '_password' => scalar($cgi->param('_password')),
+ 'popnum' => scalar($cgi->param('popnum')),
+ );
+ $svc_acct{'domsvc'} = $cgi->param('domsvc')
+ if $cgi->param('domsvc');
+
+ $svc = new FS::svc_acct \%svc_acct;
+
+ #and just in case you were silly
+ $svc->svcpart($svcpart);
+ $svc->username($cgi->param('username'));
+ $svc->_password($cgi->param('_password'));
+ $svc->popnum($cgi->param('popnum'));
+
+ } elsif ( $svcdb eq 'svc_phone' ) {
+
+ my %svc_phone = (
+ 'svcpart' => $svcpart,
+ map { $_ => scalar($cgi->param($_)) }
+ qw( countrycode phonenum sip_password pin phone_name )
+ );
+
+ $svc = new FS::svc_phone \%svc_phone;
+
+ } elsif ( $svcdb eq 'svc_dsl' ) {
+
+ my %svc_dsl = (
+ 'svcpart' => $svcpart,
+ ( map { $_ => scalar($cgi->param("ship_$_")) || scalar($cgi->param($_))}
+ qw( first last company )
+ ),
+ ( map { $_ => scalar($cgi->param($_)) }
+ qw( loop_type phonenum password isp_chg isp_prev vendor_qual_id )
+ ),
+ 'desired_due_date' => time, #XXX enter?
+ 'vendor_order_type' => 'NEW',
+ );
+ $svc = new FS::svc_dsl \%svc_dsl;
+
+ } else {
+ die "$svcdb not handled on new customer yet";
+ }
+
+ #$error ||= $svc_acct->check;
+