diff options
author | jeff <jeff> | 2008-07-01 05:03:42 +0000 |
---|---|---|
committer | jeff <jeff> | 2008-07-01 05:03:42 +0000 |
commit | 7905f5dfd903529a6de89875e6fae74638a89aa3 (patch) | |
tree | c0b2127274371c3eb040dd0fc3d9e58e0fa11627 /httemplate | |
parent | 3b268aa232236ad064c7b3f47a6a0a242e395bdf (diff) |
correct internal reason searching, prevent interleaved suspend/cancel/expire/adjourn, backporting and refactoring
Diffstat (limited to 'httemplate')
-rwxr-xr-x | httemplate/edit/REAL_cust_pkg.cgi | 11 | ||||
-rwxr-xr-x | httemplate/misc/process/cancel_pkg.html | 11 | ||||
-rwxr-xr-x | httemplate/misc/unadjourn_pkg.cgi | 17 | ||||
-rwxr-xr-x | httemplate/misc/unexpire_pkg.cgi | 17 | ||||
-rwxr-xr-x | httemplate/search/cust_pkg.cgi | 9 | ||||
-rwxr-xr-x | httemplate/view/cust_main/packages.html | 29 |
6 files changed, 66 insertions, 28 deletions
diff --git a/httemplate/edit/REAL_cust_pkg.cgi b/httemplate/edit/REAL_cust_pkg.cgi index 6f7f0d7db..b2c89c32c 100755 --- a/httemplate/edit/REAL_cust_pkg.cgi +++ b/httemplate/edit/REAL_cust_pkg.cgi @@ -44,10 +44,10 @@ <& .row_edit, cust_pkg=>$cust_pkg, column=>'setup', label=>'Setup' &> <& .row_edit, cust_pkg=>$cust_pkg, column=>'last_bill', label=>$last_bill_or_renewed &> <& .row_edit, cust_pkg=>$cust_pkg, column=>'bill', label=>$next_bill_or_prepaid_until &> - <& .row_edit, cust_pkg=>$cust_pkg, column=>'adjourn', label=>'Adjournment', note=>'(will <b>suspend</b> this package when the date is reached)' &> + <& .row_display, cust_pkg=>$cust_pkg, column=>'adjourn', label=>'Adjournment', note=>'(will <b>suspend</b> this package when the date is reached)' &> <& .row_display, cust_pkg=>$cust_pkg, column=>'susp', label=>'Suspension' &> - <& .row_edit, cust_pkg=>$cust_pkg, column=>'expire', label=>'Expiration', note=>'(will <b>cancel</b> this package when the date is reached)' &> + <& .row_display, cust_pkg=>$cust_pkg, column=>'expire', label=>'Expiration', note=>'(will <b>cancel</b> this package when the date is reached)' &> <& .row_display, cust_pkg=>$cust_pkg, column=>'cancel', label=>'Cancellation' &> <%def .row_edit> @@ -96,11 +96,16 @@ $cust_pkg $column $label + $note => '' </%args> % if ( $cust_pkg->get($column) ) { <TR> <TD ALIGN="right"><% $label %> date</TD> - <TD BGCOLOR="#ffffff"><% time2str($format,$cust_pkg->get($column)) %></TD> + <TD BGCOLOR="#ffffff"><% time2str($format,$cust_pkg->get($column)) %> +% if ( $note ) { + <BR><FONT SIZE=-1><% $note %></FONT> +% } + </TD> </TR> % } </%def> diff --git a/httemplate/misc/process/cancel_pkg.html b/httemplate/misc/process/cancel_pkg.html index d265c1849..669af9c87 100755 --- a/httemplate/misc/process/cancel_pkg.html +++ b/httemplate/misc/process/cancel_pkg.html @@ -46,6 +46,7 @@ if ($method eq 'expire' || $method eq 'adjourn'){ $date = $cgi->param('date'); str2time($cgi->param('date')) =~ /^(\d+)$/ or die "Illegal date"; $date = $1; + $method = ($method eq 'expire') ? 'cancel' : 'suspend'; } my $cust_pkg = qsearchs( 'cust_pkg', {'pkgnum'=>$pkgnum} ); @@ -61,15 +62,7 @@ if ($reasonnum == -1) { }; } -my $error; -if ($method eq 'expire' || $method eq 'adjourn'){ - my %hash = $cust_pkg->hash; - $hash{$method} = $date; - my $new = new FS::cust_pkg \%hash; - $error = $new->replace($cust_pkg, 'reason' => $reasonnum); -} else { - $error = $cust_pkg->$method( 'reason' => $reasonnum ); -} +my $error = $cust_pkg->$method( 'reason' => $reasonnum, 'date' => $date ); if ($error) { $cgi->param('error', $error); diff --git a/httemplate/misc/unadjourn_pkg.cgi b/httemplate/misc/unadjourn_pkg.cgi new file mode 100755 index 000000000..356b49cb3 --- /dev/null +++ b/httemplate/misc/unadjourn_pkg.cgi @@ -0,0 +1,17 @@ +%if ( $error ) { +% errorpage($error); +%} else { +<% $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')) %> +%} +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Suspend customer package later'); + +my ($pkgnum) = $cgi->keywords; +my $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } ); +my $error = "No package $pkgnum" unless $cust_pkg; + +$error ||= $cust_pkg->unadjourn; + +</%init> diff --git a/httemplate/misc/unexpire_pkg.cgi b/httemplate/misc/unexpire_pkg.cgi new file mode 100755 index 000000000..445025524 --- /dev/null +++ b/httemplate/misc/unexpire_pkg.cgi @@ -0,0 +1,17 @@ +%if ( $error ) { +% errorpage($error); +%} else { +<% $cgi->redirect(popurl(2). "view/cust_main.cgi?".$cust_pkg->getfield('custnum')) %> +%} +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Cancel customer package later'); + +my ($pkgnum) = $cgi->keywords; +my $cust_pkg = qsearchs( 'cust_pkg', { 'pkgnum' => $pkgnum } ); +my $error = "No package $pkgnum" unless $cust_pkg; + +$error ||= $cust_pkg->unexpire; + +</%init> diff --git a/httemplate/search/cust_pkg.cgi b/httemplate/search/cust_pkg.cgi index 6c63ed412..bd4a9466f 100755 --- a/httemplate/search/cust_pkg.cgi +++ b/httemplate/search/cust_pkg.cgi @@ -52,11 +52,10 @@ sub { my $self = shift; my $return = ''; - if ($self->getfield('cancel') || - $self->getfield('suspend')) { - my $reason = $self->last_reason;# too inefficient? - $return = $reason->reason if $reason; - + foreach my $action ( qw ( cancel susp ) ) { + my $reason = $self->last_reason($action); + $return = $reason->reason if $reason; + last if $return; } $return; }, diff --git a/httemplate/view/cust_main/packages.html b/httemplate/view/cust_main/packages.html index 093cbfae6..44c5d6304 100755 --- a/httemplate/view/cust_main/packages.html +++ b/httemplate/view/cust_main/packages.html @@ -149,15 +149,12 @@ Current packages % % % if ( $cust_pkg->get('cancel') ) { #status: cancelled -% my $cpr = $cust_pkg->last_cust_pkg_reason; +% my $cpr = $cust_pkg->last_cust_pkg_reason('cancel'); <% pkg_status_row($cust_pkg, 'Cancelled', 'cancel', 'color'=>'FF0000', conf=>$conf ) %> <% pkg_status_row_colspan( - ( ( $cpr && ( $cpr->date == $cust_pkg->get('cancel') || - $cpr->date == $cust_pkg->expire - ) - ) ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '', + ( $cpr ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '', 'align' => 'right', 'color' => 'ff0000', 'size' => '-2', ) %> @@ -178,15 +175,12 @@ Current packages % } else { % % if ( $cust_pkg->get('susp') ) { #status: suspended -% my $cpr = $cust_pkg->last_cust_pkg_reason; +% my $cpr = $cust_pkg->last_cust_pkg_reason('susp'); <% pkg_status_row( $cust_pkg, 'Suspended', 'susp', 'color'=>'FF9900', conf=>$conf ) %> <% pkg_status_row_colspan( - ( ( $cpr && ( $cpr->date == $cust_pkg->susp || - $cpr->date == $cust_pkg->adjourn - ) - ) ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '', + ( $cpr ? $cpr->reasontext. ' by '. $cpr->otaker : '' ), '', 'align' => 'right', 'color' => 'FF9900', 'size' => '-2', ) %> @@ -418,7 +412,18 @@ sub pkg_status_row { sub pkg_status_row_if { my( $cust_pkg, $title, $field, %opt ) = @_; - $cust_pkg->get($field) ? pkg_status_row(@_) : ''; + + $title = '<FONT SIZE=-1>( '. pkg_unadjourn_link($cust_pkg). ' ) </FONT>'. $title + if ( $field eq 'adjourn' && + $curuser->access_right('Suspend customer package later') + ); + + $title = '<FONT SIZE=-1>( '. pkg_unexpire_link($cust_pkg). ' ) </FONT>'. $title + if ( $field eq 'expire' && + $curuser->access_right('Cancel customer package later') + ); + + $cust_pkg->get($field) ? pkg_status_row($cust_pkg, $title, $field, %opt) : ''; } sub pkg_status_row_changed { @@ -566,6 +571,8 @@ sub pkg_adjourn_link { include( '/elements/popup_link-cust_pkg.html', sub pkg_unsuspend_link { pkg_link('misc/unsusp_pkg', 'Unsuspend', @_ ); } sub pkg_dates_link { pkg_link('edit/REAL_cust_pkg', 'Edit dates', @_ ); } +sub unadjourn_link { pkg_link('misc/unadjourn_pkg', 'Abort', @_ ); } +sub unexpire_link { pkg_link('misc/unexpire_pkg', 'Abort', @_ ); } sub pkg_cancel_link { include( '/elements/popup_link-cust_pkg.html', { 'action' => $p. 'misc/cancel_pkg.html?method=cancel', |