[freeside-commits] branch FREESIDE_3_BRANCH updated. a1bc794c10bdbc87341c3f43065d74e9f49016a7

Christopher Burger burgerc at freeside.biz
Fri May 10 07:56:17 PDT 2019


The branch, FREESIDE_3_BRANCH has been updated
       via  a1bc794c10bdbc87341c3f43065d74e9f49016a7 (commit)
       via  ec00937efee55b88408726f0293ba195f83df464 (commit)
       via  5d3c3ddddcb893966b45134a5d270f45ef91c591 (commit)
      from  2eedee9c581db67f67abee82a54ed6dc06ce8bfa (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 a1bc794c10bdbc87341c3f43065d74e9f49016a7
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Fri May 10 10:42:33 2019 -0400

    RT# 82949 - fixed error where form submits on cancel

diff --git a/httemplate/edit/bulk-part_pkg.html b/httemplate/edit/bulk-part_pkg.html
index 8570cb92c..336c5a9b2 100644
--- a/httemplate/edit/bulk-part_pkg.html
+++ b/httemplate/edit/bulk-part_pkg.html
@@ -8,11 +8,6 @@
 <& /elements/error.html &>
 
 <SCRIPT>
-  function areyousure() {
-    var warning = 'Edit these packages?';
-    if(confirm(warning)) { process(); }
-  }
-
   function toggle_section(what) {
     var id = what.id;
     var isDisabled;
@@ -26,7 +21,7 @@
   }
 </SCRIPT>
 
-<FORM ACTION="process/bulk-part_pkg.html" METHOD="POST">
+<FORM ACTION="process/bulk-part_pkg.html" METHOD="POST" onsubmit="return confirm('Edit these packages?');">
 <TABLE>
   <TR>
     <TD VALIGN="top">
@@ -72,7 +67,7 @@ Edit pricing fields.
  </TABLE>
 </DIV>
 <BR>
-<INPUT TYPE="submit" VALUE="Bulk change packages" onclick="areyousure()">
+<INPUT TYPE="submit" VALUE="Bulk change packages">
     </TD>
     <TD WIDTH="5"> </TD>
     <TD VALIGN="top">

commit ec00937efee55b88408726f0293ba195f83df464
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Thu May 9 15:13:14 2019 -0400

    RT# 82949 - changes section name from fees to pricing, better opiton

diff --git a/httemplate/edit/bulk-part_pkg.html b/httemplate/edit/bulk-part_pkg.html
index 3225392be..8570cb92c 100644
--- a/httemplate/edit/bulk-part_pkg.html
+++ b/httemplate/edit/bulk-part_pkg.html
@@ -56,12 +56,12 @@ Edit report classes
   </TABLE>
 </DIV>
 <BR>
-<INPUT TYPE="checkbox" ID="package_fees" NAME="package_fees" VALUE="1" onChange='toggle_section(this);'>
-Edit package fees.
+<INPUT TYPE="checkbox" ID="pricing" NAME="pricing" VALUE="1" onChange='toggle_section(this);'>
+Edit pricing fields.
 <BR>
-<DIV ID="package_fees_div" STYLE="display: none;">
+<DIV ID="pricing_div" STYLE="display: none;">
  <& /elements/table-grid.html &>\
-  <& /elements/tr-justtitle.html, value => mt('Package fees') &>
+  <& /elements/tr-justtitle.html, value => mt('Package pricing') &>
   <TR>
     <TD>Percentage of setup fee increase </TD>
     <TD><INPUT TYPE="text" ID="setup_fee_increase" NAME="setup_fee_increase">%</TD>
diff --git a/httemplate/edit/process/bulk-part_pkg.html b/httemplate/edit/process/bulk-part_pkg.html
index ac542cc14..4153ffc13 100644
--- a/httemplate/edit/process/bulk-part_pkg.html
+++ b/httemplate/edit/process/bulk-part_pkg.html
@@ -31,7 +31,7 @@ if ($cgi->param('report_class')) {
   }
 }
 
-if ($cgi->param('package_fees')) {
+if ($cgi->param('pricing')) {
   my $setup_fee_increase = $cgi->param('setup_fee_increase');
   my $recurring_fee_increase = $cgi->param('recurring_fee_increase');
 

commit 5d3c3ddddcb893966b45134a5d270f45ef91c591
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Thu May 9 13:22:09 2019 -0400

    RT# 82949 - added the ability to bulk increase package fees (setup and/or recurring) by a percentage
    
    Conflicts:
            httemplate/browse/part_pkg.cgi
            httemplate/elements/header-full.html

diff --git a/httemplate/browse/part_pkg.cgi b/httemplate/browse/part_pkg.cgi
index 296449650..526aaa9f3 100755
--- a/httemplate/browse/part_pkg.cgi
+++ b/httemplate/browse/part_pkg.cgi
@@ -27,6 +27,15 @@
                  'html_foot'             => $html_foot,
              )
 %>
+
+<%def .style>
+  <SCRIPT TYPE="text/javascript">
+    $(document).ready(function(){
+      $(this).scrollTop(0);
+    });
+  </SCRIPT>
+</%def>
+
 <%init>
 
 my $curuser = $FS::CurrentUser::CurrentUser;
@@ -683,8 +692,18 @@ if ( $acl_edit_bulk ) {
   $html_form = qq!<FORM ACTION="${p}edit/bulk-part_pkg.html" METHOD="POST">!;
   $html_foot = include('/search/elements/checkbox-foot.html',
                  actions => [
-                   { submit => 'edit report classes', },
-                   { label  => 'change customer packages',
+                   { label  => 'edit packages',
+                     onclick=> include('/elements/popup_link_onclick.html',
+                                 'label'       => 'edit',
+                                 'js_action'   => qq{
+                                   '${p}edit/bulk-part_pkg.html?' + \$('input[name=pkgpart]').serialize()
+                                 },
+                                 'actionlabel' => 'Bulk edit packages',
+                                 'width'       => 960,
+                                 'height'      => 420,
+                               )
+                   },
+                   { label  => 'change customers packages',
                      onclick=> include('/elements/popup_link_onclick.html',
                                  'label'       => 'change',
                                  'js_action'   => qq{
diff --git a/httemplate/edit/bulk-part_pkg.html b/httemplate/edit/bulk-part_pkg.html
index 4665c9f95..3225392be 100644
--- a/httemplate/edit/bulk-part_pkg.html
+++ b/httemplate/edit/bulk-part_pkg.html
@@ -1,5 +1,4 @@
-<& /elements/header.html, 'Edit package report classes' &>
-%# change that title if we add any other editing controls
+<% include('/elements/header-popup.html', 'Bulk edit packages') %>
 
 %# this should be centralized somewhere
 <STYLE TYPE="text/css">
@@ -8,36 +7,83 @@
 </STYLE>
 <& /elements/error.html &>
 
+<SCRIPT>
+  function areyousure() {
+    var warning = 'Edit these packages?';
+    if(confirm(warning)) { process(); }
+  }
+
+  function toggle_section(what) {
+    var id = what.id;
+    var isDisabled;
+    if (document.getElementById(id).checked == true)  { isDisabled = false; }
+    else { isDisabled = true; }
+
+    var whatDiv = document.getElementById(id+'_div');
+    if (isDisabled) { whatDiv.style.display = "none"; }
+    else { whatDiv.style.display = "block"; }
+
+  }
+</SCRIPT>
+
 <FORM ACTION="process/bulk-part_pkg.html" METHOD="POST">
-<DIV>
-The following packages will be changed:<BR>
-% foreach my $pkgpart (sort keys(%part_pkg)) {
-<INPUT TYPE="hidden" NAME="pkgpart" VALUE="<% $pkgpart %>">
-<% $part_pkg{$pkgpart}->pkg_comment |h %><BR>
-% }
-</DIV>
+<TABLE>
+  <TR>
+    <TD VALIGN="top">
+<B>Select the package information to change</B><BR>
+<INPUT TYPE="checkbox" ID="report_class" NAME="report_class" VALUE="1" onChange='toggle_section(this);'>
+Edit report classes
 <BR>
-<& /elements/table-grid.html &>\
-<& /elements/tr-justtitle.html, value => mt('Report classes') &>
+<DIV ID="report_class_div" STYLE="display: none;">
+ <& /elements/table-grid.html &>\
+  <& /elements/tr-justtitle.html, value => mt('Report classes') &>
 % my $row = 0;
 % foreach my $num (sort keys %report_class) {
-  <TR CLASS="row<%$row % 2%>">
-    <TD>
+    <TR CLASS="row<%$row % 2%>">
+     <TD>
 %   if ( $initial_state{$num} == -1 ) {
 %     # needs to be a tristate so that you can say "don't change it"
       <& /elements/checkbox-tristate.html, field => 'report_option_'.$num &>
 %   } else {
 %# for visual consistency
-      <INPUT TYPE="checkbox" CLASS="partial" NAME="report_option_<%$num%>" VALUE="1" <% $initial_state{$num} ? 'CHECKED':'' %>><LABEL />
+      <INPUT TYPE="checkbox" CLASS="partial" ID="report_option_<%$num%>" NAME="report_option_<%$num%>" VALUE="1" <% $initial_state{$num} ? 'CHECKED':'' %>><LABEL />
 %   }
-    </TD>
-    <TD><% $report_class{$num}->name %></TD>
-  </TR>
+     </TD>
+      <TD><% $report_class{$num}->name %></TD>
+    </TR>
 %   $row++;
 % }
-</TABLE>
+  </TABLE>
+</DIV>
+<BR>
+<INPUT TYPE="checkbox" ID="package_fees" NAME="package_fees" VALUE="1" onChange='toggle_section(this);'>
+Edit package fees.
+<BR>
+<DIV ID="package_fees_div" STYLE="display: none;">
+ <& /elements/table-grid.html &>\
+  <& /elements/tr-justtitle.html, value => mt('Package fees') &>
+  <TR>
+    <TD>Percentage of setup fee increase </TD>
+    <TD><INPUT TYPE="text" ID="setup_fee_increase" NAME="setup_fee_increase">%</TD>
+  </TR>
+    <TD>Percentage of recurring fee increase </TD>
+    <TD><INPUT TYPE="text" ID="recurring_fee_increase" NAME="recurring_fee_increase">%</TD>
+  </TR>
+ </TABLE>
+</DIV>
 <BR>
-<INPUT TYPE="submit">
+<INPUT TYPE="submit" VALUE="Bulk change packages" onclick="areyousure()">
+    </TD>
+    <TD WIDTH="5"> </TD>
+    <TD VALIGN="top">
+      <B>The following packages will be changed:</B><BR>
+%     foreach my $pkgpart (sort keys(%part_pkg)) {
+        <INPUT TYPE="hidden" NAME="pkgpart" VALUE="<% $pkgpart %>">
+        <% $part_pkg{$pkgpart}->pkg_comment |h %><BR>
+%     }
+    </TD>
+  </TR>
+</TABLE>
 </FORM>
 <& /elements/footer.html &>
 <%init>
diff --git a/httemplate/edit/process/bulk-part_pkg.html b/httemplate/edit/process/bulk-part_pkg.html
index 59c914a5d..ac542cc14 100644
--- a/httemplate/edit/process/bulk-part_pkg.html
+++ b/httemplate/edit/process/bulk-part_pkg.html
@@ -1,35 +1,54 @@
-% if ( $error ) {
-%  $cgi->param('error', $error);
-<% $cgi->redirect(popurl(3).'/edit/bulk-part_pkg.html?'.$cgi->query_string) %>
-% } else {
-<% $cgi->redirect(popurl(3).'/browse/part_pkg.cgi') %>
-% }
+<& /elements/popup-topreload.html, emt($message) &>
+
 <%init>
 die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Bulk edit package definitions');
 
 my @pkgparts = $cgi->param('pkgpart')
   or die "no package definitions selected";
 
-my %delete = map { 'report_option_'.($_->num) => 1 }
-  qsearch('part_pkg_report_option', {});
-my %insert;
-
-foreach my $param (grep { /^report_option_\d+$/ } $cgi->param) {
-  if ( $cgi->param($param) == 1 ) {
-    $insert{$param} = 1;
-    delete $delete{$param};
-  } elsif ( $cgi->param($param) == -1 ) {
-    # leave it alone
-    delete $delete{$param};
-  } # else it's empty, so leave it on the delete list
+my $error;
+
+if ($cgi->param('report_class')) {
+  my %delete = map { 'report_option_'.($_->num) => 1 }
+    qsearch('part_pkg_report_option', {});
+  my %insert;
+
+  foreach my $param (grep { /^report_option_\d+$/ } $cgi->param) {
+    if ( $cgi->param($param) == 1 ) {
+      $insert{$param} = 1;
+      delete $delete{$param};
+    } elsif ( $cgi->param($param) == -1 ) {
+      # leave it alone
+      delete $delete{$param};
+    } # else it's empty, so leave it on the delete list
+  }
+
+  foreach my $pkgpart (@pkgparts) {
+    my $part_pkg = FS::part_pkg->by_key($pkgpart);
+    my %options = ( $part_pkg->options, %insert );
+    delete $options{$_} foreach keys(%delete);
+    $error ||= $part_pkg->replace( options => \%options );
+  }
 }
 
+if ($cgi->param('package_fees')) {
+  my $setup_fee_increase = $cgi->param('setup_fee_increase');
+  my $recurring_fee_increase = $cgi->param('recurring_fee_increase');
 
-my $error;
-foreach my $pkgpart (@pkgparts) {
-  my $part_pkg = FS::part_pkg->by_key($pkgpart);
-  my %options = ( $part_pkg->options, %insert );
-  delete $options{$_} foreach keys(%delete);
-  $error ||= $part_pkg->replace( options => \%options );
+  foreach my $pkgpart (@pkgparts) {
+    my $part_pkg = FS::part_pkg->by_key($pkgpart);
+    my %options = $part_pkg->options;
+    if ($recurring_fee_increase) {
+      $options{'recur_fee'} = $options{'recur_fee'} + ($options{'recur_fee'} * ($recurring_fee_increase / 100));
+    }
+    if ($setup_fee_increase) {
+      $options{'setup_fee'} = $options{'setup_fee'} + ($options{'setup_fee'} * ($setup_fee_increase / 100));
+    }
+    $error ||= $part_pkg->replace( options => \%options );
+  }
 }
+
+my $message = "Packages updated successfully";
+$message = $error."=error" if $error;
+
 </%init>

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

Summary of changes:
 httemplate/browse/part_pkg.cgi             | 23 ++++++++-
 httemplate/edit/bulk-part_pkg.html         | 81 ++++++++++++++++++++++--------
 httemplate/edit/process/bulk-part_pkg.html | 67 +++++++++++++++---------
 3 files changed, 125 insertions(+), 46 deletions(-)




More information about the freeside-commits mailing list