1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
<& /elements/header-popup.html, mt($title) &>
<& /elements/error.html &>
<FORM NAME="sc_popup" ACTION="<% popurl(1) %>process/cancel_pkg.html" METHOD=POST>
<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
<INPUT TYPE="hidden" NAME="method" VALUE="<% $method %>">
<BR><BR>
<% emt(ucfirst($method)." [_1]", $part_pkg->pkg_comment) %>
<% ntable("#cccccc", 2) %>
% my $date_init = 0;
% if ($method eq 'expire' || $method eq 'adjourn' || $method eq 'resume') {
% $submit =~ /^(\w*)\s/;
<& /elements/tr-input-date-field.html, {
'name' => 'date',
'value' => $date,
'label' => mt("$1 package on"),
'format' => $date_format,
} &>
% $date_init = 1;
% }
% unless ( $method eq 'resume' ) { #the only one that doesn't need a reason
<& /elements/tr-select-reason.html,
'field' => 'reasonnum',
'reason_class' => $class,
'curr_value' => $reasonnum,
'control_button' => "document.getElementById('confirm_cancel_pkg_button')",
&>
% }
% if ( ( $method eq 'adjourn' or $method eq 'suspend' ) and
% $curuser->access_right('Unsuspend customer package') ) { #later?
% my $resume_date = $cgi->param('error')
% ? str2time($cgi->param('resume_date'))
% : $cust_pkg->get('resume');
<& /elements/tr-input-date-field.html, {
'name' => 'resume_date',
'value' => $resume_date,
'label' => mt('Unsuspend on'),
'format' => $date_format,
'noinit' => $date_init,
} &>
% }
</TABLE>
<BR>
<INPUT TYPE="submit" NAME="submit" ID="confirm_cancel_pkg_button"
VALUE="<% mt($submit) |h %>"
<% $method ne 'resume' ? 'DISABLED' : '' %>>
</FORM>
</BODY>
</HTML>
<%init>
my $conf = new FS::Conf;
my $date_format = $conf->config('date_format') || '%m/%d/%Y';
my $date;
my($pkgnum, $reasonnum);
if ( $cgi->param('error') ) {
$pkgnum = $cgi->param('pkgnum');
$reasonnum = $cgi->param('reasonnum');
$date = str2time($cgi->param('date'));
} elsif ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) {
$pkgnum = $1;
$reasonnum = '';
} else {
die "illegal query ". $cgi->keywords;
}
$cgi->param('method') =~ /^(\w+)$/ or die 'illegal method';
my $method = $1;
my($class, $submit, $right);
if ($method eq 'cancel') {
$class = 'C';
$submit = 'Cancel Now';
$right = 'Cancel customer package immediately';
} elsif ($method eq 'expire') {
$class = 'C';
$submit = 'Cancel Later';
$right = 'Cancel customer package later';
} elsif ($method eq 'suspend') {
$class = 'S';
$submit = 'Suspend Now';
$right = 'Suspend customer package';
} elsif ($method eq 'adjourn') {
$class = 'S';
$submit = "Suspend Later";
$right = 'Suspend customer package later';
} elsif ( $method eq 'resume') {
$class = '';
$submit = 'Unsuspend Later';
$right = 'Unsuspend customer package'; #later?
} else {
die 'illegal query (unknown method param)';
}
my $curuser = $FS::CurrentUser::CurrentUser;
die "access denied" unless $curuser->access_right($right);
my $title = ucfirst($method) . ' Package';
my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum})
or die "Unknown pkgnum: $pkgnum";
my $part_pkg = $cust_pkg->part_pkg;
$date ||= $cust_pkg->get($method);
$date ||= time;
</%init>
|