<& /elements/header-popup.html, mt($title) &> <& /elements/error.html &> % # only slightly different from unhold_pkg.

<% emt(($isstart ? 'Start billing' : 'Set contract end for').' [_1]', $part_pkg->pkg_comment(cust_pkg => $cust_pkg)) %>
<%init> my $field = $cgi->param('field'); my ($acl, $isstart); if ($field eq 'start_date') { $acl = 'Change package start date'; $isstart = 1; } elsif ($field eq 'contract_end') { $acl = 'Change package contract end date'; } else { die "Unknown date field"; } my $curuser = $FS::CurrentUser::CurrentUser; die "access denied" unless $curuser->access_right($acl); my $pkgnum; if ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) { $pkgnum = $1; } else { die "illegal query ". $cgi->keywords; } my $conf = new FS::Conf; my $date_format = $conf->config('date_format') || '%m/%d/%Y'; my $title = $isstart ? 'Start billing package' : 'Change contract end'; my $cust_pkg = qsearchs({ table => 'cust_pkg', addl_from => ' JOIN cust_main USING (custnum) ', hashref => { 'pkgnum' => $pkgnum }, extra_sql => ' AND '. $curuser->agentnums_sql, }) or die "Unknown pkgnum: $pkgnum"; my $next_bill_date = $cust_pkg->cust_main->next_bill_date; my $part_pkg = $cust_pkg->part_pkg; # defaults: # sticky on error, then the existing date if any, then the customer's # next bill date, and if none of those, default to now my $when = $cgi->param('when'); if (!$when) { if ($cust_pkg->get($field)) { $when = 'date'; } elsif ($next_bill_date) { $when = 'next_bill_date'; } else { $when = 'now'; } }