This commit was generated by cvs2svn to compensate for changes in r9232,
[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 <% include( '/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' => sub { shift->pkg_comment },
25               'hashref'        => \%hash,
26               'extra_option_attributes' => [ 'can_discount' ],
27               %opt,
28           )
29 %>
30 <%init>
31  
32 my( %opt ) = @_;
33
34 $opt{'records'} = delete $opt{'part_pkg'}
35   if $opt{'part_pkg'};
36
37 my %hash = ();
38 $hash{'disabled'} = '' unless $opt{'showdisabled'};
39
40 if ( exists($opt{'classnum'}) && defined($opt{'classnum'}) ) {
41   if ( $opt{'classnum'} > 0 ) {
42     $hash{'classnum'} = $opt{'classnum'};
43   } elsif ( $opt{'classnum'} eq '' || $opt{'classnum'} == 0 ) {
44     $hash{'classnum'} = '';
45   } #else -1 or not specified, all classes, so don't set classnum
46 }
47
48 $opt{'extra_sql'} .= ( keys(%hash) ? ' AND ' : ' WHERE ' ).
49                      FS::part_pkg->curuser_pkgs_sql;
50
51 </%init>