RT# 82092 - custom fields now save and fixed so name label is displayed insted of...
[freeside.git] / httemplate / edit / elements / part_svc_column.html
index aa3c647..80d325e 100644 (file)
@@ -15,6 +15,7 @@ To be called from part_svc.cgi.
 # don't allow the 'inventory' flags (M, A) to be chosen for 
 # fields that aren't free-text
 my $inv_sub = sub { $_[0]->{disable_inventory} || $_[0]->{type} ne 'text' };
 # don't allow the 'inventory' flags (M, A) to be chosen for 
 # fields that aren't free-text
 my $inv_sub = sub { $_[0]->{disable_inventory} || $_[0]->{type} ne 'text' };
+
 tie my %flag, 'Tie::IxHash',
   ''  => { 'desc' => 'No default', 'condition' => sub { 0 } },
   'D' => { 'desc' => 'Default', 
 tie my %flag, 'Tie::IxHash',
   ''  => { 'desc' => 'No default', 'condition' => sub { 0 } },
   'D' => { 'desc' => 'Default', 
@@ -38,6 +39,9 @@ tie my %flag, 'Tie::IxHash',
   'H' => { 'desc' => 'Select from hardware class',
            'condition' => sub { $_[0]->{type} ne 'select-hardware' },
          },
   'H' => { 'desc' => 'Select from hardware class',
            'condition' => sub { $_[0]->{type} ne 'select-hardware' },
          },
+  'P' => { 'desc' => 'From package FCC 477 information',
+           'condition' => sub { $_[0]->{type} ne 'fcc_477_speed' }, # get values from package fcc 477 information
+         },
   'X' => { 'desc' => 'Excluded',
            'condition' => sub { 1 }, # obsolete
          },
   'X' => { 'desc' => 'Excluded',
            'condition' => sub { 1 }, # obsolete
          },
@@ -64,26 +68,11 @@ my %communigate_fields = (
 </%once>
 <INPUT TYPE="hidden" NAME="svcdb" VALUE="<% $svcdb %>">
 <BR><BR>
 </%once>
 <INPUT TYPE="hidden" NAME="svcdb" VALUE="<% $svcdb %>">
 <BR><BR>
-<& /elements/table.html &>
-  <TR><TH COLSPAN=<% $columns %>>Exports</TH></TR>
-  <TR>
-% # exports
-% foreach my $part_export (@part_export) {
-    <TD>
-      <INPUT TYPE="checkbox" \
-             NAME="exportnum<% $part_export->exportnum %>" \
-             VALUE=1 \
-             <% $has_export_svc{$part_export->exportnum} ? 'CHECKED' : '' %>>
-      <% $part_export->label_html %>
-    </TD>
-%   $count++;
-%   if ( $count % $columns == 0 ) {
-  </TR>
-  <TR>
-%   }
-% }
-  </TR>
-</TABLE><BR><BR>
+%# include export selection
+<& export_svc.html,
+  part_svc => $part_svc,
+  svcdb => $svcdb
+&>
 For the selected table, you can give fields default or fixed (unchangeable)
 values, or select an inventory class to manually or automatically fill in 
 that field.
 For the selected table, you can give fields default or fixed (unchangeable)
 values, or select an inventory class to manually or automatically fill in 
 that field.
@@ -92,6 +81,7 @@ that field.
     <TH BGCOLOR="#cccccc">Field</TH>
     <TH BGCOLOR="#cccccc">Label</TH>
     <TH BGCOLOR="#cccccc" COLSPAN=2>Modifier</TH>
     <TH BGCOLOR="#cccccc">Field</TH>
     <TH BGCOLOR="#cccccc">Label</TH>
     <TH BGCOLOR="#cccccc" COLSPAN=2>Modifier</TH>
+    <TH BGCOLOR="#cccccc"><% $manual_require ? 'Required?' : '' %></TH>
   </TR>
 % $part_svc->set('svcpart' => $opt{'clone'}) if $opt{'clone'}; # for now
 % my $i = 0;
   </TR>
 % $part_svc->set('svcpart' => $opt{'clone'}) if $opt{'clone'}; # for now
 % my $i = 0;
@@ -108,7 +98,7 @@ that field.
     <TD ROWSPAN=2 CLASS="grid">
       <INPUT NAME="<% $svcdb %>__<% $field %>_label"
              STYLE="text-align: right"
     <TD ROWSPAN=2 CLASS="grid">
       <INPUT NAME="<% $svcdb %>__<% $field %>_label"
              STYLE="text-align: right"
-             VALUE="<% $part_svc_column->columnlabel || $def->{'label'} |h %>">
+             VALUE="<% $part_svc_column->columnlabel || escapeHTML($def->{'label'}) |h %>">
     </TD>
 
     <TD ROWSPAN=1 CLASS="grid">
     </TD>
 
     <TD ROWSPAN=1 CLASS="grid">
@@ -147,7 +137,10 @@ that field.
 %   } elsif ( $def->{'type'} eq 'select' ) {
 %
 %     if ( $def->{'select_table'} ) {
 %   } elsif ( $def->{'type'} eq 'select' ) {
 %
 %     if ( $def->{'select_table'} ) {
-      <& /elements/select-table.html,
+%       # set the 'select_svc' flag to enable two-step selection of services
+%       my $comp = '/elements/select-table.html';
+%       $comp = '/elements/select-svc.html' if $def->{'select_svc'};
+      <& $comp,
           'field'       => $name,
           'id'          => $name.'_select',
           'table'       => $def->{'select_table'},
           'field'       => $name,
           'id'          => $name.'_select',
           'table'       => $def->{'select_table'},
@@ -155,7 +148,8 @@ that field.
           'value_col'   => $def->{'select_key'},
           'order_by'    => dbdef->table($def->{'select_table'})->primary_key,
           'multiple'    => $def->{'multiple'},
           'value_col'   => $def->{'select_key'},
           'order_by'    => dbdef->table($def->{'select_table'})->primary_key,
           'multiple'    => $def->{'multiple'},
-          'disable_empty' => 1,
+          'disable_empty' => $def->{'select_allow_empty'} ? undef : 1,
+          'empty_label' => $def->{'select_allow_empty'} ? ' ' : undef,
           'curr_value'  => $value,
           # these can be switched between multiple and singular,
           # so put the complete curr_value in an attribute
           'curr_value'  => $value,
           # these can be switched between multiple and singular,
           # so put the complete curr_value in an attribute
@@ -183,8 +177,8 @@ that field.
           'curr_value'  => $value,
       &>
 %     }
           'curr_value'  => $value,
       &>
 %     }
-%   } elsif ( $def->{'type'} =~ /select-(.*?).html/ ) {
-      <& '/elements/'.$def->{'type'},
+%   } elsif ( $def->{'type'} =~ /^select-(.*?)(.html)?$/ && $1 ne 'hardware' ) {
+      <& "/elements/select-$1.html",
           'field'       => $name,
           'id'          => $name.'_select',
           'multiple'    => $def->{'multiple'},
           'field'       => $name,
           'id'          => $name.'_select',
           'multiple'    => $def->{'multiple'},
@@ -213,6 +207,20 @@ that field.
 %       $mode = 'hardware';
 %       $multiple = 0;
 %     }
 %       $mode = 'hardware';
 %       $multiple = 0;
 %     }
+%
+%     if ( $def->{'type'} eq 'fcc_477_speed' ) {
+%       if ($field eq 'speed_up') {
+          <SPAN ID="<% $name %>_select">
+            upstream speed
+            <INPUT TYPE="hidden" ID="<% $name %>_select" NAME="<% $name %>_classnum" VALUE="up">
+          </SPAN>
+%       } elsif ($field eq 'speed_down') {
+          <SPAN ID="<% $name %>_select">
+            downstream speed
+            <INPUT TYPE="hidden" ID="<% $name %>_select" NAME="<% $name %>_classnum" VALUE="down">
+          </SPAN>
+%       }
+%     } else {
       <& /elements/select-table.html,
           'field'       => $name.'_classnum',
           'id'          => $name.'_select',
       <& /elements/select-table.html,
           'field'       => $name.'_classnum',
           'id'          => $name.'_select',
@@ -220,13 +228,24 @@ that field.
           'name_col'    => 'classname',
           'curr_value'  => $value,
           'empty_label' => "Select $mode class",
           'name_col'    => 'classname',
           'curr_value'  => $value,
           'empty_label' => "Select $mode class",
-          'multiple'    => 0,
+          'multiple'    => $multiple,
       &>
       &>
+%     }
+%   }
+    </TD>
+    <TD>
+%   if ($manual_require && 
+%       (!$def->{'type'} || !(grep {$_ eq $def->{'type'}} ('checkbox','disabled')))
+%   ) {
+      <INPUT ID="<% $name.'_required' %>" TYPE="checkbox" NAME="<% $svcdb %>__<% $field %>_required" VALUE="Y" 
+        <% ($part_svc_column->required || $def->{'required'}) ? 'CHECKED' : '' %> 
+        <% $def->{'required'} ? 'DISABLED' : '' %>
+       >
 %   }
     </TD>
   </TR>
   <TR CLASS="row<%$i%>">
 %   }
     </TD>
   </TR>
   <TR CLASS="row<%$i%>">
-    <TD COLSPAN=2 CLASS="def_info">
+    <TD COLSPAN=3 CLASS="def_info">
 %   if ( $def->{def_info} ) {
       (<% $def->{def_info} %>)
     </TD>
 %   if ( $def->{def_info} ) {
       (<% $def->{def_info} %>)
     </TD>
@@ -242,20 +261,23 @@ that field.
     <TD COLSPAN=3 ALIGN="right">
       <% emt('Require "Provision" access right to edit password') %>
     </TD>
     <TD COLSPAN=3 ALIGN="right">
       <% emt('Require "Provision" access right to edit password') %>
     </TD>
-    <TD>
+    <TD COLSPAN=2>
       <INPUT TYPE="checkbox" NAME="restrict_edit_password" VALUE="Y" \
       <% $part_svc->restrict_edit_password ? 'CHECKED' : '' %>>
     </TD>
   </TR>
 % }
 % # special case: services with attached routers (false laziness...)
       <INPUT TYPE="checkbox" NAME="restrict_edit_password" VALUE="Y" \
       <% $part_svc->restrict_edit_password ? 'CHECKED' : '' %>>
     </TD>
   </TR>
 % }
 % # special case: services with attached routers (false laziness...)
-% if ( $svcdb eq 'svc_acct' or $svcdb eq 'svc_broadband' or $svcdb eq 'svc_dsl' ) {
+% if ( $svcdb eq 'svc_acct'
+%      or $svcdb eq 'svc_broadband'
+%      or $svcdb eq 'svc_dsl'
+%      or $svcdb eq 'svc_circuit' ) {
 %   push @fields, 'has_router';
   <TR>
     <TD COLSPAN=3 ALIGN="right">
       <% emt('This service has an attached router') %>
     </TD>
 %   push @fields, 'has_router';
   <TR>
     <TD COLSPAN=3 ALIGN="right">
       <% emt('This service has an attached router') %>
     </TD>
-    <TD>
+    <TD COLSPAN=2>
       <INPUT TYPE="checkbox" NAME="has_router" VALUE="Y" \
       <% $part_svc->has_router ? 'CHECKED' : '' %>>
     </TD>
       <INPUT TYPE="checkbox" NAME="has_router" VALUE="Y" \
       <% $part_svc->has_router ? 'CHECKED' : '' %>>
     </TD>
@@ -265,8 +287,9 @@ that field.
 <& /elements/progress-init.html,
   $svcdb, #form name
   [ # form fields to send
 <& /elements/progress-init.html,
   $svcdb, #form name
   [ # form fields to send
-    qw(svc svcpart classnum selfservice_access disabled preserve exportnum),
-    @fields
+    'ALL'
+#    qw(svc svcpart classnum selfservice_access disabled preserve exportnum),
+#    @fields
   ],
   'process/part_svc.cgi',   # target
   $p.'browse/part_svc.cgi', # redirect landing
   ],
   'process/part_svc.cgi',   # target
   $p.'browse/part_svc.cgi', # redirect landing
@@ -282,27 +305,18 @@ that field.
 <%init>
 my $svcdb = shift;
 my %opt = @_;
 <%init>
 my $svcdb = shift;
 my %opt = @_;
-my $columns = 3;
 my $count = 0;
 my $communigate = 0;
 my $conf = FS::Conf->new;
 
 my $part_svc = $opt{'part_svc'} || FS::part_svc->new;
 
 my $count = 0;
 my $communigate = 0;
 my $conf = FS::Conf->new;
 
 my $part_svc = $opt{'part_svc'} || FS::part_svc->new;
 
-my @part_export;
-my $export_info = FS::part_export::export_info($svcdb);
-foreach (keys %{ $export_info }) {
-  push @part_export, qsearch('part_export', { exporttype => $_ });
+# see if there are communigate exports configured
+if ( exists $communigate_fields{$svcdb} ) {
+  $communigate = FS::part_export->count("exporttype like 'communigate%'");
 }
 }
-$communigate = scalar(grep {$_->exporttype =~ /^communigate/} @part_export);
 
 my $svcpart = $opt{'clone'} || $part_svc->svcpart;
 
 my $svcpart = $opt{'clone'} || $part_svc->svcpart;
-my %has_export_svc;
-if ( $svcpart ) {
-  foreach (qsearch('export_svc', { svcpart => $svcpart })) {
-    $has_export_svc{$_->exportnum} = 1;
-  }
-}
 
 my @fields;
 if ( defined( dbdef->table($svcdb) ) ) { # when is it ever not defined?
 
 my @fields;
 if ( defined( dbdef->table($svcdb) ) ) { # when is it ever not defined?
@@ -321,4 +335,5 @@ if ( $svcdb eq 'svc_acct'
 }
 
 my @defs = map { FS::part_svc->svc_table_fields($svcdb)->{$_} } @fields;
 }
 
 my @defs = map { FS::part_svc->svc_table_fields($svcdb)->{$_} } @fields;
+my $manual_require = FS::part_svc->svc_table_info($svcdb)->{'manual_require'};
 </%init>
 </%init>