[freeside-commits] branch master updated. 53427a0d7b74c16d646196e70c95971471e1fae8

Christopher Burger burgerc at 420.am
Sun Jul 2 08:59:25 PDT 2017


The branch, master has been updated
       via  53427a0d7b74c16d646196e70c95971471e1fae8 (commit)
      from  68282d000bffde8638af4d70ec2f122356929ecd (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 53427a0d7b74c16d646196e70c95971471e1fae8
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 8c082ec..505111e 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -1760,6 +1760,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 8e21aef..511cef4 100644
--- a/FS/FS/ClientAPI_XMLRPC.pm
+++ b/FS/FS/ClientAPI_XMLRPC.pm
@@ -150,6 +150,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

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

Summary of changes:
 FS/FS/ClientAPI/MyAccount.pm               |   24 +++++++++++++++++++
 FS/FS/ClientAPI_XMLRPC.pm                  |    1 +
 ng_selfservice/packages_change.php         |   36 ++++++++++------------------
 ng_selfservice/process_packages_change.php |    2 +-
 4 files changed, 38 insertions(+), 25 deletions(-)




More information about the freeside-commits mailing list