[freeside-commits] branch FREESIDE_3_BRANCH updated. 91c7741223e84c67b64693cf4bbab6cfbd944e7e

Christopher Burger burgerc at 420.am
Fri Jul 21 20:28:50 PDT 2017


The branch, FREESIDE_3_BRANCH has been updated
       via  91c7741223e84c67b64693cf4bbab6cfbd944e7e (commit)
       via  d14018734aa489652f1e14685c44a29bf2af8cc6 (commit)
       via  0f38b0b1e43d3f37f9f0cfb3bc427004b6762d82 (commit)
       via  e820c248c68a5885843a77d87fddfb26c6eb515b (commit)
       via  bfc5435b9b9352a7eb62f7946cb77c5c5ebc88b9 (commit)
       via  2ee8675dead19d3a6669314b7a207366bf2cdf9d (commit)
       via  9c1e27955566bfddd0c756e6237a89d8427d0f3e (commit)
       via  43d43d3101e7f555422bd48276f22b1bebbf6010 (commit)
      from  a941bc2ebde67e4bb0be5d6516cf1b09c092e8a1 (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 91c7741223e84c67b64693cf4bbab6cfbd944e7e
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Fri Jul 21 10:10:00 2017 -0400

    RT# 73993 - added new API call to list and documented it.

diff --git a/fs_selfservice/FS-SelfService/SelfService.pm b/fs_selfservice/FS-SelfService/SelfService.pm
index f1b2081..d76e128 100644
--- a/fs_selfservice/FS-SelfService/SelfService.pm
+++ b/fs_selfservice/FS-SelfService/SelfService.pm
@@ -62,6 +62,7 @@ $socket .= '.'.$tag if defined $tag && length($tag);
   'process_prepay'            => 'MyAccount/process_prepay',
   'realtime_collect'          => 'MyAccount/realtime_collect',
   'list_pkgs'                 => 'MyAccount/list_pkgs',     #add to ss (added?)
+  'pkg_info'                  => 'MyAccount/pkg_info',
   'list_svcs'                 => 'MyAccount/list_svcs',     #add to ss (added?)
   'list_svc_usage'            => 'MyAccount/list_svc_usage',   
   'svc_status_html'           => 'MyAccount/svc_status_html',
@@ -878,6 +879,46 @@ Blank if the service is not over limit, or the date the service exceeded its usa
 
 =back
 
+=item pkg_info
+
+Returns package information for package.
+
+Takes a hash reference as parameter with the following keys:
+
+=over 4
+
+=item session_id
+
+Session identifier
+
+=item pkgnum
+
+Package Number
+
+=back
+
+Returns a hash reference containing customer package information.  The hash reference contains the following keys:
+
+=pkg_label
+
+Name of this package
+
+=pkgpart
+
+Part package primary key
+
+=classnum
+
+Package class number
+
+=error
+
+error message if errror.
+
+=back
+
+=back
+
 =item list_svcs
 
 Returns service information for this customer.

commit d14018734aa489652f1e14685c44a29bf2af8cc6
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Sun Jul 2 11:58:57 2017 -0400

    RT# 73993 - cleaned up code as requested, and created new call to get package info

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index e2cce0d..558e694 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -1655,6 +1655,30 @@ sub cancel {
 
 }
 
+sub pkg_info {
+  my $p = shift;
+
+  my($context, $session, $custnum) = _custoragent_session_custnum($p);
+  return { 'error' => $session } if $context eq 'error';
+
+  my $pkg = qsearchs({
+    'table'     => 'cust_pkg',
+    'addl_from' => 'LEFT JOIN part_pkg USING ( pkgpart )',
+    'hashref'   => {
+                      'custnum' => $custnum,
+                      'pkgnum'  => $p->{'pkgnum'},
+                   },
+  })
+    or return {'error' => 'unknown pkg num $pkgnum'};
+
+  return {
+        pkg_label => $pkg->pkg,
+        pkgpart   => $pkg->pkgpart,
+        classnum  => $pkg->classnum,
+  };
+
+}
+
 sub list_pkgs {
   my $p = shift;
 
diff --git a/FS/FS/ClientAPI_XMLRPC.pm b/FS/FS/ClientAPI_XMLRPC.pm
index 3f5d888..4ad0ca7 100644
--- a/FS/FS/ClientAPI_XMLRPC.pm
+++ b/FS/FS/ClientAPI_XMLRPC.pm
@@ -145,6 +145,7 @@ sub ss2clientapi {
   'finish_thirdparty'         => 'MyAccount/finish_thirdparty',
   'realtime_collect'          => 'MyAccount/realtime_collect',
   'list_pkgs'                 => 'MyAccount/list_pkgs',     #add to ss (added?)
+  'pkg_info'                  => 'MyAccount/pkg_info',
   'list_svcs'                 => 'MyAccount/list_svcs',     #add to ss (added?)
   'list_svc_usage'            => 'MyAccount/list_svc_usage',   
   'svc_status_html'           => 'MyAccount/svc_status_html',
diff --git a/ng_selfservice/packages_change.php b/ng_selfservice/packages_change.php
index 20685e8..6791a1a 100644
--- a/ng_selfservice/packages_change.php
+++ b/ng_selfservice/packages_change.php
@@ -2,39 +2,28 @@
 <? $current_menu = 'services.php'; include('elements/menu.php'); ?>
 <?
 
-$get_params = array( 'pkgnum' );
-foreach ( $get_params AS $param ) {
-  $params[$param] = $_GET[$param];
-}
-
 $customer_info = $freeside->customer_info_short( array(
   'session_id' => $_COOKIE['session_id'],
 ) );
 
-$list_pkgs = $freeside->list_pkgs( array(
-  'session_id' => $_COOKIE['session_id'],
-) );
+if ( preg_match( '/^(\d+)$/', $_GET['pkgnum'] ) ) {
+ $cust_pkg = $freeside->pkg_info( array(
+   'session_id' => $_COOKIE['session_id'],
+   'pkgnum' => $_GET['pkgnum'],
+ ) );
+}
+else { $cust_pkg['error'] = 'Bad Package Number'; }
 
-if ( isset($list_pkgs['error']) && $list_pkgs['error'] ) {
-  $error = $list_pkgs['error'];
+if ( isset($cust_pkg['error']) && $cust_pkg['error'] ) {
+  $error = $cust_pkg['error'];
   header('Location:index.php?error='. urlencode($error));
   die();
 }
 
-extract($list_pkgs);
-
-foreach ( $cust_pkg AS $pkg ) {
-  if ( $pkg['pkgnum'] == $params['pkgnum'] ) { 
-    $pkg_label = $pkg['pkg_label'];
-    $pkg_part = $pkg['pkgpart'];
-    $class_num = $pkg['classnum'];
-  }
-}
-
 $pkgselect = $freeside->mason_comp( array(
     'session_id' => $_COOKIE['session_id'],
     'comp'       => '/elements/select-part_pkg.html',
-    'args'       => [ 'classnum', $class_num, 'curr_value', $pkg_part, ],
+    'args'       => [ 'classnum', $cust_pkg['classnum'], 'curr_value', $cust_pkg['pkgpart'], ],
   )
 );
 
@@ -56,7 +45,7 @@ function enable_change_pkg () {
 }
 </SCRIPT>
 
-<FONT SIZE=4>Purchase replacement package for "<? echo htmlspecialchars($pkg_label); ?>"</FONT><BR><BR>
+<FONT SIZE=4>Purchase replacement package for "<? echo htmlspecialchars($cust_pkg['pkg_label']); ?>"</FONT><BR><BR>
 
 <? include('elements/error.php'); ?>
 
@@ -73,8 +62,7 @@ function enable_change_pkg () {
 </TABLE>
 <BR>
 <INPUT TYPE="hidden" NAME="custnum" VALUE="<? echo $customer_info['custnum'] ?>">
-<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<? echo $params['pkgnum'] ?>">
-<INPUT TYPE="hidden" NAME="pkg" VALUE="<? echo $params['pkg'] ?>">
+<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<? echo htmlspecialchars($_GET['pkgnum']) ?>">
 <INPUT TYPE="hidden" NAME="action" VALUE="process_change_pkg">
 <INPUT NAME="submit" TYPE="submit" VALUE="Change Package">
 </FORM>
diff --git a/ng_selfservice/process_packages_change.php b/ng_selfservice/process_packages_change.php
index 3ea655e..a7ba2c4 100644
--- a/ng_selfservice/process_packages_change.php
+++ b/ng_selfservice/process_packages_change.php
@@ -81,7 +81,7 @@ if ( isset($results['error']) && $results['error'] ) {
 ?>
 <? include('elements/error.php'); ?>
 
-<FONT SIZE=4>Package Successfully Changed To "<? echo $results['pkg']; ?>"</FONT><BR><BR>
+<FONT SIZE=4>Package Successfully Changed To "<? echo htmlspecialchars($results['pkg']); ?>"</FONT><BR><BR>
 
 <? include('elements/menu_footer.php'); ?>
 <? include('elements/footer.php'); ?>
\ No newline at end of file

commit 0f38b0b1e43d3f37f9f0cfb3bc427004b6762d82
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Thu Jun 8 15:52:50 2017 -0400

    RT# 73993 - updated ng_selfservice/services.php and ng_selfservice/packages_change.php to only pass one cgi param pkgnum and escaped pkg_label

diff --git a/ng_selfservice/packages_change.php b/ng_selfservice/packages_change.php
index 876f6cd..20685e8 100644
--- a/ng_selfservice/packages_change.php
+++ b/ng_selfservice/packages_change.php
@@ -2,24 +2,39 @@
 <? $current_menu = 'services.php'; include('elements/menu.php'); ?>
 <?
 
+$get_params = array( 'pkgnum' );
+foreach ( $get_params AS $param ) {
+  $params[$param] = $_GET[$param];
+}
+
 $customer_info = $freeside->customer_info_short( array(
   'session_id' => $_COOKIE['session_id'],
 ) );
 
-foreach ( $cust_pkg AS $pkg ) {
- $part_pkg .= $pkg[pkgpart];
- $class_num .= $pkg[classnum];
+$list_pkgs = $freeside->list_pkgs( array(
+  'session_id' => $_COOKIE['session_id'],
+) );
+
+if ( isset($list_pkgs['error']) && $list_pkgs['error'] ) {
+  $error = $list_pkgs['error'];
+  header('Location:index.php?error='. urlencode($error));
+  die();
 }
 
-$get_params = array( 'pkgnum', 'pkg', 'classnum', 'pkgpart' );
-foreach ( $get_params AS $param ) {
-  $params[$param] = $_GET[$param];
+extract($list_pkgs);
+
+foreach ( $cust_pkg AS $pkg ) {
+  if ( $pkg['pkgnum'] == $params['pkgnum'] ) { 
+    $pkg_label = $pkg['pkg_label'];
+    $pkg_part = $pkg['pkgpart'];
+    $class_num = $pkg['classnum'];
+  }
 }
 
 $pkgselect = $freeside->mason_comp( array(
     'session_id' => $_COOKIE['session_id'],
     'comp'       => '/elements/select-part_pkg.html',
-    'args'       => [ 'classnum', $params['classnum'], 'curr_value', $params['pkgpart'], ],
+    'args'       => [ 'classnum', $class_num, 'curr_value', $pkg_part, ],
   )
 );
 
@@ -41,7 +56,7 @@ function enable_change_pkg () {
 }
 </SCRIPT>
 
-<FONT SIZE=4>Purchase replacement package for "<? echo $params['pkg']; ?>"</FONT><BR><BR>
+<FONT SIZE=4>Purchase replacement package for "<? echo htmlspecialchars($pkg_label); ?>"</FONT><BR><BR>
 
 <? include('elements/error.php'); ?>
 
diff --git a/ng_selfservice/services.php b/ng_selfservice/services.php
index 987e582..b81f558 100644
--- a/ng_selfservice/services.php
+++ b/ng_selfservice/services.php
@@ -33,7 +33,7 @@ extract($list_pkgs);
 
     $change_link = '';
     if ( in_array("Change packages", $menu_disable) == 0) {
-      $change_link = '<a href="packages_change.php?pkgnum=' . $pkg['pkgnum'] . '&pkg=' . $pkg['pkg_label'] . '&pkgpart=' . $pkg['pkgpart'] . '&classnum=' . $pkg['classnum'] . '">[change]</a>';
+      $change_link = '<a href="packages_change.php?pkgnum=' . $pkg['pkgnum'] . '">[change]</a>';
     }
 ?>
   <TR>
@@ -41,7 +41,7 @@ extract($list_pkgs);
   </TR>
   <TR>
     <? echo $td ?><? echo $change_link ?>  </TD>
-    <? echo $td ?><? echo $pkg['pkg_label']; ?></TD>
+    <? echo $td ?><? echo htmlspecialchars($pkg['pkg_label']); ?></TD>
     <? echo $td ?>
       <FONT COLOR="#<? echo $pkg['statuscolor'] ?>"><B>
         <? echo ucfirst($pkg['status']); ?>

commit e820c248c68a5885843a77d87fddfb26c6eb515b
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Thu Jun 1 10:21:48 2017 -0400

    RT# 73993 - Updated process to display only packages customer has access to.

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index c432bb8..e2cce0d 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -2476,10 +2476,14 @@ sub change_pkg {
   my $err_or_cust_pkg = $cust_pkg->change( 'pkgpart'  => $p->{'pkgpart'},
                                            'quantity' => $p->{'quantity'} || 1,
                                          );
+  
+  my $new_pkg = qsearchs('part_pkg', { 'pkgpart' => $p->{pkgpart} } )
+    or return { 'error' => "unknown package $p->{pkgpart}" };
 
   return { error=>$err_or_cust_pkg, pkgnum=>$cust_pkg->pkgnum }
     unless ref($err_or_cust_pkg);
 
+
   if ( $conf->exists('signup_server-realtime') ) {
 
     my $bill_error = _do_bop_realtime( $cust_main, $status, 'no_invoice_void'=>1 );
@@ -2495,7 +2499,7 @@ sub change_pkg {
     $err_or_cust_pkg->reexport;
   }
 
-  return { error => '', pkgnum => $cust_pkg->pkgnum };
+  return { error => '', pkg => $new_pkg->pkg, pkgnum => $err_or_cust_pkg->pkgnum };
 
 }
 
diff --git a/ng_selfservice/packages_change.php b/ng_selfservice/packages_change.php
index 8b4386c..876f6cd 100644
--- a/ng_selfservice/packages_change.php
+++ b/ng_selfservice/packages_change.php
@@ -6,32 +6,20 @@ $customer_info = $freeside->customer_info_short( array(
   'session_id' => $_COOKIE['session_id'],
 ) );
 
-$list_pkgs = $freeside->list_pkgs( array(
-  'session_id' => $_COOKIE['session_id'],
-) );
-
-if ( isset($list_pkgs['error']) && $list_pkgs['error'] ) {
-  $error = $list_pkgs['error'];
-  header('Location:index.php?error='. urlencode($error));
-  die();
+foreach ( $cust_pkg AS $pkg ) {
+ $part_pkg .= $pkg[pkgpart];
+ $class_num .= $pkg[classnum];
 }
 
-extract($list_pkgs);
-
-$get_params = array( 'pkgnum', 'pkg' );
+$get_params = array( 'pkgnum', 'pkg', 'classnum', 'pkgpart' );
 foreach ( $get_params AS $param ) {
   $params[$param] = $_GET[$param];
 }
 
-$pkgnum = $_GET['pkgnum'];
-$pkg = $_GET['pkg'];
-
 $pkgselect = $freeside->mason_comp( array(
     'session_id' => $_COOKIE['session_id'],
     'comp'       => '/elements/select-part_pkg.html',
-    'args'       => array( 'custnum' => $customer_info['custnum'],
-                           'curr_value' => 'current_value',
-                    ),
+    'args'       => [ 'classnum', $params['classnum'], 'curr_value', $params['pkgpart'], ],
   )
 );
 
@@ -53,7 +41,7 @@ function enable_change_pkg () {
 }
 </SCRIPT>
 
-<FONT SIZE=4>Purchase replacement package for "<? echo $pkg; ?>"</FONT><BR><BR>
+<FONT SIZE=4>Purchase replacement package for "<? echo $params['pkg']; ?>"</FONT><BR><BR>
 
 <? include('elements/error.php'); ?>
 
diff --git a/ng_selfservice/process_packages_change.php b/ng_selfservice/process_packages_change.php
index 114cc6b..3ea655e 100644
--- a/ng_selfservice/process_packages_change.php
+++ b/ng_selfservice/process_packages_change.php
@@ -53,8 +53,6 @@ if ( ! $results['error'] ) {
 
   $results = $freeside->change_pkg($change_pkg);
 
-  echo $results;
-
 }
 
 #  if ( $results->{'error'} ) {
@@ -83,7 +81,7 @@ if ( isset($results['error']) && $results['error'] ) {
 ?>
 <? include('elements/error.php'); ?>
 
-<FONT SIZE=4>Package Changed Su for "<? echo $pkg; ?>"</FONT><BR><BR>
+<FONT SIZE=4>Package Successfully Changed To "<? echo $results['pkg']; ?>"</FONT><BR><BR>
 
 <? include('elements/menu_footer.php'); ?>
 <? include('elements/footer.php'); ?>
\ No newline at end of file
diff --git a/ng_selfservice/services.php b/ng_selfservice/services.php
index 25fbdde..987e582 100644
--- a/ng_selfservice/services.php
+++ b/ng_selfservice/services.php
@@ -33,7 +33,7 @@ extract($list_pkgs);
 
     $change_link = '';
     if ( in_array("Change packages", $menu_disable) == 0) {
-      $change_link = '<a href="packages_change.php?pkgnum=' . $pkg['pkgnum'] . '&pkg=' . $pkg['pkg_label'] . '">[change]</a>';
+      $change_link = '<a href="packages_change.php?pkgnum=' . $pkg['pkgnum'] . '&pkg=' . $pkg['pkg_label'] . '&pkgpart=' . $pkg['pkgpart'] . '&classnum=' . $pkg['classnum'] . '">[change]</a>';
     }
 ?>
   <TR>

commit bfc5435b9b9352a7eb62f7946cb77c5c5ebc88b9
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon May 22 22:23:45 2017 -0700

    remove debugging while fixing nadvertant breakage in mason_comp, RT#73993, RT#75279

diff --git a/FS/FS/ClientAPI/MasonComponent.pm b/FS/FS/ClientAPI/MasonComponent.pm
index 8a51354..3a4bfe1 100644
--- a/FS/FS/ClientAPI/MasonComponent.pm
+++ b/FS/FS/ClientAPI/MasonComponent.pm
@@ -100,10 +100,7 @@ my %session_callbacks = (
       }
     }
 
-use Data::Dumper;
-warn Dumper $argsref;
     my %args = @$argsref;
-warn Dumper \%args;
     $args{part_pkg} = \@part_pkg;
     $args{first_svc} = \@first_svc;
     $args{no_comment} = 1;
@@ -140,8 +137,6 @@ my( $fs_interp, $rt_interp ) = mason_interps('standalone', 'outbuf'=>\$outbuf);
 
 sub mason_comp {
   my $packet = shift;
-use Data::Dumper;
-warn Dumper($packet);
 
   warn "$me mason_comp called on $packet\n" if $DEBUG;
 

commit 2ee8675dead19d3a6669314b7a207366bf2cdf9d
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon May 22 22:21:31 2017 -0700

    fix inadvertant breakage in mason_comp, RT#73993, RT#75279

diff --git a/FS/FS/ClientAPI/MasonComponent.pm b/FS/FS/ClientAPI/MasonComponent.pm
index d09d6da..8a51354 100644
--- a/FS/FS/ClientAPI/MasonComponent.pm
+++ b/FS/FS/ClientAPI/MasonComponent.pm
@@ -100,7 +100,10 @@ my %session_callbacks = (
       }
     }
 
+use Data::Dumper;
+warn Dumper $argsref;
     my %args = @$argsref;
+warn Dumper \%args;
     $args{part_pkg} = \@part_pkg;
     $args{first_svc} = \@first_svc;
     $args{no_comment} = 1;
@@ -137,6 +140,8 @@ my( $fs_interp, $rt_interp ) = mason_interps('standalone', 'outbuf'=>\$outbuf);
 
 sub mason_comp {
   my $packet = shift;
+use Data::Dumper;
+warn Dumper($packet);
 
   warn "$me mason_comp called on $packet\n" if $DEBUG;
 
@@ -145,7 +150,7 @@ sub mason_comp {
     return { 'error' => 'Illegal component' };
   }
 
-  my @args = $packet->{'args'} ? $packet->{'args'} : ();
+  my @args = $packet->{'args'} ? @{ $packet->{'args'} } : ();
 
   if ( $session_comps{$comp} ) {
 

commit 9c1e27955566bfddd0c756e6237a89d8427d0f3e
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Tue May 2 09:00:43 2017 -0400

    RT# 73993 updated ngselfservice to allow for package change.

diff --git a/ng_selfservice/packages_change.php b/ng_selfservice/packages_change.php
new file mode 100644
index 0000000..8b4386c
--- /dev/null
+++ b/ng_selfservice/packages_change.php
@@ -0,0 +1,80 @@
+<? $title ='Change Package'; include('elements/header.php'); ?>
+<? $current_menu = 'services.php'; include('elements/menu.php'); ?>
+<?
+
+$customer_info = $freeside->customer_info_short( array(
+  'session_id' => $_COOKIE['session_id'],
+) );
+
+$list_pkgs = $freeside->list_pkgs( array(
+  'session_id' => $_COOKIE['session_id'],
+) );
+
+if ( isset($list_pkgs['error']) && $list_pkgs['error'] ) {
+  $error = $list_pkgs['error'];
+  header('Location:index.php?error='. urlencode($error));
+  die();
+}
+
+extract($list_pkgs);
+
+$get_params = array( 'pkgnum', 'pkg' );
+foreach ( $get_params AS $param ) {
+  $params[$param] = $_GET[$param];
+}
+
+$pkgnum = $_GET['pkgnum'];
+$pkg = $_GET['pkg'];
+
+$pkgselect = $freeside->mason_comp( array(
+    'session_id' => $_COOKIE['session_id'],
+    'comp'       => '/elements/select-part_pkg.html',
+    'args'       => array( 'custnum' => $customer_info['custnum'],
+                           'curr_value' => 'current_value',
+                    ),
+  )
+);
+
+if ( isset($pkgselect['error']) && $pkgselect['error'] ) {
+  $error = $pkgselect['error'];
+  header('Location:index.php?error='. urlencode($error));
+  die();
+}
+
+?>
+
+<SCRIPT TYPE="text/javascript">
+function enable_change_pkg () {
+  if ( document.ChangePkgForm.pkgpart_svcpart.selectedIndex > 0 ) {
+    document.ChangePkgForm.submit.disabled = false;
+  } else {
+    document.ChangePkgForm.submit.disabled = true;
+  }
+}
+</SCRIPT>
+
+<FONT SIZE=4>Purchase replacement package for "<? echo $pkg; ?>"</FONT><BR><BR>
+
+<? include('elements/error.php'); ?>
+
+<FORM NAME="ChangePkgForm" ACTION="process_packages_change.php" METHOD=POST>
+<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0>
+
+<TR>
+  <TD COLSPAN=2>
+    <TABLE><TR><TD> <? echo $pkgselect['output']; ?>
+
+  </TD>
+</TR>
+
+</TABLE>
+<BR>
+<INPUT TYPE="hidden" NAME="custnum" VALUE="<? echo $customer_info['custnum'] ?>">
+<INPUT TYPE="hidden" NAME="pkgnum" VALUE="<? echo $params['pkgnum'] ?>">
+<INPUT TYPE="hidden" NAME="pkg" VALUE="<? echo $params['pkg'] ?>">
+<INPUT TYPE="hidden" NAME="action" VALUE="process_change_pkg">
+<INPUT NAME="submit" TYPE="submit" VALUE="Change Package">
+</FORM>
+
+<? include('elements/menu_footer.php'); ?>
+<? include('elements/footer.php'); ?>
\ No newline at end of file
diff --git a/ng_selfservice/process_packages_change.php b/ng_selfservice/process_packages_change.php
new file mode 100644
index 0000000..114cc6b
--- /dev/null
+++ b/ng_selfservice/process_packages_change.php
@@ -0,0 +1,89 @@
+<? $title ='Change Package'; include('elements/header.php'); ?>
+<? $current_menu = 'services.php'; include('elements/menu.php'); ?>
+
+<?
+
+require_once('elements/session.php');
+
+$results = array();
+
+$params = array( 'custnum', 'pkgpart', 'pkgnum' );
+
+$matches = array();
+if ( preg_match( '/^(\d+)_(\d+)$/', $_POST['pkgpart_svcpart'], $matches ) ) {
+  $_POST['pkgpart'] = $matches[1];
+  $_POST['svcpart'] = $matches[2];
+  $params[] = 'svcpart';
+  $svcdb = $_POST['svcdb'];
+  if ( $svcdb == 'svc_acct' ) { $params[] = 'domsvc'; }
+} else {
+  $svcdb = 'svc_acct';
+}
+
+if ( $svcdb == 'svc_acct' ) {
+
+  array_push($params, 'username', '_password', '_password2', 'sec_phrase', 'popnum' );
+
+  #if ( strlen($_POST['_password']) == 0 ) {
+  #  $results['error'] = 'Empty password';
+  #}
+  #if ( $_POST['_password'] != $_POST['_password'] ) {
+  #  $results['error'] = 'Passwords do not match';
+  #  $_POST['_password'] = '';
+  #  $_POST['_password2'] = '';
+  #}
+
+} elseif ( $svcdb == 'svc_phone' ) {
+
+  array_push($params, 'phonenum', 'sip_password', 'pin', 'phone_name' );
+
+} else {
+  die("$svcdb not handled on process_change_pkg yet");
+}
+
+if ( ! $results['error'] ) {
+
+  $change_pkg = array(
+    'session_id' => $_COOKIE['session_id'],
+  );
+
+  foreach ( $params AS $param ) {
+    $change_pkg[$param] = $_POST[$param];
+  }
+
+  $results = $freeside->change_pkg($change_pkg);
+
+  echo $results;
+
+}
+
+#  if ( $results->{'error'} ) {
+#    $action = 'customer_change_pkg';
+#    return {
+#      $cgi->Vars,
+#      %{customer_change_pkg()},
+#      'error' => '<FONT COLOR="#FF0000">'. $results->{'error'}. '</FONT>',
+#    };
+#  } else {
+#    return $results;
+#  }
+
+
+## reload below except pkgnum
+if ( isset($results['error']) && $results['error'] ) {
+  $error = $results['error'];
+#  header('Location:services.php?error='. urlencode($error));
+#  die();
+}
+
+#$pkgnum = $results['pkgnum'];
+
+#header("Location:services.php"); # #pkgnum ?
+## end reload
+?>
+<? include('elements/error.php'); ?>
+
+<FONT SIZE=4>Package Changed Su for "<? echo $pkg; ?>"</FONT><BR><BR>
+
+<? include('elements/menu_footer.php'); ?>
+<? include('elements/footer.php'); ?>
\ No newline at end of file

commit 43d43d3101e7f555422bd48276f22b1bebbf6010
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Mon May 1 15:09:18 2017 -0400

    RT#73993 - updated selfservice and ngselfservice to allow for the control of changes packages by agent.

diff --git a/FS/FS/ClientAPI/MasonComponent.pm b/FS/FS/ClientAPI/MasonComponent.pm
index 3a4bfe1..d09d6da 100644
--- a/FS/FS/ClientAPI/MasonComponent.pm
+++ b/FS/FS/ClientAPI/MasonComponent.pm
@@ -145,7 +145,7 @@ sub mason_comp {
     return { 'error' => 'Illegal component' };
   }
 
-  my @args = $packet->{'args'} ? @{ $packet->{'args'} } : ();
+  my @args = $packet->{'args'} ? $packet->{'args'} : ();
 
   if ( $session_comps{$comp} ) {
 
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 1fe11a0..c7dbd0b 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -5129,6 +5129,7 @@ and customer address. Include units.',
                        'Change billing address',
                        'Change service address',
                        'Change payment information',
+                       'Change packages',
                        'Change password(s)',
                        'Logout',
                      ],
diff --git a/ng_selfservice/elements/error.php b/ng_selfservice/elements/error.php
index 2cff74f..ee60c6e 100644
--- a/ng_selfservice/elements/error.php
+++ b/ng_selfservice/elements/error.php
@@ -1,2 +1,3 @@
-<FONT SIZE="+1" COLOR="#ff0000"><? echo htmlspecialchars($error); ?><? if ($error) { echo '<BR><BR>'; } ?></FONT>
-
+<? if (isset($error)) { ?>
+	<FONT SIZE="+1" COLOR="#ff0000"><? echo htmlspecialchars($error); echo '<BR><BR>'; ?></FONT>
+<? } ?>
diff --git a/ng_selfservice/elements/menu.php b/ng_selfservice/elements/menu.php
index cb9d617..b68c8c1 100644
--- a/ng_selfservice/elements/menu.php
+++ b/ng_selfservice/elements/menu.php
@@ -32,15 +32,15 @@ extract($skin_info);
 
   foreach ($menu_array AS $menu_item) {
     if ( preg_match('/^\s*$/', $menu_item) ) {
-      print_menu($submenu, $current_menu);
+      print_menu($submenu, $current_menu, $menu_disable);
       $submenu = array();
     } else {
       $submenu[] = $menu_item;
     }
   }
-  print_menu($submenu, $current_menu);
+  print_menu($submenu, $current_menu, $menu_disable);
 
-  function print_menu($submenu_array, $current_menu) {
+  function print_menu($submenu_array, $current_menu, $menu_disable) {
     if ( count($submenu_array) == 0 ) { return; }
 
     $links = array();
@@ -71,8 +71,10 @@ extract($skin_info);
       echo '<ul>';
       foreach ($links AS $link) {
         $label = array_shift($labels);
-        print_link($link, $label, $current_menu, array($link) );
-        echo '</a></li>';
+        if ( in_array($label, $menu_disable) == 0) {
+          print_link($link, $label, $current_menu, array($link) );
+          echo '</a></li>';
+        }
       }
       echo '</ul>';
     }
diff --git a/ng_selfservice/services.php b/ng_selfservice/services.php
index ce47e9e..25fbdde 100644
--- a/ng_selfservice/services.php
+++ b/ng_selfservice/services.php
@@ -17,6 +17,7 @@ extract($list_pkgs);
 ?>
 <TABLE BORDER=0 CELLSPACING=2 CELLPADDING=1>
 <TR>
+  <TH ALIGN="LEFT"> </TH>
   <TH ALIGN="LEFT">Product</TH>
   <TH ALIGN="LEFT">Status</TH>
   <TH ALIGN="LEFT" COLSPAN=2>Service(s)</TH>
@@ -29,11 +30,17 @@ extract($list_pkgs);
     $rowspan = count($pkg['cust_svc']);
     if ( $rowspan == 0 ) { $rowspan = 1; }
     $td = '<TD ALIGN="LEFT" VALIGN="top" ROWSPAN="'. $rowspan. '">';
+
+    $change_link = '';
+    if ( in_array("Change packages", $menu_disable) == 0) {
+      $change_link = '<a href="packages_change.php?pkgnum=' . $pkg['pkgnum'] . '&pkg=' . $pkg['pkg_label'] . '">[change]</a>';
+    }
 ?>
   <TR>
     <TD COLSPAN=4 STYLE="border-top:1px solid #999999"></TD>
   </TR>
   <TR>
+    <? echo $td ?><? echo $change_link ?>  </TD>
     <? echo $td ?><? echo $pkg['pkg_label']; ?></TD>
     <? echo $td ?>
       <FONT COLOR="#<? echo $pkg['statuscolor'] ?>"><B>

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

Summary of changes:
 FS/FS/ClientAPI/MyAccount.pm                 |   30 ++++++++-
 FS/FS/ClientAPI_XMLRPC.pm                    |    1 +
 FS/FS/Conf.pm                                |    1 +
 fs_selfservice/FS-SelfService/SelfService.pm |   41 ++++++++++++
 ng_selfservice/elements/error.php            |    5 +-
 ng_selfservice/elements/menu.php             |   12 ++--
 ng_selfservice/packages_change.php           |   71 +++++++++++++++++++++
 ng_selfservice/process_packages_change.php   |   87 ++++++++++++++++++++++++++
 ng_selfservice/services.php                  |    9 ++-
 9 files changed, 248 insertions(+), 9 deletions(-)
 create mode 100644 ng_selfservice/packages_change.php
 create mode 100644 ng_selfservice/process_packages_change.php




More information about the freeside-commits mailing list