[freeside-commits] branch master updated. 1d76bfaa881079e4c44109698277525082a95733

Mark Wells mark at 420.am
Mon Aug 29 18:31:06 PDT 2016


The branch, master has been updated
       via  1d76bfaa881079e4c44109698277525082a95733 (commit)
       via  04e01775639ae8ec9d604d4b48f2e7b2ce2a95ca (commit)
       via  178f0449edee010fb87023fcf624469a825a04b4 (commit)
      from  b572042679851fe888f6c01fc2c977cda19b1f50 (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 1d76bfaa881079e4c44109698277525082a95733
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Aug 29 18:26:18 2016 -0700

    add a script to inherit report classes on cloned/customized packages, #72260

diff --git a/bin/part_pkg-clone_fix_options b/bin/part_pkg-clone_fix_options
new file mode 100755
index 0000000..4d8192b
--- /dev/null
+++ b/bin/part_pkg-clone_fix_options
@@ -0,0 +1,53 @@
+#!/usr/bin/perl
+
+use strict;
+use FS::Misc::Getopt;
+use FS::part_pkg;
+use FS::Record qw(qsearch dbh);
+
+our %opt;
+getopts('p:'); # pkgpart
+$FS::UID::AutoCommit = 0;
+
+sub usage {
+  die "Usage: part_pkg-clone_fix_options -p pkgpart[,pkgpart...] user\n\n";
+}
+
+my @pkgpart = split(',',$opt{p}) or usage();
+foreach my $base_pkgpart (@pkgpart) {
+  my $base_part_pkg = FS::part_pkg->by_key($base_pkgpart);
+  warn "Base package '".$base_part_pkg->pkg."'\n";
+  my @children = qsearch('part_pkg', { 'family_pkgpart' => $base_pkgpart });
+  next if !@children;
+  my $n_pkg = 0;
+  my $n_upd = 0;
+  my %base_options = $base_part_pkg->options;
+  my %report_classes = map { $_ => $base_options{$_} }
+                       grep /^report_option_/, keys %base_options;
+  if (!keys %report_classes) {
+    warn "No report classes.\n";
+    next;
+  }
+
+  foreach my $part_pkg (@children) {
+    my $pkgpart = $part_pkg->pkgpart;
+    next if $pkgpart == $base_pkgpart;
+    $n_pkg++;
+
+    # don't do this if it has report options already
+    my %options = $part_pkg->options;
+    if (grep /^report_option_/, keys %options) {
+      warn "#$pkgpart has report classes; skipped\n";
+    } else {
+      %options = ( %options, %report_classes );
+      my $error = $part_pkg->replace(options => \%options);
+      die "#$pkgpart: $error\n" if $error;
+      $n_upd++;
+    }
+  }
+  warn "Updated $n_upd / $n_pkg child packages.\n";
+}
+
+warn "Finished.\n";
+dbh->commit;
+

commit 04e01775639ae8ec9d604d4b48f2e7b2ce2a95ca
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Aug 29 14:23:13 2016 -0700

    retain report classes when editing package defs, #71904

diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index 7fe659f..e08f0e1 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -326,6 +326,7 @@
                      'name_col' => 'name',
                      'hashref'  => { 'disabled' => '' },
                      'multiple' => 1,
+                     'curr_value_callback' => $report_option_value_callback,
                    },
 
                    { 'type'    => 'tablebreak-tr-title',
@@ -563,29 +564,42 @@ my $new_object_callback = sub {
 
 };
 
+my $report_option_value_callback = sub {
+  my ($cgi, $object) = @_;
+  my @report_option;
+  if ( defined $cgi->param('report_option') ) {
+    @report_option = $cgi->param('report_option');
+  } else {
+    foreach ($object->options) {
+      /^report_option_(\d+)$/ && (push @report_option, $1);
+    }
+  }
+  join(',', @report_option);
+};
+
 sub set_report_option {
   my($cgi, $object, $fields ) = @_; #, $opt
 
   my @report_option = ();
   foreach ($object->options) {
     /^usage_taxproductnum_(\d+)$/ && ($taxproductnums{$1} = 1);
-    /^report_option_(\d+)$/ && (push @report_option, $1);
+#    /^report_option_(\d+)$/ && (push @report_option, $1);
   }
   foreach ($object->part_pkg_taxoverride) {
     $taxproductnums{$_->usage_class} = 1
       if $_->usage_class;
   }
 
-  $cgi->param('report_option', join(',', @report_option));
-  foreach my $field ( @$fields ) {
-    next unless ( 
-      ref($field) eq 'HASH' &&
-      $field->{field} &&
-      $field->{field} eq 'report_option'
-    );
-    #$field->{curr_value} = join(',', @report_option);
-    $field->{value} = join(',', @report_option);
-  }
+#  $cgi->param('report_option', join(',', @report_option));
+#  foreach my $field ( @$fields ) {
+#    next unless ( 
+#      ref($field) eq 'HASH' &&
+#      $field->{field} &&
+#      $field->{field} eq 'report_option'
+#    );
+#    #$field->{curr_value} = join(',', @report_option);
+#    $field->{value} = join(',', @report_option);
+#  }
 
 }
 

commit 178f0449edee010fb87023fcf624469a825a04b4
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Aug 29 12:20:34 2016 -0700

    allow "debug" option in edit/ field definitions

diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 8dd15dc..b71558d 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -372,6 +372,7 @@ Example:
 %     qw( alt_format ),                                    #select-cust_location
 %     qw( classnum ),                                   # select-inventory_item
 %     qw( aligned ),                                    # columnstart
+%     qw( debug ),                                      # select-table
 %   ;
 %
 %   #select-table

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

Summary of changes:
 bin/part_pkg-clone_fix_options     |   53 ++++++++++++++++++++++++++++++++++++
 httemplate/edit/elements/edit.html |    1 +
 httemplate/edit/part_pkg.cgi       |   36 ++++++++++++++++--------
 3 files changed, 79 insertions(+), 11 deletions(-)
 create mode 100755 bin/part_pkg-clone_fix_options




More information about the freeside-commits mailing list