%if ( scalar(@pkg_class) > 1 && ! $conf->exists('disable-cust-pkg_class') ) {
<& /elements/xmlhttp.html,
'url' => $p.'misc/cust-part_pkg.cgi',
'subs' => [ 'get_part_pkg' ],
&>
<% mt('Package Class') |h %> |
<& /elements/select-cust-pkg_class.html,
'curr_value' => $opt{'classnum'},
'pkg_class' => \@pkg_class,
'onchange' => 'classnum_changed',
&>
|
%}
<% mt('Package') |h %> |
<& /elements/select-cust-part_pkg.html,
'curr_value' => $opt{'curr_value'}, #$pkgpart
'classnum' => $opt{'classnum'},
'cust_main' => $opt{'cust_main'}, #$cust_main
'prospect_main' => $opt{'prospect_main'}, #$prospect_main
'onchange' => 'pkg_changed',
&>
|
<%init>
my $conf = new FS::Conf;
my %opt = @_;
my $pre_label = $opt{'pre_label'} || '';
$pre_label .= ' ' if length($pre_label) && $pre_label =~ /\S$/;
my $cust_main = $opt{'cust_main'};
my $prospect_main = $opt{'prospect_main'};
die "neither cust_main nor prospect_main specified"
unless $cust_main || $prospect_main;
my $agent = $cust_main ? $cust_main->agent : $prospect_main->agent;
#"normal" part_pkg agent virtualization (agentnum or type)
my @part_pkg = qsearch({
'select' => 'DISTINCT classnum',
'table' => 'part_pkg',
'hashref' => { 'disabled' => '' },
'extra_sql' =>
' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql( 'null'=>1 ).
' AND '. FS::part_pkg->agent_pkgs_sql( $agent ),
});
my @pkg_class =
sort { $a->classname cmp $b->classname } #should get a sort order in config
map { $_->pkg_class || new FS::pkg_class { 'classnum' => '',
'classname' => '(none)' }
}
@part_pkg;
%init>