From 80b548ef7cad9b01584f8ab2018e186a03148210 Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Wed, 27 Jul 2016 14:01:44 -0500 Subject: RT#71009: (v4+) OFM - Separate permissions for edit dates and contract dates [renamed start date files for generic use, original commit RT#38883] --- httemplate/misc/change_pkg_date.html | 99 ++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100755 httemplate/misc/change_pkg_date.html (limited to 'httemplate/misc/change_pkg_date.html') 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'; + } +} + -- cgit v1.2.1 From 990d718978480aa02b0031a2ec6753e64975fd34 Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Wed, 27 Jul 2016 17:23:14 -0500 Subject: RT#71009: (v4+) OFM - Separate permissions for edit dates and contract dates --- httemplate/misc/change_pkg_date.html | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'httemplate/misc/change_pkg_date.html') diff --git a/httemplate/misc/change_pkg_date.html b/httemplate/misc/change_pkg_date.html index 5a890c86e..0a23805f4 100755 --- a/httemplate/misc/change_pkg_date.html +++ b/httemplate/misc/change_pkg_date.html @@ -3,11 +3,12 @@ <& /elements/error.html &> % # only slightly different from unhold_pkg. -
+ +
-<% emt('Start billing [_1]', $part_pkg->pkg_comment(cust_pkg => $cust_pkg)) %> +<% emt(($isstart ? 'Start billing' : 'Set contract end for').' [_1]', $part_pkg->pkg_comment(cust_pkg => $cust_pkg)) %>
  • <& /elements/radio.html, @@ -16,7 +17,7 @@ value => 'now', curr_value => $when, &> - +
  • % if ( $next_bill_date ) {
  • @@ -41,13 +42,13 @@ &> <& /elements/input-date-field.html, - { name => 'start_date', - value => $cgi->param('start_date') || $cust_pkg->start_date, + { name => 'date_value', + value => $cgi->param('date_value') || $cust_pkg->get($field), } &>
- +
@@ -55,9 +56,21 @@ <%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); my $pkgnum; if ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) { @@ -69,7 +82,7 @@ if ( $cgi->param('pkgnum') =~ /^(\d+)$/ ) { my $conf = new FS::Conf; my $date_format = $conf->config('date_format') || '%m/%d/%Y'; -my $title = 'Start billing package'; +my $title = $isstart ? 'Start billing package' : 'Change contract end'; my $cust_pkg = qsearchs({ table => 'cust_pkg', @@ -83,12 +96,12 @@ 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 +# 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->start_date) { + if ($cust_pkg->get($field)) { $when = 'date'; } elsif ($next_bill_date) { $when = 'next_bill_date'; -- cgit v1.2.1 From 3e5bee7db5e58a9938edc3926d55d7e71688ddb2 Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Fri, 29 Jul 2016 18:57:14 -0500 Subject: RT#71009: (v4+) OFM - Separate permissions for edit dates and contract dates [tweaked now handling] --- httemplate/misc/change_pkg_date.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'httemplate/misc/change_pkg_date.html') diff --git a/httemplate/misc/change_pkg_date.html b/httemplate/misc/change_pkg_date.html index 0a23805f4..642a5b89e 100755 --- a/httemplate/misc/change_pkg_date.html +++ b/httemplate/misc/change_pkg_date.html @@ -17,7 +17,7 @@ value => 'now', curr_value => $when, &> - + % if ( $next_bill_date ) {
  • -- cgit v1.2.1