[freeside-commits] freeside/httemplate/elements select-table.html,
NONE, 1.1 select-agent.html, 1.1, 1.2 select-pkg_class.html,
NONE, 1.1 tr-select-pkg_class.html, NONE, 1.1
Ivan,,,
ivan at wavetail.420.am
Fri Apr 21 17:58:42 PDT 2006
Update of /home/cvs/cvsroot/freeside/httemplate/elements
In directory wavetail:/tmp/cvs-serv26322/httemplate/elements
Modified Files:
select-agent.html
Added Files:
select-table.html select-pkg_class.html
tr-select-pkg_class.html
Log Message:
start of package class web UI (add/edit package classes, package class selection in package def edit)
--- NEW FILE: tr-select-pkg_class.html ---
<%
my( $classnum, %opt ) = @_;
my @pkg_class;
if ( $opt{'pkg_class'} ) {
@pkg_class = @{ $opt{'pkg_class'} };
} else {
@pkg_class = qsearch( 'pkg_class', {} ); # { disabled=>'' } );
}
%>
<% if ( scalar(@pkg_class) == 0 ) { %>
<INPUT TYPE="hidden" NAME="classnum" VALUE="">
<% } else { %>
<TR>
<TD ALIGN="right"><%= $opt{'label'} || 'Package class' %></TD>
<TD>
<%= include( '/elements/select-pkg_class.html', $classnum,
'pkg_class' => \@pkg_class,
)
%>
</TD>
</TR>
<% } %>
--- NEW FILE: select-pkg_class.html ---
<%
my( $classnum, %opt ) = @_;
my %select_opt = ();
$select_opt{'records'} = $opt{'pkg_class'}
if $opt{'pkg_class'};
%><%= include( '/elements/select-table.html',
'table' => 'pkg_class',
'name_col' => 'classname',
'value' => $classnum,
'empty_label' => '(none)',
#'hashref' => { 'disabled' => '' },
#%select_opt,
)
%>
--- NEW FILE: select-table.html ---
<%
##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' => {},
# 'records' => \@records, #instead of hashref
my( %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( $opt{'table'}, ( $opt{'hashref'} || {} ) );
}
%>
<SELECT NAME="<%= $key %>">
<OPTION VALUE=""><%= $opt{'empty_label'} || 'all' %></OPTION>
<% 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>
Index: select-agent.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-agent.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- select-agent.html 22 Dec 2005 04:01:17 -0000 1.1
+++ select-agent.html 22 Apr 2006 00:58:39 -0000 1.2
@@ -1,24 +1,16 @@
<%
my( $agentnum, %opt ) = @_;
- my @agents;
- if ( $opt{'agents'} ) {
- @agents = @{ $opt{'agents'} };
- } else {
- @agents = qsearch( 'agent', { disabled=>'' } );
- }
+ my %select_opt = ();
+ $select_opt{'records'} = $opt{'agents'}
+ if $opt{'agents'};
+%><%= include( '/elements/select-table.html',
+ 'table' => 'agent',
+ 'name_col' => 'agent',
+ 'value' => $agentnum,
+ 'empty_label' => 'all',
+ 'hashref' => { 'disabled' => '' },
+ %select_opt,
+ )
%>
-
-<SELECT NAME="agentnum">
-
- <OPTION VALUE="">all</OPTION>
-
- <% foreach my $agent ( sort { $a->agent cmp $b->agent } @agents ) { %>
-
- <OPTION VALUE="<%= $agent->agentnum %>"<%= $agentnum == $agent->agentnum ? ' SELECTED' : '' %>><%= $agent->agent %>
-
- <% } %>
-
-</SELECT>
-
More information about the freeside-commits
mailing list