load billing events faster, RT#21572
[freeside.git] / httemplate / elements / select-part_pkg.html
1 <%doc>
2
3 Example:
4
5   include( '/elements/select-part_pkg.html',
6
7     #strongly recommended (you want your forms to be "sticky" on errors, right?)
8     'curr_value' => 'current_value',
9   
10     #opt
11     'part_pkg'   => \@records,
12
13     #select-table.html options
14   )
15
16 </%doc>
17
18 <& /elements/select-table.html,
19      'table'          => 'part_pkg',
20      'agent_virt'     => 1,
21      'agent_null'     => 1,
22      'name_col'       => 'pkg',
23      'empty_label'    => 'Select package', #should this be the default?
24      'label_callback' => $opt{'label_callback'} || sub { shift->pkg_comment_only },
25      'hashref'        => \%hash,
26      %opt,
27 &>
28 <%init>
29  
30 my( %opt ) = @_;
31
32 $opt{'records'} = delete $opt{'part_pkg'}
33   if $opt{'part_pkg'};
34
35 my %hash = ();
36 $hash{'disabled'} = '' unless $opt{'showdisabled'};
37
38 if ( exists($opt{'classnum'}) && defined($opt{'classnum'}) ) {
39   if ( $opt{'classnum'} > 0 ) {
40     $hash{'classnum'} = $opt{'classnum'};
41   } elsif ( $opt{'classnum'} eq '' || $opt{'classnum'} == 0 ) {
42     $hash{'classnum'} = '';
43   } #else -1 or not specified, all classes, so don't set classnum
44 }
45
46 $opt{'extra_sql'} .= ( keys(%hash) ? ' AND ' : ' WHERE ' ).
47                      FS::part_pkg->curuser_pkgs_sql;
48
49 </%init>