From: Jonathan Prykop Date: Wed, 27 Jul 2016 19:01:44 +0000 (-0500) Subject: RT#71009: (v4+) OFM - Separate permissions for edit dates and contract dates [renamed... X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=80b548ef7cad9b01584f8ab2018e186a03148210;ds=sidebyside RT#71009: (v4+) OFM - Separate permissions for edit dates and contract dates [renamed start date files for generic use, original commit RT#38883] --- diff --git a/httemplate/misc/change_pkg_date.html b/httemplate/misc/change_pkg_date.html new file mode 100755 index 000000000..5a890c86e --- /dev/null +++ b/httemplate/misc/change_pkg_date.html @@ -0,0 +1,99 @@ +<& /elements/header-popup.html, mt($title) &> + +<& /elements/error.html &> + +% # only slightly different from unhold_pkg. +
+ + +
+<% emt('Start billing [_1]', $part_pkg->pkg_comment(cust_pkg => $cust_pkg)) %> + + + +
+ + + +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; +die "access denied" + unless $curuser->access_right('Change package start date'); + +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 = 'Start billing package'; + +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 start 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->start_date) { + $when = 'date'; + } elsif ($next_bill_date) { + $when = 'next_bill_date'; + } else { + $when = 'now'; + } +} + diff --git a/httemplate/misc/change_pkg_start.html b/httemplate/misc/change_pkg_start.html deleted file mode 100755 index 5a890c86e..000000000 --- a/httemplate/misc/change_pkg_start.html +++ /dev/null @@ -1,99 +0,0 @@ -<& /elements/header-popup.html, mt($title) &> - -<& /elements/error.html &> - -% # only slightly different from unhold_pkg. -
- - -
-<% emt('Start billing [_1]', $part_pkg->pkg_comment(cust_pkg => $cust_pkg)) %> - - - -
- - - -<%init> - -my $curuser = $FS::CurrentUser::CurrentUser; -die "access denied" - unless $curuser->access_right('Change package start date'); - -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 = 'Start billing package'; - -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 start 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->start_date) { - $when = 'date'; - } elsif ($next_bill_date) { - $when = 'next_bill_date'; - } else { - $when = 'now'; - } -} - diff --git a/httemplate/misc/process/change_pkg_date.html b/httemplate/misc/process/change_pkg_date.html new file mode 100755 index 000000000..17a8518f9 --- /dev/null +++ b/httemplate/misc/process/change_pkg_date.html @@ -0,0 +1,53 @@ +<& /elements/header-popup.html &> + + + +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; +die "access denied" + unless $curuser->access_right('Change package start date'); + +$cgi->param('pkgnum') =~ /^(\d+)$/ + or die "illegal pkgnum"; +my $pkgnum = $1; + +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 $cust_main = $cust_pkg->cust_main; + +my $error; +my $start_date; +if ( $cgi->param('when') eq 'now' ) { + # start it the next time billing runs + $start_date = ''; +} elsif ( $cgi->param('when') eq 'next_bill_date' ) { + $start_date = $cust_main->next_bill_date; +} elsif ( $cgi->param('when') eq 'date' ) { + $start_date = parse_datetime($cgi->param('start_date')); +} + +if ( $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); + $error ||= $pkg->replace; + } + $error ? dbh->rollback : dbh->commit; +} + +if ( $error ) { + $cgi->param('error', $error); + print $cgi->redirect($fsurl.'misc/change_pkg_start.html?', $cgi->query_string); +} + diff --git a/httemplate/misc/process/change_pkg_start.html b/httemplate/misc/process/change_pkg_start.html deleted file mode 100755 index 17a8518f9..000000000 --- a/httemplate/misc/process/change_pkg_start.html +++ /dev/null @@ -1,53 +0,0 @@ -<& /elements/header-popup.html &> - - - -<%init> - -my $curuser = $FS::CurrentUser::CurrentUser; -die "access denied" - unless $curuser->access_right('Change package start date'); - -$cgi->param('pkgnum') =~ /^(\d+)$/ - or die "illegal pkgnum"; -my $pkgnum = $1; - -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 $cust_main = $cust_pkg->cust_main; - -my $error; -my $start_date; -if ( $cgi->param('when') eq 'now' ) { - # start it the next time billing runs - $start_date = ''; -} elsif ( $cgi->param('when') eq 'next_bill_date' ) { - $start_date = $cust_main->next_bill_date; -} elsif ( $cgi->param('when') eq 'date' ) { - $start_date = parse_datetime($cgi->param('start_date')); -} - -if ( $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); - $error ||= $pkg->replace; - } - $error ? dbh->rollback : dbh->commit; -} - -if ( $error ) { - $cgi->param('error', $error); - print $cgi->redirect($fsurl.'misc/change_pkg_start.html?', $cgi->query_string); -} -