[freeside-commits] freeside/httemplate/elements
select-part_referral.html, 1.2, 1.3 select-table.html, 1.5,
1.6 tr-select-pkg_class.html, 1.3, 1.4 select-pkg_class.html,
1.3, 1.4
Ivan,,,
ivan at wavetail.420.am
Wed Dec 20 01:49:10 PST 2006
Update of /home/cvs/cvsroot/freeside/httemplate/elements
In directory wavetail:/tmp/cvs-serv22977/httemplate/elements
Modified Files:
select-part_referral.html select-table.html
tr-select-pkg_class.html select-pkg_class.html
Log Message:
add ability to disable package classes
Index: select-pkg_class.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-pkg_class.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- select-pkg_class.html 23 Aug 2006 22:25:38 -0000 1.3
+++ select-pkg_class.html 20 Dec 2006 09:49:08 -0000 1.4
@@ -1,4 +1,3 @@
-%
% my( $classnum, %opt ) = @_;
%
% $opt{'records'} = delete $opt{'pkg_class'}
@@ -6,13 +5,12 @@
%
% #warn "***** select-pkg-class: \n". Dumper(%opt);
%
-%
<% include( '/elements/select-table.html',
'table' => 'pkg_class',
'name_col' => 'classname',
'value' => $classnum,
'empty_label' => '(none)',
- #'hashref' => { 'disabled' => '' },
+ 'hashref' => { 'disabled' => '' },
%opt,
)
%>
Index: tr-select-pkg_class.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/tr-select-pkg_class.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- tr-select-pkg_class.html 23 Aug 2006 22:25:38 -0000 1.3
+++ tr-select-pkg_class.html 20 Dec 2006 09:49:08 -0000 1.4
@@ -1,16 +1,14 @@
-%
% my( $classnum, %opt ) = @_;
%
-% $opt{'pkg_class'} ||= [ qsearch( 'pkg_class', {} ) ]; # { disabled=>'' } )
+% $opt{'pkg_class'} ||= [ qsearch( 'pkg_class', { disabled=>'' } ) ];
%
% #warn "***** tr-select-pkg-class: \n". Dumper(%opt);
%
% if ( scalar(@{ $opt{'pkg_class'} }) == 0 ) {
-
<INPUT TYPE="hidden" NAME="classnum" VALUE="">
-% } else {
+% } else {
<TR>
<TD ALIGN="right"><% $opt{'label'} || 'Package class' %></TD>
@@ -18,5 +16,5 @@
<% include( '/elements/select-pkg_class.html', $classnum, %opt ) %>
</TD>
</TR>
-% }
+% }
Index: select-part_referral.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-part_referral.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- select-part_referral.html 23 Aug 2006 22:25:38 -0000 1.2
+++ select-part_referral.html 20 Dec 2006 09:49:08 -0000 1.3
@@ -12,7 +12,7 @@
'empty_label' => 'Select advertising source',
'hashref' => { 'disabled' => '' },
'extra_sql' => ' AND '.
- FS::part_referral->all_part_referral(1),
+ FS::part_referral->acl_agentnum_sql(1),
%opt,
)
%>
Index: select-table.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-table.html,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- select-table.html 23 Aug 2006 22:25:38 -0000 1.5
+++ select-table.html 20 Dec 2006 09:49:08 -0000 1.6
@@ -1,65 +1,77 @@
-%
-%
-% ##required
-% # 'table' => 'table_name',
-% # 'name_col' => 'name_column',
-% #
-% ##strongly recommended (you want your forms to be "sticky" on errors, right?)
-% # 'value' => 'current_value',
-% #
-% ##opt
-% # 'empty_label' => '', #better specify it though, the default might change
-% # 'hashref' => {},
-% # 'extra_sql' => '',
-% # 'records' => \@records, #instead of hashref
-% # 'pre_options' => [ 'value' => 'option' ], #before normal options
-% # 'element_name' => '', #HTML element name, defaults to the name of
-% # # the primary key column
-% # 'element_etc' => '', #additional attributes (i.e. "DISABLED") for the
-% # #<SELECT> element
-%
-% my( %opt ) = @_;
-%
-% #warn "***** select-table: \n". Dumper(%opt);
-%
-% my $key = dbdef->table($opt{'table'})->primary_key; #? $opt{'primary_key'} ||
-%
-% my $name_col = $opt{'name_col'};
-%
-% my @records = ();
-% if ( $opt{'records'} ) {
-% @records = @{ $opt{'records'} };
-% } else {
-% @records = qsearch( {
-% 'table' => $opt{'table'},
-% 'hashref' => ( $opt{'hashref'} || {} ),
-% 'extra_sql' => ( $opt{'extra_sql'} || '' ),
-% });
-% }
-%
-% my @pre_options = $opt{'pre_options'} ? @{ $opt{'pre_options'} } : ();
-%
-%
-
-
<SELECT NAME="<% $opt{'element_name'} || $key %>" <% $opt{'element_etc'} %>>
+
% while ( @pre_options ) {
<OPTION VALUE="<% shift(@pre_options) %>"><% shift(@pre_options) %>
-% }
+% }
<OPTION VALUE=""><% $opt{'empty_label'} || 'all' %>
-% foreach my $record ( sort { $a->$name_col() cmp $b->$name_col() }
-% @records
-% )
-% {
-%
+% foreach my $record ( sort { $a->$name_col() cmp $b->$name_col() } @records ) {
<OPTION VALUE="<% $record->$key() %>"<% $opt{'value'} == $record->$key() ? ' SELECTED' : '' %>><% $record->$name_col() %>
-% }
+% }
</SELECT>
+<%init>
+
+##required
+# 'table' => 'table_name',
+# 'name_col' => 'name_column',
+#
+##strongly recommended (you want your forms to be "sticky" on errors, right?)
+# 'value' => 'current_value',
+#
+##opt
+# 'empty_label' => '', #better specify it though, the default might change
+# 'hashref' => {},
+# 'extra_sql' => '',
+# 'records' => \@records, #instead of hashref
+# 'pre_options' => [ 'value' => 'option' ], #before normal options
+# 'element_name' => '', #HTML element name, defaults to the name of
+# # the primary key column
+# 'element_etc' => '', #additional attributes (i.e. "DISABLED") for the
+# #<SELECT> element
+# 'debug' => 0, #set true to enable
+
+my( %opt ) = @_;
+
+warn "elements/select-table.html: \n". Dumper(%opt)
+ if exists $opt{debug} && $opt{debug};
+
+my $key = dbdef->table($opt{table})->primary_key; #? $opt{primary_key} ||
+
+my $name_col = $opt{name_col};
+
+$opt{hashref} ||= {};
+my @records = ();
+if ( $opt{records} ) {
+ @records = @{ $opt{records} };
+} else {
+ @records = qsearch( {
+ 'table' => $opt{table},
+ 'hashref' => $opt{hashref},
+ 'extra_sql' => ( $opt{extra_sql} || '' ),
+ });
+}
+
+unless ( ! $opt{value}
+ or ! exists( $opt{hashref}->{disabled} ) #??
+ or grep { $opt{value} == $_->$key() } @records
+ ) {
+ delete $opt{hashref}->{disabled};
+ $opt{hashref}->{$key} = $opt{value};
+ my $record = qsearchs( {
+ 'table' => $opt{table},
+ 'hashref' => $opt{hashref},
+ 'extra_sql' => ( $opt{extra_sql} || '' ),
+ });
+ push @records, $record if $record;
+}
+
+my @pre_options = $opt{pre_options} ? @{ $opt{pre_options} } : ();
+
+</%init>
More information about the freeside-commits
mailing list