summaryrefslogtreecommitdiff
path: root/httemplate/misc/cancel_pkg.html
blob: 8dffba72ebfb3326e761108dd1d74bfa1811f2c5 (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
%# if ( $link eq 'popup' ) { 
  <% include('/elements/header-popup.html', $title ) %>
%# } else { 
%#  <%  include("/elements/header.html", $title, '') %>
%# } 

<LINK REL="stylesheet" TYPE="text/css" HREF="../elements/calendar-win2k-2.css" TITLE="win2k-2">
<SCRIPT TYPE="text/javascript" SRC="../elements/calendar_stripped.js"></SCRIPT>
<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-en.js"></SCRIPT>
<SCRIPT TYPE="text/javascript" SRC="../elements/calendar-setup.js"></SCRIPT>

<% include('/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>
<% ucfirst($method) . " $pkgnum: " .$part_pkg->pkg. ' - ' .$part_pkg->comment %>
<% ntable("#cccccc", 2) %>

% if ($method eq 'expire' || $method eq 'adjourn') {
<TR>
  <TD><% $submit =~ /^(\w*)\s/ %> package on </TD>
    <TD><INPUT TYPE="text" NAME="date" ID="expire_date" VALUE="<% $date |h %>">
        <IMG SRC="<% $p %>images/calendar.png" ID="expire_button" STYLE="cursor:pointer" TITLE="Select date">
        <BR><I>m/d/y</I>
    </TD>
</TR>
<SCRIPT TYPE="text/javascript">
  Calendar.setup({
    inputField: "expire_date",
    ifFormat:   "%m/%d/%Y",
    button:     "expire_button",
    align:      "BR"
  });
</SCRIPT>
%}
%

<% include('/elements/tr-select-reason.html',
             'field'          => 'reasonnum',
             'reason_class'   => $class,
             'curr_value'     => $reasonnum,
             'control_button' => 'document.sc_popup.submit',
          )
%>

</TABLE>

<BR>
<INPUT TYPE="submit" NAME="submit" VALUE="<% $submit %>" disabled='true'>

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

<%init>

my $date = time2str("%m/%d/%Y", time);

my($pkgnum, $reasonnum);
if ( $cgi->param('error') ) {
  $pkgnum    = $cgi->param('pkgnum');
  $reasonnum = $cgi->param('reasonnum');
  $date      = $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';
} 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;

</%init>