optimize package list on order new package, RT#39822
[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{'select'} = 'part_pkg.*, setup_option.optionvalue AS _setup_fee,
47                               recur_option.optionvalue AS _recur_fee'
48   unless $opt{'select'};
49 $opt{'addl_from'} .= FS::part_pkg->join_options_sql;
50
51 $opt{'extra_sql'} .= ( keys(%hash) ? ' AND ' : ' WHERE ' ).
52                      FS::part_pkg->curuser_pkgs_sql;
53
54 </%init>