summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2008-04-13 20:35:10 +0000
committerivan <ivan>2008-04-13 20:35:10 +0000
commitc2833f823676e017f2f693364d56d86c49592028 (patch)
tree7bfbaa52c2aaefd23354130774c7e47fe73f2ab5
parent5a50cc44ea44730eb8f286b5063f0446b247381b (diff)
select-table and select-part_pkg updates so we can use select-part_pkg as an edit/elements/edit.html m2 type
-rw-r--r--httemplate/elements/select-cust-part_pkg.html25
-rw-r--r--httemplate/elements/select-part_pkg.html34
-rw-r--r--httemplate/elements/select-table.html1
-rw-r--r--httemplate/elements/tr-select-part_pkg.html44
4 files changed, 66 insertions, 38 deletions
diff --git a/httemplate/elements/select-cust-part_pkg.html b/httemplate/elements/select-cust-part_pkg.html
index 8b446b95d..57da5cd84 100644
--- a/httemplate/elements/select-cust-part_pkg.html
+++ b/httemplate/elements/select-cust-part_pkg.html
@@ -18,14 +18,9 @@ Example:
</%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,
)
%>
@@ -36,21 +31,9 @@ my( %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>
diff --git a/httemplate/elements/select-part_pkg.html b/httemplate/elements/select-part_pkg.html
new file mode 100644
index 000000000..a1d5f40f2
--- /dev/null
+++ b/httemplate/elements/select-part_pkg.html
@@ -0,0 +1,34 @@
+<%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>
diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html
index 5d6c4a82c..7339f362c 100644
--- a/httemplate/elements/select-table.html
+++ b/httemplate/elements/select-table.html
@@ -100,6 +100,7 @@ if ( $opt{'records'} ) {
'table' => $opt{'table'},
'hashref' => ( $opt{'hashref'} || {} ),
'extra_sql' => ( $opt{'extra_sql'} || '' ),
+ 'order_by' => ( $opt{'order_by'} || "ORDER BY $name_col" ),
});
}
diff --git a/httemplate/elements/tr-select-part_pkg.html b/httemplate/elements/tr-select-part_pkg.html
index b6d4d4d9e..db9afd2df 100644
--- a/httemplate/elements/tr-select-part_pkg.html
+++ b/httemplate/elements/tr-select-part_pkg.html
@@ -1,29 +1,39 @@
-% 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>