Thinktel VoIP provisioning, #32084
[freeside.git] / httemplate / edit / elements / part_svc_column.html
index d03c49d..53cda85 100644 (file)
@@ -64,26 +64,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.
@@ -157,6 +142,9 @@ that field.
           'multiple'    => $def->{'multiple'},
           'disable_empty' => 1,
           'curr_value'  => $value,
           'multiple'    => $def->{'multiple'},
           'disable_empty' => 1,
           'curr_value'  => $value,
+          # these can be switched between multiple and singular,
+          # so put the complete curr_value in an attribute
+          'element_etc' => 'default="'.encode_entities($value).'"',
       &>
 %     } else {
 %       my (@options, %labels);
       &>
 %     } else {
 %       my (@options, %labels);
@@ -180,8 +168,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'},
@@ -204,15 +192,20 @@ that field.
              NAME="<%$name%>"
              ID="<%$name%>" 
              VALUE="<%$value%>">
              NAME="<%$name%>"
              ID="<%$name%>" 
              VALUE="<%$value%>">
-%     # inventory class selection
+%     my $mode = 'inventory';
+%     my $multiple = 1;
+%     if ( $def->{'type'} eq 'select-hardware' ) {
+%       $mode = 'hardware';
+%       $multiple = 0;
+%     }
       <& /elements/select-table.html,
           'field'       => $name.'_classnum',
           'id'          => $name.'_select',
       <& /elements/select-table.html,
           'field'       => $name.'_classnum',
           'id'          => $name.'_select',
-          'table'       => 'inventory_class',
+          'table'       => $mode.'_class',
           'name_col'    => 'classname',
           'curr_value'  => $value,
           'name_col'    => 'classname',
           'curr_value'  => $value,
-          'empty_label' => 'Select inventory class',
-          'multiple'    => 1,
+          'empty_label' => "Select $mode class",
+          'multiple'    => $multiple,
       &>
 %   }
     </TD>
       &>
 %   }
     </TD>
@@ -240,6 +233,22 @@ that field.
     </TD>
   </TR>
 % }
     </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'
+%      or $svcdb eq 'svc_circuit' ) {
+%   push @fields, 'has_router';
+  <TR>
+    <TD COLSPAN=3 ALIGN="right">
+      <% emt('This service has an attached router') %>
+    </TD>
+    <TD>
+      <INPUT TYPE="checkbox" NAME="has_router" VALUE="Y" \
+      <% $part_svc->has_router ? 'CHECKED' : '' %>>
+    </TD>
+  </TR>
+% }
 </TABLE>
 <& /elements/progress-init.html,
   $svcdb, #form name
 </TABLE>
 <& /elements/progress-init.html,
   $svcdb, #form name
@@ -261,27 +270,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?