summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/part_export/ikano.pm1
-rw-r--r--httemplate/edit/process/qual.cgi35
-rw-r--r--httemplate/elements/popup_link-prospect_main.html42
-rw-r--r--httemplate/misc/qual.html19
-rwxr-xr-xhttemplate/search/qual.cgi4
-rw-r--r--httemplate/view/prospect_main.html16
-rw-r--r--httemplate/view/qual.cgi7
7 files changed, 105 insertions, 19 deletions
diff --git a/FS/FS/part_export/ikano.pm b/FS/FS/part_export/ikano.pm
index d7203af..afed6f4 100644
--- a/FS/FS/part_export/ikano.pm
+++ b/FS/FS/part_export/ikano.pm
@@ -326,6 +326,7 @@ sub qual_html {
# XXX: eventually perhaps this should return both the packages a link to
# order each package and go to the svc prov with the prequal id filled in
+ # but only if cust, not prospect!
my $list = "<B>Qualifying Packages:</B><UL>";
my @part_pkgs = qsearch( 'part_pkg', { 'disabled' => '' } );
foreach my $part_pkg ( @part_pkgs ) {
diff --git a/httemplate/edit/process/qual.cgi b/httemplate/edit/process/qual.cgi
index 789834e..5a4f68b 100644
--- a/httemplate/edit/process/qual.cgi
+++ b/httemplate/edit/process/qual.cgi
@@ -18,15 +18,21 @@ my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied"
unless $curuser->access_right('Qualify service');
-$cgi->param('custnum') =~ /^(\d+)$/
- or die 'illegal custnum '. $cgi->param('custnum');
+# copied from misc/qual.html :(
+$cgi->param('custnum') =~ /^(\d+)$/;
my $custnum = $1;
-my $cust_main = qsearchs({
- 'table' => 'cust_main',
- 'hashref' => { 'custnum' => $custnum },
+$cgi->param('prospectnum') =~ /^(\d+)$/;
+my $prospectnum = $1;
+my $cust_or_prospect = $custnum ? "cust" : "prospect";
+my $table = $cust_or_prospect . "_main";
+my $custnum_or_prospectnum = $custnum ? $custnum : $prospectnum;
+my $cust_main_or_prospect_main = qsearchs({
+ 'table' => $table,
+ 'hashref' => { $cust_or_prospect."num" => $custnum_or_prospectnum },
'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
});
-die 'unknown custnum' unless $cust_main;
+die "neither prospect nor customer specified or found"
+ unless $cust_main_or_prospect_main;
$cgi->param('exportnum') =~ /^(\d+)$/ or die 'illegal exportnum';
my $exportnum = $1;
@@ -45,7 +51,8 @@ my $error = '';
my $cust_location;
if ( $locationnum == -1 ) { # adding a new one
my %location_hash = map { $_ => scalar($cgi->param($_)) }
- qw( custnum address1 address2 city county state zip country geocode );
+ qw( address1 address2 city county state zip country geocode );
+ $location_hash{$cust_or_prospect."num"} = $custnum_or_prospectnum;
$location_hash{location_type} = $cgi->param('location_type')
if $cgi->param('location_type');
$location_hash{location_number} = $cgi->param('location_number')
@@ -57,10 +64,14 @@ if ( $locationnum == -1 ) { # adding a new one
die "Unable to insert cust_location: $error" if $error;
}
elsif ( $locationnum eq '' ) { # default service location
- $cust_location = new FS::cust_location ( {
- $cust_main->location_hash,
- custnum => $custnum,
- } );
+ if ( $custnum ) {
+ $cust_location = new FS::cust_location ( {
+ $cust_main_or_prospect_main->location_hash,
+ custnum => $custnum,
+ } );
+ } elsif ( $prospectnum ) {
+ die "a location must be specified explicitly for prospects";
+ }
}
elsif ( $locationnum != -2 ) { # -2 = address not required for qual
$cust_location = qsearchs('cust_location', { 'locationnum' => $locationnum })
@@ -81,7 +92,7 @@ if ( $locationnum != -2 && $cust_location->locationnum > 0 ) {
$qual = new FS::qual( { locationnum => $cust_location->locationnum } );
}
else { # a cust_main default service address *OR* address not required
- $qual = new FS::qual( { custnum => $custnum } );
+ $qual = new FS::qual( { $cust_or_prospect."num" => $custnum_or_prospectnum } );
}
$qual->phonenum($phonenum) if $phonenum ne '';
$qual->status('N');
diff --git a/httemplate/elements/popup_link-prospect_main.html b/httemplate/elements/popup_link-prospect_main.html
new file mode 100644
index 0000000..cc22e3e
--- /dev/null
+++ b/httemplate/elements/popup_link-prospect_main.html
@@ -0,0 +1,42 @@
+<%doc>
+
+Example:
+
+ include('/elements/init_overlib.html')
+
+ include( '/elements/popup_link-cust_main.html', { #hashref or a list, either way
+
+ #required
+ 'action' => 'content.html', # uri for content of popup which should
+ # be suitable for appending keywords
+ 'label' => 'click me', # text of <A> tag
+ 'cust_main' => $cust_main # a FS::cust_main object
+
+ #strongly recommended (you want a title, right?)
+ 'actionlabel => 'You clicked', # popup title
+
+ #opt
+ 'width' => '540',
+ 'color' => '#ff0000',
+ 'closetext' => 'Go Away', # the value '' removes the link
+ )
+
+</%doc>
+% if ( $params->{'prospect_main'} ) {
+<% include('/elements/popup_link.html', $params ) %>\
+% }
+<%init>
+
+my $params = { 'closetext' => 'Close' };
+
+if (ref($_[0]) eq 'HASH') {
+ $params = { %$params, %{ $_[0] } };
+} else {
+ $params = { %$params, @_ };
+}
+
+$params->{'action'} .=
+ ( $params->{'action'} =~ /\?/ ? ';' : '?' ).
+ 'prospectnum='. $params->{'prospect_main'}->prospectnum;
+
+</%init>
diff --git a/httemplate/misc/qual.html b/httemplate/misc/qual.html
index 298b10a..69a5f8b 100644
--- a/httemplate/misc/qual.html
+++ b/httemplate/misc/qual.html
@@ -4,7 +4,7 @@
<FORM NAME="QualForm" ACTION="<% $p %>edit/process/qual.cgi" METHOD="POST">
-<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main->custnum %>">
+<INPUT TYPE="hidden" NAME="<%$cust_or_prospect%>num" VALUE="<% $custnum_or_prospectnum %>">
<% ntable("#cccccc", 2) %>
@@ -38,7 +38,7 @@
<% include('/elements/tr-select-cust_location.html',
'cgi' => $cgi,
- 'cust_main' => $cust_main,
+ $table => $cust_main_or_prospect_main,
'alt_format' => $conf->exists('qual-alt-address-format') ? 1 : 0,
'is_optional' => 1,
'no_bold' => 1,
@@ -62,13 +62,20 @@ die "access denied"
my $conf = new FS::Conf;
my $date_format = $conf->config('date_format') || '%m/%d/%Y';
-$cgi->param('custnum') =~ /^(\d+)$/ or die "no custnum";
+$cgi->param('custnum') =~ /^(\d+)$/;
my $custnum = $1;
-my $cust_main = qsearchs({
- 'table' => 'cust_main',
- 'hashref' => { 'custnum' => $custnum },
+$cgi->param('prospectnum') =~ /^(\d+)$/;
+my $prospectnum = $1;
+my $cust_or_prospect = $custnum ? "cust" : "prospect";
+my $table = $cust_or_prospect . "_main";
+my $custnum_or_prospectnum = $custnum ? $custnum : $prospectnum;
+my $cust_main_or_prospect_main = qsearchs({
+ 'table' => $table,
+ 'hashref' => { $cust_or_prospect."num" => $custnum_or_prospectnum },
'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
});
+die "neither prospect nor customer specified or found"
+ unless $cust_main_or_prospect_main;
my @exports = grep { $_->can('qual') } qsearch( 'part_export', {} );
my @export_options = ( 0 );
diff --git a/httemplate/search/qual.cgi b/httemplate/search/qual.cgi
index 58e0114..0bb455b 100755
--- a/httemplate/search/qual.cgi
+++ b/httemplate/search/qual.cgi
@@ -73,6 +73,10 @@ my $extra_sql = '';
if ( $cgi->param('custnum') && $cgi->param('custnum') =~ /^(\d+)$/ ) {
$extra_sql = " where custnum = $1 or locationnum in "
. " (select locationnum from cust_location where custnum = $1)";
+} elsif ( $cgi->param('prospectnum')
+ && $cgi->param('prospectnum') =~ /^(\d+)$/ ) {
+ $extra_sql = " where prospectnum = $1 or locationnum in "
+ . " (select locationnum from cust_location where prospectnum = $1)";
}
</%init>
diff --git a/httemplate/view/prospect_main.html b/httemplate/view/prospect_main.html
index 9517e39..f4b2f58 100644
--- a/httemplate/view/prospect_main.html
+++ b/httemplate/view/prospect_main.html
@@ -56,6 +56,22 @@
<BR>
+% if ( $curuser->access_right('Qualify service') ) {
+<% include( '/elements/popup_link-prospect_main.html',
+ 'action' => $p. 'misc/qual.html',
+ 'label' => 'New&nbsp;Qualification',
+ 'actionlabel' => 'New Qualification',
+ 'color' => '#333399',
+ 'prospect_main' => $prospect_main,
+ 'closetext' => 'Close',
+ 'width' => 763,
+ 'height' => 436,
+ )
+%>
+ | <A HREF="<%$p%>search/qual.cgi?prospectnum=<% $prospect_main->prospectnum %>">View Qualifications</A>
+ <BR><BR>
+% }
+
<% ntable("#cccccc") %>
<TR>
diff --git a/httemplate/view/qual.cgi b/httemplate/view/qual.cgi
index ebdc5cf..c440bae 100644
--- a/httemplate/view/qual.cgi
+++ b/httemplate/view/qual.cgi
@@ -4,10 +4,15 @@
<% include( '/elements/small_custview.html', $cust_or_prospect->custnum, '', 1,
"${p}view/cust_main.cgi") %>
- <BR>
+% } elsif ( $cust_or_prospect->get('prospectnum') ) {
+% my $prospectnum = $cust_or_prospect->get('prospectnum');
+% my $link = "${p}view/prospect_main.html?$prospectnum";
+ <A HREF="<%$link%>">Prospect #<%$prospectnum%></A>
% }
+<BR><BR>
+
<B>Qualification #<% $qual->qualnum %></B>
<% ntable("#cccccc", 2) %>
<% include('elements/tr.html', label => 'Status', value => $qual->status_long ) %>