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) %>
11 <% ntable("#cccccc", 2) %>
14 % if ($method eq 'expire' || $method eq 'adjourn' || $method eq 'resume') {
15 % $submit =~ /^(\w*)\s/;
16 <& /elements/tr-input-date-field.html, {
19 'label' => mt("$1 package on"),
20 'format' => $date_format,
25 % if ($method eq 'uncancel' ) {
27 % #XXX customer also requested setup
28 % # setup: what usefulness is changing or blanking this? re-charge setup fee?
29 % # an option that says that would be better if that's what we want to do
31 % # last_bill: isn't this informational? what good would editing it do?
32 % # something about invoice display?
33 <& /elements/tr-input-date-field.html, {
34 'name' => 'last_bill',
35 'value' => ( $cgi->param('last_bill') || $cust_pkg->get('last_bill') ),
36 'label' => mt("Last bill date"),
37 'format' => $date_format,
40 <& /elements/tr-input-date-field.html, {
42 'value' => ( $cgi->param('bill') || $cust_pkg->get('bill') ),
43 'label' => mt("Next bill date"),
44 'format' => $date_format,
47 <& /elements/tr-checkbox.html,
48 'label' => mt("Uncancel even if a service can't be re-provisioned"),
49 'field' => 'svc_not_fatal',
56 % unless ( $method eq 'resume' || $method eq 'uncancel' ) {
57 <& /elements/tr-select-reason.html,
59 reason_class => $class,
60 curr_value => $reasonnum,
61 control_button => "document.getElementById('confirm_cancel_pkg_button')",
65 % if ( ( $method eq 'adjourn' or $method eq 'suspend' ) and
66 % $curuser->access_right('Unsuspend customer package') ) { #later?
67 % my $resume_date = $cgi->param('error')
68 % ? str2time($cgi->param('resume_date'))
69 % : $cust_pkg->get('resume');
71 <& /elements/tr-input-date-field.html, {
72 'name' => 'resume_date',
73 'value' => $resume_date,
74 'label' => mt('Unsuspend on'),
75 'format' => $date_format,
76 'noinit' => $date_init,
82 <INPUT TYPE="submit" NAME="submit" ID="confirm_cancel_pkg_button"
83 VALUE="<% mt($submit) |h %>"
84 <% $method !~ /^(resume|uncancel)$/ ? 'DISABLED' : '' %>>
91 use Date::Parse qw(str2time);
93 my $conf = new FS::Conf;
94 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
98 my($pkgnum, $reasonnum);
99 if ( $cgi->param('error') ) {
100 $pkgnum = $cgi->param('pkgnum');
101 $reasonnum = $cgi->param('reasonnum');
102 $date = str2time($cgi->param('date'));
103 } elsif ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) {
107 die "illegal query ". $cgi->keywords;
110 $cgi->param('method') =~ /^(\w+)$/ or die 'illegal method';
113 my($class, $submit, $right);
114 if ($method eq 'cancel') {
116 $submit = 'Cancel Now';
117 $right = 'Cancel customer package immediately';
118 } elsif ($method eq 'expire') {
120 $submit = 'Cancel Later';
121 $right = 'Cancel customer package later';
122 } elsif ($method eq 'suspend') {
124 $submit = 'Suspend Now';
125 $right = 'Suspend customer package';
126 } elsif ($method eq 'adjourn') {
128 $submit = "Suspend Later";
129 $right = 'Suspend customer package later';
130 } elsif ( $method eq 'resume') {
132 $submit = 'Unsuspend Later';
133 $right = 'Unsuspend customer package'; #later?
134 } elsif ( $method eq 'uncancel') {
136 $submit = 'Un-Cancel';
137 $right = 'Un-cancel customer package'; #later?
139 die 'illegal query (unknown method param)';
142 my $curuser = $FS::CurrentUser::CurrentUser;
143 die "access denied" unless $curuser->access_right($right);
145 my $title = ucfirst($method) . ' Package';
146 $title =~ s/Uncancel/Un-cancel/;
148 my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum})
149 or die "Unknown pkgnum: $pkgnum";
151 my $part_pkg = $cust_pkg->part_pkg;
153 $date ||= $cust_pkg->get($method);