[freeside-commits] branch FREESIDE_4_BRANCH updated. 26526fa81966352ded1b480138096c39f25523de

Ivan ivan at 420.am
Wed Apr 19 10:53:52 PDT 2017


The branch, FREESIDE_4_BRANCH has been updated
       via  26526fa81966352ded1b480138096c39f25523de (commit)
      from  db8b3ebb38dd0018922092f76c4aaf4c92d5fb73 (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 26526fa81966352ded1b480138096c39f25523de
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed Apr 19 10:53:51 2017 -0700

    wordpress plugin, RT#75279

diff --git a/FS/FS/ClientAPI/MyAccount.pm b/FS/FS/ClientAPI/MyAccount.pm
index e69122b..8072006 100644
--- a/FS/FS/ClientAPI/MyAccount.pm
+++ b/FS/FS/ClientAPI/MyAccount.pm
@@ -593,6 +593,7 @@ sub customer_info_short {
       or return { 'error' => "customer_info_short: unknown custnum $custnum" };
 
     $return{display_custnum} = $cust_main->display_custnum;
+    $return{max_invnum}      = $cust_main->max_invnum;
 
     if ( $session->{'pkgnum'} ) { 
       $return{balance} = $cust_main->balance_pkgnum( $session->{'pkgnum'} );
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 44faa27..61ecdc8 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -3646,6 +3646,20 @@ sub num_cust_attachments_deleted {
   );
 }
 
+=item max_invnum
+
+Returns the most recent invnum (invoice number) for this customer.
+
+=cut
+
+sub max_invnum {
+  my $self = shift;
+  $self->scalar_sql(
+    " SELECT MAX(invnum) FROM cust_bill WHERE custnum = ?",
+    $self->custnum
+  );
+}
+
 =item cust_bill [ OPTION => VALUE... | EXTRA_QSEARCH_PARAMS_HASHREF ]
 
 Returns all the invoices (see L<FS::cust_bill>) for this customer.
diff --git a/fs_selfservice/wordpress/README.txt b/fs_selfservice/wordpress/README.txt
index 7e4dbcd..759f839 100644
--- a/fs_selfservice/wordpress/README.txt
+++ b/fs_selfservice/wordpress/README.txt
@@ -18,8 +18,8 @@ self-service" plugin, and click "Activate".
 
 Configuration:
 
-In Wordpress, go to Settings -> General and set "Freeside self-service URL"
-to the 
+In Wordpress, go to Settings -> General and set "Freeside server"
+to your Freeside server name or IP address.
 
 
 Freeside configuration:
@@ -38,8 +38,8 @@ VPN or tunnel.
 
 Usage:
 
-See the included example_login.php, process_login.php and
-example_selfservice.php files.  These files perform a self-service login
+See the included example_login.php, process_login.php, example_selfservice.php
+and view_invoice.php files.  These files perform a self-service login
 and display a basic landing page.  To use, copy them to the wordpress content
 directory (or a subdirectory), and point your browser to example_login.php
 
diff --git a/fs_selfservice/wordpress/example_selfservice.php b/fs_selfservice/wordpress/example_selfservice.php
index ae588bf..2bfb5b3 100644
--- a/fs_selfservice/wordpress/example_selfservice.php
+++ b/fs_selfservice/wordpress/example_selfservice.php
@@ -4,9 +4,6 @@ require( dirname( __FILE__ ) . '/wp-blog-header.php' );
 
 $freeside = new FreesideSelfService();
 
-error_log( "COOKIE: ". $_COOKIE['freeside_session_id'] );
-error_log( "COOKIE: ". $GLOBALS['FREESIDE_SESSION_ID'] );
-
 $customer_info = $freeside->customer_info_short( array(
   'session_id' => $_COOKIE['freeside_session_id'],
 ) );
@@ -22,8 +19,6 @@ extract($customer_info);
 
 get_header();
 
-error_log( "COOKIE: ". $_COOKIE['freeside_session_id'] );
-
 ?>
 
 <h3>Billing</h3>
@@ -37,19 +32,21 @@ error_log( "COOKIE: ". $_COOKIE['freeside_session_id'] );
 <?php } ?>
 
 <p><big><strong>Username</strong></big></p>
-<p>me at gmail.com</p>
+<p><?php echo htmlspecialchars($svc_label) ?></p>
 
 <p><big><strong>Account Number</strong></big></p>
 <p><?php echo $display_custnum ?></p>
 
 <p><big><strong>Address</strong></big></p>
 <address>
-Box 564, Disneyland<br>
-USA
+<?php echo htmlspecialchars($address1); ?><br>
+<?php echo strlen($address2) ? htmlspecialchars($address2).'<br>' : '' ?>
+<?php echo $city ?>, <?php echo $state ?>  <?php echo $zip ?><br>
+<?php echo $country ?>
 </address>
 
 <p><big><strong>Email Address</strong></big></p>
-<p>me at gmail.com</p>
+<p><?php echo htmlspecialchars($invoicing_list) ?></p>
 
 <br>
 <br>
@@ -60,8 +57,8 @@ USA
 <br>
 <br>
 <br>
-<p><big><strong> <font color="	#4682B4">View my Bill</strong></big></font></p>
-<p><big><strong> <font color="#4682B4">Change Bill Deliver Options</strong></big></font></p>
+<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>
 
 
 
@@ -70,7 +67,6 @@ USA
 <h4><font color="#4682B4"> <i class="fa fa-laptop"> </i> </font> Internet </h4>
 <h4><font color="#4682B4"> <i class="fa fa-volume-control-phone"> </i> </font>   Voice </h4>
 
-
 <?php echo $announcement ?>
 
 <!--
diff --git a/fs_selfservice/wordpress/freeside_selfservice.php b/fs_selfservice/wordpress/freeside_selfservice.php
index 5fe7aa7..f619e81 100644
--- a/fs_selfservice/wordpress/freeside_selfservice.php
+++ b/fs_selfservice/wordpress/freeside_selfservice.php
@@ -50,8 +50,6 @@ function freeside_init() {
 
   //error_log($GLOBALS['$FREESIDE_PROCESS_LOGIN']);
   if ( ! $GLOBALS['FREESIDE_PROCESS_LOGIN'] ) {
-error_log("DACOOKIE: ". $_COOKIE['freeside_session_id']);
-    $GLOBALS['FREESIDE_SESSION_ID'] = $_COOKIE['freeside_session_id'];
     return;
   } else {
     $GLOBALS['FREESIDE_PROCESS_LOGIN'] = false;
@@ -90,7 +88,7 @@ error_log("DACOOKIE: ". $_COOKIE['freeside_session_id']);
 
   $session_id = $response['session_id'];
 
-  error_log("[login] logged into freeside with session_id=$freeside_session_id, setting cookie");
+  //error_log("[login] logged into freeside with session_id=$freeside_session_id, setting cookie");
 
 // now what?  for now, always redirect to the main page (or the select a
 // customer diversion).
diff --git a/fs_selfservice/wordpress/view_invoice.php b/fs_selfservice/wordpress/view_invoice.php
new file mode 100644
index 0000000..a1e1680
--- /dev/null
+++ b/fs_selfservice/wordpress/view_invoice.php
@@ -0,0 +1,30 @@
+<?php
+
+require( dirname( __FILE__ ) . '/wp-blog-header.php' );
+
+$freeside = new FreesideSelfService();
+
+$invoice_info = $freeside->invoice( array(
+  'session_id' => $_COOKIE['freeside_session_id'],
+  'invnum'     => $_REQUEST['invnum'],
+) );
+
+
+if ( isset($invoice_info['error']) && $invoice_info['error'] ) {
+  $error = $invoice_info['error'];
+  wp_redirect('example_login.php?freeside_error='. urlencode($error));
+  die();
+}
+
+extract($invoice_info);
+
+get_header();
+
+?>
+
+<h3>Invoice</h3>
+
+<?php echo $invoice_html ?>
+
+<?php get_footer(); ?>
+

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

Summary of changes:
 FS/FS/ClientAPI/MyAccount.pm                      |    1 +
 FS/FS/cust_main.pm                                |   14 ++++++++++
 fs_selfservice/wordpress/README.txt               |    8 +++---
 fs_selfservice/wordpress/example_selfservice.php  |   20 ++++++--------
 fs_selfservice/wordpress/freeside_selfservice.php |    4 +--
 fs_selfservice/wordpress/view_invoice.php         |   30 +++++++++++++++++++++
 6 files changed, 58 insertions(+), 19 deletions(-)
 create mode 100644 fs_selfservice/wordpress/view_invoice.php




More information about the freeside-commits mailing list