diff options
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/part_export/ikano.pm | 51 | ||||
-rw-r--r-- | FS/FS/qual.pm | 15 |
2 files changed, 53 insertions, 13 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 |