X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fikano.pm;h=153b4a6062a58c2c54efdf25468f1a4ce3a8fb05;hb=4fee4d1074c4a0844292c2204bc0a849f9bf119c;hp=fe645e479e326c7543f6231d34f554adcba8f633;hpb=6568e7bb436d6ac4ae2ec984446e8fc4a999f0af;p=freeside.git diff --git a/FS/FS/part_export/ikano.pm b/FS/FS/part_export/ikano.pm index fe645e479..153b4a606 100644 --- a/FS/FS/part_export/ikano.pm +++ b/FS/FS/part_export/ikano.pm @@ -42,6 +42,21 @@ sub rebless { shift; } sub external_pkg_map { 1; } +sub location_types { + ( + '' => '(None)', + 'APT' => 'Apartment', + 'BLDG' => 'Building', + 'FLR' => 'Floor', + 'LOT' => 'Lot', + 'RM' => 'Room', + 'SLIP' => 'Slip', + 'TRLR' => 'Trailer', + 'UNIT' => 'Unit', + 'WING' => 'Wing', + ); +} + sub dsl_pull { # we distinguish between invalid new data (return error) versus data that # has legitimately changed (may eventually execute hooks; now just update) @@ -258,12 +273,15 @@ sub ikano2fsnote { } ); } +# address always required for Ikano qual, TN optional (assume dry if not given) sub qual { my($self,$qual) = (shift,shift); -# address always required for Ikano qual, TN optional (assume dry if not given) - my %location_hash = $qual->location; - return 'No address provided' unless %location_hash; + my %location_hash = $qual->location_hash; + return 'No address provided' unless keys %location_hash; + + return 'Location kind is required' unless $location_hash{location_kind}; + my $svctn = $qual->phonenum; my $result = $self->ikano_command('PREQUAL', @@ -313,7 +331,7 @@ sub qual { }; } -sub qual_html { +sub qual_result { my($self,$qual) = (shift,shift); my %qual_options = $qual->options; @@ -325,23 +343,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 = "Qualifying Packages:"; - $list; + + $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 ); + } + } + + @filtered_quals; } sub notes_html {