</%doc>
-<% include( '/elements/select-table.html',
- 'table' => 'part_pkg',
- 'name_col' => 'pkg',
- 'empty_label' => 'Select package',
- 'label_callback' => sub { $_[0]->pkgpart. ': '.
- $_[0]->pkg. ' - '.
- $_[0]->comment;
- },
+<% include( '/elements/select-part_pkg.html',
+ 'empty_label' => 'Select package', #? need here in case removed
+ #from select-part_pkg ??
%opt,
)
%>
my $cust_main = $opt{'cust_main'}
or die "cust_main not specified";
-$opt{'records'} = delete $opt{'part_pkg'}
- if $opt{'part_pkg'};
-
-my $extra_sql = $opt{'extra_sql'}.
+$opt{'extra_sql'} .=
' AND 0 < ( SELECT COUNT(*) FROM type_pkgs '.
' WHERE typenum = '. $cust_main->agent->typenum.
' AND type_pkgs.pkgpart = part_pkg.pkgpart )';
-$opt{'records'} ||= [ qsearch({
- 'table' => 'part_pkg',
- 'hashref' => { 'disabled' => '', },
- 'extra_sql' => "$extra_sql ORDER BY pkg",
- #'extra_sql' => $extra_sql,
- #'order_by' => 'ORDER BY pkg',
- })
- ];
-
</%init>
--- /dev/null
+<%doc>
+
+Example:
+
+ include( '/elements/select-part_pkg.html',
+
+ #strongly recommended (you want your forms to be "sticky" on errors, right?)
+ 'curr_value' => 'current_value',
+
+ #opt
+ 'part_pkg' => \@records,
+
+ #select-table.html options
+ )
+
+</%doc>
+
+<% include( '/elements/select-table.html',
+ 'table' => 'part_pkg',
+ 'name_col' => 'pkg',
+ 'empty_label' => 'Select package', #should this be the default?
+ 'label_callback' => sub { shift->pkg_comment },
+ 'hashref' => { 'disabled' => '' },
+ %opt,
+ )
+%>
+<%init>
+
+my( %opt ) = @_;
+
+$opt{'records'} = delete $opt{'part_pkg'}
+ if $opt{'part_pkg'};
+
+</%init>
'table' => $opt{'table'},
'hashref' => ( $opt{'hashref'} || {} ),
'extra_sql' => ( $opt{'extra_sql'} || '' ),
+ 'order_by' => ( $opt{'order_by'} || "ORDER BY $name_col" ),
});
}
-% if ( scalar(@{ $opt{'part_pkg'} }) == 0 ) {
+% if ( $opt{'part_pkg'} && scalar(@{ $opt{'part_pkg'} }) == 0 ) {
+% unless ( $opt{'js_only'} ) {
- <INPUT TYPE="hidden" NAME="<% $opt{'field'} || 'pkgpart' %>" VALUE="">
+ <INPUT TYPE="hidden" NAME="<% $opt{'field'} || 'pkgpart' %>" VALUE="">
+% }
+%
% } else {
+%
+% unless ( $opt{'js_only'} ) {
- <TR>
- <TD ALIGN="right"><% $opt{'label'} || 'Package definition' %></TD>
- <TD>
- <% include( '/elements/select-table.html',
- 'table' => 'part_pkg',
- 'name_col' => 'pkg',
- 'multiple' => 1,
- #N/A 'empty_label' => '(none)',
- %opt,
- )
- %>
- </TD>
- </TR>
+ <% include('tr-td-label.html', %opt) %>
+ <TD <% $cell_style %>>
-% }
+% }
+%
+ <% include( '/elements/select-part_pkg.html', %opt ) %>
+%
+% unless ( $opt{'js_only'} ) {
+
+ </TD>
+ </TR>
+% }
+%
+% }
<%init>
my( %opt ) = @_;
-$opt{'part_pkg'} ||= [ qsearch( 'part_pkg', {} ) ]; # { disabled=>'' } )
+my $cell_style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
+
+$opt{'label'} ||= 'Package definition';
+
+#taken care of (better) in select-part_pkg now (is there anything using this
+# that needs to override the disabed=>'' ??)
+#$opt{'part_pkg'} ||= [ qsearch( 'part_pkg', {} ) ]; # { disabled=>'' } )
</%init>