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