wordpress plugin, RT#75279
authorIvan Kohler <ivan@freeside.biz>
Wed, 19 Apr 2017 17:53:49 +0000 (10:53 -0700)
committerIvan Kohler <ivan@freeside.biz>
Wed, 19 Apr 2017 17:53:49 +0000 (10:53 -0700)
FS/FS/ClientAPI/MyAccount.pm
FS/FS/cust_main.pm
fs_selfservice/wordpress/README.txt
fs_selfservice/wordpress/example_selfservice.php
fs_selfservice/wordpress/freeside_selfservice.php
fs_selfservice/wordpress/view_invoice.php [new file with mode: 0644]

index e69122b..8072006 100644 (file)
@@ -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'} );
index f4990a4..19a5816 100644 (file)
@@ -3432,6 +3432,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.
index 7e4dbcd..759f839 100644 (file)
@@ -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
 
index ae588bf..2bfb5b3 100644 (file)
@@ -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@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@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 ?>
 
 <!--
index 5fe7aa7..f619e81 100644 (file)
@@ -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 (file)
index 0000000..a1e1680
--- /dev/null
@@ -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(); ?>
+