summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/part_export/ikano.pm51
-rw-r--r--FS/FS/qual.pm15
-rw-r--r--httemplate/edit/process/quick-cust_pkg.cgi22
-rw-r--r--httemplate/edit/svc_dsl.cgi17
-rw-r--r--httemplate/elements/popup_link-cust_main.html4
-rw-r--r--httemplate/elements/tr-select-cust_location.html5
-rw-r--r--httemplate/misc/order_pkg.html5
-rw-r--r--httemplate/view/cust_main/order_pkg_link.html10
-rw-r--r--httemplate/view/qual.cgi36
9 files changed, 146 insertions, 19 deletions
diff --git a/FS/FS/part_export/ikano.pm b/FS/FS/part_export/ikano.pm
index fe645e479..5d8285e6b 100644
--- a/FS/FS/part_export/ikano.pm
+++ b/FS/FS/part_export/ikano.pm
@@ -313,7 +313,7 @@ sub qual {
};
}
-sub qual_html {
+sub qual_result {
my($self,$qual) = (shift,shift);
my %qual_options = $qual->options;
@@ -325,23 +325,52 @@ sub qual_html {
&& $optionvalue ne '' );
}
- # 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 %pkglist = ();
+ my $result = { 'header' => 'Qualifying Packages',
+ 'pkglist' => \%pkglist,
+ };
+
my @part_pkgs = qsearch( 'part_pkg', { 'disabled' => '' } );
foreach my $part_pkg ( @part_pkgs ) {
my %vendor_pkg_ids = $part_pkg->vendor_pkg_ids;
my $externalid = $vendor_pkg_ids{$self->exportnum}
if defined $vendor_pkg_ids{$self->exportnum};
- if ( $externalid ) {
- $list .= "<LI>".$part_pkg->pkgpart.": ".$part_pkg->pkg." - "
- .$part_pkg->comment."</LI>"
- if grep( $_ eq $externalid, @externalids );
+ if ( $externalid && grep( $_ eq $externalid, @externalids )) {
+ $pkglist{$part_pkg->pkgpart} = $part_pkg->pkg." - ".$part_pkg->comment;
+ }
+ }
+
+ $result;
+}
+
+sub quals_by_cust_and_pkg {
+ my($self, $custnum, $pkgpart) = (shift,shift,shift);
+
+ die "invalid custnum or pkgpart"
+ unless ($custnum =~ /^\d+$/ && $pkgpart =~ /^\d+$/);
+
+ my $part_pkg = qsearchs('part_pkg', { 'pkgpart' => $pkgpart } );
+ die "no part_pkg found" unless $part_pkg;
+ my %vendor_pkg_ids = $part_pkg->vendor_pkg_ids;
+ my $external_id = $vendor_pkg_ids{$self->exportnum};
+ die "no vendor package id defined on this package" unless $external_id;
+
+ my $extra_sql = "where custnum = $custnum or locationnum in (select "
+ . "locationnum from cust_location where custnum = $custnum)";
+ my @quals = qsearch( { 'table' => 'qual', 'extra_sql' => $extra_sql, } );
+
+ my @filtered_quals;
+ foreach my $qual ( @quals ) {
+ my %qual_options = $qual->options;
+ my( $optionname, $optionvalue );
+ while (($optionname, $optionvalue) = each %qual_options) {
+ push @filtered_quals, $qual
+ if ( $optionname =~ /^ikano_Network_(\d+)_ProductGroup_(\d+)_Product_(\d+)_ProductCustomId$/
+ && $optionvalue eq $external_id );
}
}
- $list .= "</UL>";
- $list;
+
+ @filtered_quals;
}
sub notes_html {
diff --git a/FS/FS/qual.pm b/FS/FS/qual.pm
index 23a827224..8f5838973 100644
--- a/FS/FS/qual.pm
+++ b/FS/FS/qual.pm
@@ -141,11 +141,22 @@ sub location {
if ( $self->locationnum ) {
my $l = qsearchs( 'cust_location',
{ 'locationnum' => $self->locationnum });
- return $l->location_hash if $l;
+ if ( $l ) {
+ my %loc_hash = $l->location_hash;
+ $loc_hash{locationnum} = $self->locationnum;
+ return %loc_hash;
+ }
}
if ( $self->custnum ) {
my $c = qsearchs( 'cust_main', { 'custnum' => $self->custnum });
- return $c->location_hash if $c;
+
+ if($c) {
+ # always override location_kind as it would never be known in the
+ # case of cust_main "default service address"
+ my %loc_hash = $c->location_hash;
+ $loc_hash{location_kind} = $c->company ? 'B' : 'R';
+ return %loc_hash;
+ }
}
# prospectnum does not imply any particular address! must specify locationnum
diff --git a/httemplate/edit/process/quick-cust_pkg.cgi b/httemplate/edit/process/quick-cust_pkg.cgi
index 599f7607c..704d256e6 100644
--- a/httemplate/edit/process/quick-cust_pkg.cgi
+++ b/httemplate/edit/process/quick-cust_pkg.cgi
@@ -6,12 +6,23 @@
% my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
% ? ''
% : ';show=packages';
+% my $redir_url = popurl(3)
+% ."view/cust_main.cgi?custnum=$custnum$show;fragment=$frag#$frag";
+%
+% # for going right to a provision service after ordering a package
+% if ( $svcpart ) {
+% my $part_svc = qsearchs('part_svc', { 'svcpart' => $svcpart } );
+% if ( $part_svc ) {
+% $redir_url = popurl(3)."edit/".$part_svc->svcdb.".cgi?"
+% ."pkgnum=".$cust_pkg->pkgnum.";svcpart=$svcpart";
+% }
+% }
<% header('Package ordered') %>
<SCRIPT TYPE="text/javascript">
// XXX fancy ajax rebuild table at some point, but a page reload will do for now
// XXX chop off trailing #target and replace... ?
- window.top.location = '<% popurl(3). "view/cust_main.cgi?custnum=$custnum$show;fragment=$frag#$frag" %>';
+ window.top.location = '<% $redir_url %>';
</SCRIPT>
@@ -49,6 +60,13 @@ $cgi->param('discountnum') =~ /^(\-?\d*)$/
or die 'illegal discountnum '. $cgi->param('discountnum');
my $discountnum = $1;
+# for going right to a provision service after ordering a package
+my $svcpart;
+if ( $cgi->param('svcpart') ) {
+ $cgi->param('svcpart') =~ /^(\-?\d*)$/
+ or die 'illegal svcpart '. $cgi->param('svcpart');
+ $svcpart = $1;
+}
my $cust_pkg = new FS::cust_pkg {
'custnum' => $custnum,
@@ -83,6 +101,6 @@ if ( $locationnum == -1 ) {
$opt{'cust_location'} = $cust_location;
}
-my $error = $cust_main->order_pkg( %opt );
+my $error = $cust_main->order_pkg( \%opt );
</%init>
diff --git a/httemplate/edit/svc_dsl.cgi b/httemplate/edit/svc_dsl.cgi
index 9b4d1c77d..48464fbad 100644
--- a/httemplate/edit/svc_dsl.cgi
+++ b/httemplate/edit/svc_dsl.cgi
@@ -95,6 +95,16 @@ my $new_cb = sub {
my $ddd = $cust_pkg->start_date;
$ddd = time unless $ddd;
+ my @quals = $export->quals_by_cust_and_pkg($cust_pkg->cust_main->custnum,$cust_pkg->pkgpart);
+ my @prequalids;
+ my %prequal_labels;
+ foreach my $qual ( @quals ) {
+ my $prequalid = $qual->vendor_qual_id;
+ push @prequalids, $prequalid;
+ $prequal_labels{$prequalid} = "$prequalid - qualification #"
+ .$qual->qualnum;
+ }
+
my @addl_fields = (
{ field => 'loop_type',
type => 'select',
@@ -105,7 +115,12 @@ my $new_cb = sub {
'password',
{ field => 'isp_chg', type => 'checkbox', },
'isp_prev',
- 'vendor_qual_id',
+ { field => 'vendor_qual_id',
+ type => 'select',
+ options => \@prequalids,
+ labels => \%prequal_labels,
+ onchange => 'ikano_vendor_qual_id_changed',
+ },
{ field => 'vendor_order_type',
type => 'hidden',
value => 'NEW' },
diff --git a/httemplate/elements/popup_link-cust_main.html b/httemplate/elements/popup_link-cust_main.html
index 454fcc4c8..78e50e782 100644
--- a/httemplate/elements/popup_link-cust_main.html
+++ b/httemplate/elements/popup_link-cust_main.html
@@ -39,4 +39,8 @@ $params->{'action'} .=
( $params->{'action'} =~ /\?/ ? ';' : '?' ).
'custnum='. $params->{'cust_main'}->custnum;
+$params->{'action'} .= ';pkgpart='.$params->{'pkgpart'} if $params->{'pkgpart'};
+$params->{'action'} .= ';locationnum='.$params->{'locationnum'} if $params->{'locationnum'};
+$params->{'action'} .= ';svcpart='.$params->{'svcpart'} if $params->{'svcpart'};
+
</%init>
diff --git a/httemplate/elements/tr-select-cust_location.html b/httemplate/elements/tr-select-cust_location.html
index fa19405b2..5802f4ec2 100644
--- a/httemplate/elements/tr-select-cust_location.html
+++ b/httemplate/elements/tr-select-cust_location.html
@@ -154,11 +154,16 @@ Example:
<<%$th%> ALIGN="right"><% $opt{'label'} || 'Service&nbsp;location' %></<%$th%>>
<TD COLSPAN=7>
<SELECT NAME="locationnum" onChange="locationnum_changed(this);">
+% if ( !$prospect_main ) {
<OPTION VALUE=""><% $opt{'empty_label'} || '(default service address)' |h %>
+% }
% if ( $opt{'is_optional'} ) {
<OPTION VALUE="-2" <% $locationnum == -2 ? 'SELECTED' : ''%>><% $opt{'optional_label'} || '(not required)' |h %>
% }
% my @locations = $cust_main ? $cust_main->cust_location : ();
+% @locations = qsearch('cust_location',
+% { 'prospectnum' => $prospect_main->prospectnum } )
+% if $prospect_main;
% push @locations, $cust_location
% if !$cust_main && $cust_location && $cust_location->locationnum>0;
% foreach my $loc ( sort $location_sort @locations ) {
diff --git a/httemplate/misc/order_pkg.html b/httemplate/misc/order_pkg.html
index b232debd7..dcbc01636 100644
--- a/httemplate/misc/order_pkg.html
+++ b/httemplate/misc/order_pkg.html
@@ -28,6 +28,9 @@
<FORM NAME="OrderPkgForm" ACTION="<% $p %>edit/process/quick-cust_pkg.cgi" METHOD="POST">
<INPUT TYPE="hidden" NAME="custnum" VALUE="<% $cust_main->custnum %>">
+% if ( $svcpart ) {
+ <INPUT TYPE="hidden" NAME="svcpart" VALUE="<% $svcpart %>">
+% }
<% ntable("#cccccc", 2) %>
<% include('/elements/tr-select-cust-part_pkg.html',
@@ -139,4 +142,6 @@ if( ! $conf->exists('order_pkg-no_start_date') ) {
$start_date = $start_date ? time2str($format, $start_date) : '';
}
+my $svcpart = $cgi->param('svcpart');
+
</%init>
diff --git a/httemplate/view/cust_main/order_pkg_link.html b/httemplate/view/cust_main/order_pkg_link.html
index 30c86a757..2e8b1dac1 100644
--- a/httemplate/view/cust_main/order_pkg_link.html
+++ b/httemplate/view/cust_main/order_pkg_link.html
@@ -1,16 +1,22 @@
<% include( '/elements/popup_link-cust_main.html',
'action' => $p. 'misc/order_pkg.html',
- 'label' => 'Order&nbsp;new&nbsp;package',
+ 'label' => $opt{'label'} || 'Order&nbsp;new&nbsp;package',
'actionlabel' => 'Order new package',
'color' => '#333399',
'cust_main' => $cust_main,
'closetext' => 'Close',
'width' => 763,
'height' => 538,
+ %optional,
)
%>
<%init>
-my($cust_main) = @_;
+my($cust_main, %opt) = @_;
+
+my %optional = ();
+$optional{'pkgpart'} = $opt{'pkgpart'} if $opt{'pkgpart'};
+$optional{'locationnum'} = $opt{'locationnum'} if $opt{'locationnum'};
+$optional{'svcpart'} = $opt{'svcpart'} if $opt{'svcpart'};
</%init>
diff --git a/httemplate/view/qual.cgi b/httemplate/view/qual.cgi
index 8ab0032ad..45f3d2a62 100644
--- a/httemplate/view/qual.cgi
+++ b/httemplate/view/qual.cgi
@@ -28,7 +28,41 @@
<BR><BR>
% if ( $export ) {
-<% $export->qual_html($qual) %>
+% my $qual_result = $export->qual_result($qual);
+% if ($qual_result->{'header'}) {
+ <B><% $qual_result->{'header'} %></B>
+% }
+% if ($qual_result->{'pkglist'}) { # one of the possible formats
+% my $svcpart = '';
+% my $pkglist = $qual_result->{'pkglist'};
+% my $cust_or_prospect = $qual->cust_or_prospect;
+% my $locationnum = '';
+% my %location = $qual->location;
+% if (%location && $location{'locationnum'}) {
+% $locationnum = $location{'locationnum'};
+% }
+ <UL>
+% foreach my $pkgpart ( keys %$pkglist ) {
+% my %opt = ( 'label' => $pkglist->{$pkgpart},
+% 'pkgpart' => $pkgpart,
+% 'locationnum' => $locationnum, );
+% if ( $export->exporttype eq 'ikano' ) {
+% my $pkg_svc = qsearchs('pkg_svc', { 'pkgpart' => $pkgpart,
+% 'primary_svc' => 'Y',
+% } );
+% $opt{'svcpart'} = $pkg_svc->svcpart if $pkg_svc;
+% }
+ <LI>
+% if($cust_or_prospect && $cust_or_prospect->custnum) {
+ <% include('/view/cust_main/order_pkg_link.html', $qual->cust_or_prospect, %opt) %>
+% }
+% else {
+ <% $opt{label} %>
+% }
+ </LI>
+% }
+ </UL>
+% }
% }
<%init>