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