4 use FS::UID qw(adminsuidsetup);
5 use FS::Record qw(qsearchs qsearch);
8 my $user = shift or die &usage;
9 my $dbh = adminsuidsetup($user);
11 my $fcc_up_speed = "(select part_pkg_fcc_option.optionvalue from part_pkg_fcc_option where fccoptionname = 'broadband_upstream' and pkgpart = cust_pkg.pkgpart) AS fcc477_upstream";
12 my $fcc_down_speed = "(select part_pkg_fcc_option.optionvalue from part_pkg_fcc_option where fccoptionname = 'broadband_downstream' and pkgpart = cust_pkg.pkgpart) AS fcc477_downstream";
14 foreach my $rec (qsearch({
15 'select' => 'svc_broadband.*, cust_svc.svcpart, cust_pkg.pkgpart, '.$fcc_up_speed.', '.$fcc_down_speed,
16 'table' => 'svc_broadband',
17 'addl_from' => 'LEFT JOIN cust_svc USING ( svcnum ) LEFT JOIN cust_pkg USING ( pkgnum )',
19 $rec->{Hash}->{speed_test_up} = $rec->{Hash}->{speed_up} ? $rec->{Hash}->{speed_up} : "null";
20 $rec->{Hash}->{speed_test_down} = $rec->{Hash}->{speed_down} ? $rec->{Hash}->{speed_down} : "null";
21 $rec->{Hash}->{speed_up} = $rec->{Hash}->{fcc477_upstream} ? $rec->{Hash}->{fcc477_upstream} * 1000 : "null";
22 $rec->{Hash}->{speed_down} = $rec->{Hash}->{fcc477_downstream} ? $rec->{Hash}->{fcc477_downstream} * 1000 : "null";
24 my $sql = "UPDATE svc_broadband set
25 speed_up = $rec->{Hash}->{speed_up},
26 speed_down = $rec->{Hash}->{speed_down},
27 speed_test_up = $rec->{Hash}->{speed_test_up},
28 speed_test_down = $rec->{Hash}->{speed_test_down}
29 WHERE svcnum = $rec->{Hash}->{svcnum}";
31 warn "Fixing broadband service speeds for service ".$rec->{Hash}->{svcnum}."-".$rec->{Hash}->{description}."\n";
33 my $sth = $dbh->prepare($sql) or die $dbh->errstr;
34 $sth->execute or die $sth->errstr;
40 warn "Completed fixing broadband service speeds!\n";
46 move_svc_broadband_speeds
50 move_svc_broadband_speeds.pl [ user ]
54 Moves value for speed_down to speed_test_down, speed_up to speed_test_up,
55 and sets speed_down, speed_up to matching fcc_477 speeds from package for
56 all svc_broadband services.
58 user: freeside username