Add line items to invoice
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 15 Mar 2018 18:49:42 +0000 (14:49 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 15 Mar 2018 18:49:42 +0000 (14:49 -0400)
If line_items_post is set to true

classes/data/dataInvoices.php
models/admin/billing/index.php
models/admin/billing/invoices.php

index 07b21f3..2fefd06 100644 (file)
@@ -12,6 +12,8 @@
  * @release  SVN: $Id: dataEvents.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
  */
 
+require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/billingSupport.php';
+
 /**
  * GlmDataBillingManagement class
  *
@@ -72,6 +74,10 @@ class GlmDataInvoices extends GlmDataAbstract
      * @access public
      */
     public $fields = false;
+    /**
+     * Grab line items for each invoice
+     */
+    public $line_items_post = false;
 
     /**
      * Constructor
@@ -216,6 +222,11 @@ class GlmDataInvoices extends GlmDataAbstract
                 $r['id']
             )
         );
+        if ( $this->line_items_post ) {
+            // Get line items for each invoice
+            $Billing = new GlmBillingSupport( $this->wpdb, $this->config );
+            $r['line_items'] = $Billing->getLineItemsForInvoice( $r['id'] );
+        }
         return $r;
     }
 
index 3f0102e..6f45be1 100644 (file)
@@ -337,7 +337,10 @@ class GlmMembersAdmin_billing_index extends GlmDataInvoices
 
             // Get the list of invoices and determine number of invoices in list
             $orderBy = 'transaction_time desc';
+            $this->line_items_post = true;
             $invoicesResult = $this->getList($where, $orderBy, true, 'id', $start, $limit);
+            echo '<pre>$invoicesResult: ' . print_r( $invoicesResult, true ) . '</pre>';
+            $this->line_items_post = false;
 
             // Get paging results
             $numbDisplayed = $invoicesResult['returned'];
index 43c4c1b..684b094 100644 (file)
@@ -415,7 +415,10 @@ class GlmMembersAdmin_billing_invoices extends GlmDataInvoices
 
             // Get the list of invoices and determine number of invoices in list
             $orderBy = 'transaction_time desc';
+            $this->line_items_post = true;
             $invoicesResult = $this->getList($where, $orderBy, true, 'id', $start, $limit);
+            echo '<pre>$invoicesResult: ' . print_r( $invoicesResult, true ) . '</pre>';
+            $this->line_items_post = false;
 
             // Get paging results
             $numbDisplayed = $invoicesResult['returned'];