communigate (phase 2): rules. RT#7514
[freeside.git] / httemplate / edit / part_svc.cgi
index 4b8a240..6fe015a 100755 (executable)
@@ -15,10 +15,12 @@ Disable new orders <INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $hashref->
 Service definitions are the templates for items you offer to your customers.
 <UL><LI>svc_acct - Accounts - anything with a username (Mailboxes, PPP accounts, shell accounts, RADIUS entries for broadband, etc.)
     <LI>svc_domain - Domains
-    <LI>svc_forward - mail forwarding
+    <LI>svc_forward - Mail forwarding
+    <LI>svc_mailinglist - Mailing list
     <LI>svc_www - Virtual domain website
     <LI>svc_broadband - Broadband/High-speed Internet service (always-on)
     <LI>svc_phone - Customer phone numbers
+    <LI>svc_pbx - Customer PBXs
     <LI>svc_external - Externally-tracked service
 <!--   <LI>svc_charge - One-time charges (Partially unimplemented)
        <LI>svc_wo - Work orders (Partially unimplemented)
@@ -64,10 +66,9 @@ that field.
 %             'condition' =>
 %               sub { !ref($_[0]) || $_[0]->{disable_select} }, 
 %           },
-%# need to template-ize httemplate/edit/svc_* first
-%#    'M' => { 'desc' => 'Manual selection from inventory',
-%#             'condition' => $inv_sub,
-%#           },
+%    'M' => { 'desc' => 'Manual selection from inventory',
+%             'condition' => $inv_sub,
+%           },
 %    'A' => { 'desc' => 'Automatically fill in from inventory',
 %             'condition' => $inv_sub,
 %           },
@@ -122,6 +123,7 @@ that field.
 %      $html .= include('/elements/table-grid.html', 'cellpadding' => 4 ).
 %               '<TR>'.
 %                 '<TH CLASS="grid" BGCOLOR="#cccccc">Field</TH>'.
+%                 '<TH CLASS="grid" BGCOLOR="#cccccc">Label</TH>'.
 %                 '<TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=2>Modifier</TH>'.
 %               '</TR>';
 %
@@ -131,7 +133,14 @@ that field.
 %
 %      #yucky kludge
 %      my @fields = defined( dbdef->table($layer) )
-%                      ? grep { $_ ne 'svcnum' } fields($layer)
+%                      ? grep {
+%                               $_ ne 'svcnum' &&
+%                               ( !FS::part_svc->svc_table_fields($layer)
+%                                     ->{$_}->{disable_part_svc_column}   ||
+%                                 $part_svc->part_svc_column($_)->columnflag
+%                               )
+%                             }
+%                             fields($layer)
 %                      : ();
 %      push @fields, 'usergroup' if $layer eq 'svc_acct'; #kludge
 %      $part_svc->svcpart($clone) if $clone; #haha, undone below
@@ -139,13 +148,15 @@ that field.
 %
 %      foreach my $field (@fields) {
 %
-%        #my $def = $defs{$layer}{$field};
+%        #a few lines of false laziness w/browse/part_svc.cgi
 %        my $def = FS::part_svc->svc_table_fields($layer)->{$field};
-%        my $label = $def->{'def_label'} || $def->{'label'};
+%        my $def_info  = $def->{'def_info'};
 %        my $formatter = $def->{'format'} || sub { shift };
+%
 %        my $part_svc_column = $part_svc->part_svc_column($field);
+%        my $label = $part_svc_column->columnlabel || $def->{'label'};
 %        my $value = &$formatter($part_svc_column->columnvalue);
-%        my $flag = $part_svc_column->columnflag;
+%        my $flag  = $part_svc_column->columnflag;
 %
 %        if ( $bgcolor eq $bgcolor1 ) {
 %          $bgcolor = $bgcolor2;
@@ -153,9 +164,12 @@ that field.
 %          $bgcolor = $bgcolor1;
 %        }
 %        
-%        $html .= qq!<TR><TD CLASS="grid" BGCOLOR="$bgcolor" ALIGN="right">!.
-%                 ( $label || $field ).
+%        $html .= qq!<TR><TD ROWSPAN=2 CLASS="grid" BGCOLOR="$bgcolor" ALIGN="right">!.
+%                 ( $def->{'label'} || $field ).
 %                 "</TD>";
+%
+%        $html .= qq!<TD ROWSPAN=2 CLASS="grid" BGCOLOR="$bgcolor"><INPUT NAME="${layer}__${field}_label" VALUE="!. encode_entities($label). '" STYLE="text-align:right"></TD>';
+%
 %        $flag = '' if $def->{type} eq 'disabled';
 %
 %        $html .= qq!<TD CLASS="grid" BGCOLOR="$bgcolor">!;
@@ -171,6 +185,9 @@ that field.
 %
 %          foreach my $f ( keys %flag ) {
 %
+%            # need to template-ize more httemplate/edit/svc_* first
+%            next if $f eq 'M' and $layer !~ /^svc_(broadband|external|phone)$/;
+%
 %            #here is where the SUB from above is called, to skip some choices
 %            next if $flag{$f}->{condition}
 %                 && &{ $flag{$f}->{condition} }( $def, $layer, $field );
@@ -252,6 +269,14 @@ that field.
 %                             'empty_label'  => 'Select inventory class',
 %                          );
 %
+%        } elsif ( $def->{type} eq 'checkbox' ) {
+%
+%          $html .= include('/elements/checkbox.html',
+%                             'field'      => $layer.'__'.$field,
+%                             'curr_value' => $value,
+%                             'value'      => 'Y',
+%                          );
+%
 %        } elsif ( $def->{type} eq 'select' ) {
 %
 %          $html .= qq!<SELECT NAME="${layer}__${field}" $disabled!;
@@ -261,9 +286,10 @@ that field.
 %          if ( $def->{select_table} ) {
 %            foreach my $record ( qsearch( $def->{select_table}, {} ) ) {
 %              my $rvalue = $record->getfield($def->{select_key});
+%              my $select_label = $def->{select_label};
 %              $html .= qq!<OPTION VALUE="$rvalue"!.
 %                  (grep(/^$rvalue$/, split(',',$value)) ? ' SELECTED>' : '>' ).
-%                  $record->getfield($def->{select_label}). '</OPTION>';
+%                  $record->$select_label(). '</OPTION>';
 %            } #next $record
 %          } else { # select_list
 %            foreach my $item ( @{$def->{select_list}} ) {
@@ -274,6 +300,21 @@ that field.
 %          } #endif
 %          $html .= '</SELECT>';
 %
+%        } elsif ( $def->{type} eq 'textarea' ) {
+%
+%          $html .=
+%            qq!<TEXTAREA NAME="${layer}__${field}">!. encode_entities($value).
+%            '</TEXTAREA>';
+%
+%        } elsif ( $def->{type} eq 'select-svc_pbx.html' ) {
+%
+%          $html .= include('/elements/select-svc_pbx.html',
+%                             'curr_value'   => $value,
+%                             'element_name' => "${layer}__${field}",
+%                             'element_etc'  => $disabled,
+%                             'multiple'     => ($flag eq 'S'),
+%                          );
+%
 %        } elsif ( $def->{type} eq 'radius_usergroup_selector' ) {
 %
 %          #XXX disable the RADIUS usergroup selector?  ugh it sure does need
@@ -282,6 +323,14 @@ that field.
 %          $html .= FS::svc_acct::radius_usergroup_selector(
 %            [ split(',', $value) ], "${layer}__${field}" );
 %
+%        } elsif ( $def->{type} eq 'communigate_pro-accessmodes' ) {
+%
+%          $html .= include('/elements/communigate_pro-accessmodes.html',
+%                             'element_name_prefix' => "${layer}__${field}_",
+%                             'curr_value'          => $value,
+%                             #doesn't work#'element_etc'  => $disabled,
+%                          );
+%
 %        } elsif ( $def->{type} eq 'disabled' ) {
 %
 %          $html .=
@@ -289,11 +338,20 @@ that field.
 %
 %        } else {
 %
-%          $html .= '<font color="#ff0000">unknown type'. $def->{type};
+%          $html .= '<font color="#ff0000">unknown type '. $def->{type};
 %
 %        }
 %
 %        $html .= "</TD></TR>\n";
+
+%        $def_info = "($def_info)" if $def_info;
+%        $html .=
+%          qq!<TR>!.
+%          qq!  <TD COLSPAN=2 BGCOLOR="$bgcolor" ALIGN="center" !.
+%          qq!      STYLE="padding:0; border-top: none">!.
+%          qq!    <FONT SIZE="-1"><I>$def_info</I></FONT>!.
+%          qq!  </TD>!.
+%          qq!</TR>\n!;
 %
 %      } #foreach my $field (@fields) {
 %