[freeside-commits] branch master updated. e884af8c6997d97753598ccec16a3156e0dcbf3f

Ivan Kohler ivan at freeside.biz
Mon Apr 23 17:08:59 PDT 2018


The branch, master has been updated
       via  e884af8c6997d97753598ccec16a3156e0dcbf3f (commit)
      from  a1e1a1510968526f0c94e4eb684c66c7e3b93a8c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e884af8c6997d97753598ccec16a3156e0dcbf3f
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Apr 23 17:08:58 2018 -0700

    bulk customer package edit from multiple source package definitions, RT#79885

diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index b24b3abe3..07c5a4756 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -3329,11 +3329,10 @@ sub process_bulk_cust_pkg {
   my $param = shift;
   warn Dumper($param) if $DEBUG;
 
-  my $old_part_pkg = qsearchs('part_pkg', 
-                              { pkgpart => $param->{'old_pkgpart'} });
   my $new_part_pkg = qsearchs('part_pkg',
                               { pkgpart => $param->{'new_pkgpart'} });
-  die "Must select a new package type\n" unless $new_part_pkg;
+  die "Must select a new package definition\n" unless $new_part_pkg;
+
   #my $keep_dates = $param->{'keep_dates'} || 0;
   my $keep_dates = 1; # there is no good reason to turn this off
 
@@ -3341,7 +3340,14 @@ sub process_bulk_cust_pkg {
   local $FS::UID::AutoCommit = 0;
   my $dbh = dbh;
 
-  my @cust_pkgs = qsearch('cust_pkg', { 'pkgpart' => $param->{'old_pkgpart'} } );
+  my @old_pkgpart = ref($param->{'old_pkgpart'}) ? @{ $param->{'old_pkgpart'} }
+                                                 : $param->{'old_pkgpart'};
+
+  my @cust_pkgs = qsearch({
+                    'table' => 'cust_pkg',
+                    'extra_sql' => ' WHERE pkgpart IN ('.
+                                       join(',', @old_pkgpart). ')',
+                  });
 
   my $i = 0;
   foreach my $old_cust_pkg ( @cust_pkgs ) {
diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi
index 8c51b35f4..f25c00ef2 100755
--- a/httemplate/browse/part_pkg.cgi
+++ b/httemplate/browse/part_pkg.cgi
@@ -562,7 +562,7 @@ if ( $acl_edit_global ) {
                                 'action'      => "${p}edit/bulk-cust_pkg.html?".
                                                  'pkgpart='.$part_pkg->pkgpart,
                                 'actionlabel' => 'Change Packages',
-                                'width'       => 569,
+                                'width'       => 960,
                                 'height'      => 210,
                               ).' ]</FONT>',
                             'align' => 'left',
@@ -796,8 +796,22 @@ if ( $acl_edit_bulk ) {
   $align .= 'c';
   $html_form = qq!<FORM ACTION="${p}edit/bulk-part_pkg.html" METHOD="POST">!;
   $html_foot = include('/search/elements/checkbox-foot.html',
-      submit  => 'edit report classes', # for now it's only report classes
-  ) . '</FORM>';
+                 actions => [
+                   { submit => 'edit report classes', },
+                   { label  => 'change customer packages',
+                     onclick=> include('/elements/popup_link_onclick.html',
+                                 'label'       => 'change',
+                                 'js_action'   => qq{
+                                   '${p}edit/bulk-cust_pkg.html?' + \$('input[name=pkgpart]').serialize()
+                                 },
+                                 'actionlabel' => 'Change customer packages',
+                                 'width'       => 960,
+                                 'height'      => 420,
+                               )
+                   },
+                 ],
+               ).
+               '</FORM>';
 }
 
 my @menubar;
diff --git a/httemplate/edit/bulk-cust_pkg.html b/httemplate/edit/bulk-cust_pkg.html
index 2ff38ca53..8a082f47f 100644
--- a/httemplate/edit/bulk-cust_pkg.html
+++ b/httemplate/edit/bulk-cust_pkg.html
@@ -19,24 +19,18 @@ function areyousure() {
 }
 </SCRIPT>
 <FORM NAME="OneTrueForm">
-% #false laziness with bulk-cust_svc.html
-%  $cgi->param('pkgpart') =~ /^(\d+)$/
-%    or die "illegal pkgpart: ". $cgi->param('pkgpart');
-%
-%  my $old_pkgpart = $1;
-%  my $src_part_pkg = qsearchs('part_pkg', { 'pkgpart' => $old_pkgpart } )
-%    or die "unknown pkgpart: $old_pkgpart";
-%
 
+% foreach my $src_part_pkg (@src_part_pkg) {
+  <INPUT NAME="old_pkgpart" TYPE="hidden" VALUE="<% $src_part_pkg->pkgpart %>">
+  Change <B><% $src_part_pkg->pkg_comment |h %></B><BR>
+% }
 
-<INPUT NAME="old_pkgpart" TYPE="hidden" VALUE="<% $old_pkgpart %>">
-Change <B><% $src_part_pkg->pkg_comment %></B><BR>
-
+<BR>
 to new package definition
 <SELECT NAME="new_pkgpart">
 % foreach my $dest_part_pkg ( qsearch('part_pkg', { 'disabled' => '' } ) ) {
 
-  <OPTION VALUE="<% $dest_part_pkg->pkgpart %>"><% $dest_part_pkg->pkgpart %>: <% $dest_part_pkg->pkg %>
+  <OPTION VALUE="<% $dest_part_pkg->pkgpart %>"><% $dest_part_pkg->pkgpart %>: <% $dest_part_pkg->pkg |h %>
 % } 
 
 </SELECT>
@@ -57,4 +51,18 @@ to new package definition
 die "access denied"
   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
 
+my @src_part_pkg = ();
+foreach my $pkgpart ( $cgi->multi_param('pkgpart') ) {
+
+  $pkgpart =~ /^(\d+)$/
+    or die "illegal pkgpart: $pkgpart";
+
+  my $old_pkgpart = $1;
+  my $src_part_pkg = qsearchs('part_pkg', { 'pkgpart' => $old_pkgpart } )
+    or die "unknown pkgpart: $old_pkgpart";
+
+  push @src_part_pkg, $src_part_pkg;
+
+}
+
 </%init>
diff --git a/httemplate/search/elements/checkbox-foot.html b/httemplate/search/elements/checkbox-foot.html
index ae8b79470..f33a87467 100644
--- a/httemplate/search/elements/checkbox-foot.html
+++ b/httemplate/search/elements/checkbox-foot.html
@@ -4,7 +4,7 @@
   html_foot => include('elements/checkbox-foot.html',
                   actions => [
                     { label   => 'Edit selected packages',
-                      action  => 'popup_package_edit()',
+                      onclick => 'popup_package_edit()',
                     },
                     { submit  => 'Delete selected packages',
                       confirm => 'Really delete these packages?'
@@ -50,7 +50,7 @@ false.
 <BR>
 % foreach my $action (@$actions) {
 %   if ( $action->{onclick} ) {
-<INPUT TYPE="button" <% $action->{name} %> onclick="<% $opt{onclick} %>"\
+<INPUT TYPE="button" <% $action->{name} %> onclick="<% $action->{onclick} %>"\
   VALUE="<% $action->{label} |h%>">
 %   } elsif ( $action->{submit} ) {
 <INPUT TYPE="submit" <% $action->{name} %> <% $action->{confirm} %>\

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/cust_pkg.pm                             | 14 ++++++++----
 httemplate/browse/part_pkg.cgi                | 20 ++++++++++++++---
 httemplate/edit/bulk-cust_pkg.html            | 32 +++++++++++++++++----------
 httemplate/search/elements/checkbox-foot.html |  4 ++--
 4 files changed, 49 insertions(+), 21 deletions(-)




More information about the freeside-commits mailing list