+ #false laziness, copied from FS::cust_pkg::order
+ my %part_pkg;
+ if ( scalar(@agents) == 1 ) {
+ # generate %part_pkg
+ # $part_pkg{$pkgpart} is true iff $custnum may purchase $pkgpart
+ #my($cust_main)=qsearchs('cust_main',{'custnum'=>$custnum});
+ #my($agent)=qsearchs('agent',{'agentnum'=> $cust_main->agentnum });
+ my($agent)=qsearchs('agent',{'agentnum'=> $agentnum });
+
+ my($type_pkgs);
+ foreach $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) {
+ my($pkgpart)=$type_pkgs->pkgpart;
+ $part_pkg{$pkgpart}++;
+ }
+ } else {
+ #can't know (agent not chosen), so, allow all
+ my %typenum;
+ foreach my $agent ( @agents ) {
+ next if $typenum{$agent->typenum}++;
+ foreach my $type_pkgs ( qsearch('type_pkgs',{'typenum'=> $agent->typenum }) ) {
+ my($pkgpart)=$type_pkgs->pkgpart;
+ $part_pkg{$pkgpart}++;
+ }
+ }
+
+ }
+ #eslaf
+