From ca1b4450c6eeedf64c9284b5586547f7ed39d100 Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 29 Jan 2008 03:16:26 +0000 Subject: bulk package changing (RT#1394) --- httemplate/misc/bulk_change_pkg.cgi | 69 +++++++++++++++++++++++++++++ httemplate/misc/process/bulk_change_pkg.cgi | 56 +++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100755 httemplate/misc/bulk_change_pkg.cgi create mode 100755 httemplate/misc/process/bulk_change_pkg.cgi (limited to 'httemplate/misc') diff --git a/httemplate/misc/bulk_change_pkg.cgi b/httemplate/misc/bulk_change_pkg.cgi new file mode 100755 index 000000000..ebf20ebc2 --- /dev/null +++ b/httemplate/misc/bulk_change_pkg.cgi @@ -0,0 +1,69 @@ +<% include('/elements/header-popup.html', "Change Packages") %> + +% if ( $cgi->param('error') ) { + Error: <% $cgi->param('error') %> +

+% } + +
+ + +% for my $param (qw(agentnum magic status classnum pkgpart)) { + +% } +% +% foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) { +% + "> + "> + "> + "> +% } + +<% ntable('#cccccc') %> + + + New package: + <% include('/elements/select-table.html', + 'table' => 'part_pkg', + 'name_col' => 'pkg', + 'empty_label' => 'Select package', + 'label_callback' => sub { $_[0]->pkgpart. ': '. + $_[0]->pkg. ' - '. + $_[0]->comment; + }, + 'element_name' => 'new_pkgpart', + 'curr_value' => ( $cgi->param('error') + ? scalar($cgi->param('new_pkgpart')) + : '' + ), + ) + %> + + + + + +
+ + +
+ + + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Bulk change customer packages'); + +#false laziness w/report_cust_pkg.html +my %disable = ( + 'all' => {}, + 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, }, + 'active' => { 'susp'=>1, 'cancel'=>1 }, + 'suspended' => { 'cancel' => 1 }, + 'cancelled' => {}, + '' => {}, +); + + diff --git a/httemplate/misc/process/bulk_change_pkg.cgi b/httemplate/misc/process/bulk_change_pkg.cgi new file mode 100755 index 000000000..d2ab4bf49 --- /dev/null +++ b/httemplate/misc/process/bulk_change_pkg.cgi @@ -0,0 +1,56 @@ +% if ($error) { +<% $cgi->redirect(popurl(2)."/bulk_change_pkg.cgi?".$cgi->query_string ) %> +% } +<% include('/elements/header-popup.html', "Packages Changed") %> +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Bulk change customer packages'); + +my %search_hash = (); + +$search_hash{'query'} = $cgi->param('query'); + +for my $param (qw(agentnum magic status classnum pkgpart)) { + $search_hash{$param} = $cgi->param($param) + if $cgi->param($param); +} + +### +# parse dates +### + +#false laziness w/report_cust_pkg.html +my %disable = ( + 'all' => {}, + 'one-time charge' => { 'last_bill'=>1, 'bill'=>1, 'adjourn'=>1, 'susp'=>1, 'expire'=>1, 'cancel'=>1, }, + 'active' => { 'susp'=>1, 'cancel'=>1 }, + 'suspended' => { 'cancel' => 1 }, + 'cancelled' => {}, + '' => {}, +); + +foreach my $field (qw( setup last_bill bill adjourn susp expire cancel )) { + + my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi, $field); + + next if $beginning == 0 && $ending == 4294967295 + or $disable{$cgi->param('status')}->{$field}; + + $search_hash{$field} = [ $beginning, $ending ]; + +} + +my $sql_query = FS::cust_pkg->search_sql(\%search_hash); +$sql_query->{'select'} = 'cust_pkg.pkgnum'; + +my $error = FS::cust_pkg::bulk_change( [ $cgi->param('new_pkgpart') ], + [ map { $_->pkgnum } qsearch($sql_query) ], + ); + +$cgi->param("error", substr($error, 0, 512)); # arbitrary length believed + # suited for all supported + # browsers + + + -- cgit v1.2.1