RT# 75095 - Added Ooma integration to one time charges
[freeside.git] / httemplate / misc / change_pkg_date.html
1 <& /elements/header-popup.html, mt($title) &>
2
3 <& /elements/error.html &>
4
5 % # only slightly different from unhold_pkg.
6 <FORM NAME="MyForm" ACTION="process/change_pkg_date.html" METHOD=POST>
7 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
8 <INPUT TYPE="hidden" NAME="field" VALUE="<% $field %>">
9
10 <BR>
11 <% emt(($isstart ? 'Start billing' : 'Set contract end for').' [_1]', $part_pkg->pkg_comment(cust_pkg => $cust_pkg)) %>
12 <UL STYLE="padding-left: 3ex; list-style: none; background-color: #cccccc">
13 <LI>
14   <& /elements/radio.html,
15     field => 'when',
16     id    => 'when_now',
17     value => 'now',
18     curr_value => $when,
19   &>
20   <label for="when_now"><% emt($isstart ? 'Now' : 'Never') %></label>
21 </LI>
22 % if ( $next_bill_date ) {
23 <LI>
24   <& /elements/radio.html,
25     field => 'when',
26     id    => 'when_next_bill_date',
27     value => 'next_bill_date',
28     curr_value => $when,
29   &>
30   <label for="when_next_bill_date">
31     <% emt('On the next bill date: [_1]', 
32       time2str($date_format, $next_bill_date) ) %>
33   </label>
34 </LI>
35 % }
36 <LI>
37 <& /elements/radio.html,
38   field => 'when',
39   id    => 'when_date',
40   value => 'date',
41   curr_value => $when,
42 &>
43 <label for="when_date"> <% emt('On this date:') %> </label>
44 <& /elements/input-date-field.html,
45   { name  => 'date_value',
46     value => ( scalar($cgi->param('date_value')) || $cust_pkg->get($field) ),
47   }
48 &>
49 </LI>
50 </UL>
51 <INPUT TYPE="submit" NAME="submit" VALUE="<% emt('Set '.($isstart ? 'start date' : 'contract end')) %>">
52
53 </FORM>
54 </BODY>
55 </HTML>
56
57 <%init>
58
59 my $field = $cgi->param('field');
60
61 my ($acl, $isstart);
62 if ($field eq 'start_date') {
63   $acl = 'Change package start date';
64   $isstart = 1;
65 } elsif ($field eq 'contract_end') {
66   $acl = 'Change package contract end date';
67 } else {
68   die "Unknown date field";
69 }
70
71 my $curuser = $FS::CurrentUser::CurrentUser;
72 die "access denied"
73   unless $curuser->access_right($acl);
74
75 my $pkgnum;
76 if ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) {
77   $pkgnum = $1;
78 } else {
79   die "illegal query ". $cgi->keywords;
80 }
81
82 my $conf = new FS::Conf;
83 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
84
85 my $title = $isstart ? 'Start billing package' : 'Change contract end';
86
87 my $cust_pkg = qsearchs({
88   table     => 'cust_pkg',
89   addl_from => ' JOIN cust_main USING (custnum) ',
90   hashref   => { 'pkgnum' => $pkgnum },
91   extra_sql => ' AND '. $curuser->agentnums_sql,
92 }) or die "Unknown pkgnum: $pkgnum";
93
94 my $next_bill_date = $cust_pkg->cust_main->next_bill_date;
95
96 my $part_pkg = $cust_pkg->part_pkg;
97
98 # defaults:
99 # sticky on error, then the existing date if any, then the customer's
100 # next bill date, and if none of those, default to now
101 my $when = $cgi->param('when');
102
103 if (!$when) {
104   if ($cust_pkg->get($field)) {
105     $when = 'date';
106   } elsif ($next_bill_date) {
107     $when = 'next_bill_date';
108   } else {
109     $when = 'now';
110   }
111 }
112 </%init>