[freeside-commits] branch master updated. 288a1a44dd09ebed51e0a5800624b4ed49ecdf9f

Ivan ivan at 420.am
Tue Jul 23 21:51:11 PDT 2013


The branch, master has been updated
       via  288a1a44dd09ebed51e0a5800624b4ed49ecdf9f (commit)
       via  a940c3bf8468cca2b8910516b4bee8d7390e7f78 (commit)
      from  04e3881b4d2d515464eec0573782d4eac7e08e7c (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 288a1a44dd09ebed51e0a5800624b4ed49ecdf9f
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Jul 23 21:51:10 2013 -0700

    svc_cable, RT#22009

diff --git a/httemplate/edit/cable_device.html b/httemplate/edit/cable_device.html
index eb91ad7..963bbf7 100644
--- a/httemplate/edit/cable_device.html
+++ b/httemplate/edit/cable_device.html
@@ -18,6 +18,9 @@
 			       { field => 'mac_addr',
 			         type => 'select-mac',
 			       },
+			       { field => 'serial',
+			         type  => 'text', #select-serial
+			       },
                                { 'field' => 'svcnum',
                                  'type'  => 'hidden',
                                },

commit a940c3bf8468cca2b8910516b4bee8d7390e7f78
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Jul 23 21:14:54 2013 -0700

    script to restore removed setup dates, RT#24130

diff --git a/bin/cust_pkg-remove_setup b/bin/cust_pkg-remove_setup
new file mode 100755
index 0000000..58dc6b9
--- /dev/null
+++ b/bin/cust_pkg-remove_setup
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+
+use strict;
+use FS::UID qw( adminsuidsetup );
+use FS::Record qw( qsearchs );
+use FS::cust_pkg;
+
+my $user = shift or &usage;
+adminsuidsetup $user;
+
+my $pkgnum = shift or &usage;
+
+my $cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $pkgnum } )
+  or die "unknown pkgnum $pkgnum\n";
+
+$cust_pkg->setup('');
+my $error = $cust_pkg->replace;
+
+die $error if $error;
+
+sub usage {
+  die "usage: cust_pkg-remove_setup employee_username pkgnum\n";
+}
+
+1;
+
diff --git a/bin/cust_pkg-restore_setup b/bin/cust_pkg-restore_setup
new file mode 100755
index 0000000..5467ead
--- /dev/null
+++ b/bin/cust_pkg-restore_setup
@@ -0,0 +1,119 @@
+#!/usr/bin/perl
+
+use strict;
+use vars qw( $opt_s $opt_e $opt_r $opt_u $opt_c );
+use Getopt::Std;
+use Date::Parse qw(str2time);
+use Date::Format;
+use FS::UID qw(adminsuidsetup dbh);
+use FS::Record qw(qsearch qsearchs);
+use FS::cust_pkg;
+use FS::h_cust_pkg;
+
+getopts('s:e:ruc');
+
+my $user = shift or &usage;
+adminsuidsetup $user;
+
+my $sdate = $opt_s ? str2time($opt_s) : 0;
+my $edate = $opt_e ? str2time($opt_e) + 86399 #not strictly correct on time zone boundary days, but good enough for this purpose
+                   : 2147397248;
+
+my $oldAutoCommit = $FS::UID::AutoCommit;
+local $FS::UID::AutoCommit = 0;
+my $dbh = dbh;
+
+my $fuzz = 2;
+
+my $changed = 0;
+
+foreach my $cust_pkg (
+  qsearch({ table       => 'cust_pkg',
+            hashref     => { 
+                             setup          => '',
+                           },
+         })
+) {
+
+  #XXX only canceled packages?
+  #XXX only suspended packages?
+
+  my $h_cust_pkg =
+    qsearchs({ table       => 'h_cust_pkg',
+               hashref     => { 
+                                pkgnum         => $cust_pkg->pkgnum,
+                                history_action => 'replace_old',
+                                setup          => { op=>'!=', value=>'' },
+                                ($opt_u ? ('susp' => { op=>'!=', value=>'' })
+                                        : ()
+                                ),
+                                ($opt_c ? ('cancel' => { op=>'!=', value=>'' })
+                                        : ()
+                                ),
+                              },
+               extra_sql   => ' AND history_date >= ? AND history_date <= ? ',
+               extra_param => [ [$sdate,'int'], [$edate,'int'] ],
+               order_by    => 'ORDER BY history_date DESC LIMIT 1',
+            })
+    or next;
+
+  $changed++;
+
+  #if ( $opt_r ) {
+    print "restoring setup for pkgnum ". $cust_pkg->pkgnum.
+          " (custnum ". $cust_pkg->custnum.
+          ") to ". time2str('%D', $h_cust_pkg->setup). "\n";
+  #}
+
+  $cust_pkg->set('setup', $h_cust_pkg->setup);
+  my $error = $cust_pkg->replace;
+  die $error if $error;
+
+}
+
+if ( $opt_r ) {
+  $dbh->rollback or die $dbh->errstr; #if $oldAutoCommit;
+} else {
+  $dbh->commit or die $dbh->errstr; #if $oldAutoCommit;
+}
+
+print "changed $changed packages\n";
+
+sub usage {
+  die "usage: cust_pkg-restore_setup [ -s history_start ] [ -e history_end ] [-r ]  employee_username\n";
+}
+
+=head1 NAME
+
+cust_pkg-restore_setup
+
+=head1 SYNOPSIS
+
+  cust_pkg-restore_setup -d date -u history_username [ -r ] employee_username
+
+=head1 DESCRIPTION
+
+Command-line tool to restore removed setup dates.
+
+-s: Start date of time period to restore changes from
+
+-e: End date of time period to restore changes from
+
+-u: sUspended packages only
+
+-c: Cancelled packages only
+
+-r: dRy run
+
+employee_username
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<FS::part_pkg>
+
+=cut
+
+1;
+

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

Summary of changes:
 bin/cust_pkg-remove_setup         |   26 ++++++++
 bin/cust_pkg-restore_setup        |  119 +++++++++++++++++++++++++++++++++++++
 httemplate/edit/cable_device.html |    3 +
 3 files changed, 148 insertions(+), 0 deletions(-)
 create mode 100755 bin/cust_pkg-remove_setup
 create mode 100755 bin/cust_pkg-restore_setup




More information about the freeside-commits mailing list