diff options
Diffstat (limited to 'httemplate')
| -rw-r--r-- | httemplate/edit/elements/edit.html | 117 | ||||
| -rwxr-xr-x | httemplate/edit/part_pkg.cgi | 42 | ||||
| -rwxr-xr-x | httemplate/edit/process/part_pkg.cgi | 30 | ||||
| -rw-r--r-- | httemplate/elements/checkbox.html | 19 | ||||
| -rw-r--r-- | httemplate/elements/tr-checkbox.html | 8 | ||||
| -rw-r--r-- | httemplate/elements/tr-justtitle.html | 2 | ||||
| -rw-r--r-- | httemplate/elements/tr-title.html | 7 | 
7 files changed, 193 insertions, 32 deletions
| diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index 4a6079a85..23d4db30d 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -289,7 +289,8 @@ Example:  %     foreach grep exists($f->{$_}), qw( hashref agent_virt agent_null_right );  %  %   if ( $type eq 'tablebreak-tr-title' ) { -%     $include_common{'table_id'} = 'TableNumber'. $tablenum++ +%     $include_common{'table_id'} = 'TableNumber'. $tablenum++; +%     $include_common{'colspan'} = $f->{colspan} if $f->{colspan};  %   }  %  %   my $layer_prefix_on = ''; @@ -317,6 +318,27 @@ Example:  %     @include;  %   };  % +%   my $column_sub = sub { +%     my %opt = @_; +% +%     my $column   = delete($opt{field}); +%     my $fieldnum = delete($opt{fieldnum}); +%     my $include  = delete($opt{type}) || 'text'; +%     $include = "input-$include" if $include =~ /^(text|money|percentage)$/; +% +%     ( "/elements/$include.html", +%         'field'        => $field.'__'.$column.$fieldnum, +%         'id'           => $field.'__'.$column.$fieldnum, +%         'layer_prefix' => $field.'__'.$column.$fieldnum.".", +%         ( $fieldnum +%             ? ('cell_style' => 'border-top:1px solid black') +%             : () +%         ), +%         'cgi' => $cgi, +%         %opt, +%     ); +%   }; +%  %   unless ( $type =~ /^column/ ) {  %     $g_row = 1 if $type eq 'tablebreak-tr-title';  %     $g_row++; @@ -382,8 +404,35 @@ Example:  %         'layer_values' => $layer_values,  %         'cell_style'   => ( $fieldnum ? 'border-top:1px solid black' : '' ),  %       ); +%       $existing[0] =~ s(^/elements/tr-)(/elements/); +%       my @label = @existing; +%       $label[0] = '/elements/tr-td-label.html'; +        <% include( @label ) %> +        <TD>          <% include( @existing ) %> +        </TD> + +%       if ( $f->{'m2_fields'} ) { +%         foreach my $c ( @{ $f->{'m2_fields'} } ) { +%           my $column = $c->{field}; +%           my @column = &{ $column_sub }( %$c, +%                                          'fieldnum' => $fieldnum, +%                                          'curr_value' => $name_obj->$column() +%                                        ); + +            <TD id='<% $field %>__<% $column %>_label<% $fieldnum %>' +                style='text-align:right;vertical-align:top; +                       border-top:1px solid black;padding-top:5px;'> +              <% $c->{'label'} || '' %> +            </TD> +            <TD style='border-top:1px solid black;padding-top:3px;'> +              <% include( @column ) %> +            </TD> +%         } +%       } + +        </TR>  %       $fieldnum++;  %       $g_row++; @@ -409,9 +458,40 @@ Example:  %     'onchange'   => $onchange,  %     ( $fieldnum ? ('cell_style' => 'border-top:1px solid black') : () ),  %   ); +% +%   if ( $f->{'m2name_table'} || $f->{'m2m_method'} ) { +%     $include[0] =~ s(^/elements/tr-)(/elements/); +%     my @label = @include; +%     $label[0] = '/elements/tr-td-label.html'; + +      <% include( @label ) %> +      <TD> +      <% include( @include ) %> +      </TD> + +%     if ( $f->{'m2_fields'} ) { +%       foreach my $c ( @{ $f->{'m2_fields'} } ) { +%         my $column = $c->{field}; +%         my @column = &{ $column_sub }( %$c, 'fieldnum' => $fieldnum ); + +          <TD id='<% $field %>__<% $column %>_label<% $fieldnum %>' +              style='text-align:right;vertical-align:top; +                     border-top:1px solid black;padding-top:5px;'> +            <% $c->{'label'} || '' %> +          </TD> +          <TD style='border-top:1px solid black;padding-top:3px;'> +            <% include( @column ) %> +          </TD> +%       } +%     } -    <% include( @include ) %> +      </TR> +%   } else { + +      <% include( @include ) %> + +%   }  %   if ( $f->{'m2name_table'} || $f->{'m2m_method'} ) {        <SCRIPT TYPE="text/javascript"> @@ -499,6 +579,39 @@ Example:            row.appendChild(widget_cell); +%         if ( $f->{'m2_fields'} ) { +%           foreach my $c ( @{ $f->{'m2_fields'} } ) { +%             my $column = $c->{field}; +%             my @column = &{ $column_sub }(%$c, 'fieldnum' => 'MAGIC_NUMBER'); + +              var column =  <% include(@column, html_only=>1) |js_string %>; +              column  = column.replace(  magic_regex, <%$field%>_fieldnum ); + +              var column_label = document.createElement('TD'); +              column_label.id = +                '<% $field %>__<% $column %>_label' + <%$field%>_fieldnum; + +              column_label.style.textAlign = "right"; +              column_label.style.verticalAlign = "top"; +              column_label.style.borderTop = "1px solid black"; +              column_label.style.paddingTop = "5px"; + +              column_label.innerHTML = '<% $c->{'label'} || '' %>'; + +              row.appendChild(column_label); +           +              var column_widget = document.createElement('TD'); + +              column_widget.style.borderTop = "1px solid black"; +              column_widget.style.paddingTop = "3px"; + +              column_widget.innerHTML = column; + +              row.appendChild(column_widget); + +%           } +%         } +  %         if ( $f->{'m2_new_js'} ) {              // take out items selected in previous dropdowns              var new_element = document.getElementById("<%$field%>" + <%$field%>_fieldnum ); diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi index a78aa87d8..690e884db 100755 --- a/httemplate/edit/part_pkg.cgi +++ b/httemplate/edit/part_pkg.cgi @@ -175,8 +175,9 @@                              }, -                            { 'type'  => 'tablebreak-tr-title', -                              'value' => 'Pricing add-ons', +                            { 'type'    => 'tablebreak-tr-title', +                              'value'   => 'Pricing add-ons', +                              'colspan' => 4,                              },                              { 'field'      => 'bill_dst_pkgpart',                                'type'       => 'select-part_pkg', @@ -185,6 +186,13 @@                                'm2m_dstcol' => 'dst_pkgpart',                                'm2_error_callback' =>                                  &{$m2_error_callback_maker}('bill'), +                              'm2_fields' => [ { 'field' => 'hidden', +                                                 'type'  => 'checkbox', +                                                 'value' => 'Y', +                                                 'curr_value' => '', +                                                 'label' => 'Bundle', +                                               }, +                                             ],                              },                              { type  => 'tablebreak-tr-title', @@ -385,16 +393,26 @@ my $m2_error_callback_maker = sub {    my $link_type = shift; #yay closures    return sub {      my( $cgi, $object ) = @_; -      map  { -             new FS::part_pkg_link { -               'link_type'   => $link_type, -               'src_pkgpart' => $object->pkgpart, -               'dst_pkgpart' => $_, -             }; -           } -      grep $_, -      map  $cgi->param($_), -      grep /^${link_type}_dst_pkgpart(\d+)$/, $cgi->param; +    my $num; +    map { + +          if ( /^${link_type}_dst_pkgpart(\d+)$/ && +               ( my $dst = $cgi->param("${link_type}_dst_pkgpart$1") ) ) +          { + +            my $hidden = $cgi->param("${link_type}_dst_pkgpart__hidden$1") +                         || ''; +            new FS::part_pkg_link { +              'link_type'   => $link_type, +              'src_pkgpart' => $object->pkgpart, +              'dst_pkgpart' => $dst, +              'hidden'      => $hidden, +            }; +          } else { +            (); +          } +        } +    $cgi->param;    };  }; diff --git a/httemplate/edit/process/part_pkg.cgi b/httemplate/edit/process/part_pkg.cgi index 107d45972..7229f305d 100755 --- a/httemplate/edit/process/part_pkg.cgi +++ b/httemplate/edit/process/part_pkg.cgi @@ -163,16 +163,28 @@ my @process_m2m = (      'target_table' => 'part_pkg',      'base_field'   => 'src_pkgpart',      'target_field' => 'dst_pkgpart', -    'hashref'      => { 'link_type' => 'bill' }, -    'params'       => [ map $cgi->param($_), grep /^bill_dst_pkgpart/, $cgi->param ], -  }, -  { 'link_table'   => 'part_pkg_link', -    'target_table' => 'part_pkg', -    'base_field'   => 'src_pkgpart', -    'target_field' => 'dst_pkgpart', -    'hashref'      => { 'link_type' => 'svc' }, -    'params'       => [ map $cgi->param($_), grep /^svc_dst_pkgpart/, $cgi->param ], +    'hashref'      => { 'link_type' => 'svc', 'hidden' => '' }, +    'params'       => [ map $cgi->param($_), +                        grep /^svc_dst_pkgpart/, $cgi->param +                      ],    }, +  map {  +    my $hidden = $_; +    { 'link_table'   => 'part_pkg_link', +      'target_table' => 'part_pkg', +      'base_field'   => 'src_pkgpart', +      'target_field' => 'dst_pkgpart', +      'hashref'      => { 'link_type' => 'bill', 'hidden' => $hidden }, +      'params'       => [ map { $cgi->param($_) } +                          grep { my $param = "bill_dst_pkgpart__hidden"; +                                 my $digit = ''; +                                 (($digit) = /^bill_dst_pkgpart(\d+)/ ) && +                                 $cgi->param("$param$digit") eq $hidden; +                               } +                          $cgi->param +                        ], +    }, +  } ( '', 'Y' ),  );  foreach my $override_class ($cgi->param) { diff --git a/httemplate/elements/checkbox.html b/httemplate/elements/checkbox.html new file mode 100644 index 000000000..51760701e --- /dev/null +++ b/httemplate/elements/checkbox.html @@ -0,0 +1,19 @@ +<% $opt{'prefix'} %><INPUT TYPE  = "checkbox" +                           NAME  = "<% $opt{field} %>" +                           ID    = "<% $opt{id} %>" +                           VALUE = "<% $opt{value} %>" +                           <% $opt{curr_value} eq $opt{value} +                                ? ' CHECKED' +                                : '' +                           %> +                           <% $onchange %> +                    ><% $opt{'postfix'} %> +<%init> + +my %opt = @_; + +my $onchange = $opt{'onchange'} +                 ? 'onChange="'. $opt{'onchange'}. '(this)"' +                 : ''; + +</%init> diff --git a/httemplate/elements/tr-checkbox.html b/httemplate/elements/tr-checkbox.html index 2e6d1f107..c3cf92ddc 100644 --- a/httemplate/elements/tr-checkbox.html +++ b/httemplate/elements/tr-checkbox.html @@ -1,13 +1,7 @@  <% 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 %> -    > +    <% include('checkbox.html', @_) %>    </TD>  </TR> diff --git a/httemplate/elements/tr-justtitle.html b/httemplate/elements/tr-justtitle.html index 7839a8ce5..8c14d349d 100644 --- a/httemplate/elements/tr-justtitle.html +++ b/httemplate/elements/tr-justtitle.html @@ -1,5 +1,5 @@  <TR> -  <TH BGCOLOR="#e8e8e8" COLSPAN=2 ALIGN="left"> +  <TH BGCOLOR="#e8e8e8" COLSPAN=<% $opt{colspan} || 2 %> ALIGN="left">      <FONT SIZE="+1"><% $opt{value} %></FONT>    </TH>  </TR> diff --git a/httemplate/elements/tr-title.html b/httemplate/elements/tr-title.html index 8517737ae..f2d269e93 100644 --- a/httemplate/elements/tr-title.html +++ b/httemplate/elements/tr-title.html @@ -1,5 +1,10 @@  <TR> -  <TD BGCOLOR="#e8e8e8" COLSPAN=2> </TD> +  <TD BGCOLOR="#e8e8e8" COLSPAN=<% $opt{colspan} || 2 %>> </TD>  </TR>  <% include('tr-justtitle.html', @_) %> +<%init> + +my %opt = @_; + +</%init> | 
