1 <& /elements/header-popup.html, mt($title) &>
3 <& /elements/error.html &>
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 %>">
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">
14 <& /elements/radio.html,
20 <label for="when_now"><% emt($isstart ? 'Now' : 'Never') %></label>
22 % if ( $next_bill_date ) {
24 <& /elements/radio.html,
26 id => 'when_next_bill_date',
27 value => 'next_bill_date',
30 <label for="when_next_bill_date">
31 <% emt('On the next bill date: [_1]',
32 time2str($date_format, $next_bill_date) ) %>
37 <& /elements/radio.html,
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) ),
51 <INPUT TYPE="submit" NAME="submit" VALUE="<% emt('Set '.($isstart ? 'start date' : 'contract end')) %>">
59 my $field = $cgi->param('field');
62 if ($field eq 'start_date') {
63 $acl = 'Change package start date';
65 } elsif ($field eq 'contract_end') {
66 $acl = 'Change package contract end date';
68 die "Unknown date field";
71 my $curuser = $FS::CurrentUser::CurrentUser;
73 unless $curuser->access_right($acl);
76 if ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) {
79 die "illegal query ". $cgi->keywords;
82 my $conf = new FS::Conf;
83 my $date_format = $conf->config('date_format') || '%m/%d/%Y';
85 my $title = $isstart ? 'Start billing package' : 'Change contract end';
87 my $cust_pkg = qsearchs({
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";
94 my $next_bill_date = $cust_pkg->cust_main->next_bill_date;
96 my $part_pkg = $cust_pkg->part_pkg;
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');
104 if ($cust_pkg->get($field)) {
106 } elsif ($next_bill_date) {
107 $when = 'next_bill_date';