[freeside-commits] branch FREESIDE_3_BRANCH updated. 77f2d55e48d2a59ec020b6fd64cb627b38dd9340
Mark Wells
mark at 420.am
Mon Aug 29 18:33:05 PDT 2016
The branch, FREESIDE_3_BRANCH has been updated
via 77f2d55e48d2a59ec020b6fd64cb627b38dd9340 (commit)
from ac602a212f0cb29cc9f2693de4df75c70dc5211f (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 77f2d55e48d2a59ec020b6fd64cb627b38dd9340
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;
+
-----------------------------------------------------------------------
Summary of changes:
bin/part_pkg-clone_fix_options | 53 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 53 insertions(+)
create mode 100755 bin/part_pkg-clone_fix_options
More information about the freeside-commits
mailing list