[freeside-commits] branch FREESIDE_3_BRANCH updated. 88a08dcdebbdfe2d9ad223922e3505ee019862ae

Jonathan Prykop jonathan at 420.am
Thu Mar 31 21:21:38 PDT 2016


The branch, FREESIDE_3_BRANCH has been updated
       via  88a08dcdebbdfe2d9ad223922e3505ee019862ae (commit)
       via  8672cdda3e564f871544d2569c1edc64c711cdbf (commit)
      from  4573e0bbb9eae530da0d711b97fcb161ba4662d8 (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 88a08dcdebbdfe2d9ad223922e3505ee019862ae
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Thu Mar 31 23:07:19 2016 -0500

    RT#39958 Service Provisioning History - New Requirement [bug fix]

diff --git a/httemplate/view/cust_main/change_history.html b/httemplate/view/cust_main/change_history.html
index fe11b95..d46a4ff 100644
--- a/httemplate/view/cust_main/change_history.html
+++ b/httemplate/view/cust_main/change_history.html
@@ -159,10 +159,10 @@ foreach my $table ( keys %tables ) {
 #   but it would spoil database optimizations on this lookup
 my @svcnumobj = qsearch({
   'select' => 'DISTINCT svcnum',
-  'hashref'   => { 'custnum' => $cust_main->custnum,
-                   'history_date' =>  { op=>'>=', value=>$newer_than } },
+  'hashref'   => { 'history_date' =>  { op=>'>=', value=>$newer_than } },
   'table'  => 'h_cust_svc',
   'addl_from' => 'JOIN cust_pkg USING (pkgnum)',
+  'extra_sql' => ' AND custnum = '. $cust_main->custnum,
 });
 
 # now grab those svcs explicitly 

commit 8672cdda3e564f871544d2569c1edc64c711cdbf
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Fri Mar 25 04:24:42 2016 -0500

    RT#39958: Service Provisioning History - New Requirement

diff --git a/httemplate/view/cust_main/change_history.html b/httemplate/view/cust_main/change_history.html
index 09c1d6c..fe11b95 100644
--- a/httemplate/view/cust_main/change_history.html
+++ b/httemplate/view/cust_main/change_history.html
@@ -51,20 +51,25 @@ tie my %tables, 'Tie::IxHash',
 my $pkg_join = "JOIN cust_pkg USING ( pkgnum )";
 my $svc_join = "JOIN cust_svc USING ( svcnum ) $pkg_join";
 
+my @svc_tables = qw(
+  svc_acct
+  svc_domain
+  svc_www
+  svc_forward
+  svc_broadband
+  svc_external
+  svc_phone
+  svc_cable
+);
+
 my %table_join = (
-  'svc_acct'         => $svc_join,
   'radius_usergroup' => $svc_join,
-  'svc_domain'       => $svc_join,
-  'svc_www'          => $svc_join,
-  'svc_forward'      => $svc_join,
-  'svc_broadband'    => $svc_join,
-  'svc_external'     => $svc_join,
-  'svc_phone'        => $svc_join,
-  'svc_cable'        => $svc_join,
   'phone_device'     => $svc_join,
   'cust_pkg_discount'=> $pkg_join,
 );
 
+%table_join = (%table_join, map { $_ => $svc_join } @svc_tables);
+
 
 # cust_main
 # cust_main_invoice
@@ -134,6 +139,7 @@ my $newer_than = int( time - $years * 31556736 ); #60*60*24*365.24
 
 local($FS::Record::nowarn_classload) = 1;
 
+my %foundsvcs;
 foreach my $table ( keys %tables ) {
   my @items = qsearch({
     'table'     => "h_$table",
@@ -141,9 +147,51 @@ foreach my $table ( keys %tables ) {
     'hashref'   => { 'history_date' =>  { op=>'>=', value=>$newer_than }, },
     'extra_sql' => ' AND custnum = '. $cust_main->custnum,
   });
+  %foundsvcs = (%foundsvcs, map { $_->svcnum => 1 } @items)
+    if $table =~ /^svc/;
+  push @history, @items;
+}
+
+### Load svcs that are no longer linked (cust_svc has been deleted)
+
+# get list of all svcs for this customer from h_cust_svc
+# could also load svcdb here by joining to part_svc on svcpart,
+#   but it would spoil database optimizations on this lookup
+my @svcnumobj = qsearch({
+  'select' => 'DISTINCT svcnum',
+  'hashref'   => { 'custnum' => $cust_main->custnum,
+                   'history_date' =>  { op=>'>=', value=>$newer_than } },
+  'table'  => 'h_cust_svc',
+  'addl_from' => 'JOIN cust_pkg USING (pkgnum)',
+});
+
+# now grab those svcs explicitly 
+foreach my $svcnum ( map { $_->get('svcnum') } @svcnumobj ) {
+  # can skip the services we already found
+  next if $foundsvcs{$svcnum};
+  # grab any given h_cust_svc record for this svcnum to get svcdb
+  my $svcdbobj = qsearchs({
+    'select' => 'svcdb',
+    'hashref' => { svcnum => $svcnum },
+    'table'  => 'h_cust_svc',
+    'addl_from' => 'JOIN part_svc USING (svcpart)',
+    'extra_sql' => 'LIMIT 1',
+  });
+  unless ($svcdbobj && $svcdbobj->get('svcdb')) {
+    # don't think this ever happens, but just in case, don't break history page over it
+    warn "Could not load svcdb for svcnum $svcnum";
+    next;
+  }
+  my @items = qsearch({
+    'table'     => "h_".$svcdbobj->get('svcdb'),
+    'hashref'   => { 'history_date' =>  { op=>'>=', value=>$newer_than },
+                     'svcnum' => $svcnum },
+  });
   push @history, @items;
 }
 
+## legacy history
+
 my @legacy_items = qsearch({
   'table'     => 'legacy_cust_history',
   'hashref'   => { 'history_date' =>  { op=>'>=', value=>$newer_than }, },

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

Summary of changes:
 httemplate/view/cust_main/change_history.html |   64 +++++++++++++++++++++----
 1 file changed, 56 insertions(+), 8 deletions(-)




More information about the freeside-commits mailing list