summaryrefslogtreecommitdiff
path: root/httemplate/misc/process
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2016-07-27 17:23:14 -0500
committerJonathan Prykop <jonathan@freeside.biz>2016-08-09 20:26:20 -0500
commitb304500723fefa090154bd3101508bf635030ab9 (patch)
tree4909f2225f8a36a22825acc4da96babfe96413e1 /httemplate/misc/process
parentb5793c12cf77cd1e0ccc8c666d21c5cd8820397d (diff)
RT#71009: (v4+) OFM - Separate permissions for edit dates and contract dates [v4 reconcile]
Diffstat (limited to 'httemplate/misc/process')
-rwxr-xr-xhttemplate/misc/process/change_pkg_date.html31
1 files changed, 22 insertions, 9 deletions
diff --git a/httemplate/misc/process/change_pkg_date.html b/httemplate/misc/process/change_pkg_date.html
index 17a8518f9..5b1eedfad 100755
--- a/httemplate/misc/process/change_pkg_date.html
+++ b/httemplate/misc/process/change_pkg_date.html
@@ -6,9 +6,21 @@
</HTML>
<%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('Change package start date');
+ unless $curuser->access_right($acl);
$cgi->param('pkgnum') =~ /^(\d+)$/
or die "illegal pkgnum";
@@ -24,23 +36,24 @@ my $cust_pkg = qsearchs({
my $cust_main = $cust_pkg->cust_main;
my $error;
-my $start_date;
+my $date_value;
if ( $cgi->param('when') eq 'now' ) {
- # start it the next time billing runs
- $start_date = '';
+ # blank start means start it the next time billing runs
+ $date_value = $isstart ? '' : time;
} elsif ( $cgi->param('when') eq 'next_bill_date' ) {
- $start_date = $cust_main->next_bill_date;
+ $date_value = $cust_main->next_bill_date;
} elsif ( $cgi->param('when') eq 'date' ) {
- $start_date = parse_datetime($cgi->param('start_date'));
+ $date_value = parse_datetime($cgi->param('date_value'));
}
-if ( $cust_pkg->setup ) {
+if ( $isstart && $cust_pkg->setup ) {
# shouldn't happen
$error = 'This package has already started billing.';
} else {
local $FS::UID::AutoCommit = 0;
foreach my $pkg ($cust_pkg, $cust_pkg->supplemental_pkgs) {
- $pkg->set('start_date', $start_date);
+ last if $error;
+ $pkg->set($field, $date_value);
$error ||= $pkg->replace;
}
$error ? dbh->rollback : dbh->commit;
@@ -48,6 +61,6 @@ if ( $cust_pkg->setup ) {
if ( $error ) {
$cgi->param('error', $error);
- print $cgi->redirect($fsurl.'misc/change_pkg_start.html?', $cgi->query_string);
+ print $cgi->redirect($fsurl.'misc/change_pkg_date.html?', $cgi->query_string);
}
</%init>