[freeside-commits] branch master updated. 990d718978480aa02b0031a2ec6753e64975fd34

Jonathan Prykop jonathan at 420.am
Wed Jul 27 15:24:08 PDT 2016


The branch, master has been updated
       via  990d718978480aa02b0031a2ec6753e64975fd34 (commit)
       via  80b548ef7cad9b01584f8ab2018e186a03148210 (commit)
      from  da5bcce2b8fdd32e5e9ab54523fc5e5a1705f1dd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 990d718978480aa02b0031a2ec6753e64975fd34
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Wed Jul 27 17:23:14 2016 -0500

    RT#71009: (v4+) OFM - Separate permissions for edit dates and contract dates

diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm
index 0ee0aa0..13a826f 100644
--- a/FS/FS/access_right.pm
+++ b/FS/FS/access_right.pm
@@ -253,7 +253,9 @@ sub _upgrade_data { # class method
     'Generate quotation' => 'Disable quotation',
     'Add on-the-fly void credit reason' => 'Add on-the-fly void reason',
     '_ALL' => 'Employee preference telephony integration',
-    'Edit customer package dates' => 'Change package start date', #4.x
+    'Edit customer package dates' => [ 'Change package start date', #4.x
+                                       'Change package contract end date',
+                                     ],
     'Resend invoices' => 'Print and mail invoices',
   );
 
diff --git a/httemplate/misc/change_pkg_date.html b/httemplate/misc/change_pkg_date.html
index 5a890c8..0a23805 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.
-<FORM NAME="MyForm" ACTION="process/change_pkg_start.html" METHOD=POST>
+<FORM NAME="MyForm" ACTION="process/change_pkg_date.html" METHOD=POST>
 <INPUT TYPE="hidden" NAME="pkgnum" VALUE="<% $pkgnum %>">
+<INPUT TYPE="hidden" NAME="field" VALUE="<% $field %>">
 
 <BR>
-<% 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)) %>
 <UL STYLE="padding-left: 3ex; list-style: none; background-color: #cccccc">
 <LI>
   <& /elements/radio.html,
@@ -16,7 +17,7 @@
     value => 'now',
     curr_value => $when,
   &>
-  <label for="when_now"><% emt('Immediately') %></label>
+  <label for="when_now"><% emt('Now') %></label>
 </LI>
 % if ( $next_bill_date ) {
 <LI>
@@ -41,13 +42,13 @@
 &>
 <label for="when_date"> <% emt('On this date:') %> </label>
 <& /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),
   }
 &>
 </LI>
 </UL>
-<INPUT TYPE="submit" NAME="submit" VALUE="<% emt('Set start date') %>">
+<INPUT TYPE="submit" NAME="submit" VALUE="<% emt('Set '.($isstart ? 'start date' : 'contract end')) %>">
 
 </FORM>
 </BODY>
@@ -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';
diff --git a/httemplate/misc/process/change_pkg_date.html b/httemplate/misc/process/change_pkg_date.html
index 17a8518..5b1eedf 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>
diff --git a/httemplate/view/cust_main/packages/status.html b/httemplate/view/cust_main/packages/status.html
index 97011c3..3f629e1 100644
--- a/httemplate/view/cust_main/packages/status.html
+++ b/httemplate/view/cust_main/packages/status.html
@@ -104,6 +104,14 @@
       <TR>
         <TD COLSPAN=<%$opt{colspan}%>>
           <FONT SIZE=-1>
+%           if ( !$cust_pkg->change_to_pkgnum # because on a technical level, change won't propagate,
+%                                             # and there's not really a use case worth making that work
+%                 and $part_pkg->freq # technically possible to have contract_end w/o freq, but nonsensical
+%                 and $curuser->access_right('Change package contract end date')
+%           ) {
+                ( <% pkg_change_contract_end_link($cust_pkg) %> )
+                <BR>
+%           }
 %           if ( $cust_pkg->change_to_pkgnum ) {
 %               # then you can modify the package change
 %               if ( $curuser->access_right('Change customer package') ) {
@@ -188,21 +196,6 @@
           <% pkg_status_row_if($cust_pkg, emt('Start billing'), 'start_date', %opt) %>
           <% pkg_status_row_if($cust_pkg, emt('Un-cancelled'), 'uncancel', %opt ) %>
 
-%         if ( !$opt{no_links}
-%               and !$change_from
-%               and !$supplemental # can be changed from its main package
-%               and $curuser->access_right('Change package start date') )
-%         {
-
-        <TR>
-          <TD COLSPAN=<%$opt{colspan}%>>
-            <FONT SIZE=-1>
-            ( <% pkg_change_start_link($cust_pkg) %> )
-            </FONT>
-          </TD>
-        </TR>
-%         }
-          
 %       } 
 %
 %     } else { #setup
@@ -286,6 +279,28 @@
         <TR>
           <TD COLSPAN=<%$opt{colspan}%>>
             <FONT SIZE=-1>
+
+% #change date links
+%           if ( !$change_from and !$supplemental ) {
+%             my $has_date_links = 0;
+%             if ( !$cust_pkg->get('setup')
+%                   and $curuser->access_right('Change package start date')
+%             ) {
+            ( <% pkg_change_start_link($cust_pkg) %> )
+%               $has_date_links = 1;
+%             }
+%             if ( !$cust_pkg->change_to_pkgnum # because on a technical level, change won't propagate,
+%                                               # and there's not really a use case worth making that work
+%                   and $curuser->access_right('Change package contract end date')
+%             ) {
+            ( <% pkg_change_contract_end_link($cust_pkg) %> )
+%               $has_date_links = 1;
+%             }
+%             if ($has_date_links) {
+            <BR>
+%             }
+%           }
+
 % # action links
 %           if ( $change_from ) {
 %               # nothing
@@ -745,7 +760,7 @@ sub pkg_change_later_link {
 sub pkg_change_start_link {
   my $cust_pkg = shift;
   include( '/elements/popup_link-cust_pkg.html',
-    'action'      => $p . 'misc/change_pkg_start.html',
+    'action'      => $p . 'misc/change_pkg_date.html?field=start_date',
     'label'       => emt('Set start date'),
     'actionlabel' => emt('Set start of billing for'),
     'cust_pkg'    => $cust_pkg,
@@ -754,6 +769,18 @@ sub pkg_change_start_link {
   )
 }
 
+sub pkg_change_contract_end_link {
+  my $cust_pkg = shift;
+  include( '/elements/popup_link-cust_pkg.html',
+    'action'      => $p . 'misc/change_pkg_date.html?field=contract_end',
+    'label'       => emt('Set contract end'),
+    'actionlabel' => emt('Set contract end for'),
+    'cust_pkg'    => $cust_pkg,
+    'width'       => 510,
+    'height'      => 310,
+  )
+}
+
 sub svc_recharge_link {
   include( '/elements/popup_link-cust_svc.html',
              'action'      => $p. 'misc/recharge_svc.html',

commit 80b548ef7cad9b01584f8ab2018e186a03148210
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Wed Jul 27 14:01:44 2016 -0500

    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_start.html b/httemplate/misc/change_pkg_date.html
similarity index 100%
rename from httemplate/misc/change_pkg_start.html
rename to httemplate/misc/change_pkg_date.html
diff --git a/httemplate/misc/process/change_pkg_start.html b/httemplate/misc/process/change_pkg_date.html
similarity index 100%
rename from httemplate/misc/process/change_pkg_start.html
rename to httemplate/misc/process/change_pkg_date.html

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/access_right.pm                              |    4 +-
 ...{change_pkg_start.html => change_pkg_date.html} |   33 +++++++----
 ...{change_pkg_start.html => change_pkg_date.html} |   31 +++++++---
 httemplate/view/cust_main/packages/status.html     |   59 ++++++++++++++------
 4 files changed, 91 insertions(+), 36 deletions(-)
 rename httemplate/misc/{change_pkg_start.html => change_pkg_date.html} (65%)
 rename httemplate/misc/process/{change_pkg_start.html => change_pkg_date.html} (59%)




More information about the freeside-commits mailing list