temporarily disabling torrus source build
[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>
10 <% emt(ucfirst($method)." [_1]", $part_pkg->pkg_comment(cust_pkg=>$cust_pkg) ) %>
11 <BR>
12 <font color="red">
13 % for ( @unprovision_warning ) {
14 <% $_ |h %><BR>
15 % }
16 </font>
17 <table style="background-color: #cccccc; border-spacing: 2; width: 100%">
18
19 % my $date_init = 0;
20 % if ($method eq 'expire' || $method eq 'adjourn' || $method eq 'resume') {
21 %   $submit =~ /^(\w*)\s/;
22   <& /elements/tr-input-date-field.html, {
23       'name'    => 'date',
24       'value'   => $date,
25       'label'   => mt("$1 package on"),
26       'format'  => $date_format,
27   } &>
28 %   $date_init = 1;
29 % }
30
31 % if ($method eq 'uncancel' ) {
32 %
33 % #XXX customer also requested setup
34 % # setup: what usefulness is changing or blanking this?  re-charge setup fee?
35 % #        an option that says that would be better if that's what we want to do
36
37 % # last_bill: isn't this informational?  what good would editing it do?
38 % #            something about invoice display?
39   <& /elements/tr-input-date-field.html, {
40       'name'    => 'last_bill',
41       'value'   => ( $cgi->param('last_bill') || $cust_pkg->get('last_bill') ),
42       'label'   => mt("Last bill date"),
43       'format'  => $date_format,
44   } &>
45
46   <& /elements/tr-input-date-field.html, {
47       'name'    => 'bill',
48       'value'   => ( $cgi->param('bill') || $cust_pkg->get('bill') ),
49       'label'   => mt("Next bill date"),
50       'format'  => $date_format,
51   } &>
52
53   <& /elements/tr-checkbox.html,
54        'label'  => mt("Uncancel even if service reprovisioning fails"),
55        'field'  => 'svc_not_fatal',
56        'value'  => 'Y',
57   &>
58
59 %   $date_init = 1;
60 %   my @uncancel_svcs = sort { $b->{'reprovisionable'} <=> $a->{'reprovisionable'} }
61 %                       sort { $a->{'svcpart'} <=> $b->{'svcpart'} } 
62 %                       $cust_pkg->uncancel_svc_summary();
63 %   if (@uncancel_svcs) {
64 <TR><TD COLSPAN="2">&nbsp;</TD></TR>
65 <TR><TH ALIGN="right"><% emt("Re-provision the following services") %></TH><TD></TD>
66 %     foreach my $uncancel_svc (@uncancel_svcs) {
67 %       my $uncancel_curr_value = $uncancel_svc->{'uncancel_svcnum'};
68 %       my $uncancel_disabled = '';
69 %       my $uncancel_postfix = '';
70 %       if ($cgi->param('error')) {
71 %         $uncancel_curr_value = '' unless grep { $_ == $uncancel_svc->{'uncancel_svcnum'} } $cgi->param('only_svcnum');
72 %       }
73 %       unless ($uncancel_svc->{'reprovisionable'}) {
74 %         $uncancel_curr_value = '';
75 %         $uncancel_disabled = 1;
76 %         $uncancel_postfix = '<I>(' . emt('Cannot be reprovisioned') . ')</I>';
77 %       }
78   <& /elements/tr-checkbox.html,
79        'label'  => $uncancel_svc->{'svc'} . ': ' . $uncancel_svc->{'label'},
80        'field'  => 'only_svcnum',
81        'value'  => $uncancel_svc->{'uncancel_svcnum'},
82        'curr_value' => $uncancel_curr_value,
83        'disabled'   => $uncancel_disabled,
84        'cell_style' => 'font-weight: normal',
85        'postfix' => $uncancel_postfix,
86   &>
87 %     }
88 %   }
89 % }
90
91 % unless ( $method eq 'resume' || $method eq 'uncancel' ) {
92   <& /elements/tr-select-reason.html,
93        field          => 'reasonnum',
94        reason_class   => $class,
95        curr_value     => $reasonnum,
96        control_button => "confirm_cancel_pkg_button",
97   &>
98 % }
99
100 % if (( $method eq 'adjourn' || $method eq 'suspend' ) && $curuser->access_right('Customize billing during suspension')) {
101     <TR><TD COLSPAN=2>
102 %   if ( $part_pkg->option('suspend_bill', 1) ) {
103       <& /elements/checkbox.html, name=>'no_suspend_bill', value=>'Y' &>
104       Disable recurring billing while suspended
105 %   } else {
106       <& /elements/checkbox.html, name=>'suspend_bill', value=>'Y' &>
107       Continue recurring billing while suspended
108 %   }
109     </TD></TR>
110 % }
111
112 % if ( ( $method eq 'adjourn' || $method eq 'suspend' ) and 
113 %      $curuser->access_right('Unsuspend customer package') )  { #later?
114 %   my $resume_date = $cgi->param('error') 
115 %                     ? str2time($cgi->param('resume_date'))
116 %                     : $cust_pkg->get('resume');
117
118   <& /elements/tr-input-date-field.html, {
119       'name'    => 'resume_date',
120       'value'   => $resume_date,
121       'label'   => mt('Unsuspend on'),
122       'format'  => $date_format,
123       'noinit'  => $date_init,
124   } &>
125 % }
126 </TABLE>
127
128 <BR>
129 <INPUT TYPE="submit" NAME="submit" ID="confirm_cancel_pkg_button" 
130   VALUE="<% mt($submit) |h %>"
131   <% $method !~ /^(resume|uncancel)$/ ? 'DISABLED' : '' %>>
132
133 </FORM>
134 </BODY>
135 </HTML>
136
137 <%init>
138 use Date::Parse qw(str2time);
139
140 my $conf = new FS::Conf;
141 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
142
143 my $date;
144
145 my($pkgnum, $reasonnum);
146 if ( $cgi->param('error') ) {
147   $pkgnum    = $cgi->param('pkgnum');
148   $reasonnum = $cgi->param('reasonnum');
149   $date      = str2time($cgi->param('date'));
150 } elsif ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) {
151   $pkgnum    = $1;
152   $reasonnum = '';
153 } else {
154   die "illegal query ". $cgi->keywords;
155 }
156
157 $cgi->param('method') =~ /^(\w+)$/ or die 'illegal method';
158 my $method = $1;
159
160 my($class, $submit, $right);
161 if ($method eq 'cancel') {
162   $class  = 'C';
163   $submit = 'Cancel Now';
164   $right  = 'Cancel customer package immediately';
165 } elsif ($method eq 'expire') {
166   $class  = 'C';
167   $submit = 'Cancel Later';
168   $right  = 'Cancel customer package later';
169 } elsif ($method eq 'suspend') {
170   $class  = 'S';
171   $submit = 'Suspend Now';
172   $right  = 'Suspend customer package';
173 } elsif ($method eq 'adjourn') {
174   $class  = 'S';
175   $submit = "Suspend Later";
176   $right  = 'Suspend customer package later';
177 } elsif ( $method eq 'resume') {
178   $class  = '';
179   $submit = 'Unsuspend Later';
180   $right  = 'Unsuspend customer package'; #later?
181 } elsif ( $method eq 'uncancel') {
182   $class  = '';
183   $submit = 'Un-Cancel';
184   $right  = 'Un-cancel customer package'; #later?
185 } else {
186   die 'illegal query (unknown method param)';
187 }
188
189 my $curuser = $FS::CurrentUser::CurrentUser;
190 die "access denied" unless $curuser->access_right($right);
191
192 my $title = ucfirst($method) . ' Package';
193 $title =~ s/Uncancel/Un-cancel/;
194
195 my $cust_pkg = qsearchs('cust_pkg', {'pkgnum' => $pkgnum})
196   or die "Unknown pkgnum: $pkgnum";
197
198 my $part_pkg = $cust_pkg->part_pkg;
199
200 my @unprovision_warning;
201 {
202     my @services_w_export;
203     for ( $cust_pkg->cust_svc ) {
204         push( @services_w_export, ($_->label)[0] . ': ' . ($_->label)[1], )
205           if $_->part_svc->export_svc;
206     }
207     if ( @services_w_export ) {
208         push( @unprovision_warning, 'NOTE: This package has '
209           . @services_w_export . ' ' . PL( "service", @services_w_export )
210           . ' that will be unprovisioned', );
211         if ( @services_w_export < 10 ) {
212             $unprovision_warning[0] .= ':';
213             push( @unprovision_warning, @services_w_export, );
214         }
215         else {
216             $unprovision_warning[0] .= '.';
217         }
218     }
219 }
220
221 $date ||= $cust_pkg->get($method);
222 $date ||= time;
223
224 </%init>