[freeside-commits] branch master updated. 76b2f486c109892260bb7d7ba6d4898f742beca8

Ivan ivan at 420.am
Tue May 23 10:05:02 PDT 2017


The branch, master has been updated
       via  76b2f486c109892260bb7d7ba6d4898f742beca8 (commit)
      from  ffbb66f856373807aeed3f26ea42fd3ee6f3e497 (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 76b2f486c109892260bb7d7ba6d4898f742beca8
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue May 23 10:05:01 2017 -0700

    order package/service in example wordpress self-service, RT#75279

diff --git a/fs_selfservice/wordpress/README.txt b/fs_selfservice/wordpress/README.txt
index f068e82..47c381d 100644
--- a/fs_selfservice/wordpress/README.txt
+++ b/fs_selfservice/wordpress/README.txt
@@ -29,6 +29,16 @@ Freeside services to turn on the daemon ("etc/init.d/freeside restart", or
 "service freeside restart")
 
 
+Freeside self-service:
+
+If you are using signup or additional package order with the API-provided
+package selection HTML (as in the services_new.php example), make sure the
+regular Freeside self-service is installed on the same server as the wordpress
+site.  Make sure the Freeside configuration setting
+"selfservice_server-base_url" is correct and matches the hostname used to
+access the site, including https:// if using (which you certainly should!).
+
+
 Firewall/network configuration:
 
 Allow the Wordpress machine to connect to port 8080 on the Freeside machine.
diff --git a/fs_selfservice/wordpress/example_selfservice.php b/fs_selfservice/wordpress/example_selfservice.php
index 6e5049c..d753f2d 100644
--- a/fs_selfservice/wordpress/example_selfservice.php
+++ b/fs_selfservice/wordpress/example_selfservice.php
@@ -59,7 +59,7 @@ get_header();
 <br>
 <p><a href="view_invoice.php?invnum=<?php echo $max_invnum ?>">View my Bill</a></p>
 <p><a href="change_bill.php">Change Bill Deliver Options</a></p>
-
+<p><a href="services_new.php">Order a new service</a></p>
 <p><a href="process_logout.php">Logout</a></p>
 
 
diff --git a/fs_selfservice/wordpress/process_login.php b/fs_selfservice/wordpress/process_login.php
index c1080ce..a4c2fff 100644
--- a/fs_selfservice/wordpress/process_login.php
+++ b/fs_selfservice/wordpress/process_login.php
@@ -15,7 +15,7 @@ if ( $response['custnum'] || $response['svcnum'] ) {
   get_header();
 ?>
 
-  <?php include('elements/error.php'); ?>
+  <?php include(dirname(__FILE__).'/elements/error.php'); ?>
 
   <FORM NAME="SelectCustomerForm" ACTION="process_select_cust.php" METHOD=POST>
   <INPUT TYPE="hidden" NAME="action" VALUE="switch_cust">
diff --git a/fs_selfservice/wordpress/services_new.php b/fs_selfservice/wordpress/services_new.php
new file mode 100644
index 0000000..8ed6410
--- /dev/null
+++ b/fs_selfservice/wordpress/services_new.php
@@ -0,0 +1,113 @@
+<?php
+
+require( dirname( __FILE__ ) . '/wp-blog-header.php' );
+
+$freeside = new FreesideSelfService();
+
+if ( isset($_POST['pkgpart_svcpart']) && $_POST['pkgpart_svcpart'] ) {
+
+  $results = array();
+
+  $params = array( 'custnum', 'pkgpart' );
+
+  $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['_password2'] ) {
+      $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_order_pkg yet");
+  }
+
+  if ( ! $results['error'] ) {
+    $order_pkg = array(
+      'session_id' => $_COOKIE['freeside_session_id'],
+    );
+
+    foreach ( $params AS $param ) {
+      $order_pkg[$param] = $_POST[$param];
+    }
+
+    $results = $freeside->order_pkg($order_pkg);
+
+  }
+
+  if ( isset($results['error']) && $results['error'] ) {
+    $_REQUEST['freeside_error'] = $results['error'];
+  } else {
+    #$pkgnum = $results['pkgnum'];
+    #wp_redirect("services.php"); # #pkgnum ?
+    #wp_redirect("service_order_success.php"); # #pkgnum ?
+    wp_redirect("example_selfservice.php"); # #pkgnum ?
+    die();
+  }
+
+}
+
+$pkgselect = $freeside->mason_comp( [
+    'session_id' => $_COOKIE['freeside_session_id'],
+    'comp'       => '/edit/cust_main/first_pkg/select-part_pkg.html',
+    'args'       => [ 'password_verify', 1,
+                      'onchange'       , 'enable_order_pkg()',
+                      #'relurls'        , 1,
+                      'empty_label'    , 'Select package',
+                      'form_name'      , 'OrderPkgForm',
+                      'pkgpart_svcpart', $_POST['pkgpart_svcpart'],
+                      'username'       , $_POST['username'],
+                      'password'       , $_POST['_password'],
+                      'password2'      , $_POST['_password2'],
+                      'popnum'         , $_POST['popnum'],
+                      'saved_domsvc'   , $_POST['domsvc'],
+                    ],
+]);
+
+get_header();
+
+?>
+
+<h3>Order a new service</h3>
+
+<SCRIPT TYPE="text/javascript">
+function enable_order_pkg () {
+  if ( document.OrderPkgForm.pkgpart_svcpart.selectedIndex > 0 ) {
+    document.OrderPkgForm.submit.disabled = false;
+  } else {
+    document.OrderPkgForm.submit.disabled = true;
+  }
+}
+</SCRIPT>
+
+<?php include(dirname(__FILE__).'/elements/error.php'); ?>
+
+<FORM NAME="OrderPkgForm" ACTION="services_new.php" METHOD=POST>
+
+<?php echo $pkgselect['output']; ?>
+
+<BR>
+<INPUT NAME="submit" TYPE="submit" VALUE="Purchase" <?php if ( ! $_POST['pkgpart_svcpart'] ) { echo 'DISABLED'; } ?>>
+</FORM>
+
+<?php get_footer(); ?>

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

Summary of changes:
 fs_selfservice/wordpress/README.txt              |   10 ++
 fs_selfservice/wordpress/example_selfservice.php |    2 +-
 fs_selfservice/wordpress/process_login.php       |    2 +-
 fs_selfservice/wordpress/services_new.php        |  113 ++++++++++++++++++++++
 4 files changed, 125 insertions(+), 2 deletions(-)
 create mode 100644 fs_selfservice/wordpress/services_new.php




More information about the freeside-commits mailing list