# 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 ) {
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;
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')
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 })
$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');
--- /dev/null
+<%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>
<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) %>
<% 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,
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 );
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>
<BR>
+% if ( $curuser->access_right('Qualify service') ) {
+<% include( '/elements/popup_link-prospect_main.html',
+ 'action' => $p. 'misc/qual.html',
+ 'label' => 'New 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>
<% 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 ) %>