From: Ivan Kohler Date: Tue, 4 Jun 2013 10:23:27 +0000 (-0700) Subject: move services between packages, RT#22619 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=4cd40172ccbfce9cfa49bff5a6338f3c6c978f4b;p=freeside.git move services between packages, RT#22619 --- diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm index 4753d3166..d7e5a17e3 100644 --- a/FS/FS/AccessRight.pm +++ b/FS/FS/AccessRight.pm @@ -160,6 +160,7 @@ tie my %rights, 'Tie::IxHash', 'View customer services', #NEW 'Provision customer service', 'Bulk provision customer service', + 'Bulk move customer services', #NEWNEW 'Recharge customer service', #NEW 'Unprovision customer service', 'Change customer service', #NEWNEW diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 42b4b8f9c..4e164592e 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -5084,13 +5084,6 @@ and customer address. Include units.', 'select_enum' => [ 'misc_info', 'top' ], }, - { - 'key' => 'maestro-status_test', - 'section' => 'UI', - 'description' => 'Display a link to the maestro status test page on the customer view page', - 'type' => 'checkbox', - }, - { 'key' => 'cust_main-custom_link', 'section' => 'UI', diff --git a/FS/FS/XMLRPC.pm b/FS/FS/XMLRPC.pm index 73ce13f7a..62ae43d18 100644 --- a/FS/FS/XMLRPC.pm +++ b/FS/FS/XMLRPC.pm @@ -11,8 +11,6 @@ use FS::Conf; use FS::Record; use FS::cust_main; -use FS::Maestro; - use Data::Dumper; $DEBUG = 0; diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm index a42d7f280..f8e30d0d2 100644 --- a/FS/FS/access_right.pm +++ b/FS/FS/access_right.pm @@ -234,6 +234,7 @@ sub _upgrade_data { # class method ], 'Change customer package' => 'Detach customer package', 'Services: Accounts' => 'Services: Cable Subscribers', + 'Bulk change customer packages' => 'Bulk move customer services', ; foreach my $old_acl ( keys %onetime ) { diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index c49007ce1..425fe6833 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -3191,6 +3191,46 @@ sub transfer { return $remaining; } +=item grab_svcnums SVCNUM, SVCNUM ... + +Change the pkgnum for the provided services to this packages. If there is an +error, returns the error, otherwise returns false. + +=cut + +sub grab_svcnums { + my $self = shift; + my @svcnum = @_; + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + foreach my $svcnum (@svcnum) { + my $cust_svc = qsearchs('cust_svc', { svcnum=>$svcnum } ) or do { + $dbh->rollback if $oldAutoCommit; + return "unknown svcnum $svcnum"; + }; + $cust_svc->pkgnum( $self->pkgnum ); + my $error = $cust_svc->replace; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + ''; + +} + =item reexport This method is deprecated. See the I option to the insert and diff --git a/httemplate/edit/bulk-cust_svc-pkgnum.html b/httemplate/edit/bulk-cust_svc-pkgnum.html new file mode 100644 index 000000000..a3437292f --- /dev/null +++ b/httemplate/edit/bulk-cust_svc-pkgnum.html @@ -0,0 +1,47 @@ +<& /elements/header-popup.html, 'Move services' &> + +Select the target package and the services to be moved.

+ +
+ +<& /view/cust_main/packages.html, $cust_main, + no_links => 1, + before_pkg_callback => sub { + my $cust_pkg = shift; + ''; + }, + before_svc_callback => sub { + my $cust_svc = shift; + my $nameid = 'svcnum'. $cust_svc->svcnum; + '
'. + qq( ). + ' '; + }, + after_svc_callback => sub { + #my $cust_svc = shift; + '
'; + }, +&> + +
+ + +
+ + + +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; +die "access denied" unless $curuser->access_right('Bulk move customer services'); + +$cgi->param('custnum') =~ /^(\d+)$/ or die 'illegal custnum'; +my $custnum = $1; + +my $cust_main = qsearchs({ + 'table' => 'cust_main', + 'hashref' => { 'custnum' => $custnum }, + 'extra_sql' => ' AND '. $curuser->agentnums_sql, +}) or die 'unknown customer'; + + diff --git a/httemplate/elements/tr-cust_svc.html b/httemplate/elements/tr-cust_svc.html index b66654f38..3710b27ff 100644 --- a/httemplate/elements/tr-cust_svc.html +++ b/httemplate/elements/tr-cust_svc.html @@ -15,20 +15,35 @@ Usage: 'manage_link' => '', #for svc_broadband 'manage_link_text' => '', #default 'Manage Device' 'manage_link_loc' => '', #default 'bottom', or 'right' - 'maestro-status_test' => '', ) %> - <% -FS::UI::Web::svc_link($m, $part_svc, $cust_svc) -%> - <% $cust_svc->agent_svcid ? $cust_svc->agent_svcid.': ' : '' %><% -FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) -%> + +% if ( $opt{no_links} ) { + <% $part_svc->svc |h %>: +% } else { + <% FS::UI::Web::svc_link($m, $part_svc, $cust_svc) %> +% } + + +% if ( $opt{before_svc_callback} ) { + <% &{ $opt{before_svc_callback} }( $cust_svc ) %> +% } + <% $cust_svc->agent_svcid ? $cust_svc->agent_svcid.': ' : '' %> +% if ( $opt{no_links} ) { + <% ($cust_svc->label)[1] |h %> +% } else { + <% FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) %> +% } + +% if ( $opt{after_svc_callback} ) { + <% &{ $opt{after_svc_callback} }( $cust_svc ) %> +% } + <% FS::UI::Web::svc_export_links($m, $part_svc, $cust_svc) %> -% if ( $manage_link and $opt{'manage_link_loc'} eq 'right' ) { +% if ( $manage_link and $opt{'manage_link_loc'} eq 'right' && ! $opt{no_links} ) { ><% $opt{'manage_link_text'} |h %> % } @@ -49,6 +64,7 @@ $cust_svc->overlimit ) % if ( $curuser->access_right('Recharge customer service') % && $part_svc->svcdb eq 'svc_acct' +% && ! $opt{no_links} % && ( $svc_x->seconds ne '' % || $svc_x->upbytes ne '' % || $svc_x->downbytes ne '' @@ -60,21 +76,17 @@ $cust_svc->overlimit ) % # second column: all other action links -% if ( $part_svc->svcdb eq 'svc_broadband' ) { +% if ( $part_svc->svcdb eq 'svc_broadband' && ! $opt{no_links} ) { ( <% include('/elements/popup_link-ping.html', 'ip' => $svc_x->ip_addr ) %> ) -% if ( $manage_link and $opt{'manage_link_loc'} eq 'bottom' ) { +% if ( $manage_link and $opt{'manage_link_loc'} eq 'bottom' && ! $opt{no_links} ) { ><% $opt{'manage_link_text'} |h %> ) % } % } #svc_broadband -% if ( $curuser->access_right('Unprovision customer service') ) { +% if ( $curuser->access_right('Unprovision customer service') && ! $opt{no_links} ) { ( <% $svc_unprovision_link %> ) -% } -% if ( $part_svc->svcdb eq 'svc_pbx' && $opt{'maestro-status_test'} ) { - Test maestro status ) - % } diff --git a/httemplate/elements/tr-cust_svc_cancel.html b/httemplate/elements/tr-cust_svc_cancel.html index e7fa47a92..44276ec82 100644 --- a/httemplate/elements/tr-cust_svc_cancel.html +++ b/httemplate/elements/tr-cust_svc_cancel.html @@ -3,12 +3,20 @@ tr-cust_svc_cancel - Short display of a canceled customer service for use in view/cust_main. - <% -FS::UI::Web::svc_link($m, $part_svc, $cust_svc) -%> - <% -FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) -%> + +% if ( $opt{no_links} ) { + <% $part_svc->svc |h %>: +% } else { + <% FS::UI::Web::svc_link($m, $part_svc, $cust_svc) %> +% } + + +% if ( $opt{no_links} ) { + <% ($cust_svc->label)[1] |h %> +% } else { + <% FS::UI::Web::svc_label_link($m, $part_svc, $cust_svc) %> +% } + %# no action links, the service is canceled diff --git a/httemplate/view/cust_main.cgi b/httemplate/view/cust_main.cgi index be0100fb3..1f9e0f904 100755 --- a/httemplate/view/cust_main.cgi +++ b/httemplate/view/cust_main.cgi @@ -162,11 +162,6 @@ function areyousure(href, message) {

% } -%if ( $conf->exists('maestro-status_test') ) { - <% mt('Test maestro status') |h %> -

-% } - diff --git a/httemplate/view/cust_main/locations.html b/httemplate/view/cust_main/locations.html index 689c9a390..7eb52ca46 100755 --- a/httemplate/view/cust_main/locations.html +++ b/httemplate/view/cust_main/locations.html @@ -28,15 +28,19 @@ STYLE="padding-bottom: 0px; % } <% $loc->location_label %> -% if ( $locationnum and !$loc->disabled ) { +% if ( $locationnum && !$loc->disabled && ! $opt{no_links} ) { <% edit_location_link($locationnum) %> % } -% if ( $locationnum and !$loc->disabled and !$active{$locationnum} ) { +% if ( $locationnum && !$loc->disabled && !$active{$locationnum} && ! $opt{no_links} ) {  <% disable_location_link($locationnum) %> % } % if (@$packages) { -<& packages/section.html, 'packages' => $packages, 'cust_main' => $cust_main &> + <& packages/section.html, + 'packages' => $packages, + 'cust_main' => $cust_main, + 'no_links' => $opt{no_links} + &> % }

% } #foreach $locationnum diff --git a/httemplate/view/cust_main/packages.html b/httemplate/view/cust_main/packages.html index 546dd89c3..e32fe4c03 100755 --- a/httemplate/view/cust_main/packages.html +++ b/httemplate/view/cust_main/packages.html @@ -24,7 +24,10 @@ table.usage { .row1 { background-color: #ffffff; } -% my $s = 0; + +% unless ( $opt{no_links} ) { + +% my $s = 0; % if ( $curuser->access_right('Qualify service') ) { <% $s++ ? ' | ' : '' %> @@ -43,21 +46,33 @@ table.usage { <& one_time_charge_link.html, $cust_main &> % } +% if ( $curuser->access_right('Bulk move customer services') ) { + <% $s++ ? ' | ' : '' %> + + <& /elements/popup_link-cust_main.html, + 'label' => emt('Move services between packages'), + 'action' => "${p}edit/bulk-cust_svc-pkgnum.html", + 'cust_main' => $cust_main, + 'actionlabel' => emt('Move services'), + 'width' => 968, #763, + 'height' => 575, + &> + +% } + % if ( $curuser->access_right('Bulk change customer packages') ) { <% $s++ ? ' | ' : '' %> - <% mt('Bulk order and cancel packages') |h %> (<% mt('preserves services') |h %>) + <% mt('Bulk order and cancel packages') |h %> % }

+% } # unless $opt{no_links} + + +% unless ( $opt{no_links} ) { + + +% } # unless $opt{no_links} + @@ -105,6 +126,7 @@ table.usage { <& locations.html, 'cust_main' => $cust_main, 'packages' => $packages, + %opt, &> % } % else { @@ -113,6 +135,7 @@ table.usage { <& packages/section.html, 'cust_main' => $cust_main, 'packages' => $packages, + %opt, &>
-% if ( @$packages ) { - -<% mt('Current packages') |h %> -% } % if ( $cust_main->num_cancelled_pkgs ) { % if ( $cgi->param('showcancelledpackages') eq '0' #see if it was set by me % || ( $conf->exists('hidecancelledpackages') @@ -86,6 +101,9 @@ table.usage { % } <% mt('Package reports') |h %> % if ( $curuser->access_right('Qualify service') ) { @@ -97,6 +115,9 @@ table.usage { <% mt('Usage reports:') |h %> <% mt('CDRs') |h %>
% } diff --git a/httemplate/view/cust_main/packages/contact.html b/httemplate/view/cust_main/packages/contact.html index fe8b71534..93985e404 100644 --- a/httemplate/view/cust_main/packages/contact.html +++ b/httemplate/view/cust_main/packages/contact.html @@ -1,16 +1,16 @@ % if ( $contact ) { <% $contact->line |h %> -% if ( $show_change_link ) { +% if ( $show_change_link && ! $opt{no_links} ) { ( <%pkg_change_contact_link($cust_pkg)%> ) % } -% if ( $show_detach_link ) { +% if ( $show_detach_link && ! $opt{no_links} ) { ( <%pkg_detach_link($cust_pkg)%> ) % } -% } elsif ( $show_contact_link ) { +% } elsif ( $show_contact_link && ! $opt{no_links} ) { ( <%pkg_add_contact_link($cust_pkg)%> ) diff --git a/httemplate/view/cust_main/packages/location.html b/httemplate/view/cust_main/packages/location.html index f2d379841..470fad0f1 100644 --- a/httemplate/view/cust_main/packages/location.html +++ b/httemplate/view/cust_main/packages/location.html @@ -32,8 +32,10 @@ % {
- ( <%pkg_change_location_link($cust_pkg)%> ) -% if ( $cust_pkg->locationnum ) { +% unless ( $opt{no_links} ) { + ( <%pkg_change_location_link($cust_pkg)%> ) +% } +% if ( $cust_pkg->locationnum && ! $opt{no_links} ) { ( <%edit_location_link($cust_pkg->locationnum)%> ) % } diff --git a/httemplate/view/cust_main/packages/package.html b/httemplate/view/cust_main/packages/package.html index 520305a9a..5b9c53012 100644 --- a/httemplate/view/cust_main/packages/package.html +++ b/httemplate/view/cust_main/packages/package.html @@ -3,6 +3,10 @@ -% if ( $curuser->access_right('Change customer package') and -% !$cust_pkg->get('cancel') and -% !$supplemental and -% $part_pkg->freq ne '0' ) { +% if ( $curuser->access_right('Change customer package') +% && ! $cust_pkg->get('cancel') +% && ! $supplemental +% && $part_pkg->freq ne '0' +% && ! $opt{no_links} +% ) +% { % if ( FS::Conf->new->exists('invoice-unitprice') ) {
+ <% $opt{before_pkg_callback} + ? &{ $opt{before_pkg_callback} }( $cust_pkg ) + : '' + %> <% $curuser->option('show_pkgnum') ? $cust_pkg->pkgnum.': ' : '' %><% $part_pkg->pkg |h %> @@ -24,7 +28,7 @@ -% unless ( $cust_pkg->get('cancel') ) { +% unless ( $cust_pkg->get('cancel') || $opt{no_links} ) { % % if ( $supplemental or $part_pkg->freq eq '0' ) { % # Supplemental packages can't be changed independently. @@ -99,7 +103,7 @@ <% mt('Invoice details') |h %> -% if ( $editi && ! $cust_pkg->get('cancel') ) { +% if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) { (<& /elements/popup_link.html, { 'action' => $editlink. 'I', 'label' => emt('edit'), @@ -121,7 +125,7 @@ % } else { -% if ( $editi && ! $cust_pkg->get('cancel') ) { +% if ( $editi && ! $cust_pkg->get('cancel') && ! $opt{no_links} ) { ( <% include('/elements/popup_link.html', { 'action' => $editlink. 'I', @@ -143,7 +147,7 @@ <% mt('Comments') |h %> -% if ( $editc ) { +% if ( $editc && ! $opt{no_links} ) { (<& /elements/popup_link.html, { 'action' => $editlink. 'C', 'label' => emt('edit'), @@ -165,7 +169,7 @@ % } else { -% if ( $editc ) { +% if ( $editc && ! $opt{no_links} ) { ( <& /elements/popup_link.html, { 'action' => $editlink. 'C', @@ -181,10 +185,13 @@ % }
diff --git a/httemplate/view/cust_main/packages/section.html b/httemplate/view/cust_main/packages/section.html index 391a13b5f..82d06203b 100755 --- a/httemplate/view/cust_main/packages/section.html +++ b/httemplate/view/cust_main/packages/section.html @@ -10,8 +10,10 @@ % #$FS::cust_pkg::DEBUG = 2; % foreach my $cust_pkg (@$packages) { <& .packagerow, $cust_pkg, - 'cust_main' => $opt{'cust_main'}, - 'bgcolor' => $opt{'bgcolor'}, + ( map { $_ => $opt{$_} } qw( + cust_main bgcolor + no_links before_pkg_callback before_svc_callback after_svc_callback + )), %conf_opt &> % } @@ -92,7 +94,6 @@ my %conf_opt = ( 'manage_link_text' => scalar($conf->config('svc_broadband-manage_link_text')), 'manage_link_loc' => scalar($conf->config('svc_broadband-manage_link_loc')), 'manage_link-new_window' => $conf->exists('svc_broadband-manage_link-new_window'), - 'maestro-status_test' => $conf->exists('maestro-status_test'), 'cust_pkg-large_pkg_size' => scalar($conf->config('cust_pkg-large_pkg_size')), ); diff --git a/httemplate/view/cust_main/packages/status.html b/httemplate/view/cust_main/packages/status.html index c0213e90b..ed360cca4 100644 --- a/httemplate/view/cust_main/packages/status.html +++ b/httemplate/view/cust_main/packages/status.html @@ -36,7 +36,7 @@
> -% if ( $curuser->access_right('Un-cancel customer package') ) { +% if ( $curuser->access_right('Un-cancel customer package') && ! $opt{no_links} ) { ( <% pkg_uncancel_link($cust_pkg) %> ) % } @@ -79,7 +79,7 @@ <% pkg_status_row_if( $cust_pkg, emt('Expires'), 'expire', %opt, curuser=>$curuser ) %> <% pkg_status_row_if( $cust_pkg, emt('Contract ends'), 'contract_end', %opt ) %> -% if ( !$supplemental ) { +% if ( !$supplemental && ! $opt{no_links} ) {
> @@ -117,7 +117,7 @@ <% pkg_status_row_if($cust_pkg, emt('Un-cancelled'), 'uncancel', %opt ) %> -% if (!$supplemental) { +% if ( !$supplemental && ! $opt{no_links} ) {
> @@ -210,7 +210,7 @@ <% pkg_status_row_if( $cust_pkg, emt('Expires'), 'expire', %opt, curuser=>$curuser ) %> <% pkg_status_row_if( $cust_pkg, emt('Contract ends'), 'contract_end', %opt ) %> -% if ( $part_pkg->freq and !$supplemental ) { +% if ( $part_pkg->freq and !$supplemental && ! $opt{no_links} ) {
>