[freeside-commits] branch FREESIDE_4_BRANCH updated. 2f6f9c28f41be0f92139fb5593df61040cb31b17

Christopher Burger burgerc at freeside.biz
Mon May 13 07:55:47 PDT 2019


The branch, FREESIDE_4_BRANCH has been updated
       via  2f6f9c28f41be0f92139fb5593df61040cb31b17 (commit)
      from  eb09c7c7ace14565bcbfa8d547f5574f1e5ad2e1 (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 2f6f9c28f41be0f92139fb5593df61040cb31b17
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Mon May 13 10:16:32 2019 -0400

    RT# 83251 - added option to update tower/sector
    
    Conflicts:
            httemplate/edit/tower.html

diff --git a/bin/svc_broadband_update_speeds b/bin/svc_broadband_update_speeds
index 6bbd93e63..3a7759286 100755
--- a/bin/svc_broadband_update_speeds
+++ b/bin/svc_broadband_update_speeds
@@ -11,20 +11,22 @@ use Data::Dumper;
 # parse command line
 ###
 
-use vars qw( $opt_h $opt_v $opt_n $opt_e $opt_s $opt_c $opt_r $opt_p $opt_d );
-getopts('hvnes:c:r:pd:');
+use vars qw( $opt_h $opt_v $opt_n $opt_e $opt_a $opt_s $opt_c $opt_r $opt_p $opt_t $opt_d );
+getopts('hvneas:c:r:pt:d:');
 
 my $user = shift or die &usage;
 adminsuidsetup $user;
 
 sub usage { "
   Usage:
-      svc_broadband_update_speeds [ -h help] [ -v verbose] [ -n only update services with a null up/down speed] [ -e export service ] [ -s service_part_num (required) ] [ -c sibling service_part_num ] [ -r (speed rate in KB 'up,down') ] [ -p (get speed from package fcc rate) ] [ -d directory for exception file (required) ] user (required)\n
+      svc_broadband_update_speeds: [ -h help] [ -v verbose] [ -n only update services with a null up/down speed] [ -e export service ] [ -a update tower_sector_num ] [ -s service_part_num (required) ] [ -c sibling service_part_num ] [ -r (speed rate in KB 'up,down') ] [ -p (get speed from package fcc rate) ] [ -t tower_sector_num ] [ -d directory for exception file (required) ] user (required)\n
       A directory for the exception file, freeside user name and a service to update is required.\n
       Must set one or more of options p, c, or r. \n
       Also must run this report as user freeside.\n
       Option r up and down speed seperated by a comma in kbps.
       Getting speed from option p (package fcc rates) first if set, if no rates found then checks for option c (rate of sibling service) if set, if still no rates found checks for rate in option r if set.  If no rates found service will be placed in exception file.
+      Option a will update tower/sector with that of sibling service if tower sector is null.
+      If option t is set, svc tower/sector will be set to sibling service set in -c, if no sibling service tower/sector found will set tower_sector to option t value.  This will only update services with a null tower/sector field.
       By default serivce will not export if there is a export assigned to service.  Setting option e will perform the export.
 " }
 
@@ -97,23 +99,45 @@ sub _update_service {
      warn ("Option r speeds not correct.  Must be in kbps up and down seperated by comma. [ -r xxxxxx,xxxxxx ]\n") if $opt_v && (!$speed_up || !$speed_down);
   }
 
-  ## update service with new speed.
   if ($speed_up && $speed_down) {
     $service->set('speed_up', $speed_up);
     $service->set('speed_down', $speed_down);
+  }
+
+  ## if option t, then update tower/sector for service.
+  if ($opt_a) {
+    warn ("Getting tower/sector for service ".$service->description."(".$service->svcnum.") from sibling service of package ".$service->pkgnum) if $opt_v;
+    my $tower_sector;
+    my $sibling_service = qsearchs({
+       'select'    => 'svc_broadband.*, cust_svc.svcpart',
+       'table'     => 'svc_broadband',
+       'addl_from' => ' LEFT JOIN cust_svc USING ( svcnum )',
+       'extra_sql' => ' WHERE cust_svc.pkgnum = '.$service->pkgnum.' AND cust_svc.svcpart = '.$opt_c.' AND svc_broadband.sectornum IS NOT NULL',
+    }) if $opt_c;
+    $tower_sector = $sibling_service->sectornum if $sibling_service;
+    $tower_sector = $opt_t if (!$tower_sector && $opt_t);
+    $service->set('sectornum', $tower_sector) if $tower_sector;
+  }
 
-    warn("updating service ".$service->description."(".$service->svcnum.") with upload speed ($speed_up) and download speed ($speed_down)\n") if $opt_v;
+  ## update service with new speed and tower/sector num.
+  if ($service->speed_up && $service->speed_down && $service->sectornum) {
+    warn("updating service ".$service->description."(".$service->svcnum.") with upload speed (".$service->speed_up.") and download speed (".$service->speed_down.") and sector num (".$service->sectornum.")\n") if $opt_v;
     $service->set('no_export', $opt_e);
     my $error = $service->replace();
     warn($error) if $error;
     ###todo: if no error provision service if not provisioned ie new svc_broadband.
   }
   else {
+    my $error;
+    $error .= " no download speed set," unless $service->speed_down;
+    $error .= " no upload speed set," unless $service->speed_up;
+    $error .= " no tower sector set" unless $service->sectornum;
+
     open(FILE, ">>$exception_file")
       or die "can't open $opt_d: $!";
-      print FILE "Service ".$service->description."(".$service->svcnum.") could not set a up or download speed.\n";
+      print FILE "Service ".$service->description."(".$service->svcnum.") could not be updated.$error.\n";
     close FILE or die "can't close $opt_d: $!";
-    warn($service->description."(".$service->svcnum.") could not set a up or download speed, added to exception file.\n") if $opt_v;
+    warn("Service ".$service->description."(".$service->svcnum.") could not be updated.$error. added to exception file.\n") if $opt_v;
   }
   return;
 }
@@ -127,7 +151,9 @@ This script allows for the mas update of up and down speeds for a svc_broadband
 the script will obtain the new speed from option p (package fcc rates) first if set, 
 if no rates found then checks for option c (rate of sibling service) if set, 
 if still no rates found checks for rate in option r if set.  
-If no rates found service will be placed in exception file. 
+If no rates found service will be placed in exception file.
+
+If option a is set, will also update tower/sector num with that of sibling service or option t
 
 Script must be run as user freeside.
 Options -s, -d and freeside user are required.
@@ -135,4 +161,18 @@ Options -s, -d and freeside user are required.
 example:
 sudo -u freeside ./svc_broadband_update_speeds -v -s 4 -c 2 -r 148000,248000 -p -d /home/freeside/ freesideuser
 
-=cut
\ No newline at end of file
+available options:
+[ -h help]
+[ -v verbose]
+[ -n only update services with a null up/down speed]
+[ -e export service ]
+[ -a update tower_sector_num ]
+[ -s service_part_num (required) ]
+[ -c sibling service_part_num ]
+[ -r (speed rate in KB 'up,down') ]
+[ -p (get speed from package fcc rate) ]
+[ -t tower_sector_num ]
+[ -d directory for exception file (required) ]
+freesideuser
+
+=cut
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 27ed0f5d7..6bc05591d 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -515,12 +515,15 @@ Example:
 %     }
 %     foreach my $name_obj ( @existing ) {
 %
+%       my $m2_label = $f->{'m2_label'};
+%       $m2_label = &{ $f->{'m2_label_callback'} }($name_obj) if $f->{'m2_label_callback'};
+%
 %       my $ex_label = '<INPUT TYPE="button" VALUE="X" TITLE="Remove this '.
 %                      lc($f->{'m2_label'}).
 %                      qq(" onClick="remove_$field($fieldnum);").
 %                      ' STYLE="color:#ff0000;font-weight:bold;'.
 %                              'padding-left:2px;padding-right:2px"'.
-%                      '> '. ($f->{'m2_label'} || $field ). ' ';
+%                      '> '. ($m2_label || $field ). ' ';
 %       
 %       if ( $f->{'layer_values_callback'} ) {
 %         my %switches = ( 'mode' => $mode );
diff --git a/httemplate/edit/tower.html b/httemplate/edit/tower.html
index 93b7235b7..e35fa615c 100644
--- a/httemplate/edit/tower.html
+++ b/httemplate/edit/tower.html
@@ -18,6 +18,7 @@
                           type              => 'tower_sector',
                           o2m_table         => 'tower_sector',
                           m2_label          => 'Sector',
+                          m2_label_callback => sub { 'Sector #'.shift->sectornum; },
                           m2_error_callback => $m2_error_callback,
                         },
                       ],
diff --git a/httemplate/elements/tr-tower_sectors.html b/httemplate/elements/tr-tower_sectors.html
index 8acedb84b..b3d453282 100644
--- a/httemplate/elements/tr-tower_sectors.html
+++ b/httemplate/elements/tr-tower_sectors.html
@@ -184,7 +184,10 @@ $(function() {
 % my $id = $opt{id}; # sectornumX
 <div id="<% $id %>">
 % # no id on this one, the panel gets the "sectornumX" id
-  <input type="hidden" name="<% $id %>" value="<% $sector->sectornum |h %>">
+  <p>
+    <label><% emt('Sector number') %></label> <% $sector->sectornum |h %>
+    <input type="hidden" name="<% $id %>" value="<% $sector->sectornum |h %>">
+  </p>
   <p>
     <label><% emt('Sector name') %></label>
     <input style="text-align: left"

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

Summary of changes:
 bin/svc_broadband_update_speeds           | 58 ++++++++++++++++++++++++++-----
 httemplate/edit/elements/edit.html        |  5 ++-
 httemplate/edit/tower.html                |  1 +
 httemplate/elements/tr-tower_sectors.html |  5 ++-
 4 files changed, 58 insertions(+), 11 deletions(-)




More information about the freeside-commits mailing list