%init>
my %opt = @_;
my $svcdb = $opt{table};
my $field = $opt{field} || 'svcnum';
my $id = $opt{id} || $opt{field};
my $curr_value = [ split(',', $opt{curr_value} || '') ];
my $label = $opt{name_col} || 'label';
# cut-down, jquerified version of select-tiered
# XXX do we need to agent-virt this? edit/part_svc is Configuration-access.
my @part_svc = qsearch('part_svc', {
disabled => '',
svcdb => $svcdb
});
my %labels; # service labels, of some kind
my %values; # svcnums
my (@all_l, @all_v);
foreach my $part_svc (@part_svc) {
my (@l, @v);
foreach my $svc_x (qsearch({
'table' => 'cust_svc',
'addl_from' => " JOIN $svcdb USING (svcnum)",
'select' => "$svcdb.*, cust_svc.svcpart",
'hashref' => { 'svcpart' => $part_svc->svcpart },
}))
{
push @l, $svc_x->$label;
push @all_l, $svc_x->$label;
push @v, $svc_x->svcnum;
push @all_v, $svc_x->svcnum;
}
$labels{ $part_svc->svcpart } = \@l;
$values{ $part_svc->svcpart } = \@v;
}
$labels{ '' } = \@all_l;
$values{ '' } = \@all_v;
%init>
<& /elements/select-table.html,
'table' => 'part_svc',
'records' => \@part_svc,
'id' => $id.'_svcpart',
'name_col' => 'svc',
'empty_label' => 'any',
'curr_value' => '',
'field' => $id.'_svcpart', # avoid confusion with any other field
&>
<& /elements/select.html,
%opt,
'field' => $field,
'id' => $id,
&>