summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/cust_main.pm61
-rw-r--r--FS/FS/prospect_main.pm15
-rwxr-xr-xhttemplate/edit/cust_main.cgi18
-rwxr-xr-xhttemplate/edit/process/cust_main.cgi6
-rw-r--r--httemplate/view/cust_main/contacts.html2
-rw-r--r--httemplate/view/cust_main/contacts_new.html22
6 files changed, 103 insertions, 21 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index b333aa253..973b5b837 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -67,6 +67,7 @@ use FS::agent_payment_gateway;
use FS::banned_pay;
use FS::cust_main_note;
use FS::cust_attachment;
+use FS::contact;
# 1 is mostly method/subroutine entry and options
# 2 traces progress of some operations
@@ -368,7 +369,8 @@ invoicing_list destination to the newly-created svc_acct. Here's an example:
$cust_main->insert( {}, [ $email, 'POST' ] );
-Currently available options are: I<depend_jobnum>, I<noexport> and I<tax_exemption>.
+Currently available options are: I<depend_jobnum>, I<noexport>,
+I<tax_exemption> and I<prospectnum>.
If I<depend_jobnum> is set, all provisioning jobs will have a dependancy
on the supplied jobnum (they will not run until the specific job completes).
@@ -382,6 +384,8 @@ the B<reexport> method.)
The I<tax_exemption> option can be set to an arrayref of tax names.
FS::cust_main_exemption records will be created and inserted.
+If I<prospectnum> is set, moves contacts and locations from that prospect.
+
=cut
sub insert {
@@ -480,16 +484,41 @@ sub insert {
}
}
- if ( $invoicing_list ) {
- $error = $self->check_invoicing_list( $invoicing_list );
+ my $prospectnum = delete $options{'prospectnum'};
+ if ( $prospectnum ) {
+
+ warn " moving contacts and locations from prospect $prospectnum\n"
+ if $DEBUG > 1;
+
+ my $prospect_main =
+ qsearchs('prospect_main', { 'prospectnum' => $prospectnum } );
+ unless ( $prospect_main ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "Unknown prospectnum $prospectnum";
+ }
+ $prospect_main->custnum($self->custnum);
+ $prospect_main->disabled('Y');
+ my $error = $prospect_main->replace;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
- #return "checking invoicing_list (transaction rolled back): $error";
return $error;
}
- $self->invoicing_list( $invoicing_list );
- }
+ my @contact = $prospect_main->contact;
+ my @cust_location = $prospect_main->cust_location;
+ my @qual = $prospect_main->qual;
+
+ foreach my $r ( @contact, @cust_location, @qual ) {
+ $r->prospectnum('');
+ $r->custnum($self->custnum);
+ my $error = $r->replace;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
+ }
warn " setting cust_main_exemption\n"
if $DEBUG > 1;
@@ -2033,6 +2062,18 @@ sub cust_location {
qsearch('cust_location', { 'custnum' => $self->custnum } );
}
+=item cust_contact
+
+Returns all contacts (see L<FS::contact>) for this customer.
+
+=cut
+
+#already used :/ sub contact {
+sub cust_contact {
+ my $self = shift;
+ qsearch('contact', { 'custnum' => $self->custnum } );
+}
+
=item unsuspend
Unsuspends all unflagged suspended packages (see L</unflagged_suspended_pkgs>
@@ -2216,9 +2257,9 @@ sub notes {
$orderby = "CLASSNUM ASC, $orderby" if $orderby_classnum;
qsearch( 'cust_main_note',
{ 'custnum' => $self->custnum },
- '',
- "ORDER BY $orderby",
- );
+ '',
+ "ORDER BY $orderby",
+ );
}
=item agent
@@ -4696,7 +4737,7 @@ sub _agent_plandata {
" ORDER BY
CASE WHEN part_event_condition_option.optionname IS NULL
THEN -1
- ELSE ". FS::part_event::Condition->age2seconds_sql('part_event_condition_option.optionvalue').
+ ELSE ". FS::part_event::Condition->age2seconds_sql('part_event_condition_option.optionvalue').
" END
, part_event.weight".
" LIMIT 1"
diff --git a/FS/FS/prospect_main.pm b/FS/FS/prospect_main.pm
index 079ad2561..5a4048f51 100644
--- a/FS/FS/prospect_main.pm
+++ b/FS/FS/prospect_main.pm
@@ -8,6 +8,7 @@ use FS::Record qw( dbh qsearch ); #qsearchs );
use FS::agent;
use FS::cust_location;
use FS::contact;
+use FS::qual;
$DEBUG = 0;
@@ -221,7 +222,7 @@ sub name {
my $contact = ($self->contact)[0]; #first contact? good enough for now
return $contact->line if $contact;
- $self->prospectnum;
+ 'Prospect #'. $self->prospectnum;
}
=item contact
@@ -246,6 +247,18 @@ sub cust_location {
qsearch( 'cust_location', { 'prospectnum' => $self->prospectnum } );
}
+=item qual
+
+Returns the qualifications (see L<FS::qual>) associated with this prospect.
+
+=cut
+
+sub qual {
+ my $self = shift;
+ qsearch( 'qual', { 'prospectnum' => $self->prospectnum } );
+}
+
+
=item search HASHREF
(Class method)
diff --git a/httemplate/edit/cust_main.cgi b/httemplate/edit/cust_main.cgi
index d4217bbcc..61d92b998 100755
--- a/httemplate/edit/cust_main.cgi
+++ b/httemplate/edit/cust_main.cgi
@@ -194,6 +194,8 @@ function samechanged(what) {
% }
+<INPUT TYPE="hidden" NAME="locationnum" VALUE="<% $locationnum %>">
+
<INPUT TYPE="hidden" NAME="usernum" VALUE="<% $cust_main->usernum %>">
%# cust_main/bottomfixup.js
@@ -241,6 +243,7 @@ my($username, $password, $popnum, $saved_domsvc) = ( '', '', 0, 0 ); #svc_acct
my %svc_phone = ();
my %svc_dsl = ();
my $prospectnum = '';
+my $locationnum = '';
if ( $cgi->param('error') ) {
@@ -260,8 +263,12 @@ if ( $cgi->param('error') ) {
$stateid = $cust_main->stateid; # don't mask an entered value on errors
$payinfo = $cust_main->payinfo; # don't mask an entered value on errors
+ $prospectnum = $cgi->param('prospectnum') || '';
+
$pkgpart_svcpart = $cgi->param('pkgpart_svcpart') || '';
+ $locationnum = $cgi->param('locationnum') || '';
+
#svc_acct
$username = $cgi->param('username');
$password = $cgi->param('_password');
@@ -334,11 +341,7 @@ if ( $cgi->param('error') ) {
my $contact = $contacts[0];
$cust_main->first( $contact->first );
$cust_main->set( 'last', $contact->get('last') );
- #XXX contact phone numbers
-
- #XXX additional/all contacts -> alas (notes for now? add add'l contact support?)
-
- #XXX move all contacts and locations
+ #contact phone numbers?
#location -> address (all prospect quals have location, right?)
my $cust_location = $qual->cust_location;
@@ -346,9 +349,10 @@ if ( $cgi->param('error') ) {
$cust_main->$_( $cust_location->$_ )
foreach qw( address1 address2 city county state zip country geocode );
- #pkgpart handled by lock_pkgpart below
+ #locationnum -> package order
+ $locationnum = $qual->locationnum;
- #XXX locationnum -> package order
+ #pkgpart handled by lock_pkgpart below
#service telephone & vendor_qual_id -> svc_dsl
$svc_dsl{$_} = $qual->$_
diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi
index c43ffa30e..3fe7c3987 100755
--- a/httemplate/edit/process/cust_main.cgi
+++ b/httemplate/edit/process/cust_main.cgi
@@ -159,7 +159,8 @@ if ( $new->custnum eq '' ) {
$cust_pkg = new FS::cust_pkg ( {
#later 'custnum' => $custnum,
- 'pkgpart' => $pkgpart,
+ 'pkgpart' => $pkgpart,
+ 'locationnum' => scalar($cgi->param('locationnum')),
} );
#$error ||= $cust_pkg->check;
@@ -226,7 +227,8 @@ if ( $new->custnum eq '' ) {
tie my %hash, 'Tie::RefHash';
%hash = ( $cust_pkg => [ $svc ] ) if $cust_pkg;
$error ||= $new->insert( \%hash, \@invoicing_list,
- 'tax_exemption' => \@tax_exempt,
+ 'tax_exemption'=> \@tax_exempt,
+ 'prospectnum' => scalar($cgi->param('prospectnum')),
);
my $conf = new FS::Conf;
diff --git a/httemplate/view/cust_main/contacts.html b/httemplate/view/cust_main/contacts.html
index e91af54e6..a86c35cdd 100644
--- a/httemplate/view/cust_main/contacts.html
+++ b/httemplate/view/cust_main/contacts.html
@@ -96,7 +96,7 @@
<BR>
% }
% }
-
+<% include('contacts_new.html', $cust_main) %>
<%once>
my $daytime_label = FS::Msgcat::_gettext('daytime') =~ /^(daytime)?$/
diff --git a/httemplate/view/cust_main/contacts_new.html b/httemplate/view/cust_main/contacts_new.html
new file mode 100644
index 000000000..bd812c7e7
--- /dev/null
+++ b/httemplate/view/cust_main/contacts_new.html
@@ -0,0 +1,22 @@
+% if ( @contacts ) {
+<BR>
+Contacts
+<% ntable("#cccccc",2) %>
+% foreach my $contact ( @contacts ) {
+ <TR>
+ <TD ALIGN="right">Contact</TD>
+ <TD BGCOLOR="#FFFFFF"><% $contact->line %></TD>
+ </TR>
+% }
+</TABLE>
+
+% }
+
+<%init>
+
+my( $cust_main ) = @_;
+#my $conf = new FS::Conf;
+
+my @contacts = $cust_main->cust_contact;
+
+</%init>