1 <& /elements/header-popup.html, mt($title) &>
3 <& /elements/error.html &>
5 <FORM NAME="sc_popup" ACTION="<% popurl(1) %>process/cancel_pkg.html" METHOD=POST>
6 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
7 <INPUT TYPE="hidden" NAME="method" VALUE="<% $method %>">
10 <% emt(ucfirst($method)." [_1]", $part_pkg->pkg_comment(cust_pkg=>$cust_pkg) ) %>
12 <font color="red"><% $unprovision_warning |h %></font>
13 <table style="background-color: #cccccc; border-spacing: 2; width: 100%">
16 % if ($method eq 'expire' || $method eq 'adjourn' || $method eq 'resume') {
17 % $submit =~ /^(\w*)\s/;
18 <& /elements/tr-input-date-field.html, {
21 'label' => mt("$1 package on"),
22 'format' => $date_format,
27 % if ($method eq 'uncancel' ) {
29 % #XXX customer also requested setup
30 % # setup: what usefulness is changing or blanking this? re-charge setup fee?
31 % # an option that says that would be better if that's what we want to do
33 % # last_bill: isn't this informational? what good would editing it do?
34 % # something about invoice display?
35 <& /elements/tr-input-date-field.html, {
36 'name' => 'last_bill',
37 'value' => ( $cgi->param('last_bill') || $cust_pkg->get('last_bill') ),
38 'label' => mt("Last bill date"),
39 'format' => $date_format,
42 <& /elements/tr-input-date-field.html, {
44 'value' => ( $cgi->param('bill') || $cust_pkg->get('bill') ),
45 'label' => mt("Next bill date"),
46 'format' => $date_format,
49 <& /elements/tr-checkbox.html,
50 'label' => mt("Uncancel even if service reprovisioning fails"),
51 'field' => 'svc_not_fatal',
56 % my @uncancel_svcs = sort { $b->{'reprovisionable'} <=> $a->{'reprovisionable'} }
57 % sort { $a->{'svcpart'} <=> $b->{'svcpart'} }
58 % $cust_pkg->uncancel_svc_summary();
59 % if (@uncancel_svcs) {
60 <TR><TD COLSPAN="2"> </TD></TR>
61 <TR><TH ALIGN="right"><% emt("Re-provision the following services") %></TH><TD></TD>
62 % foreach my $uncancel_svc (@uncancel_svcs) {
63 % my $uncancel_curr_value = $uncancel_svc->{'uncancel_svcnum'};
64 % my $uncancel_disabled = '';
65 % my $uncancel_postfix = '';
66 % if ($cgi->param('error')) {
67 % $uncancel_curr_value = '' unless grep { $_ == $uncancel_svc->{'uncancel_svcnum'} } $cgi->param('only_svcnum');
69 % unless ($uncancel_svc->{'reprovisionable'}) {
70 % $uncancel_curr_value = '';
71 % $uncancel_disabled = 1;
72 % $uncancel_postfix = '<I>(' . emt('Cannot be reprovisioned') . ')</I>';
74 <& /elements/tr-checkbox.html,
75 'label' => $uncancel_svc->{'svc'} . ': ' . $uncancel_svc->{'label'},
76 'field' => 'only_svcnum',
77 'value' => $uncancel_svc->{'uncancel_svcnum'},
78 'curr_value' => $uncancel_curr_value,
79 'disabled' => $uncancel_disabled,
80 'cell_style' => 'font-weight: normal',
81 'postfix' => $uncancel_postfix,
87 % unless ( $method eq 'resume' || $method eq 'uncancel' ) {
88 <& /elements/tr-select-reason.html,
90 reason_class => $class,
91 curr_value => $reasonnum,
92 control_button => "confirm_cancel_pkg_button",
96 % if (( $method eq 'adjourn' || $method eq 'suspend' ) && $curuser->access_right('Customize billing during suspension')) {
98 % if ( $part_pkg->option('suspend_bill', 1) ) {
99 <& /elements/checkbox.html, name=>'no_suspend_bill', value=>'Y' &>
100 Disable recurring billing while suspended
102 <& /elements/checkbox.html, name=>'suspend_bill', value=>'Y' &>
103 Continue recurring billing while suspended
108 % if ( ( $method eq 'adjourn' || $method eq 'suspend' ) and
109 % $curuser->access_right('Unsuspend customer package') ) { #later?
110 % my $resume_date = $cgi->param('error')
111 % ? str2time($cgi->param('resume_date'))
112 % : $cust_pkg->get('resume');
114 <& /elements/tr-input-date-field.html, {
115 'name' => 'resume_date',
116 'value' => $resume_date,
117 'label' => mt('Unsuspend on'),
118 'format' => $date_format,
119 'noinit' => $date_init,
125 <INPUT TYPE="submit" NAME="submit" ID="confirm_cancel_pkg_button"
126 VALUE="<% mt($submit) |h %>"
127 <% $method !~ /^(resume|uncancel)$/ ? 'DISABLED' : '' %>>
134 use Date::Parse qw(str2time);
136 my $conf = new FS::Conf;
137 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
141 my($pkgnum, $reasonnum);
142 if ( $cgi->param('error') ) {
143 $pkgnum = $cgi->param('pkgnum');
144 $reasonnum = $cgi->param('reasonnum');
145 $date = str2time($cgi->param('date'));
146 } elsif ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) {
150 die "illegal query ". $cgi->keywords;
153 $cgi->param('method') =~ /^(\w+)$/ or die 'illegal method';
156 my($class, $submit, $right);
157 if ($method eq 'cancel') {
159 $submit = 'Cancel Now';
160 $right = 'Cancel customer package immediately';
161 } elsif ($method eq 'expire') {
163 $submit = 'Cancel Later';
164 $right = 'Cancel customer package later';
165 } elsif ($method eq 'suspend') {
167 $submit = 'Suspend Now';
168 $right = 'Suspend customer package';
169 } elsif ($method eq 'adjourn') {
171 $submit = "Suspend Later";
172 $right = 'Suspend customer package later';
173 } elsif ( $method eq 'resume') {
175 $submit = 'Unsuspend Later';
176 $right = 'Unsuspend customer package'; #later?
177 } elsif ( $method eq 'uncancel') {
179 $submit = 'Un-Cancel';
180 $right = 'Un-cancel customer package'; #later?
182 die 'illegal query (unknown method param)';
185 my $curuser = $FS::CurrentUser::CurrentUser;
186 die "access denied" unless $curuser->access_right($right);
188 my $title = ucfirst($method) . ' Package';
189 $title =~ s/Uncancel/Un-cancel/;
191 my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum})
192 or die "Unknown pkgnum: $pkgnum";
194 my $part_pkg = $cust_pkg->part_pkg;
196 my $unprovision_warning = '';
198 my @services_w_export;
199 for ( $cust_pkg->cust_svc ) {
200 push( @services_w_export, ($_->label)[0] . ': ' . ($_->label)[1], )
201 if $_->part_svc->export_svc;
203 if ( @services_w_export ) {
204 $unprovision_warning = 'NOTE: This package has ' . @services_w_export
205 . ' ' . PL( "service", @services_w_export )
206 . ' that will be unprovisioned';
207 $unprovision_warning .= ' (' . join( ', ', @services_w_export, ) . ')'
208 if @services_w_export < 10;
209 $unprovision_warning .= '.';
213 $date ||= $cust_pkg->get($method);