[freeside-commits] freeside/httemplate/elements checkboxes-table-name.html, 1.2, 1.3 freeside.css, 1.2, 1.3 hidden.html, NONE, 1.1 menu.html, 1.23, 1.24 select-agent.html, 1.6, 1.7 select-agent_type.html, NONE, 1.1 select-cust_main-status.html, NONE, 1.1 select-cust_pkg-status.html, 1.3, 1.4 select-part_referral.html, 1.3, 1.4 select-pkg_class.html, 1.4, 1.5 select-table.html, 1.7, 1.8 selectlayers.html, NONE, 1.1 table-grid.html, 1.4, 1.5 tr-checkbox-multiple.html, NONE, 1.1 tr-checkbox.html, NONE, 1.1 tr-fixed.html, NONE, 1.1 tr-freq.html, NONE, 1.1 tr-input-money.html, NONE, 1.1 tr-input-text.html, NONE, 1.1 tr-password.html, NONE, 1.1 tr-select-agent.html, 1.4, 1.5 tr-select-agent_type.html, NONE, 1.1 tr-select-cust_main-status.html, NONE, 1.1 tr-select-cust_pkg-status.html, 1.2, 1.3 tr-select-invoice_template.html, NONE, 1.1 tr-select-part_pkg.html, NONE, 1.1 tr-select-part_referral.html, 1.2, 1.3 tr-select-pkg_class.html, 1.4, 1.5 tr-select-reason.html, 1.3, 1.4 tr-select-taxclass.html, 1.1, 1.2 tr-select.html, NONE, 1.1 tr-selectlayers.html, NONE, 1.1 tr-selectmultiple-part_pkg.html, 1.2, 1.3 tr-td-label.html, NONE, 1.1 tr-title.html, NONE, 1.1

Ivan,,, ivan at wavetail.420.am
Wed Aug 1 15:25:12 PDT 2007


Update of /home/cvs/cvsroot/freeside/httemplate/elements
In directory wavetail:/tmp/cvs-serv23435/httemplate/elements

Modified Files:
	checkboxes-table-name.html freeside.css menu.html 
	select-agent.html select-cust_pkg-status.html 
	select-part_referral.html select-pkg_class.html 
	select-table.html table-grid.html tr-select-agent.html 
	tr-select-cust_pkg-status.html tr-select-part_referral.html 
	tr-select-pkg_class.html tr-select-reason.html 
	tr-select-taxclass.html tr-selectmultiple-part_pkg.html 
Added Files:
	hidden.html select-agent_type.html 
	select-cust_main-status.html selectlayers.html 
	tr-checkbox-multiple.html tr-checkbox.html tr-fixed.html 
	tr-freq.html tr-input-money.html tr-input-text.html 
	tr-password.html tr-select-agent_type.html 
	tr-select-cust_main-status.html 
	tr-select-invoice_template.html tr-select-part_pkg.html 
	tr-select.html tr-selectlayers.html tr-td-label.html 
	tr-title.html 
Log Message:
event refactor, landing on HEAD!

Index: select-pkg_class.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-pkg_class.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- select-pkg_class.html	20 Dec 2006 09:49:08 -0000	1.4
+++ select-pkg_class.html	1 Aug 2007 22:25:09 -0000	1.5
@@ -1,10 +1,3 @@
-%  my( $classnum, %opt ) = @_;
-%
-%  $opt{'records'} = delete $opt{'pkg_class'}
-%    if $opt{'pkg_class'};
-%
-%  #warn "***** select-pkg-class: \n". Dumper(%opt);
-%
 <% include( '/elements/select-table.html',
                  'table'       => 'pkg_class',
                  'name_col'    => 'classname',
@@ -14,3 +7,12 @@
                  %opt,
              )
 %>
+<%init>
+
+my %opt = @_;
+my $classnum = $opt{'curr_value'} || $opt{'value'};
+
+$opt{'records'} = delete $opt{'pkg_class'}
+  if $opt{'pkg_class'};
+
+</%init>

--- NEW FILE: tr-checkbox.html ---
<% include('tr-td-label.html', @_ ) %>

  <TD <% $style %>>
    <INPUT TYPE  = "checkbox"
           NAME  = "<% $opt{field} %>"
           ID    = "<% $opt{id} %>"
           VALUE = "<% $opt{value} %>"
           <% $opt{curr_value} eq $opt{value} ? ' CHECKED' : '' %>
           <% $onchange %>
    >
  </TD>

</TR>

<%init>

my %opt = @_;

my $onchange = $opt{'onchange'}
                 ? 'onChange="'. $opt{'onchange'}. '(this)"'
                 : '';

my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';

</%init>

Index: tr-select-part_referral.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/tr-select-part_referral.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- tr-select-part_referral.html	23 Aug 2006 22:25:38 -0000	1.2
+++ tr-select-part_referral.html	1 Aug 2007 22:25:10 -0000	1.3
@@ -1,30 +1,35 @@
-%
-%  my( $refnum, %opt ) = @_;
-%
-%  $opt{'part_referrals'} ||=
-%    [ FS::part_referral->all_part_referral( 1 ) ]; #1: include global
-%
-%  my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
-%
-%
 % if ( scalar( @{$opt{'part_referrals'}} ) == 0 ) {
 %     eidiot "You have not created any advertising sources.  You must create at least one advertising source before adding a customer.  Go to ". popurl(2). "browse/part_referral.html and create one or more advertising sources.";
 %   } elsif ( scalar( @{$opt{'part_referrals'}} ) == 1 ) {
-%
 
+     <INPUT TYPE="hidden" NAME="<% $opt{'element_name'} || $opt{'field'} || 'refnum' %>" VALUE="<% $opt{'part_referrals'}->[0]->refnum %>">
 
-     <INPUT TYPE="hidden" NAME="refnum" VALUE="<% $opt{'part_referrals'}->[0]->refnum %>">
 % } else { 
 
-
      <TR>
-       <TH ALIGN="right"><%$r%>Advertising source</TH>
+%      if ( $opt{'label'} ) {
+         <TD ALIGN="right"><% $opt{'label'} %></TD>
+%      } else {
+         <TH ALIGN="right"><%$r%>Advertising source</TH>
+%      }
        <TD>
-         <% include( '/elements/select-part_referral.html', $refnum,
-                        'part_referrals' => $opt{'part_referrals'},
-                    )
+         <% include( '/elements/select-part_referral.html',
+                       'curr_value' => $refnum,
+                       %opt
+                   )
          %>
        </TD>
      </TR>
+
 % } 
+<%init>
 
+my %opt = @_;
+my $refnum = $opt{'curr_value'} || $opt{'value'};
+
+$opt{'part_referrals'} ||=
+  [ FS::part_referral->all_part_referral( 1 ) ]; #1: include global
+
+my $r = qq!<font color="#ff0000">*</font>&nbsp;!;
+
+</%init>

--- NEW FILE: tr-select.html ---
<% include('tr-td-label.html', @_ ) %>

  <TD <% $style %>>

    <SELECT NAME          = "<% $opt{field} %>"
            ID            = "<% $opt{id} %>"
            previousValue = "<% $curr_value %>"
            previousText  = "<% $labels->{$curr_value} || $curr_value %>"
            <% $onchange %>
    >

%   if ( $opt{options} ) {
%
%     foreach my $option ( @{ $opt{options} } ) { #just arrayref for now

        <OPTION VALUE="<% $option %>"
                <% $opt{curr_value} eq $option ? 'SELECTED' : '' %>
        >
          <% $labels->{$option} || $option %>
        </OPTION>

%     }
%
%   } else { #deprecated weird value hashref used only by reason.html
%
%     my $aref = $opt{'value'}->{'values'};
%     my $vkey = $opt{'value'}->{'vcolumn'};
%     my $ckey = $opt{'value'}->{'ccolumn'};
%     foreach my $v (@$aref) {

        <OPTION VALUE="<% $v->$vkey %>"
                <% ($opt{curr_value} eq $v->$vkey) ? 'SELECTED' : '' %>
        >
          <% $v->$ckey %>
        </OPTION>

%     }
%
%   }

    </SELECT>

  </TD>

</TR>

<%init>

my %opt = @_;

my $onchange = $opt{'onchange'}
                 ? 'onChange="'. $opt{'onchange'}. '(this)"'
                 : '';

my $labels = $opt{'option_labels'} || $opt{'labels'};

my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';

my $curr_value = $opt{'curr_value'};

</%init>

--- NEW FILE: tr-td-label.html ---
<TR>

  <TD ALIGN="right" VALIGN="top" STYLE="<% $style %>" ID="<% $opt{label_id} || $opt{id}. '_label0' %>">

    <% $opt{label} %>

  </TD>

<%init>

my %opt = @_;

my $style = 'padding-top: 3px';
$style .= '; '. $opt{'cell_style'}
  if $opt{'cell_style'};

</%init>

Index: tr-select-agent.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/tr-select-agent.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- tr-select-agent.html	23 Aug 2006 22:25:38 -0000	1.4
+++ tr-select-agent.html	1 Aug 2007 22:25:10 -0000	1.5
@@ -1,34 +1,37 @@
-%
-%  my( $agentnum, %opt ) = @_;
-%
-%  my @agents;
-%  if ( $opt{'agents'} ) {
-%    #@agents = @{ $opt{'agents'} };
-%    #here is the agent virtualization
-%    my $agentnums_href = $FS::CurrentUser::CurrentUser->agentnums_href;
-%    @agents = grep $agentnums_href->{$_->agentnum}, @{ $opt{'agents'} };
-%    delete $opt{'agents'};
-%  } else {
-%    @agents = $FS::CurrentUser::CurrentUser->agents;
-%  }
-%
-%
 % if ( scalar(@agents) == 1 ) { 
 
+  <INPUT TYPE="hidden" NAME="<% $opt{'field'} || 'agentnum' %>" VALUE="<% $agents[0]->agentnum %>">
 
-  <INPUT TYPE="hidden" NAME="agentnum" VALUE="<% $agents[0]->agentnum %>">
 % } else { 
 
-
   <TR>
     <TD ALIGN="right"><% $opt{'label'} || 'Agent' %></TD>
     <TD>
-      <% include( '/elements/select-agent.html', $agentnum,
-                     'agents' => \@agents,
+      <% include( '/elements/select-agent.html',
+                     'curr_value' => $agentnum,
+                     'agents'     => \@agents,
                      %opt,
                  )
       %>
     </TD>
   </TR>
+
 % } 
 
+<%init>
+
+my %opt = @_;
+my $agentnum = $opt{'curr_value'} || $opt{'value'};
+
+my @agents;
+if ( $opt{'agents'} ) {
+  #@agents = @{ $opt{'agents'} };
+  #here is the agent virtualization
+  my $agentnums_href = $FS::CurrentUser::CurrentUser->agentnums_href;
+  @agents = grep $agentnums_href->{$_->agentnum}, @{ $opt{'agents'} };
+  delete $opt{'agents'};
+} else {
+  @agents = $FS::CurrentUser::CurrentUser->agents;
+}
+
+</%init>

--- NEW FILE: tr-select-part_pkg.html ---
% if ( scalar(@{ $opt{'part_pkg'} }) == 0 ) { 

  <INPUT TYPE="hidden" NAME="<% $opt{'field'} || 'pkgpart' %>" VALUE="">

% } else { 

  <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>

% } 

<%init>

my( %opt ) = @_;

$opt{'part_pkg'} ||= [ qsearch( 'part_pkg', {} ) ]; # { disabled=>'' } )

</%init>

--- NEW FILE: tr-input-money.html ---
<% include('tr-input-text.html', @_,
             'type'   => 'text',
             'prefix' => $money_char,
             'size'   => 8,
          )
%>
<%once>

my $conf = new FS::Conf;
my $money_char = $conf->config('money_char') || '$';

</%once>


Index: select-part_referral.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-part_referral.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- select-part_referral.html	20 Dec 2006 09:49:08 -0000	1.3
+++ select-part_referral.html	1 Aug 2007 22:25:09 -0000	1.4
@@ -1,10 +1,3 @@
-%
-%  my( $refnum, %opt ) = @_;
-%
-%  $opt{'records'} = delete $opt{'part_referrals'}
-%    if $opt{'part_referrals'};
-%
-%
 <% include( '/elements/select-table.html',
                  'table'       => 'part_referral',
                  'name_col'    => 'referral',
@@ -16,3 +9,12 @@
                  %opt,
              )
 %>
+<%init>
+
+my %opt = @_;
+my $refnum = $opt{'curr_value'} || $opt{'value'};
+
+$opt{'records'} = delete $opt{'part_referrals'}
+  if $opt{'part_referrals'};
+
+</%init>

--- NEW FILE: tr-password.html ---
<% include('tr-input-text.html', @_,
             'type'   => 'password',
          )
%>

--- NEW FILE: select-agent_type.html ---
<% include( '/elements/select-table.html',
                 'table'       => 'agent_type',
                 'name_col'    => 'atype',
                 'value'       => $typenum || '',
                 'empty_label' => 'all',
                 'hashref'     => { 'disabled' => '' },
                 #'extra_sql'   => ' AND '.
                 #                 $FS::CurrentUser::CurrentUser->agentnums_sql.
                 #                 ' ORDER BY agent',
                 %opt,
             )
%>
<%init>

my %opt = @_;
my $typenum = $opt{'curr_value'} || $opt{'value'};

$opt{'records'} = delete $opt{'agent_types'}
  if $opt{'agent_types'};

</%init>

Index: tr-selectmultiple-part_pkg.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/tr-selectmultiple-part_pkg.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- tr-selectmultiple-part_pkg.html	25 Oct 2006 04:51:29 -0000	1.2
+++ tr-selectmultiple-part_pkg.html	1 Aug 2007 22:25:10 -0000	1.3
@@ -1,8 +1,3 @@
-%
-%  my( %opt ) = @_;
-%
-
-
 <TR>
   <TD ALIGN="right"><% $opt{'label'} || 'Packages' %></TD>
   <TD>
@@ -17,3 +12,9 @@
     %>
   </TD>
 </TR>
+
+<%init>
+
+my %opt = @_;
+
+</%init>

Index: select-agent.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-agent.html,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- select-agent.html	29 Dec 2006 21:48:49 -0000	1.6
+++ select-agent.html	1 Aug 2007 22:25:09 -0000	1.7
@@ -1,10 +1,3 @@
-%
-%  my( $agentnum, %opt ) = @_;
-%
-%  $opt{'records'} = delete $opt{'agents'}
-%    if $opt{'agents'};
-%
-%
 <% include( '/elements/select-table.html',
                  'table'       => 'agent',
                  'name_col'    => 'agent',
@@ -17,3 +10,12 @@
                  %opt,
              )
 %>
+<%init>
+
+my %opt = @_;
+my $agentnum = $opt{'curr_value'} || $opt{'value'};
+
+$opt{'records'} = delete $opt{'agents'}
+  if $opt{'agents'};
+
+</%init>

Index: select-cust_pkg-status.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-cust_pkg-status.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- select-cust_pkg-status.html	14 Feb 2007 08:48:35 -0000	1.3
+++ select-cust_pkg-status.html	1 Aug 2007 22:25:09 -0000	1.4
@@ -1,21 +1,30 @@
-<SELECT NAME="status" <% $opt{'onchange'} %>>
+<SELECT NAME="<% $opt{'field'} || 'status' %>"
+        <% $opt{'multiple'} ? 'MULTIPLE' : '' %>
+        <% $onchange %>
+>
 
   <OPTION VALUE="">all
 
 % foreach my $option ( @{ $opt{'statuses'} } ) { 
-       <OPTION VALUE="<% $option %>" <% $option eq $status ? 'SELECTED' : '' %>><% $option %>
+
+    <OPTION VALUE="<% $option %>"
+            <% $option eq $curr_value ? 'SELECTED' : '' %>
+    ><% $option %>
+
 % } 
 
 </SELECT>
+
 <%init>
-  my( $status, %opt ) = @_;
 
-  $opt{'statuses'} ||= [ FS::cust_pkg->statuses() ]; # { disabled=>'' } )
+my %opt = @_;
 
-  if ( exists $opt{'onchange'} && $opt{'onchange'} ) {
-    $opt{'onchange'} = ' onChange="' . $opt{'onchange'}. '"';
-  } else {
-    $opt{'onchange'} = '';
-  }
+$opt{'statuses'} ||= [ FS::cust_pkg->statuses() ]; # { disabled=>'' } )
+
+my $onchange = $opt{'onchange'}
+                 ? 'onChange="'. $opt{'onchange'}. '(this)"'
+                 : '';
+
+my $curr_value = $opt{'curr_value'} || $opt{'value'};
 
 </%init>

--- NEW FILE: tr-input-text.html ---
<% include('tr-td-label.html', @_ ) %>

  <TD <% $style %>>

    <% $opt{'prefix'} %><INPUT TYPE  = "<% $opt{type} || 'text' %>"
                               NAME  = "<% $opt{field} %>"
                               ID    = "<% $opt{id} %>"
                               VALUE = "<% $opt{curr_value} || $opt{value} %>"
                               <% $size %>
                               <% $onchange %>
                        >

  </TD>

</TR>

<%init>

my %opt = @_;

my $onchange = $opt{'onchange'}
                 ? 'onChange="'. $opt{'onchange'}. '(this)"'
                 : '';

my $size = $opt{'size'}
             ? 'SIZE="'. $opt{'size'}. '"'
             : '';

my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';

</%init>

--- NEW FILE: tr-fixed.html ---
<% include('tr-td-label.html', @_ ) %>

  <TD BGCOLOR="#dddddd" <% $style %>><% $opt{'value'} %></TD>

</TR>

<% include('hidden.html', %opt ) %>

<%init>

my %opt = @_;

my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';

</%init>

Index: table-grid.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/table-grid.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- table-grid.html	23 Aug 2006 22:25:38 -0000	1.4
+++ table-grid.html	1 Aug 2007 22:25:09 -0000	1.5
@@ -1,10 +1,3 @@
-%
-%  my %opt = @_;
-%  $opt{cellspacing} ||= 0;
-%  $opt{cellpadding} ||= 0;
-%
-%
-
 <STYLE TYPE="text/css">
 
 .grid table { border: solid; empty-cells: show }
@@ -17,5 +10,16 @@
 
 </STYLE>
 
-<TABLE CLASS="grid" CELLSPACING=<% $opt{cellspacing} %> CELLPADDING=<% $opt{cellpadding} %> BORDER=1 BORDERCOLOR="#000000" STYLE="border: solid 1px black; empty-cells: show">
+<TABLE CLASS="grid" CELLSPACING=<% $opt{cellspacing} %> CELLPADDING=<% $opt{cellpadding} %> BORDER=1 BORDERCOLOR="#000000" <% $opt{bgcolor} %> STYLE="border: solid 1px black; empty-cells: show">
+
+<%init>
+
+my %opt = @_;
+$opt{cellspacing} ||= 0;
+$opt{cellpadding} ||= 0;
+
+$opt{bgcolor} =~ s/^#//;
+$opt{bgcolor} = 'BGCOLOR="#'. $opt{bgcolor}. '"' if length($opt{bgcolor});
+
+</%init>
 

--- NEW FILE: selectlayers.html ---
<%doc>

Example:

  include( '/elements/selectlayers.html',
    'field'        => $key, # SELECT element NAME (passed as form field)
                            # also used as ID and a unique key for layers and
                            # functions
    'curr_value'   => $selected_layer,
    'options'      => [ 'option1', 'option2' ],
    'labels'       => { 'option1' => 'Option 1 Label',
                        'option2' => 'Option 2 Label',
                      },

    #XXX put this handling it its own selectlayers-fields.html element?
    'layer_prefix' => 'prefix_', #optional prefix for fieldnames
    'layer_fields' => [ 'layer'  => [ 'fieldname',
                                      { label => 'fieldname2',
                                        type  => 'text', #implemented:
                                                         # text, money, fixed,
                                                         # hidden, checkbox,
                                                         # checkbox-multiple,
                                                         # select, select-agent,
                                                         # select-pkg_class,
                                                         # select-part_referral,
                                                         # select-table,
                                                         #XXX tbd:
                                                         # more?
                                      },
                                      ...
                                    ],
                        'layer2' => [ 'l2fieldname',
                                      ...
                                    ],

    #current values for layer fields above
    'layer_values' => { 'layer'  => { 'fieldname'  => 'current_value',
                                      'fieldname2' => 'field2value',
                                      ...
                                    },
                        'layer2' => { 'l2fieldname' => 'l2value',
                                      ...
                                    },
                        ...
                      },

    'html_between  => '', #optional HTML displayed between the SELECT and the
                          #layers, scalar or coderef ('field' passed as a param)
    'onchange'     => '', #javascript code run when the SELECT changes
                          # ("what" is the element)
    'js_only'      => 0, #set true to return only the JS portions
    'html_only'    => 0, #set true to return only the HTML portions
  )

</%doc>
% unless ( $opt{html_only} || $opt{js_only} ) {
    <SCRIPT TYPE="text/javascript">
% }
% unless ( $opt{html_only} ) {
      //alert('start function define');
      function <% $key %>changed(what) {

        <% $opt{'onchange'} %>

        var <% $key %>layer = what.options[what.selectedIndex].value;

%       foreach my $layer ( keys %$options ) {

          if (<% $key %>layer == "<% $layer %>" ) {

%           foreach my $not ( grep { $_ ne $layer } keys %$options ) {
%             my $element = "document.getElementById('${key}d$not').style";
              <% $element %>.display = "none";
              <% $element %>.zIndex = 0;
%           }

%           my $element = "document.getElementById('${key}d$layer').style";
            <% $element %>.display = "";
            <% $element %>.zIndex = 1;

          }
%       }

        //<% $opt{'onchange'} %>

      }
      //alert('end function define');
% }
% unless ( $opt{html_only} || $opt{js_only} ) {
    </SCRIPT>
% }
%
% unless ( $opt{js_only} ) {

    <SELECT NAME          = "<% $key %>"
            ID            = "<% $key %>"
            previousValue = "<% $selected %>"
            previousText  = "<% $options{$selected} %>"
            onChange="<% $key %>changed(this);"
    >

%     foreach my $option ( keys %$options ) {

        <OPTION VALUE="<% $option %>"
                <% $option eq $selected ? ' SELECTED' : '' %>
        ><% $options->{$option} %></OPTION>

%     }

    </SELECT>

<% ref($between) ? &{$between}($key) : $between %>

%   foreach my $layer ( keys %$options ) {

      <DIV ID="<% $key %>d<% $layer %>"
           STYLE="<% $layer eq $selected
                       ? 'display: ""  ; z-index: 1'
                       : 'display: none; z-index: 0'
                  %>"
      >

        <% layer_callback($layer, $layer_fields, $layer_values, $layer_prefix) %>

      </DIV>

%   }

% }
<%once>

my $conf = new FS::Conf;
my $money_char = $conf->config('money_char') || '$';

</%once>
<%init>

my %opt = @_;

#use Data::Dumper;
#warn Dumper(%opt);

my $key = $opt{field}; # || 'generate_one' #?

tie my %options, 'Tie::IxHash',
   map { $_ => $opt{'labels'}->{$_} }
       @{ $opt{'options'} }; #just arrayref for now

my $between = exists($opt{html_between}) ? $opt{html_between} : '';
my $options = \%options;

my $selected = exists($opt{curr_value}) ? $opt{curr_value} : '';

#XXX eek.  also eek $layer_fields in the layer_callback() call...
my $layer_fields = $opt{layer_fields};
my $layer_values = $opt{layer_values};
my $layer_prefix = $opt{layer_prefix};

sub layer_callback {
  my( $layer, $layer_fields, $layer_values, $layer_prefix ) = @_;

  return  '' unless $layer && exists $layer_fields->{$layer};
  tie my %fields, 'Tie::IxHash', @{ $layer_fields->{$layer} };

  #XXX this should become an element itself... (false laziness w/edit.html)
  # but at least all the elements inside are the shared mason elements now

  return '' unless keys %fields;
  my $html = "<TABLE>";

  foreach my $field ( keys %fields ) {

    my $lf = ref($fields{$field})
               ? $fields{$field}
               : { 'label'=>$fields{$field} };

    my $value = $layer_values->{$layer}{$field};

    my $type = $lf->{type} || 'text';

    my $include = $type;
    $include = "input-$include" if $include =~ /^(text|money)$/;
    $include = "tr-$include" unless $include eq 'hidden';

    $html .= include( "/elements/$include.html",
                        %$lf,
                        'field'      => "$layer_prefix$field",
                        'id'         => "$layer_prefix$field", #separate?
                        #don't want field0_label0...?
                        'label_id'   => $layer_prefix.$field."_label",

                        'value'      => ( $lf->{'value'} || $value ), #hmm.
                        'curr_value' => $value,
                    );

  }
  $html .= '</TABLE>';
  return $html;
}

</%init>

--- NEW FILE: tr-selectlayers.html ---
% unless ( $opt{js_only} ) {

  <% include('tr-td-label.html', @_ ) %>

    <TD <% $style %>>

% }

      <% include('selectlayers.html', @_ ) %>

% unless ( $opt{js_only} ) {

    </TD>

  </TR>

% }

<%init>

my %opt = @_;

my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';

</%init>

--- NEW FILE: tr-select-invoice_template.html ---
<% include('tr-td-label.html', @_) %>

  <TD <% $style %>>

    <SELECT NAME = "<% $opt{'field'} || 'templatename' %>"
            ID   = "<% $opt{'id'} %>"
    >

%     foreach my $templatename ( '', @templatenames ) {
            
        <OPTION VALUE="<% $templatename %>"
                <% $templatename eq $curr_value ? 'SELECTED' : '' %>
        ><% $templatename || '(Default)' %>

%     }

    </SELECT>

  </TD>

</TR>

<%init>

my %opt = @_;

my $onchange = $opt{'onchange'}
                 ? 'onChange="'. $opt{'onchange'}. '(this)"'
                 : '';

my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';

my $curr_value = $opt{'curr_value'} || $opt{'value'};

my $conf = new FS::Conf;

my @templatenames = $conf->invoice_templatenames;

</%init>

--- NEW FILE: tr-freq.html ---
<% include('tr-td-label.html', @_) %>

  <TD <% $style %>>

    <INPUT TYPE  = "text"
           SIZE  = "<% $opt{'size'} || 4 %>"
           NAME  = "<% $opt{'field'} || 'freq' %>"
           ID    = "<% $opt{'id'} %>"
           VALUE = "<% $curr_value %>"
    >

    <SELECT NAME = "<% $opt{'field'} || 'freq' %>_units">
%     foreach my $freq ( keys %freq ) {
        <OPTION VALUE="<% $freq %>"
                <% $freq eq $units ? 'SELECTED' : '' %>
        ><% $freq{$freq} %>
%     }
    </SELECT>

  </TD>

</TR>

<%once>

  tie my %freq, 'Tie::IxHash',
    #'y' => 'years',
    'm' => 'months',
    'w' => 'weeks',
    'd' => 'days',
    'h' => 'hours',
  ;

</%once>
<%init>

my %opt = @_;

my $onchange = $opt{'onchange'}
                 ? 'onChange="'. $opt{'onchange'}. '(this)"'
                 : '';

my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';

my $curr_value = $opt{'curr_value'} || $opt{'value'};
my $units = 'm';

if ( $curr_value =~ /^(\d*)([mwdh])$/i ) {
  $curr_value = $1;
  $units = lc($2);
}

</%init>


Index: tr-select-cust_pkg-status.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/tr-select-cust_pkg-status.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- tr-select-cust_pkg-status.html	23 Aug 2006 22:25:38 -0000	1.2
+++ tr-select-cust_pkg-status.html	1 Aug 2007 22:25:10 -0000	1.3
@@ -1,14 +1,29 @@
-%
-%  my( $status, %opt ) = @_;
-%
-%  $opt{'statuses'} ||= [ FS::cust_pkg->statuses() ]; # { disabled=>'' } )
-%
-%
+<% include ('tr-td-label.html', @_ ) %>
 
+  <TD <% $style %>>
+
+    <% include( '/elements/select-cust_pkg-status.html', 
+                  'curr_value' => $curr_value,
+                  %opt
+              )
+    %>
 
-<TR>
-  <TD ALIGN="right"><% $opt{'label'} || 'Status' %></TD>
-  <TD>
-    <% include( '/elements/select-cust_pkg-status.html', $status, %opt ) %>
   </TD>
+
 </TR>
+
+<%init>
+
+my %opt = @_;
+
+#my $onchange = $opt{'onchange'}
+#                 ? 'onChange="'. $opt{'onchange'}. '(this)"'
+#                 : '';
+
+my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
+
+$opt{'statuses'} ||= [ FS::cust_pkg->statuses() ]; # { disabled=>'' } )
+
+my $curr_value = $opt{'curr_value'} || $opt{'value'};
+
+</%init>

Index: freeside.css
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/freeside.css,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- freeside.css	15 May 2006 13:57:15 -0000	1.2
+++ freeside.css	1 Aug 2007 22:25:08 -0000	1.3
@@ -1,5 +1,6 @@
 * {
   font-family: Arial, Verdana, Helvetica, sans-serif;
+  /* font-family: Verdana, Arial, Helvetica, sans-serif; */
 }
 
 A:link IMG, A:visited { border-style: none }

--- NEW FILE: hidden.html ---
<INPUT TYPE  = "hidden"
       NAME  = "<% $opt{field} %>"
       ID    = "<% $opt{field} %>"
       VALUE = "<% $opt{curr_value} || $opt{value} %>"
>

<%init>

my %opt = @_;

</%init>

--- NEW FILE: tr-checkbox-multiple.html ---
<% include('tr-td-label.html', @_ ) %>

  <TD <% $style %>>

%   foreach my $option ( @{ $opt{options} } ) { #just arrayref for now

      <INPUT TYPE  = "checkbox"
             NAME  = "<% $opt{field} %>"
             ID    = "<% $opt{id}.'_'.$option %>"
             VALUE = "<% $option %>"
             <% ref($value) && $value->{$option} || $value eq $option
                  ? ' CHECKED' : ''
             %>
             <% $onchange %>

      >&nbsp;<% $labels->{$option} %>

      <BR>

%   }

  </TD>

</TR>

<%init>

my %opt = @_;

my $onchange = $opt{'onchange'}
                 ? 'onChange="'. $opt{'onchange'}. '(this)"'
                 : '';

my $value = $opt{'curr_value'} || $opt{'value'};

my $labels = $opt{'option_labels'} || $opt{'labels'};

my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';

</%init>

--- NEW FILE: tr-title.html ---
<TR>
  <TD BGCOLOR="#e8e8e8" COLSPAN=2>&nbsp;</TD>
</TR>

<TR>
  <TH BGCOLOR="#e8e8e8" COLSPAN=2 ALIGN="left">
    <FONT SIZE="+1"><% $opt{value} %></FONT>
  </TH>
</TR>

<%init>

my %opt = @_;

</%init>

--- NEW FILE: select-cust_main-status.html ---
<SELECT NAME="<% $opt{'field'} || 'status' %>"
        <% $opt{'multiple'} ? 'MULTIPLE' : '' %>
        <% $onchange %>
>

  <OPTION VALUE="">all

% foreach my $option ( @{ $opt{'statuses'} } ) { 

    <OPTION VALUE="<% $option %>"
            <% $option eq $curr_value ? 'SELECTED' : '' %>
    ><% $option %>

% } 

</SELECT>

<%init>

my %opt = @_;

$opt{'statuses'} ||= [ FS::cust_main->statuses() ]; # { disabled=>'' } )

my $onchange = $opt{'onchange'}
                 ? 'onChange="'. $opt{'onchange'}. '(this)"'
                 : '';

my $curr_value = $opt{'curr_value'} || $opt{'value'};

</%init>

Index: checkboxes-table-name.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/checkboxes-table-name.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- checkboxes-table-name.html	23 Aug 2006 22:25:37 -0000	1.2
+++ checkboxes-table-name.html	1 Aug 2007 22:25:08 -0000	1.3
@@ -1,56 +1,54 @@
+<%doc>
+
+Example:
+
+  include( '/elements/checkboxes-table-name.html',
+
+    ###
+    # required
+    ###
+    'link_table'      => 'table_name',
+   
+    'name_col' => 'name_column',
+    #or
+    'name_callback' => sub { },
+   
+    'names_list' => [ 'value',
+                      'other value',
+                      [ 'complex value' => { 'desc' => "Add'l description",
+                                             'note' => '&nbsp;*',
+                                           }
+                      ],
+                    ],
+   
+    ###
+    # recommended (required?)
+    ###
+    'source_obj'   => $obj,
+    #or?
+    #'source_table' => 'table_name',
+    #'sourcenum'    => '4', #current value of primary key in source_table
+    #                       # (none is okay, just pass it if you have it)
+
+    ###
+    # optional
+    ###
+    'num_col' => 'col_name' #if column name is different in link_table than
+                            #source_table
+    'link_static' => { 'column' => 'value' },
+
+  )
+
+</%doc>
+
+<TABLE CELLSPACING=0 CELLPADDING=0>
+
+% foreach my $item ( @{ $opt{'names_list'} } ) {
 %
-%
-%  ##
-%  # required
-%  ##
-%  # 'link_table'      => 'table_name',
-%  #
-%  # 'name_col' => 'name_column',
-%  # #or
-%  # 'name_callback' => sub { },
-%  #
-%  # 'names_list' => [ 'value', 'other value' ],
-%  #
-%  ##
-%  # recommended (required?)
-%  ##
-%  # 'source_obj'   => $obj,
-%  # #or?
-%  # #'source_table' => 'table_name',
-%  # #'sourcenum'    => '4', #current value of primary key in source_table
-%  # #                       # (none is okay, just pass it if you have it)
-%  ##
-%  # optional
-%  ##
-%  # 'num_col' => 'col_name' #if column name is different in link_table than
-%  #                         #source_table
-%  # 'link_static' => { 'column' => 'value' },
-%
-%  my( %opt ) = @_;
-%
-%  my( $source_pkey, $sourcenum, $source_obj );
-%  if ( $opt{'source_obj'} ) {
-%
-%    $source_obj = $opt{'source_obj'};
-%    #$source_table = $source_obj->dbdef_table->table;
-%    $source_pkey = $source_obj->dbdef_table->primary_key;
-%    $sourcenum = $source_obj->$source_pkey();
-%
-%  } else {
-%
-%    #$source_obj?
-%    $source_pkey = $opt{'source_table'}
-%                     ? dbdef->table($opt{'source_table'})->primary_key
-%                     : '';
-%    $sourcenum = $opt{'sourcenum'};
-%  }
-%
-%  $source_pkey = $opt{'num_col'} || $source_pkey;
-%
-%  my $link_static = $opt{'link_static'} || {};
-%
-%
-% foreach my $name ( @{ $opt{'names_list'} } ) {
+%     my $name = ref($item) ? $item->[0] : $item;
+%     ( my $display = $name ) =~ s/ /&nbsp;/g;
+%     $display .= $item->[1]{note} if ref($item) && $item->[1]{note};
+%     my $desc = ref($item) && $item->[1]{desc} ? $item->[1]{desc} : '';
 %
 %     my $checked;
 %     if ( $cgi->param('error') ) {
@@ -71,15 +69,45 @@
 %                    : ''
 %
 %     }
-%
-%
 
+  <TR>
+    <TD VALIGN="top">
+      <INPUT TYPE="checkbox" NAME="<% $opt{'link_table'}. ".$name" %>" <% $checked %> VALUE="ON">
+    </TD>
+    <TD><% $display %>
+%     if ( $desc ) {
+        <BR><FONT SIZE="-2"><% $desc %></FONT>
+%     }
+    </TD>
+  </TR>
+
+% } 
 
-  <INPUT TYPE="checkbox" NAME="<% $opt{'link_table'}. ".$name" %>" <% $checked %> VALUE="ON">
+</TABLE>
 
-  <% $name %>
+<%init>
 
-  <BR>
-% } 
+my( %opt ) = @_;
+
+my( $source_pkey, $sourcenum, $source_obj );
+if ( $opt{'source_obj'} ) {
 
+  $source_obj = $opt{'source_obj'};
+  #$source_table = $source_obj->dbdef_table->table;
+  $source_pkey = $source_obj->dbdef_table->primary_key;
+  $sourcenum = $source_obj->$source_pkey();
+
+} else {
+
+  #$source_obj?
+  $source_pkey = $opt{'source_table'}
+                   ? dbdef->table($opt{'source_table'})->primary_key
+                   : '';
+  $sourcenum = $opt{'sourcenum'};
+}
 
+$source_pkey = $opt{'num_col'} || $source_pkey;
+
+my $link_static = $opt{'link_static'} || {};
+
+</%init>

--- NEW FILE: tr-select-cust_main-status.html ---
<% include ('tr-td-label.html', @_ ) %>

  <TD <% $style %>>

    <% include( '/elements/select-cust_main-status.html', 
                  'curr_value' => $curr_value,
                  %opt
              )
    %>

  </TD>

</TR>

<%init>

my %opt = @_;

#my $onchange = $opt{'onchange'}
#                 ? 'onChange="'. $opt{'onchange'}. '(this)"'
#                 : '';

my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';

$opt{'statuses'} ||= [ FS::cust_main->statuses() ]; # { disabled=>'' } )

my $curr_value = $opt{'curr_value'} || $opt{'value'};

</%init>

Index: select-table.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-table.html,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- select-table.html	8 Feb 2007 01:46:44 -0000	1.7
+++ select-table.html	1 Aug 2007 22:25:09 -0000	1.8
@@ -1,73 +1,89 @@
-<SELECT NAME="<% $opt{'element_name'} || $key %>" <% $opt{'element_etc'} %>>
+<%doc>
 
-% while ( @pre_options ) { 
+Example:
+
+  include( '/elements/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'       => {},
+    '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
+    'field'         => '', #synonym for element_name
+    'element_etc'   => '', #additional attributes (i.e. "DISABLED") for the
+                           #<SELECT> element
+    'multiple'      => 0, # bool
+    'disable_empty' => 0, # bool (implied by multiple)
+    'debug'         => 0, #set true to enable
+
+  )
+
+</%doc>
 
+<SELECT <% $opt{'multiple'} ? 'MULTIPLE' : '' %> NAME="<% $opt{'element_name'} || $opt{'field'} || $key %>" <% $opt{'element_etc'} %>>
+
+% while ( @pre_options ) { 
     <OPTION VALUE="<% shift(@pre_options) %>"><% shift(@pre_options) %>
 
 % } 
 
-  <OPTION VALUE=""><% $opt{'empty_label'} || 'all' %>
+% unless ( $opt{'multiple'} || $opt{'disable_empty'} ) {
+    <OPTION VALUE=""><% $opt{'empty_label'} || 'all' %>
+% }
 
 % foreach my $record ( sort { $a->$name_col() cmp $b->$name_col() } @records ) {
-%   my $matches = 0;
-%   ref($opt{'value'}) ? (exists($opt{'value'}->{$record->$key()}) and $matches=1)
-%                      : ($opt{'value'} == $record->$key() and $matches=1);
-
-    <OPTION VALUE="<% $record->$key() %>"<% $matches ? ' SELECTED' : '' %>><% $record->$name_col() %>
-
+%   my $recvalue = $record->$key();
+    <OPTION VALUE="<% $recvalue %>"
+            <% ref($value) && $value->{$recvalue} || $value == $recvalue
+               ? ' 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
+<%init>
 
 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 $key = dbdef->table($opt{'table'})->primary_key; #? $opt{'primary_key'} ||
 
-my $name_col = $opt{name_col};
+my $name_col = $opt{'name_col'};
 
-$opt{hashref} ||= {};
+my $value = $opt{'curr_value'} || $opt{'value'};
+$value = [ split(/\s*,\s*/, $value) ] if $opt{'multiple'} && $value =~ /,/;
 
 my @records = ();
-if ( $opt{records} ) {
-  @records = @{ $opt{records} };
+if ( $opt{'records'} ) {
+  @records = @{ $opt{'records'} };
 } else {
   @records = qsearch( {
-    'table'     => $opt{table},
-    'hashref'   => $opt{hashref},
-    'extra_sql' => ( $opt{extra_sql} || '' ),
+    'table'     => $opt{'table'},
+    'hashref'   => ( $opt{'hashref'} || {} ),
+    'extra_sql' => ( $opt{'extra_sql'} || '' ),
   });
 }
 
-unless (    ! $opt{value}
-         or ref($opt{value})
+unless (    ! $value
+         or ref($value)
          or ! exists( $opt{hashref}->{disabled} ) #??
-         or grep { $opt{value} == $_->$key() } @records
+         or grep { $value == $_->$key() } @records
        ) {
   delete $opt{hashref}->{disabled};
-  $opt{hashref}->{$key} = $opt{value};
+  $opt{hashref}->{$key} = $value;
   my $record = qsearchs( {
     'table'     => $opt{table},
     'hashref'   => $opt{hashref},
@@ -76,8 +92,8 @@
   push @records, $record if $record;
 }
 
-if ( ref( $opt{value} ) eq 'ARRAY' ) {
-  $opt{value} = { map { $_ => 1 } @{$opt{value}} };
+if ( ref( $value ) eq 'ARRAY' ) {
+  $value = { map { $_ => 1 } @$value };
 }
 
 my @pre_options = $opt{pre_options} ? @{ $opt{pre_options} } : ();

Index: tr-select-taxclass.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/tr-select-taxclass.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- tr-select-taxclass.html	31 Jan 2007 04:26:44 -0000	1.1
+++ tr-select-taxclass.html	1 Aug 2007 22:25:10 -0000	1.2
@@ -2,7 +2,7 @@
 %      || scalar(@{ $opt{'taxclasses'} }) == 0
 % ) { 
 
-  <INPUT TYPE="hidden" NAME="taxclass" VALUE="<% $taxclass %>">
+  <INPUT TYPE="hidden" NAME=""<% $opt{'element_name'} || $opt{'field'} || 'taxclass' %>" VALUE="<% $taxclass %>">
 
 % } else { 
 

Index: tr-select-pkg_class.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/tr-select-pkg_class.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- tr-select-pkg_class.html	20 Dec 2006 09:49:08 -0000	1.4
+++ tr-select-pkg_class.html	1 Aug 2007 22:25:10 -0000	1.5
@@ -1,20 +1,27 @@
-%  my( $classnum, %opt ) = @_;
-%
-%  $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="">
+  <INPUT TYPE="hidden" NAME="<% $opt{'field'} || 'classnum' %>" VALUE="">
 
 % } else { 
 
   <TR>
     <TD ALIGN="right"><% $opt{'label'} || 'Package class' %></TD>
     <TD>
-      <% include( '/elements/select-pkg_class.html', $classnum, %opt ) %>
+      <% include( '/elements/select-pkg_class.html',
+                    'curr_value' => $classnum,
+                    %opt
+                )
+      %>
     </TD>
   </TR>
 
 % } 
+
+<%init>
+
+my %opt = @_;
+my $classnum = $opt{'curr_value'} || $opt{'value'};
+
+$opt{'pkg_class'} ||= [ qsearch( 'pkg_class', {} ) ]; # { disabled=>'' } )
+
+</%init>

--- NEW FILE: tr-select-agent_type.html ---
% if ( scalar(@agent_types) == 1 ) { 

  <INPUT TYPE="hidden" NAME="<% $opt{'field'} || 'typenum' %>" VALUE="<% $agent_types[0]->typenum %>">

% } else { 

  <TR>
    <TD ALIGN="right"><% $opt{'label'} || 'Agent Type' %></TD>
    <TD>
      <% include( '/elements/select-agent_type.html',
                     'curr_value'  => $typenum,
                     'agent_types' => \@agent_types,
                     %opt,
                 )
      %>
    </TD>
  </TR>

% } 

<%init>

my %opt = @_;
my $typenum = $opt{'curr_value'} || $opt{'value'};

my @agent_types = ();
if ( $opt{'agent_types'} ) {
  #@agents = @{ $opt{'agents'} };

  #here is the agent virtualization
#  my $agentnums_href = $FS::CurrentUser::CurrentUser->agentnums_href;
#  @agent_types = grep $agentnums_href->{$_->agentnum}, @{ $opt{'agent_types'} };

  delete $opt{'agent_types'};
} else {
#  @agents = $FS::CurrentUser::CurrentUser->agents;
}

</%init>

Index: menu.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/menu.html,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- menu.html	19 Apr 2007 20:18:05 -0000	1.23
+++ menu.html	1 Aug 2007 22:25:09 -0000	1.24
@@ -152,8 +152,10 @@
 ;
 
 tie my %report_bill_event, 'Tie::IxHash',
-  'All billing events' => [ $fsurl.'search/cust_bill_event.html', 'All billing events for a date range' ],
-  'Invoice event errors' => [ $fsurl.'search/cust_bill_event.html?failed=1', 'failed credit cards, processor or printer problems, etc.' ],
+  'All billing events' => [ $fsurl.'search/report_cust_event.html', 'All billing events for a date range' ],
+  'Billing event errors' => [ $fsurl.'search/report_cust_event.html?failed=1', 'Failed credit cards, processor or printer problems, etc.' ],
+  'All invoice events' => [ $fsurl.'search/cust_bill_event.html', 'Reports on deprecated, old-style invoice events for a date range' ],
+  'Invoice event errors' => [ $fsurl.'search/cust_bill_event.html?failed=1', 'Reports on deprecated, old-style events for failed credit cards, processor or printer problems, etc.' ],
 ;
 
 tie my %report_financial, 'Tie::IxHash', 
@@ -235,12 +237,18 @@
 ;
 
 tie my %config_billing, 'Tie::IxHash',
-  'View/Edit payment gateways'         => [ $fsurl.'browse/payment_gateway.html', 'Credit card and electronic check processors' ],
-  'View/Edit invoice events'           => [ $fsurl.'browse/part_bill_event.cgi', 'Actions for overdue invoices' ],
-  'View/Edit prepaid cards'            => [ $fsurl.'search/prepay_credit.html', 'View outstanding cards, generate new cards' ],
-  'View/Edit call rates and regions'   => [ $fsurl.'browse/rate.cgi', 'Manage rate plans, regions and prefixes for VoIP and call billing' ],
-  'View/Edit locales and tax rates'    => [ $fsurl.'browse/cust_main_county.cgi', 'Change tax rates, or break down a country into states, or a state into counties and assign different tax rates to each' ],
-;
+  'View/Edit payment gateways'         => [ $fsurl.'browse/payment_gateway.html', 'Credit card and electronic check processors' ];
+$config_billing{'View/Edit billing events'} = [ $fsurl.'browse/part_event.html', 'Billing actions for customers, invoices and packages' ]
+    if $curuser->access_right('Configuration')
+    || $curuser->access_right('Edit billing events')
+    || $curuser->access_right('Edit global billing events');
+if ( $curuser->access_right('Configuration') ) {
+  $config_billing{'View/Edit invoice events'}         = [ $fsurl.'browse/part_bill_event.cgi', 'Deprecated, old-style actions for overdue invoices' ];
+  $config_billing{'View/Edit invoice templates'}      = [ $fsurl.'browse/invoice_template.html', 'Edit templates for HTML, plaintext and typeset invoices' ];
+  $config_billing{'View/Edit prepaid cards'}          = [ $fsurl.'search/prepay_credit.html', 'View outstanding cards, generate new cards' ];
+  $config_billing{'View/Edit call rates and regions'} = [ $fsurl.'browse/rate.cgi', 'Manage rate plans, regions and prefixes for VoIP and call billing' ];
+  $config_billing{'View/Edit locales and tax rates'}  = [ $fsurl.'browse/cust_main_county.cgi', 'Change tax rates, or break down a country into states, or a state into counties and assign different tax rates to each' ];
+}
 
 tie my %config_dialup, 'Tie::IxHash',
   'View/Edit access numbers' => [ $fsurl.'browse/svc_acct_pop.cgi', 'Points of Presence' ],
@@ -271,12 +279,17 @@
     'Provisioning, services and packages'
                     => [ \%config_export_svc_pkg, ''    ],
     'Resellers'     => [ \%config_agent, ''    ],
-    'Billing'       => [ \%config_billing, ''    ],
-    'Dialup'        => [ \%config_dialup, ''    ],
-    'Fixed (username-less) broadband'
-                    => [ \%config_broadband, ''    ],
   );
 }
+$config_menu{'Billing'} = [ \%config_billing, ''    ]
+  if $curuser->access_right('Configuration')
+  || $curuser->access_right('Edit billing events')
+  || $curuser->access_right('Edit global billing events');
+if ( $curuser->access_right('Configuration') ) {
+  $config_menu{'Dialup'}  = [ \%config_dialup, ''    ];
+  $config_menu{'Fixed (username-less) broadband'} = 
+                            [ \%config_broadband, ''    ];
+}
 $config_menu{'Miscellaneous'} = [ \%config_misc, ''    ]
   if $curuser->access_right('Configuration')
   || $curuser->access_right('Edit advertising sources')

Index: tr-select-reason.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/tr-select-reason.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- tr-select-reason.html	28 Dec 2006 20:52:00 -0000	1.3
+++ tr-select-reason.html	1 Aug 2007 22:25:10 -0000	1.4
@@ -1,31 +1,30 @@
-
 <SCRIPT TYPE="text/javascript">
-  function sh_add<% $name %>()
+  function sh_add<% $func_suffix %>()
   {
 
-    if (document.getElementById('<% $name %>').selectedIndex == 0){
+    if (document.getElementById('<% $id %>').selectedIndex == 0){
       <% $controlledbutton ? $controlledbutton.'.disabled = true;' : ';' %>
     }else{
       <% $controlledbutton ? $controlledbutton.'.disabled = false;' : ';' %>
     }
 
-%if ($curuser->access_right($access_right)){
+%if ($curuser->access_right($add_access_right)){
 
-    if (document.getElementById('<% $name %>').selectedIndex == 
-         (document.getElementById('<% $name %>').length - 1)) {
-      document.getElementById('new<% $name %>').disabled = false;
-      document.getElementById('new<% $name %>').style.display = 'inline';
-      document.getElementById('new<% $name %>Label').style.display = 'inline';
-      document.getElementById('new<% $name %>T').disabled = false;
-      document.getElementById('new<% $name %>T').style.display = 'inline';
-      document.getElementById('new<% $name %>TLabel').style.display = 'inline';
-    }else{
-      document.getElementById('new<% $name %>').disabled = true;
-      document.getElementById('new<% $name %>').style.display = 'none';
-      document.getElementById('new<% $name %>Label').style.display = 'none';
-      document.getElementById('new<% $name %>T').disabled = true;
-      document.getElementById('new<% $name %>T').style.display = 'none';
-      document.getElementById('new<% $name %>TLabel').style.display = 'none';
+    if (document.getElementById('<% $id %>').selectedIndex == 
+         (document.getElementById('<% $id %>').length - 1)) {
+      document.getElementById('new<% $id %>').disabled = false;
+      document.getElementById('new<% $id %>').style.display = 'inline';
+      document.getElementById('new<% $id %>Label').style.display = 'inline';
+      document.getElementById('new<% $id %>T').disabled = false;
+      document.getElementById('new<% $id %>T').style.display = 'inline';
+      document.getElementById('new<% $id %>TLabel').style.display = 'inline';
+    } else {
+      document.getElementById('new<% $id %>').disabled = true;
+      document.getElementById('new<% $id %>').style.display = 'none';
+      document.getElementById('new<% $id %>Label').style.display = 'none';
+      document.getElementById('new<% $id %>T').disabled = true;
+      document.getElementById('new<% $id %>T').style.display = 'none';
+      document.getElementById('new<% $id %>TLabel').style.display = 'none';
     }
 
 %}
@@ -36,7 +35,7 @@
 <TR>
   <TD ALIGN="right">Reason</TD>
   <TD>
-    <SELECT id="<% $name %>" name="<% $name %>" onFocus="sh_add<% $name %>()" onChange="sh_add<% $name %>()">
+    <SELECT id="<% $id %>" name="<% $name %>" onFocus="sh_add<% $func_suffix %>()" onChange="sh_add<% $func_suffix %>()">
 %    my @reasons = qsearch( { table =>'reason', 
 %                             hashref => {},
 %                             extra_sql => $extra_sql,
@@ -44,9 +43,9 @@
 %			     });
       <OPTION VALUE="" <% ($init_reason eq "") ? 'SELECTED' : '' %>>Select Reason...</OPTION>
 %    foreach my $reason (@reasons) {
-      <OPTION VALUE="<% $reason->reasonnum %>" <% ($init_reason == $reason->reasonnum) ? 'SELECTED' : '' %>><% $reason->reason %></OPTION>
+      <OPTION VALUE="<% $reason->reasonnum %>" <% ($init_reason == $reason->reasonnum) ? 'SELECTED' : '' %>><% $reason->reasontype->type %> : <% $reason->reason %></OPTION>
 %    }
-%    if ($curuser->access_right($access_right)) {
+%    if ($curuser->access_right($add_access_right)) {
       <OPTION VALUE="-1" <% ($init_reason == -1) ? 'SELECTED' : '' %>>Add new reason</OPTION>
 %    }
 %
@@ -56,10 +55,10 @@
 
 <TR>
   <TD ALIGN="right">
-    <P id="new<% $name %>TLabel" style="display:<% $display %>">Reason Type</P>
+    <P id="new<% $id %>TLabel" style="display:<% $display %>">Reason Type</P>
   </TD>
   <TD>
-    <SELECT id="new<% $name %>T" name="new<% $name %>T" disabled="<% $disabled %>" style="display:<% $display %>">
+    <SELECT id="new<% $id %>T" name="new<% $name %>T" "<% $disabled %>" style="display:<% $display %>">
 %     for my $type (qsearch( 'reason_type', { 'class' => $class } )){
         <OPTION VALUE="<% $type->typenum %>" <% ($init_type == $type->typenum) ? 'SELECTED' : '' %>><% $type->type %></OPTION>
 %     }
@@ -69,33 +68,52 @@
 
 <TR>
   <TD ALIGN="right">
-    <P id="new<% $name %>Label" style="display:<% $display %>">New Reason</P>
+    <P id="new<% $id %>Label" style="display:<% $display %>">New Reason</P>
   </TD>
-  <TD><INPUT id="new<% $name %>" name="new<% $name %>" type="text" value="<% $init_newreason %>" disabled="<% $disabled %>" style="display:<% $display %>"></TD>
+  <TD><INPUT id="new<% $id %>" name="new<% $name %>" type="text" value="<% $init_newreason %>" "<% $disabled %>" style="display:<% $display %>"></TD>
 </TR>
 
 <%init>
-my($name, $class, $init_reason, $init_type, $init_newreason, $controlledbutton) = @_;
-my($extra_sql, $curuser, $access_right, $display, $disabled); 
 
+my %opt = @_;
+
+my $name = $opt{'field'};
+my $class = $opt{'reason_class'};
+my $init_reason = $opt{'curr_value'};
+
+my $controlledbutton = $opt{'control_button'};
+
+( my $func_suffix = $name ) =~ s/\./_/g;
+
+my $id = $opt{'id'} || $func_suffix;
+
+my( $add_access_right, $access_right ); 
 if ($class eq 'C') {
-  $access_right='Add on-the-fly cancel reason';
-}elsif ($class eq 'S') {
-  $access_right='Add on-the-fly suspend reason';
-}else{
-  print "illegal class: $class";
+  $access_right = 'Cancel customer';
+  $add_access_right = 'Add on-the-fly cancel reason';
+} elsif ($class eq 'S') {
+  $access_right = 'Suspend customer package';
+  $add_access_right = 'Add on-the-fly suspend reason';
+} else {
+  die "illegal class: $class";
 }
 
-if ($init_reason == -1){
+my( $display, $disabled ) = ( 'none', 'DISABLED' );
+my( $init_type, $init_newreason ) = ( '', '' );
+if ($init_reason == -1 || ref($init_reason) ) {
+
   $display = 'inline';
-  $disabled = 'false';
-}else{
-  $display = 'none';
-  $disabled = 'true';
+  $disabled = '';
+
+  if ( ref($init_reason) ) {
+    $init_type      = $init_reason->{'typenum'};
+    $init_newreason = $init_reason->{'reason'};
+    $init_reason = -1;
+  }
+
 }
 
-$extra_sql = "WHERE class = '$class' ORDER BY reason_type";
-$curuser = $FS::CurrentUser::CurrentUser;
+my $extra_sql = "WHERE class = '$class' ORDER BY reason_type";
+my $curuser = $FS::CurrentUser::CurrentUser;
 
 </%init>
-



More information about the freeside-commits mailing list