summaryrefslogtreecommitdiff
path: root/httemplate/misc/cancel_pkg.html
blob: c80b2b27869003d89066d05b29bb880e36e92490 (plain)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<& /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>
<% emt(ucfirst($method)." [_1]", $part_pkg->pkg_comment(cust_pkg=>$cust_pkg) ) %>
<table style="background-color: #cccccc; border-spacing: 2; width: 100%">

% 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;
% }

% if ($method eq 'uncancel' ) {
%
% #XXX customer also requested setup
% # setup: what usefulness is changing or blanking this?  re-charge setup fee?
% #        an option that says that would be better if that's what we want to do

% # last_bill: isn't this informational?  what good would editing it do?
% #            something about invoice display?
  <& /elements/tr-input-date-field.html, {
      'name'    => 'last_bill',
      'value'   => ( $cgi->param('last_bill') || $cust_pkg->get('last_bill') ),
      'label'   => mt("Last bill date"),
      'format'  => $date_format,
  } &>

  <& /elements/tr-input-date-field.html, {
      'name'    => 'bill',
      'value'   => ( $cgi->param('bill') || $cust_pkg->get('bill') ),
      'label'   => mt("Next bill date"),
      'format'  => $date_format,
  } &>

  <& /elements/tr-checkbox.html,
       'label'  => mt("Uncancel even if a service can't be re-provisioned"),
       'field'  => 'svc_not_fatal',
       'value'  => 'Y',
  &>

%   $date_init = 1;
% }

% unless ( $method eq 'resume' || $method eq 'uncancel' ) {
  <& /elements/tr-select-reason.html,
       field          => 'reasonnum',
       reason_class   => $class,
       curr_value     => $reasonnum,
       control_button => "confirm_cancel_pkg_button",
  &>
% }

% if ( $method eq 'adjourn' || $method eq 'suspend' ) {
    <TR><TD COLSPAN=2>
%   if ( $part_pkg->option('suspend_bill', 1) ) {
      <& /elements/checkbox.html, name=>'no_suspend_bill', value=>'Y' &>
      Disable recurring billing while suspended
%   } else {
      <& /elements/checkbox.html, name=>'suspend_bill', value=>'Y' &>
      Continue recurring billing while suspended
%   }
    </TD></TR>
% }

% if ( ( $method eq 'adjourn' || $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 !~ /^(resume|uncancel)$/ ? 'DISABLED' : '' %>>

</FORM>
</BODY>
</HTML>

<%init>
use Date::Parse qw(str2time);

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?
} elsif ( $method eq 'uncancel') {
  $class  = '';
  $submit = 'Un-Cancel';
  $right  = 'Un-cancel 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';
$title =~ s/Uncancel/Un-cancel/;

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>