event refactor, landing on HEAD!
[freeside.git] / httemplate / edit / part_pkg.cgi
index 185d66a..90e328d 100755 (executable)
 %my ($query) = $cgi->keywords;
 %
 %my $part_pkg = '';
+%my @agent_type = ();
 %if ( $cgi->param('error') ) {
 %  $part_pkg = new FS::part_pkg ( {
 %    map { $_, scalar($cgi->param($_)) } fields('part_pkg')
 %  } );
+%  (@agent_type) = $cgi->param('agent_type');
 %}
 %
 %my $action = '';
@@ -30,6 +32,8 @@
 %  $part_pkg ||= $clone_part_pkg->clone;
 %  $part_pkg->disabled('Y'); #isn't sticky on errors
 %} elsif ( $query && $query =~ /^(\d+)$/ ) {
+%  (@agent_type) = map {$_->typenum} qsearch('type_pkgs',{'pkgpart'=>$1})
+%    unless $part_pkg;
 %  $part_pkg ||= qsearchs('part_pkg',{'pkgpart'=>$1});
 %  $pkgpart = $part_pkg->pkgpart;
 %} else {
@@ -85,7 +89,10 @@ Package information
       <INPUT TYPE="text" NAME="comment" SIZE=32 VALUE="<%$part_pkg->comment%>">
     </TD>
   </TR>
-  <% include( '/elements/tr-select-pkg_class.html', $part_pkg->classnum ) %>
+  <% include( '/elements/tr-select-pkg_class.html',
+                'curr_value' => $part_pkg->classnum,
+            )
+  %>
   <TR>
     <TD ALIGN="right">Promotional code</TD>
     <TD>
@@ -117,25 +124,61 @@ Tax information
       <INPUT TYPE="checkbox" NAME="recurtax" VALUE="Y" <% $hashref->{recurtax} eq 'Y' ? ' CHECKED' : '' %>>
     </TD>
   </TR>
+
 % my $conf = new FS::Conf; 
 % if ( $conf->exists('enable_taxclasses') ) { 
 
-
   <TR>
     <TD align="right">Tax class</TD>
     <TD>
       <% include('/elements/select-taxclass.html', $hashref->{taxclass} ) %>
     </TD>
   </TR>
-% } else { 
 
+% } else { 
 
   <% include('/elements/select-taxclass.html', $hashref->{taxclass} ) %>
+
 % } 
 
+</TABLE>
+<BR>
 
+Line-item revenue recognition
+<% ntable("#cccccc", 2) %>
+% tie my %weight, 'Tie::IxHash',
+%   'pay_weight'    => 'Payment',
+%   'credit_weight' => 'Credit'
+% ;
+% foreach my $weight (keys %weight) {
+    <TR>
+      <TD ALIGN="right"><% $weight{$weight} %> weight</TD>
+      <TD>
+        <INPUT TYPE="text" NAME="<% $weight %>" SIZE=6 VALUE=<% $hashref->{$weight} || 0 %>>
+      </TD>
+    </TR>
+% }
 </TABLE>
 
+</TD><TD VALIGN="top">
+
+Reseller information 
+<% ntable("#cccccc", 2) %>
+  <TR>
+    <TD ALIGN="right"><% 'Agent Types' %></TD>
+    <TD>
+      <% include( '/elements/select-table.html',
+                  'element_name' => 'agent_type',
+                  'table'        => 'agent_type',
+                 'name_col'     => 'atype',
+                 'value'        => \@agent_type,
+                 'empty_label'  => '(none)',
+                 'element_etc'  => 'multiple size="10"',
+                )
+      %>
+    </TD>
+  </TR>
+</TABLE>
 </TD></TR></TABLE>
 %
 %
@@ -225,12 +268,13 @@ Tax information
 %
 %tie my %options, 'Tie::IxHash', map { $_=>$plans{$_}->{'name'} } keys %plans;
 %
-%my @form_select = ('classnum');
-%if ( $conf->exists('enable_taxclasses') ) {
-%  push @form_select, 'taxclass';
-%} else {
-%  push @fixups, 'taxclass'; #hidden
-%}
+%#my @form_select = ('classnum');
+%#if ( $conf->exists('enable_taxclasses') ) {
+%#  push @form_select, 'taxclass';
+%#} else {
+%#  push @fixups, 'taxclass'; #hidden
+%#}
+%my @form_elements = ( 'classnum', 'taxclass', 'agent_type' );
 %
 %my @form_radio = ();
 %if ( dbdef->table('pkg_svc')->column('primary_svc') ) {
@@ -247,12 +291,13 @@ Tax information
 %  'options'        => \%options,
 %  'form_name'      => 'dummy',
 %  'form_action'    => 'process/part_pkg.cgi',
+%  'form_elements'  => \@form_elements,
 %  'form_text'      => [ qw(pkg comment promo_code clone pkgnum pkgpart),
-%                        @fixups
+%                        qw(pay_weight credit_weight), #keys(%weight),
+%                        @fixups,
 %                      ],
 %  'form_checkbox'  => [ qw(setuptax recurtax disabled) ],
 %  'form_radio'     => \@form_radio,
-%  'form_select'    => \@form_select,
 %  'layer_callback' => sub {
 %    my $layer = shift;
 %    my $html = qq!<INPUT TYPE="hidden" NAME="plan" VALUE="$layer">!.
@@ -281,12 +326,14 @@ Tax information
 %
 %      $html .= '<TR><TD ALIGN="right">'. $href->{$field}{'name'}. '</TD><TD>';
 %
+%      my $format = sub { shift };
+%      $format = $href->{$field}{'format'} if exists($href->{$field}{'format'});
 %      if ( ! exists($href->{$field}{'type'}) ) {
 %        $html .= qq!<INPUT TYPE="text" NAME="$field" VALUE="!.
 %                 ( exists($plandata{$field})
-%                     ? $plandata{$field}
+%                     ? &$format($plandata{$field})
 %                     : $href->{$field}{'default'} ).
-%                 qq!" onChange="fchanged(this)">!;
+%                 qq!">!;
 %      } elsif ( $href->{$field}{'type'} eq 'checkbox' ) {
 %        $html .= qq!<INPUT TYPE="checkbox" NAME="$field" VALUE=1 !.
 %                 ( exists($plandata{$field}) && $plandata{$field}
@@ -297,7 +344,7 @@ Tax information
 %        $html .= '<SELECT';
 %        $html .= ' MULTIPLE'
 %          if $href->{$field}{'type'} eq 'select_multiple';
-%        $html .= qq! NAME="$field" onChange="fchanged(this)">!;
+%        $html .= qq! NAME="$field">!;
 %
 %        if ( $href->{$field}{'select_table'} ) {
 %          foreach my $record (
@@ -341,7 +388,7 @@ Tax information
 %             
 %    $html .= '<INPUT TYPE="submit" VALUE="'.
 %             ( $hashref->{pkgpart} ? "Apply changes" : "Add package" ).
-%             '" onClick="fchanged(this)">';
+%             '">';
 %
 %    $html;
 %